Jump to content

Acess Extension


diegojmap

Recommended Posts

I need to access a chome extension.

I'm using beforeshow in ExtEvents.

function window.beforeshow(sender, eOpts)
{  
      var extensionId = "pnahlmehglnaomfnngekhphldmbjhdel";

                    chrome.runtime.sendMessage(extensionId, { message: "certs", body: "list certificates" }, function (response) {
                                               console.log(response);
                    });
                
   }

Return the message:

Cannot read properties of undefined (reading 'sendMessage')

What would be the correct way to call it?

Link to comment
Share on other sites

1 hour ago, diegojmap said:

I need to access a chome extension.

I'm using beforeshow in ExtEvents.

function window.beforeshow(sender, eOpts)
{  
      var extensionId = "pnahlmehglnaomfnngekhphldmbjhdel";

                    chrome.runtime.sendMessage(extensionId, { message: "certs", body: "list certificates" }, function (response) {
                                               console.log(response);
                    });
                
   }

Return the message:

Cannot read properties of undefined (reading 'sendMessage')

What would be the correct way to call it?

Hello

It seems "chrome.runtime" not ready yet. Can you try aftershow event?

Link to comment
Share on other sites

Hayri ASLAN
sorry
This error appears when accessing any extension.
Are you telling me that with unigui I can't access an extension?
I showed you a ready-made example.
I just need to do it in with Unigui.
If you're telling me it's not possible I'm very worried.

How to access chrome.runtime.sendmessage with unigui?
It has nothing to do with my extension.

@Sherzod

 

 
Link to comment
Share on other sites

I noticed the following problem, when I load a local html file like "file:///C:/Users/elvis/Desktop/example/index.html" the chrome functions are not available, but when I load the same file hosted by a server "http://localhost/index.html" the functions is available.

I think it's the same as the way unigui loads files, because the "chrome.runtime.sendMessage" function is not loaded in unigui

Link to comment
Share on other sites

the problem i have when i use a javascript pro call inside unigui and the same behavior.
the function does not exist within unigui chrome.runtime.sendMessage javascript execution.
the error he mentioned the extension is not linked to the extension but to native browser functions that are not available within unigui.

 

you can easily simulate the error with the code below.

chrome.runtime.sendMessage({message: "hi"}, (response) => {
   console.log(response.message);
});

even without having a listener for the message

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...