Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@midlan 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