Skip to content

Instantly share code, notes, and snippets.

@phillipalexander
Created August 8, 2013 19:39
Show Gist options
  • Save phillipalexander/6187965 to your computer and use it in GitHub Desktop.
Save phillipalexander/6187965 to your computer and use it in GitHub Desktop.
inject a JS library into the current webpage
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