Created
April 5, 2017 13:15
-
-
Save uxter/50fb1c7011471442862bd921ec589a64 to your computer and use it in GitHub Desktop.
How to inject custom JavaScript in web page? (simple google chrome plugin)
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
// Your code |
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
var script = document.createElement('script'); | |
script.setAttribute('type', 'text/javascript'); | |
script.src = chrome.extension.getURL('injected.js'); | |
setTimeout(function() { | |
document.head.appendChild(script); | |
}); |
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
{ | |
"manifest_version": 2, | |
"name": "Inject custom script", | |
"short_name": "InjectCustomScript", | |
"version": "1.0.0", | |
"content_scripts": [{ | |
"matches": [ | |
"*://*/*" | |
], | |
"js": [ "injector.js" ], | |
"run_at": "document_start", | |
"persistent": false | |
}], | |
"web_accessible_resources": [ | |
"injected.js" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment