Getting error while detect chrome extension installed or not using javascript

China☆狼群 提交于 2019-12-01 23:20:29

问题


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 have tried this method. But i'm getting following error: Uncaught TypeError: Cannot read property 'get' of undefined


回答1:


If it's undefined then you're missing the management declaration in the manifest:

"permissions": [
          "management"
        ],

Source




回答2:


Check in another extension:

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

Check in webpage

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

In manifest file, remember to register webpage you want to check extension from.

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

then you can use chrome.runtime.sendMessage in that page.



来源:https://stackoverflow.com/questions/27166278/getting-error-while-detect-chrome-extension-installed-or-not-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!