内容脚本在铬错误页面上 [英] Content script on chrome error page
本文介绍了内容脚本在铬错误页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Google Chrome错误页面上运行我的扩展内容脚本?
例如在此网页不可用错误页面上?这是我的manifest.json配置:
{
manifest_version:2,
name :injectbox,
version:1.1,
background:{
scripts:[jquery-1.11.1.min.js,bg。 js]
},
content_scripts:[
{
js:[jquery-1.11.1.min.js],
匹配:[< all_urls> ],
match_about_blank:true,
run_at:document_end
},
{
js:[content.js],
css:[styles.css],
matches:[< all_urls> ],
match_about_blank:true,
run_at:document_end
}
],
permissions:[
tabs ,http:// * / *,https:// * / *,file:// * / *,ftp:// * / *,
webRequest,
存储
}
解决方案 div>
我不认为这是可能的,很可能这是一个内部的 chrome://
页面,它们被排除在页面匹配之外。
另一种解决方案是监听 webRequest
/ webNavigation
中的错误事件。 API并用您自己的名称替换错误页面。
How can I run my extension content script on Google Chrome error page?
For example on the "This webpage is not available" error page? Here is my manifest.json config:
{
"manifest_version": 2,
"name": "injectbox",
"version": "1.1",
"background": {
"scripts": ["jquery-1.11.1.min.js", "bg.js" ]
},
"content_scripts": [
{
"js": [ "jquery-1.11.1.min.js" ],
"matches": [ "<all_urls>" ],
"match_about_blank": true,
"run_at": "document_end"
},
{
"js": [ "content.js" ],
"css":["styles.css"],
"matches": [ "<all_urls>" ],
"match_about_blank": true,
"run_at": "document_end"
}
],
"permissions": [
"tabs", "http://*/*", "https://*/*", "file://*/*", "ftp://*/*",
"webRequest",
"storage"
]
}
解决方案
I don't think it's possible, most probably this is an internal chrome://
page, which are excluded from page matches.
An alternative solution would be to listen to error events in webRequest
/webNavigation
APIs and replace the error page with your own.
这篇关于内容脚本在铬错误页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文