Skip to content

Instantly share code, notes, and snippets.

@adambutler
Last active August 29, 2015 14:01
Show Gist options
  • Save adambutler/ec470e3b1e588d8cc160 to your computer and use it in GitHub Desktop.
Save adambutler/ec470e3b1e588d8cc160 to your computer and use it in GitHub Desktop.
Gremlins Bookmarklet

Gremlins Bookmarklet

An simple bookmarklet to create a horde or gremlins and unleash them on any website. See gremlins.js by marmelab for more information.

Edit a bookmarklet and set the URL to be -

javascript:(function()%7Bvar%20ScriptLoader%2CscriptLoader%3BScriptLoader%3Dfunction()%7Bfunction%20a()%7B%7Dreturn%20a.prototype.setupCallback%3Dfunction(a%2Cb)%7Breturn%20a.readyState%3Fa.onreadystatechange%3Dfunction()%7Breturn%22loaded%22%3D%3D%3Da.readyState%7C%7C%22complete%22%3D%3D%3Da.readyState%3Fb()%3Avoid%200%7D%3Aa.onload%3Dfunction()%7Breturn%20b()%7D%7D%2Ca.prototype.createScript%3Dfunction(a)%7Bvar%20b%3Breturn%20b%3Ddocument.createElement(%22script%22)%2Cb.type%3D%22text%2Fjavascript%22%2Cb.charset%3D%22UTF-8%22%2Cb.src%3Da%2Cb%7D%2Ca.prototype.add%3Dfunction(a%2Cb)%7Bvar%20c%3Breturn%20c%3Dthis.createScript(a)%2Cdocument.body.appendChild(c)%2Cnull!%3Db%3Fthis.setupCallback(c%2Cb)%3Avoid%200%7D%2Ca%7D()%2CscriptLoader%3Dnew%20ScriptLoader%2CscriptLoader.add(%22%2F%2Fcdn.rawgit.com%2Fmarmelab%2Fgremlins.js%2Fmaster%2Fgremlins.min.js%22%2Cfunction()%7Breturn%20gremlins.createHorde().unleash()%7D)%7D)()

GitHub do not allow me to create a link with a JavaScript href, sorry I couldn't just give you a link to drag.

class ScriptLoader
setupCallback: (script, callback) ->
if script.readyState
script.onreadystatechange = ->
callback() if script.readyState is "loaded" or script.readyState is "complete"
else
script.onload = ->
callback()
createScript: (scriptUrl) ->
script = document.createElement 'script'
script.type = 'text/javascript'
script.charset = 'UTF-8'
script.src = scriptUrl
return script
add: (scriptUrl, callback) ->
script = @createScript(scriptUrl)
document.body.appendChild script
@setupCallback(script, callback) if callback?
scriptLoader = new ScriptLoader()
scriptLoader.add '//cdn.rawgit.com/marmelab/gremlins.js/master/gremlins.min.js', ->
gremlins.createHorde().unleash()
var ScriptLoader, scriptLoader;
ScriptLoader = (function() {
function ScriptLoader() {}
ScriptLoader.prototype.setupCallback = function(script, callback) {
if (script.readyState) {
return script.onreadystatechange = function() {
if (script.readyState === "loaded" || script.readyState === "complete") {
return callback();
}
};
} else {
return script.onload = function() {
return callback();
};
}
};
ScriptLoader.prototype.createScript = function(scriptUrl) {
var script;
script = document.createElement('script');
script.type = 'text/javascript';
script.charset = 'UTF-8';
script.src = scriptUrl;
return script;
};
ScriptLoader.prototype.add = function(scriptUrl, callback) {
var script;
script = this.createScript(scriptUrl);
document.body.appendChild(script);
if (callback != null) {
return this.setupCallback(script, callback);
}
};
return ScriptLoader;
})();
scriptLoader = new ScriptLoader();
scriptLoader.add('//cdn.rawgit.com/marmelab/gremlins.js/master/gremlins.min.js', function() {
return gremlins.createHorde().unleash();
});
var ScriptLoader,scriptLoader;ScriptLoader=function(){function a(){}return a.prototype.setupCallback=function(a,b){return a.readyState?a.onreadystatechange=function(){return"loaded"===a.readyState||"complete"===a.readyState?b():void 0}:a.onload=function(){return b()}},a.prototype.createScript=function(a){var b;return b=document.createElement("script"),b.type="text/javascript",b.charset="UTF-8",b.src=a,b},a.prototype.add=function(a,b){var c;return c=this.createScript(a),document.body.appendChild(c),null!=b?this.setupCallback(c,b):void 0},a}(),scriptLoader=new ScriptLoader,scriptLoader.add("//cdn.rawgit.com/marmelab/gremlins.js/master/gremlins.min.js",function(){return gremlins.createHorde().unleash()});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment