我创建了一个扩展,使用executescript
api注入一段代码(如下所示),基本上window.onbeforeunload
确认他们要关闭页面。我有脚本工作,并使用file://*/*
权限,让它注入文件URL。但是,在我下载的flash游戏中进行测试时,脚本没有注入。该网址为externalfile:drive-randomtext/root/SWFNAME.swf
。我尝试在权限中添加externalfile://*/*
,但收到以下错误消息:There were warnings when trying to install this extension: Permission 'externalfile://*/*' is unknown or URL pattern is malformed.
是否有外部文件权限或其他方式执行此操作?
的manifest.json:
{
"name": "name",
"short_name": "name",
"version": "3.6",
"manifest_version": 2,
"description": "Desc",
"permissions": [
"storage",
"http://*/",
"https://*/",
"tabs",
"activeTab",
"webNavigation",
"*://*/*",
"file://*/*"
],
"page_action": {
"default_icon": "logo.png"
},
"background": {
"scripts": ["disabled.js"]
}
}
执行的脚本:
(热键绑定代码太长,可以找到here)
Mousetrap.bind('ctrl+m', function(e) {
window.onbeforeunload = confirmExit;function confirmExit(){alert('confirm exit is being called');return'Close page?';}
alert('Enabled');
return false;
});
Mousetrap.bind('ctrl+q', function(e) {
location.reload();
return false;
});