diff --git a/Js/anywhere.js b/Js/anywhere.js index bf27315..8590c85 100644 --- a/Js/anywhere.js +++ b/Js/anywhere.js @@ -3,15 +3,18 @@ * - naive code - */ -javascript:(function(){ +javascript:(function(r = "http://swapthatlink.com", c = document.location.href){ var l = Array.prototype.slice.call(document.getElementsByTagName('a')), - c = document.location.href; - var e = new RegExp("^(mailto|(https?)?"+c+"/?#)"), - r = "http://swapthatlink.com"; - for (var i = l.length-1;i>=0;i--){ - if (e.test(l[i].href.slice(0,1)) || l[i].href == c) l.splice(i,0); - }; - if (l.length>0) r = l[Math.floor(Math.random()*l.length)].href; + e = new RegExp("^(mailto|(https?)?" + c + "/?#)"), + 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; + } + } document.location.href = r; return; })(); \ No newline at end of file diff --git a/Js/anywhere.min.js b/Js/anywhere.min.js index 2c621a6..e7d62fb 100644 --- a/Js/anywhere.min.js +++ b/Js/anywhere.min.js @@ -1 +1 @@ -javascript:(function(){var l=Array.prototype.slice.call(document.getElementsByTagName('a')),c=document.location.href;var e=new RegExp("^(mailto|(https?)?"+c+"/?#)"),r="http://swapthatlink.com";for(var i=l.length-1;i>=0;i--){if(e.test(l[i].href.slice(0,1))||l[i].href==c)l.splice(i,0)};if(l.length>0)r=l[Math.floor(Math.random()*l.length)].href;document.location.href=r;return})(); \ No newline at end of file +javascript:(function(r="http://swapthatlink.com",c=document.location.href){var l=Array.prototype.slice.call(document.getElementsByTagName('a')),e=new RegExp("^(mailto|(https?)?"+c+"/?#)"),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}}document.location.href=r;return})(); \ No newline at end of file