Getting error when detecting chrome extension installed or not using javascript

Here is my code,

var myExtension = chrome.management.get( "my_extention_id" );
if (myExtension.enabled)
{
// installed
}
else { ... }

      

source: http://developer.chrome.com/extensions/management.html#method-get I tried this method. But I am getting the following error: Uncaught TypeError: Cannot read property 'get' from undefined

+3


source to share


2 answers


If it's undefined, then the control declaration is missing from the manifest:

"permissions": [
          "management"
        ],

      



Source

+2


source


Check another extension:

https://gist.github.com/greatghoul/321b4f32c0b7a6ad8a97

Check the web page

https://developer.chrome.com/extensions/messaging#external-webpage



In your manifest file, don't forget to register the webpage you want to test the extension for.

"externally_connectable": {
    "matches": ["*://developer.chrome.com/*"]
}

      

then you can use chrome.runtime.sendMessage

this page.

+6


source







All Articles