我有一個簡單的chrome腳本,它修改了特定網頁的tab鍵。 這工作得很好,直到鉻v27來了。這是代碼:修改tab鍵的Chrome用戶腳本停止工作了
的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"
}
編輯: 我原來的劇本仍在運行,但只能在initally加載幀。所以我加了
「all_frames」:真實,
到清單中,沒有工作。
有什麼我可以做的嗎? 感謝您的幫助
它調用事件偵聽器還是根本不調用事件偵聽器? –
我已更新問題... – spoekes
您是否嘗試過我的答案? –