Last active
December 21, 2015 03:59
-
-
Save Calvein/6246582 to your computer and use it in GitHub Desktop.
Underscorify puts underscore on the current page (based on jQuerify http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:!function(){function e(e,t){var n=document.createElement("script");n.src=e;var o=document.getElementsByTagName("head")[0],i=!1;n.onload=n.onreadystatechange=function(){i||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(i=!0,t(),n.onload=n.onreadystatechange=null,o.removeChild(n))},o.appendChild(n)}function t(){n.innerHTML=d,o.appendChild(n),n.style.opacity=1,"undefined"==typeof _?o.removeChild(n):setTimeout(function(){n.style.opacity=0,n.style.transition="4s 3s",n.addEventListener("transitionend",function(){o.removeChild(n)}),n.addEventListener("webkitTransitionEnd",function(){o.removeChild(n)}),i&&(underscore=_.noConflict())},500)}var n=document.createElement("div"),o=document.getElementsByTagName("body")[0],i=!1,d="";return n.style.position="fixed",n.style.height="36px",n.style.width="220px",n.style.marginLeft="-110px",n.style.top="0",n.style.left="50%",n.style.padding="5px 10px",n.style.zIndex=1001,n.style.fontSize="12px",n.style.color="#222",n.style.backgroundColor="#f99","undefined"!=typeof _?(d="This page already using underscore v"+_.VERSION,t()):("function"==typeof _&&(i=!0),e("https://rawgit.com/jashkenas/underscore/master/underscore.js",function(){return"undefined"==typeof _?d="Sorry, but underscore wasn't able to load":(d="This page is now underscorified with v"+_.VERSION,i&&(d+=" and noConflict(). Use underscore, not _.")),t()}),void 0)}() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var el = document.createElement('div'), | |
b = document.getElementsByTagName('body')[0] | |
, otherlib = false, msg = ''; | |
el.style.position = 'fixed'; | |
el.style.height = '36px'; | |
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 _ != 'undefined') { | |
msg = 'This page already using underscore v' + _.VERSION; | |
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('https://rawgit.com/jashkenas/underscore/master/underscore.js', function() { | |
if (typeof _ == 'undefined') { | |
msg = 'Sorry, but underscore wasn\'t able to load'; | |
} else { | |
msg = 'This page is now underscorified with v' + _.VERSION; | |
if (otherlib) { | |
msg += ' and noConflict(). Use underscore, not _.'; | |
} | |
} | |
return showMsg(); | |
}); | |
function showMsg() { | |
el.innerHTML = msg; | |
b.appendChild(el); | |
el.style.opacity = 1 | |
if (typeof _ == 'undefined') { | |
b.removeChild(el); | |
} else { | |
setTimeout(function() { | |
el.style.opacity = 0 | |
el.style.transition = '4s 3s' | |
el.addEventListener('transitionend', function() { | |
b.removeChild(el) | |
}) | |
el.addEventListener('webkitTransitionEnd', function() { | |
b.removeChild(el) | |
}) | |
if (otherlib) { | |
underscore = _.noConflict(); | |
} | |
}, 500) | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment