Created
August 10, 2011 22:13
-
-
Save MarkTraceur/1138419 to your computer and use it in GitHub Desktop.
Random reloader
This file contains 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
<html> | |
<head> | |
<script type="text/javascript" src="randomreload.js"></script> | |
</head> | |
<body> | |
<h2>Currently implemented: | |
<script type="text/javascript"> | |
reloading = new reloader(1); | |
document.write(reloading.r.length); | |
</script> | |
ways to reload the page. | |
</h2> | |
<button id="abutton">I'm a button!</button> | |
<script type="text/javascript"> | |
document.getElementById('abutton').onclick = function() { | |
reloading.reload(); | |
}; | |
</script> | |
</body> | |
</html> |
This file contains 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
/* | |
randomreload.js -- reload using a random method | |
based on this list: http://www.phpied.com/files/location-location/location-location.html | |
USE: | |
... | |
<script type="text/javascript" src="randomreload.js"></script> | |
... | |
<script type="text/javascript"> | |
rl = new reloader(); | |
rl.reload(); | |
</script> | |
... | |
Protip: Use reloader.reload as a callback! | |
LICENSE: http://sam.zoy.org/wtfpl | |
*/ | |
function reloader(recurse) { | |
recurse = recurse || 1; | |
var smp = ["location", | |
"location.href", | |
"location['href']"]; | |
var smf = ["location.assign(%)", | |
"location.replace(%)", | |
"location['assign'](%)", | |
"location['replace'](%)"]; | |
var smo = ["location.reload()", | |
"location['reload']()"] | |
var p = ["location", | |
"location.href", | |
"window.location", | |
"window.location.href", | |
"self.location", | |
"self.location.href", | |
"location['href']", | |
"window['location']", | |
"window['location'].href", | |
"window['location']['href']", | |
"window.location['href']", | |
"self['location']", | |
"self['location'].href", | |
"self['location']['href']", | |
"self.location['href']"]; | |
var f = ["location.assign(%)", | |
"location.replace(%)", | |
"window.location.assign(%)", | |
"window.location.replace(%)", | |
"self.location.assign(%)", | |
"self.location.replace(%)", | |
"location['assign'](%)", | |
"location['replace'](%)", | |
"window.location['assign'](%)", | |
"window.location['replace'](%)", | |
"window['location'].assign(%)", | |
"window['location'].replace(%)", | |
"window['location']['assign'](%)", | |
"window['location']['replace'](%)", | |
"self.location['assign'](%)", | |
"self.location['replace'](%)", | |
"self['location'].assign(%)", | |
"self['location'].replace(%)", | |
"self['location']['assign'](%)", | |
"self['location']['replace'](%)"]; | |
this.r = []; | |
for(var i in p) { | |
for(var j in p) { | |
this.r[this.r.length] = p[i] + ' = ' + p[j]; | |
} | |
for(var k in f) { | |
var tpl = f[k]; | |
this.r[this.r.length] = tpl.replace('%', p[i]); | |
} | |
} | |
var o = ["location.reload()", | |
"location['reload']()", | |
"window.location.reload()", | |
"window['location'].reload()", | |
"window.location['reload']()", | |
"window['location']['reload']()", | |
"self.location.reload()", | |
"self['location'].reload()", | |
"self.location['reload']()", | |
"self['location']['reload']()"]; | |
for (var i in o) { | |
this.r[this.r.length] = o[i]; | |
} | |
var d = this.r.slice(0); | |
for (var i in d) { | |
this.r[this.r.length] = 'eval(\"' + d[i] + '\")'; | |
} | |
for (var i in d) { | |
this.r[this.r.length] = 'new Function(\"' + d[i] + '\")()'; | |
} | |
var ix = 2; | |
while (ix <= recurse) { | |
var tar = ''; | |
for (var ixx=0; ixx < ix; ixx++) | |
tar += 'self.'; | |
for (var i in smp) { | |
for (var j in p) { | |
this.r[this.r.length] = tar + smp[i] + ' = ' + p[j]; | |
} | |
for (var k in f) { | |
var tpl = f[k]; | |
this.r[this.r.length] = tpl.replace('%', tar + smp); | |
} | |
} | |
for (var i in smo) { | |
this.r[this.r.length] = tar + smo[i]; | |
} | |
ix++; | |
} | |
this.reload = function() { | |
var i = Math.floor(Math.random() * this.r.length); | |
eval(this.r[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment