1
0
Fork 0
mirror of https://github.com/prise6/anywhere synced 2024-05-02 05:02:44 +02:00
anywhere/Js/anywhere.js
François Vieille 4d8fde4a61 Init
2016-04-28 01:21:14 +02:00

14 lines
403 B
JavaScript

/**
* Redirect to a "random" link in current page
* - naive code -
*/
javascript:(function(){
var l = Array.prototype.slice.call(document.getElementsByTagName('a'));
for(var i = l.length-1;i>=0;i--){
if(/^(#|mailto)/.test(l[i].href.slice(0,1))||l[i].href==document.location.href)l.splice(i,0);
};
r=l[Math.floor(Math.random()*l.length)].href;
console.log(r);
document.location.href=r;
})();