一,文件一,main.js
let icon = 'https://www.baidu.com/favicon.ico';
document.title="吧";
let logo = document.images;
for (let i=0;i<logo.length;i++){
if (logo[i].src.indexOf('logo.png') > -1) {
logo[i].style.display = 'none';
}
}
const changeFavicon = link => {
let $favicon = document.querySelector('link[rel="icon"]');
if ($favicon !== null) {
$favicon.href = link;
} else {
$favicon = document.createElement("link");
$favicon.rel = "icon";
$favicon.href = link;
document.head.appendChild($favicon);
}
};
changeFavicon(icon);
二,文件二,manifest.json
{
"name": "change title", // 插件的名称
"description": "change web title", // 插件描述
"version": "1.0", // 插件的版本
"manifest_version": 5, // 清单文件的版本
"content_scripts": [ // 需要直接注入页面的JS
{
"matches": [
"http://*/*", //更改指定的网站域名
"https://*/*" //更改指定的网站域名
],
"js": [
"main.js"
],
"all_frames": false
}
]
}
进阶开发 extension-boilerplate
https://github.com/EmailThis/extension-boilerplate
Git clone
修改 package.json “gulp-sass”: “^2.2.0”, 为 “gulp-sass”: “^3.0.0”,
npm i
开发
npm run chrome-watch
npm run opera-watch
npm run firefox-watch
打包
npm run build