1
0
Fork 0
mirror of https://github.com/prise6/anywhere synced 2024-04-28 07:52:44 +02:00
anywhere/Js/anywhere.js

20 lines
523 B
JavaScript
Raw Normal View History

2016-04-28 01:21:14 +02:00
/**
* Redirect to a "random" link in current page
* - naive code -
*/
2016-05-01 22:30:38 +02:00
javascript:(function(r, c){
2016-04-28 02:13:23 +02:00
var l = Array.prototype.slice.call(document.getElementsByTagName('a')),
2016-05-01 20:21:46 +02:00
e = new RegExp("^(javascript|mailto|(https?)?" + c + "/?#)"),
2016-04-28 03:13:11 +02:00
f = false;
while(!f & l.length>0){
i = Math.floor(Math.random()*l.length);
if (e.test(l[i].href) || l[i].href == c) l.splice(i,1);
else {
r = l[i].href;
f = true;
}
}
2016-04-28 02:13:23 +02:00
document.location.href = r;
return;
2016-05-01 22:30:38 +02:00
})("http://swapthatlink.com", document.location.href);