【发布时间】:2013-05-27 20:00:55
【问题描述】:
我有一个简单的 chrome 用户脚本,可以修改特定网页的 tab 键。 在 chrome v27 出现之前,这一直很好。这是代码:
script.js:
// ==UserScript==
// @name Name
// @namespace http://www.someNameSpace.com/
// @description Description
// @include http://weburl1.com/*
// @include http://weburl2.com/*
// ==/UserScript==
function key_event(event){
if(event.keyCode == 9){ //get tab pressed
/* do something here */
}
}
document.addEventListener("keydown", key_event, true);
manifest.json:
{
"content_scripts": [ {
"all_frames" : true,
"exclude_globs": [ ],
"include_globs": [ "http://weburl1.com/*", "http://weburl2.com/*" ],
"js": [ "script.js" ],
"matches": [ "http://*/*", "https://*/*" ],
"run_at": "document_idle"
} ],
"converted_from_user_script": true,
"description": "Description",
"key": "kVJUyHgHhlZtX2koEeV1ZF7yYHXfLyCyprC+I18+QzI=",
"name": "Name",
"version": "1.01"
}
编辑: 我发现该脚本仍在运行,但仅在初始加载的帧上运行。所以我加了
“all_frames”:是的,
到没有工作的清单。
我能做些什么吗? 感谢您的帮助
【问题讨论】:
-
它是否调用了事件监听器?
-
我已经更新了问题...
-
你试过我的答案了吗?
-
不,我还没有尝试过,但我在 chrome 调试器中测试了该页面,发现该脚本仍然适用于最初加载的框架,但不适用于后续框架。
-
hmm .. 似乎你也包含 glob,你是否在 weburl1.com*"、"weburl2.com 上测试扩展?
标签: google-chrome google-chrome-extension userscripts