function content_scriptsCSS(file) {
var link = document.createElement('link');
link.href = chrome.runtime.getURL(file);
link.rel = 'stylesheet';
(document.head || document.documentElement).appendChild(link);
}
// 注入css
content_scriptsCSS('content_scripts.css');
function master_process(file) {
var script = document.createElement('script');
script.src = chrome.runtime.getURL(file);
script.onload = function () {
this.remove();
};
(document.head || document.documentElement).appendChild(script);
}
// 注入js
master_process('master_process.js');
// manifest.js
{
"name": "addCssJs",
"version": "1.0.0",
"manifest_version": 3,
"web_accessible_resources": [
{
"resources": [
"content_scripts.css",
"master_process.js"
],
"matches": [
"<all_urls>"
]
}
]
}