Search code examples
javascriptmicrosoft-edgemicrosoft-edge-extension

Microsoft Edge popup extension how to get backgroundpage?


I am trying to use my Chrome extension on Microsoft Edge to adapt it, but I can't build the popup because in the script of my popup, some variables seem to not exist:

var bg = chrome.extension.getBackgroundPage();

This line isn't working, it supposed to access data of content scripts. I've found some guys saying browser.extension.getBackgroundPage() must be used to replace it, but it doesn't work to.

By what should I replace this line?


Solution

    1. Since Microsoft Edge uses browser.* namespace, you should use browser.extension.getBackgroundPage() instead.

    2. For debugging background script and content script, see Debugging extensions for more details

    3. For debugging popup scripts, it seems there is no visible entry. One workaround would be manually opening that page in Microsoft Edge via typing the popup url, something like ms-browser-extension://[Extension_Id]/html/popup.html