Skip to content

Instantly share code, notes, and snippets.

@xdanger
Forked from girlcheese/inject.javascript.js
Last active October 6, 2018 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdanger/1c02597387f084f040eb35633db09a96 to your computer and use it in GitHub Desktop.
Save xdanger/1c02597387f084f040eb35633db09a96 to your computer and use it in GitHub Desktop.
Inject jQuery into a page
%%javascript
function injectJavaScript(url) {
var tag = document.createElement('script');
tag.src = url;
tag.type = 'text/javascript';
tag.async = 'true';
var hookTag = document.getElementsByTagName('script')[0];
hookTag.parentNode.insertBefore(tag, hookTag);
}
;(function() {
injectJavaScript('https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js');
injectJavaScript('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment