I can successfully inject jQuery to a page with the following bookmarklet:
javascript: void((function(doc) {
if (typeof jQuery == 'undefined') {
var script_jQuery = document.createElement('script');
script_jQuery.setAttribute('src', 'https://code.jquery.com/jquery-latest.min.js');
Node.prototype.appendChild.call(document.body, script_jQuery);
console.log('jQuery included ^_^');
} else {
console.log('jQuery already included ...');
}
})(document));
Is there a way to use the just injected jQuery within the same bookmarklet? I tried putting console.log(jQuery.toString())
after the apend part, but it didn't work. It seems to me that jQuery is only available for using after the bookmarklet finishes.