我开发了chrome扩展程序。像往常一样,我在工具栏中有扩展按钮。在弹出窗口中,我有开始按钮。单击开始时,将发送带有“开始”的消息,并且内容脚本中的某些过程正在启动。问题是当我切换标签页或卷起(隐藏)Chrome时,该过程将暂停。当我切换到扩展名所在的选项卡时-该过程继续执行。为了进行测试,我进行了简单的测试,结果是相同的-脚本已暂停:
var TTT = 0;
function TEST() {
setTimeout(function () {
TTT = TTT + 1;
console.clear();
console.log(TTT);
TEST();
}, 500)
}
清单:
{
"background": {
"scripts": [ "background.js" ]
},
"content_scripts": [ {
"js": [ "libs/jquery.js", "js/js.js" ],
"matches": [ "\u003Call_urls>" ]
} ],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"description": "DESCR",
"icons": {
"128": "images/ic_wmid.png"
},
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCA98AMIIBC8KCBQEAurLyivtW46v1EZWRUryw0OYepQtEhjOkUixB5tDfXieDCZKQGEzv8ODtaOJKyAe/GEtnYKYJ50RP0FiYUUxk6p7biROiI1yt/YWajE3pVMwe8X2Iwuv2oXaUswSIlydIUkCcyiBVp5XqhCtH4/JA07QlX4g0sy8dyBSz9X0jbGcWMdvmUME52YqbnSCGuzNf/sL0hSv3NJuvG2e/mtnW4Zr9lKUYDfzc0rKOTAvQw7wlrnyFg3oadnuR1KkZM3Zt2vSE2eSlG7HF+8riwzFJZA5SIdN7i7kkXqbuprxs36qv+hJgnl4bIHEiE+MFBjujPRMaO3aFi0wLC3TCaZYIWQIDAHYE",
"manifest_version": 2,
"name": "NAME,
"page_action": {
"default_icon": {
"19": "images/icon.png",
"38": "images/icon.png"
},
"default_title": "TITLE"
},
"permissions": [ "activeTab", "webRequest", "webRequestBlocking", "tabs", "notifications", "http://*/*", "https://*/*" ],
"version": "1.2",
"web_accessible_resources": [ "images/ic_wmid48.png" ]
}
我认为其他任何文件和代码都可能无法触及。