gpt4 book ai didi

javascript - Chrome 扩展扰乱了 iframe

转载 作者:行者123 更新时间:2023-11-27 23:56:51 28 4
gpt4 key购买 nike

这很奇怪,但是 chrome 扩展正在加载 iframe 中的内容文件。我有一个 <all_urls>在内容脚本匹配中,我将其切换为 "http://*/*", "https://*/*" .这很奇怪,因为它仍在 iframes 中加载页面。甚至想到了iframe's src不适合那场比赛。

我找到了一个脚本来检测对象是否被加载到 iframe 中,现在内容脚本不会影响 google adchoices 或其他广告,但值得注意的是,当我的扩展程序打开时,jsfiddle 不起作用。

我不想发布代码,所以请告诉我我需要发布什么代码。

似乎它唯一起作用的时候是当内容脚本有一些无效代码并且根本不起作用时。

所有的扩展程序都这样做吗?我将如何解决它?什么代码可能会执行此操作?

非常感谢您。

list :

{
"name": "NA",
"version": "1.0.9",
"manifest_version": 2,
"description": "NA",
"browser_action":{
"default_icon": {
"19": "img/icon19.png",
"38": "img/icon38.png"
},
"default_popup":"popup.html"
},
"permissions": [
"storage",
"tabs",
"contextMenus"
],
"background":{
"scripts":["background.js"]
},
"icons": {
"16": "img/icon16.png",
"48": "img/icon48.png",
"128": "img/icon128.png"
},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["scripts/jquery-for-content-only.js","scripts/content.js"],
"run_at": "document_end",
"all_frames": true
}
]
}

最佳答案

Chrome 扩展 list 文件决定了内容脚本的运行方式和位置,不仅在 URL 模式匹配方面,而且在它们是否适用于父页面下方的框架方面:

来自 Google's "Content Scripts" documentation :

Name: all_frames

Type: boolean

Description:

Optional. Controls whether the content script runs in all frames of the matching page, or only the top frame.

Defaults to false, meaning that only the top frame is matched.

由于您将此属性设置为 true,因此您的脚本在 iframe 中运行。将此属性设置为 false 或将其删除,然后脚本应仅在父页面中运行。

关于javascript - Chrome 扩展扰乱了 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23446752/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com