Google chrome extension 铬延伸<;所有URL>;但不是在所有网站上都有效

Google chrome extension 铬延伸<;所有URL>;但不是在所有网站上都有效,google-chrome-extension,pattern-matching,manifest,Google Chrome Extension,Pattern Matching,Manifest,问题解释 我编写了一个小扩展,几乎在所有网站上都可以正常工作,没有错误/警告,但有少量页面无法运行。例如,chrome webstore本身 我假设必须在清单中插入/更改某些内容,但由于匹配模式中“”的定义,我不知道是什么 我用Chrome开发者工具检查了“ui.html”的内容。内容必须插入到每个网站,但在插件不起作用的网站上,它们不会出现 也许谷歌阻止代码注入? 所以我要问你们:我必须做什么 使用的代码 我的舱单: { "manifest_version": 2, "nam

问题解释

我编写了一个小扩展,几乎在所有网站上都可以正常工作,没有错误/警告,但有少量页面无法运行。例如,chrome webstore本身

我假设必须在清单中插入/更改某些内容,但由于匹配模式中“”的定义,我不知道是什么

我用Chrome开发者工具检查了“ui.html”的内容。内容必须插入到每个网站,但在插件不起作用的网站上,它们不会出现

也许谷歌阻止代码注入? 所以我要问你们:我必须做什么

使用的代码

我的舱单:

{
    "manifest_version": 2,

    "name": "Drag gestures",
    "description": "While holding down right mouse button, move left to go back and right to go forth the browser history. 
    Easy as pie but damn useful.",
    "version": "1.0",

    "options_page": "popup.html",
    "browser_action": {
        "default_icon": "icon-48px.png",
        "default_popup": "popup.html"
    },
    "icons": { 
        "16": "icon-16px.png",
        "48": "icon-48px.png",
        "128": "icon-128px.png" 
    },
    "background": {
        "page": "ui.html",
        "css": "ui.css",
        "persistent": false
    },
    "content_scripts": [
        {
            "js": ["jquery.js", "draggestures.js"],
            "html": ["ui.html"],
            "css": ["ui.css"],
            "matches": ["<all_urls>"],
            "run_at": "document_end"
        }
    ],
    "web_accessible_resources": [
        "jquery-1.10.2.min.map",
        "jquery.js",
        "draggestures.js",
        "ui.html",
        "ui.css",
        "move.png"
    ]
}
{
“清单版本”:2,
“名称”:“拖动手势”,
“说明”:“在按住鼠标右键的同时,向左移动可返回浏览器历史记录,向右移动可返回浏览器历史记录。
简单得像馅饼,但非常有用。”,
“版本”:“1.0”,
“选项页面”:“popup.html”,
“浏览器操作”:{
“默认图标”:“icon-48px.png”,
“默认弹出窗口”:“popup.html”
},
“图标”:{
“16”:“icon-16px.png”,
“48”:“icon-48px.png”,
“128”:“icon-128px.png”
},
“背景”:{
“页面”:“ui.html”,
“css”:“ui.css”,
“持续”:假
},
“内容脚本”:[
{
“js”:[“jquery.js”,“draggestures.js”],
“html”:[“ui.html”],
“css”:[“ui.css”],
“匹配项”:[“”],
“运行时间”:“文档结束”
}
],
“网络可访问资源”:[
“jquery-1.10.2.min.map”,
“jquery.js”,
“draggestures.js”,
“ui.html”,
“ui.css”,
“move.png”
]
}
ui内容加载在draggestures.js中:

// append the html with the move divs
$("body").append($('<div>').load(getHTML));
//用move div追加html
$(“body”).append($('').load(getHTML));
ui.html包含:

<div class="move" id="idle"></div>
<div class="move" id="back"></div>
<div class="move" id="forth"></div>

更新

问题是,一些站点阻止了javascript的注入,所以什么也没发生。多亏了rsanchez在下面链接的帖子,我才有了这个想法。我也曾在易趣上体验过产品描述框架中的不当行为。还没有找到解决办法

更新2

Rob W为我指出了有关iFrame的正确方向。我所要做的就是在“内容脚本”的清单中插入“All_frames”:true。现在一切都很好


谢谢:)

响应“更新”时可能会重复@karl:内容脚本仅插入顶层框架中。如果要在子帧中激活它们,请将
“所有帧”:true
添加到内容脚本中。@Rob W:很好。在web应用商店中实现并更新:)现在它工作得更好了。在我刷新页面之前,我的内容脚本不会在匹配的页面上运行。知道是什么原因吗?!可能重复的