Last active
November 8, 2021 15:53
-
-
Save Mufanc/25b68b4088e07921dbba4b261db28950 to your computer and use it in GitHub Desktop.
[使用 Chrome 扩展优雅地注入] 一种几乎「完全无感」的脚本注入方式 #JavaScript #Chromium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* code in inject.js | |
* added "web_accessible_resources": ["injected.js"] to manifest.json | |
*/ | |
var script = document.createElement('script'); | |
script.src = chrome.extension.getURL('injected.js'); | |
script.onload = function() { | |
this.remove(); | |
}; | |
(document.head || document.documentElement).appendChild(script); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment