Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Terkwood/e8a3b24f08353952b29299a001e55d0f to your computer and use it in GitHub Desktop.
Save Terkwood/e8a3b24f08353952b29299a001e55d0f to your computer and use it in GitHub Desktop.
Inject javascript into HTML pages from console

#Inject javascript into HTML pages from console

An easy way to inject Javascripts into the current loaded dom using the developer console in chrome.

jQuery

var script = document.createElement('script');
script.src = 'http://code.jquery.com/jquery-1.7.2.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);

to-markdown

var script = document.createElement('script');
script.src = 'https://domchristie.github.io/to-markdown/bower_components/to-markdown/dist/to-markdown.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);

underscore

var script = document.createElement('script');
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);

luxon

var script = document.createElement('script');
script.src = 'https://moment.github.io/luxon/global/luxon.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment