-
-
Save smerrill/70c1836401581b0546d91810a859862e to your computer and use it in GitHub Desktop.
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
// add event helper | |
function addEvent( obj, type, fn ) { | |
if ( obj.addEventListener ) { | |
obj.addEventListener( type, fn, false ); | |
} else if ( obj.attachEvent ) { | |
obj.attachEvent( "on" + type, fn ); | |
} | |
} | |
function cornifyThisGuy() { | |
var script = document.createElement('script'); | |
script.src = 'http://www.cornify.com/js/cornify.js'; | |
if ( window.console ) { | |
window.console.log('YAY! You hot-linked desandro.com/mint/?js! Prepare for unicorns!'); | |
} | |
window.onload = function() { | |
document.body.appendChild( script ); | |
var isFirstCornified = false; | |
function cornifyAgain() { | |
if ( window.cornify_add ) { | |
window.cornify_add(); | |
window.cornify_add(); | |
window.cornify_add(); | |
isFirstCornified = true; | |
} | |
// keep trying it until it happens | |
if ( !isFirstCornified ) { | |
setTimeout( cornifyAgain, 1000 ); | |
} | |
} | |
cornifyAgain(); | |
if ( window.cornify_add ) { | |
window.cornify_add(); | |
} | |
// cornify with every click | |
addEvent( document, 'click', function( event ) { | |
if ( window.cornify_add ) { | |
event.preventDefault(); | |
event.stopPropagation(); | |
window.cornify_add(); | |
} | |
}); | |
} | |
} | |
cornifyThisGuy(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment