内容脚本加载到错误的窗口中

时间:2018-09-07 09:20:15

标签: javascript google-chrome-extension shadow-dom content-script

在我的chrome扩展中,内容脚本加载到错误的窗口中,而不是加载到顶级浏览器窗口中,而是加载到iframe中!

因此,我希望在https://www.google.com标签上将其加载到主窗口中,但要在Google产品下拉菜单中加载-具有网址https://notifications.google.com的iframe。

如果我尝试使用window.topwindow.parent访问顶层窗口,则会显示错误消息:

DOMException: Blocked a frame with origin "https://notifications.google.com" from accessing a cross-origin frame.

如何使内容脚本加载到顶级窗口中?

我的manifest.josn contanis:

"content_scripts": [
    {
      "matches": ["http://*/*", "https://*/*", "<all_urls>"],
      "match_about_blank": true,
      "js": ["dist/contentScript.js"],
      "run_at": "document_idle",
      "all_frames": true
    }
  ],

0 个答案:

没有答案