Skip to content

Instantly share code, notes, and snippets.

@misterpah
Forked from fastmover/tampermonkey.jquery.js
Created August 18, 2014 04:33
Show Gist options
  • Save misterpah/1a3930bc38a07c6b17c0 to your computer and use it in GitHub Desktop.
Save misterpah/1a3930bc38a07c6b17c0 to your computer and use it in GitHub Desktop.
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function main(){
// your code here
}
// load jQuery and execute the main function
addJQuery(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment