Check whether user has a Chrome extension installed

前端 未结 16 2443
一向
一向 2020-11-22 08:50

I am in the process of building a Chrome extension, and for the whole thing to work the way I would like it to, I need an external JavaScript script to be able to detect if

16条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 09:25

    Webpage interacts with extension through background script.

    manifest.json:

    "background": {
        "scripts": ["background.js"],
        "persistent": true
    },
    "externally_connectable": {
        "matches": ["*://(domain.ext)/*"]
    },
    
    background.js:
    chrome.runtime.onMessageExternal.addListener(function(msg, sender, sendResponse) {
        if ((msg.action == "id") && (msg.value == id))
        {
            sendResponse({id : id});
        }
    });
    

    page.html:

    
    

提交回复
热议问题