![](/img/trans.png)
[英]Chrome extension: how to trap/handle content-script errors globally?
[英]How to trigger a Chrome extension, content-script for a given hash in the URL?
我的比赛计划:
"content_scripts" : [
{
"matches" : [
"https://stackoverflow.com/questions#epic*"
],
"js" : ["silly.js"]
}
],
因此,如果用户访问网页(如https://stackoverflow.com/questions )然后添加#epic
它将转到https://stackoverflow.com/questions#epic但在 URL 末尾会有#epic
,这将激活内容脚本silly.js
。
这就是应该发生的事情,但这不起作用。
请参阅内容脚本,匹配模式。
匹配模式不对 URL 的 片段部分进行操作。
要将内容脚本限制为给定的哈希,请使用include_globs
和/或exclude_globs
属性。
例如,在这种情况下,您可以使用:
"content_scripts" : [ {
"matches" : [
"*://stackoverflow.com/questions/*"
],
"include_globs" : ["*#epic*"],
"js" : ["silly.js"]
} ],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.