Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SantoshSrinivas79/69f235e0876a87c53668 to your computer and use it in GitHub Desktop.
Save SantoshSrinivas79/69f235e0876a87c53668 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);
@midlan
Copy link

midlan commented Feb 7, 2019

thanks, I started with your code and created universal script injection using browser bookmarks: https://gist.github.com/midlan/5b9e786266bdca68b45ae88da92c7669

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment