Microsoft Edge popup扩展如何获取后台页面?(Microsoft Edge popup extension how to get backgroundpage?)
我正在尝试在Microsoft Edge上使用我的Chrome扩展程序来调整它,但我无法构建弹出窗口,因为在我的弹出窗口的脚本中,某些变量似乎不存在:
var bg = chrome.extension.getBackgroundPage();
这行不起作用,它应该访问内容脚本的数据。 我发现有些人说必须使用browser.extension.getBackgroundPage()替换它,但它不起作用。
我该怎么替换这条线?
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?
最满意答案
由于Microsoft Edge使用
browser.*
命名空间,因此您应该使用browser.extension.getBackgroundPage()
。有关调试后台脚本和内容脚本的信息,请参阅调试扩展以获取更多详细信
对于调试弹出脚本,似乎没有可见的条目。 一种解决方法是通过键入弹出网址在Microsoft Edge中手动打开该页面,类似于
ms-browser-extension://[Extension_Id]/html/popup.html
Since Microsoft Edge uses
browser.*
namespace, you should usebrowser.extension.getBackgroundPage()
instead.For debugging background script and content script, see Debugging extensions for more details
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
相关问答
更多-
要定位Edge,我们可以检查-ms-ime-align支持,Edge是唯一支持此属性的Microsoft浏览器: @supports (-ms-ime-align: auto) { .selector { color: red; } } 或者这一行: _:-ms-lang(x), .selector { color: red; } 在本文中可以找到进一步的解释,包括支持特定版本Edge的变体。 To target Edge, we can check for -ms-ime-al ...
-
您可以使用Windows 10 SDK中的Inspect.exe查看Microsoft Edge的辅助功能树。 如果从Inspect的“选项”菜单中选择“UI自动化模式”和“控制视图”,您将获得最准确的表示。 有关Edge中可访问性的更多信息,请参阅此博客文章: 可访问性:使用Microsoft Edge和Windows 10建立更具包容性的Web 。 You can view the accessibility tree of Microsoft Edge using Inspect.exe from t ...
-
您不需要“释放AudioContext” - 它将作为垃圾回收的一部分发生。 close()是为了帮助更高级的场景。 一般来说,你可以创建一个AudioContext并保存它的引用,直到你不再需要它,然后释放引用(例如“myAudioContext = null;”),并在适当的时候收到垃圾回收。 You don't "need" to release the AudioContext - it will happen as part of garbage collection. The close() w ...
-
发生这种情况是因为Edge为扩展和页面上下文分割了Cookie存储。 我听说它既是一个功能,也是一个bug。 如果你需要去解决这个问题,你可以: 在上下文脚本中创建ajax请求并将结果返回给background.html; 使用更新的Edge安装Insiders Preview(在边缘39.14936上测试),它应该正确添加cookie; 如果您只需要cookie值,则可以执行browser.cookie.get API调用。 将无法使用HttpOnly cookie; This happens becau ...
-
Microsoft Edge popup扩展如何获取后台页面?(Microsoft Edge popup extension how to get backgroundpage?)[2023-02-04]
由于Microsoft Edge使用browser.*命名空间,因此您应该使用browser.extension.getBackgroundPage() 。 有关调试后台脚本和内容脚本的信息,请参阅调试扩展以获取更多详细信 对于调试弹出脚本,似乎没有可见的条目。 一种解决方法是通过键入弹出网址在Microsoft Edge中手动打开该页面,类似于ms-browser-extension://[Extension_Id]/html/popup.html Since Microsoft Edge uses br ... -
这是Microsoft Edge和Microsoft Internet Explorer的预期行为:它们在评估同源策略时不包括端口号,因此http://localhost:8080和(例如) http://localhost:8081是相同的来源对他们来说 这就是为什么Edge不会抱怨没有在响应中找到Access-Control-Allow-Origin标头(因为它甚至不是跨源请求)。 参考: Internet Explorer 11不会在CORS请求中添加Origin标头? This is the exp ...
-
您可以使用browserAction.onClicked( https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/browserAction/onClicked )API将IFRAME注入网页。 使用z-index CSS属性可以使其浮动在实际页面内容的顶部。 这将使弹出窗口停留在页面上,就像它被固定一样。 You could use browserAction.onClicked (https://developer.mozilla.o ...
-
如果我不得不猜测,Edge以外的所有东西都会返回 url("http://www.becreativeagencja.com/elplast-wp/wp-content/themes/BeCreative_ELPLAST/assets/img/docisk-dwustronny.jpg") Edge不带引号返回相同的值 url(http://www.becreativeagencja.com/elplast-wp/wp-content/themes/BeCreative_ELPLAST/assets/im ...
-
在Chrome中,可以通过选中Allow access to file URLs chrome://extensions Allow access to file URLs来实现本地文件访问,但Microsoft Edge目前不支持此功能 。 至于功能计划,您可能希望在其反馈网站中提供反馈。 In Chrome, local file access can be achieved by checking Allow access to file URLs in chrome://extensions, ho ...
-
由于扩展是appx包,请尝试C:\Users\%username%\AppData\Local\Packages 。 搜索以扩展名开头的文件夹。 编辑:实际源代码位于C:\Program Files\WindowsApps您可能需要将文件夹所有者更改为自己才能获得访问权限。 Since extensions are appx packages, try C:\Users\%username%\AppData\Local\Packages. Search for the folder starting wit ...