我在这个问题中尝试了所有解决方案
Check whether user has a Chrome extension installed
我做了什么:
1-我添加了背景js文件,在清单中我添加了以下内容
"background": {
"scripts": ["js/background.js"],
"persistent": true
},
"permissions": [ "https://*.mydomain.com/*" ],
在background.js中我添加了
chrome.runtime.onMessageExternal.addListener(function(msg, sender, sendResponse) {
if ((msg.action == "id") && (msg.value == id))
{
sendResponse({id : id});
}
});
在我的网站上我添加了这段代码
<script>
var id = "madbfblbpcoiddlankhkdbagjeemnlof";
chrome.runtime.sendMessage(id, {action: "id", value : id}, function(response) {
if(response && (response.id == id)) //extension installed
{
console.log(response);
}
else //extension not installed
{
console.log("Please consider installig extension");
}
});
</script>
我总是得到请考虑installig扩展
如何解决此问题?