Skip to content

Instantly share code, notes, and snippets.

@seutje
Created March 14, 2014 15:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save seutje/9549554 to your computer and use it in GitHub Desktop.
Save seutje/9549554 to your computer and use it in GitHub Desktop.
gremlins.js bookmarklet
(function (e, a, h, f, c, b, d) {
c = a.createElement("script");
c.type = "text/javascript";
c.src = "https://rawgithub.com/marmelab/gremlins.js/master/gremlins.min.js";
c.onload = c.onreadystatechange = function () {
if (!b && (!(d = this.readyState) || d == "loaded" || d == "complete")) {
h();
f(c).remove()
}
};
a.documentElement.childNodes[0].appendChild(c);
})(window, document, function () { gremlins && gremlins.createHorde().unleash(); });
javascript:(function(e,a,h,f,c,b,d){c=a.createElement("script");c.type="text/javascript";c.src="https://rawgithub.com/marmelab/gremlins.js/master/gremlins.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h();f(c).remove()}};a.documentElement.childNodes[0].appendChild(c);})(window,document,function(){gremlins&&gremlins.createHorde().unleash();});
@artoliukkonen
Copy link

If tested site is using RequireJS this bookmarklet won't work. Here's a working version for this case (optimal would ofc be one script for all cases, however this is enough for me..).

require.config({
    paths: { 
        gremlins:  'https://rawgithub.com/marmelab/gremlins.js/master/gremlins.min'
    }
});
require(['gremlins'], function(gremlins) {
    gremlins.createHorde()
        .unleash();
});

Minified for bookmarklet:

javascript:require.config({paths:{gremlins:"https://rawgithub.com/marmelab/gremlins.js/master/gremlins.min"}}),require(["gremlins"],function(a){a.createHorde().unleash()});

@seutje
Copy link
Author

seutje commented Mar 28, 2014

Neat, I didn't think of that use-case, thanks!
I'll see if I can roll it up in a conditional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment