Script appending from jQuery’s source code, adapted by Paul Irish. Tested & working on Chrome Snippets as well!
src - https://www.smashingmagazine.com/2010/05/make-your-own-bookmarklets-with-jquery/
JavaScript:
(function(){
// the minimum version of jQuery we want
var v = "1.3.2";
// check prior inclusion and version
if (window.jQuery === undefined || window.jQuery.fn.jquery < v) {
var done = false;
var script = document.createElement("script");
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/" + v + "/jquery.min.js";
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
done = true;
initMyBookmarklet();
}
};
document.getElementsByTagName("head")[0].appendChild(script);
} else {
initMyBookmarklet();
}
function initMyBookmarklet() {
(window.myBookmarklet = function() {
// your JavaScript code goes here!
})();
}
})();
src - https://www.smashingmagazine.com/2010/05/make-your-own-bookmarklets-with-jquery/