Created
August 8, 2013 19:39
-
-
Save phillipalexander/6187965 to your computer and use it in GitHub Desktop.
inject a JS library into the current webpage
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
injectLib = do -> | |
scriptSrc = prompt('Source to inject') | |
head = document.getElementsByTagName('head') | |
body = document.getElementsByTagName('body') | |
target = if head? then head else body | |
scriptEl = document.createElement('script') | |
scriptEl.src = scriptSrc | |
target[0].appendChild(scriptEl) | |
console.log("injected: #{scriptSrc}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment