我剛開始使用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";