Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bookmarklet to load Helium without modifying the page
/*
Loads http://github.com/geuis/helium-css for testing without modifying the source pages
Crunched by http://ted.mielczarek.org/code/mozilla/bookmarklet.html to:
javascript:(function(){(function(msg,target){var loader=function(){if(arguments.callee._executed)return;arguments.callee._executed=true;if(typeof target==="function"){target();}else{jQuery.getScript(target);}var el=document.createElement('div');el.style.position='absolute';el.style.height='30px';el.style.width='200px';el.style.margin='0 auto 0 auto';el.style.top='0';el.style.left='40%';el.style.padding='5px 10px';el.style.backgroundColor='#F00';el.style.fontWeight="bold";el.style.textAlign="center";el.innerHTML=msg;document.body.appendChild(el);window.setTimeout(function(){jQuery(el).fadeOut('slow',function(){jQuery(this).remove();});},2500);};if(typeof jQuery!=='undefined'){loader();}else{var s=document.createElement('script');s.type="text/javascript";s.setAttribute('src',document.location.protocol+'//ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js');if(s.addEventListener){s.addEventListener("load",loader,false);}else if("onreadystatechange" in s){s.onreadystatechange=function(){if(this.readyState=='complete'||this.readyState=='loaded'){loader();}};}else{window.setTimeout(loader(),2500);}document.getElementsByTagName('head')[0].appendChild(s);}})("Helium Loaded!",function(){jQuery.getScript('http://github.com/geuis/helium-css/raw/master/helium.js',function(){helium.init();});});})();
*/
(function (msg, target) {
var loader = function() {
// Avoid executing this function twice:
if (arguments.callee._executed) return;
arguments.callee._executed = true;
if (typeof target === "function") {
target();
} else {
jQuery.getScript(target);
}
// Now that we're done with the actual work, let's display a
// confirmation message so the user knows it's ready:
var el = document.createElement('div');
el.style.position='absolute';
el.style.height='30px';
el.style.width='200px';
el.style.margin='0 auto 0 auto';
el.style.top='0';
el.style.left='40%';
el.style.padding='5px 10px';
el.style.backgroundColor='#F00';
el.style.fontWeight="bold";
el.style.textAlign="center";
el.innerHTML=msg;
document.body.appendChild(el);
window.setTimeout( function() { jQuery(el).fadeOut('slow', function() { jQuery(this).remove(); } ); }, 2500 );
};
if (typeof jQuery !== 'undefined') {
// Nice - this page already uses jQuery!
loader();
} else {
var s = document.createElement('script');
s.type = "text/javascript";
s.setAttribute('src', document.location.protocol + '//ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js');
if (s.addEventListener) { // Mozilla / WebKit
s.addEventListener("load", loader, false);
} else if ("onreadystatechange" in s) { // IE
s.onreadystatechange = function () {
if (this.readyState == 'complete' || this.readyState == 'loaded') { loader(); }
};
} else {
// Chances are if your browser is this old jQuery won't even work but just in case:
window.setTimeout(loader(), 2500);
}
document.getElementsByTagName('head')[0].appendChild(s);
}
})("Helium Loaded!",
function() {
jQuery.getScript('http://github.com/geuis/helium-css/raw/master/helium.js', function() { helium.init(); });
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.