1
votes

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?

2
Did you assign chrome = browser already? This API is currently documented as being supported in Microsoft Edge.Sampson
No, but I've remplaced it by browser.extension.getBackgroundPage() as shown in the documentation and It doesn't work. How can I display my variables? It would help me to debug, and console.log doesn't work in background and content scripts.Nucktrooper

2 Answers

3
votes
  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

1
votes

There is a software named "Tool kit" provided by Microsoft to convert your existing chrome extension to Microsoft extension by bridging the Chrome APIs. This tool help to remove errors from the convertible version and also highlights the syntax error which not allowed in edge extension.