在我的chrome扩展中,内容脚本加载到错误的窗口中,而不是加载到顶级浏览器窗口中,而是加载到iframe中!
因此,我希望在https://www.google.com
标签上将其加载到主窗口中,但要在Google产品下拉菜单中加载-具有网址https://notifications.google.com
的iframe。
如果我尝试使用window.top
或window.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
}
],