-
Notifications
You must be signed in to change notification settings - Fork 1
/
one_click_bookmarklet.js
4 lines (3 loc) 路 1.84 KB
/
one_click_bookmarklet.js
1
2
3
4
// Most of this bookmarkletis borrowed from
// http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
javascript:(function(){ var el = document.createElement('div'), b = document.getElementsByTagName('body')[0], otherlib = false, msg=''; el.style.position='fixed'; el.style.height='32px'; el.style.width='220px'; el.style.marginLeft='-110px'; el.style.top='0'; el.style.left='50%'; el.style.padding='5px 10px'; el.style.zIndex=1001; el.style.fontSize='12px'; el.style.color='#222'; el.style.backgroundColor='#f99'; if(typeof jQuery!='undefined') { msg='This page already using jQuery v'+jQuery.fn.jquery; return showMsg(); } else if(typeof $=='function') { otherlib=true; } function getScript(url,success) { var script=document.createElement('script'); script.src=url; var head=document.getElementsByTagName('head')[0],done=false; script.onload = script.onreadystatechange = function() { if(!done&&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')) { done=true; success(); script.onload = script.onreadystatechange = null; head.removeChild(script); } }; head.appendChild(script); } getScript('http://code.jquery.com/jquery-latest.min.js', function() { if(typeof jQuery=='undefined') { msg='Sorry, but jQuery wasn\'t able to load'; } else { msg = 'This page is now jQuerified with v' + jQuery.fn.jquery; if(otherlib) { msg += ' and noConflict(). Use $jq(), not $().'; } } showPicks(); return showMsg(); }); function showPicks() { getScript('https://raw.github.com/dpritchett/sagarin_cfb_picks/master/yahoo_scraper.js', function(){alert("Picks loaded!"); }); } function showMsg() { el.innerHTML = msg; b.appendChild(el); window.setTimeout(function(){ if(typeof jQuery=='undefined'){ b.removeChild(el); } else{ jQuery(el).fadeOut('slow',function(){ jQuery(this).remove();}); if(otherlib) { $jq=jQuery.noConflict(); } } }, 2500); } })();