我刚开始使用JavaScript和想修改的MDN教程脚本“匹配” content_scripts运行不同的脚本,Your First WebExtension基于
我想周围画一个红色或蓝色的盒子一个网页取决于它是http://还是https://。但是,只有一个脚本会运行。
的manifest.json的是这样的:
{
"manifest_version": 2,
"name": "HTTPS Detect",
"version": "1.0",
"description": "Draws a blue border around HTTPS protected websites. Non-HTTPS sites are given a red border, indicating they do not provide encryption.",
"icons": {
"48": "icons/border-48.png"
},
"content_scripts": [
{
\t
"matches": ["https://*/*"],
"js": ["httpsdetect.js"],
"matches": ["http://*/*"],
"js": ["nohttps.js"]
\t }
\t
\t ]
}
的httpsdetect.js如下:
document.body.style.border = "5px solid blue";
而且nohttps.js被:
document.body.style.border = "5px solid red";