crazy4groovy
8/30/2013 - 8:35 PM

bookmarklet: insert arbitrary asset (js/css) into current webpage (defaults to jQuery 1.8.x).

bookmarklet: insert arbitrary asset (js/css) into current webpage (defaults to jQuery 1.8.x).

//bookmarkletify it on: http://benalman.com/code/test/jquery-run-code-bookmarklet/ or http://chriszarate.github.io/bookmarkleter/

(function(){
 var filename=prompt("resource URL [jquery 1.8.x]:");
 filename=filename || 'https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js';
 var type=prompt("type (js/css) [js]:");
 type = type || 'js';
 var s;
 if (type==="js"){
  s=document.createElement('script');
  s.setAttribute("type","text/javascript");
  s.setAttribute("src", filename);
 }
 else if (type==="css"){
  s=document.createElement("link");
  s.setAttribute("rel", "stylesheet");
  s.setAttribute("type", "text/css");
  s.setAttribute("href", filename);
 }
 if (typeof s!="undefined") {
  document.getElementsByTagName("head")[0].appendChild(s); 
  setTimeout(function(){alert('DONE - jQuery:'+jQuery.fn.jquery)}, 500);
 }
})();