diff --git a/Js/anywhere.js b/Js/anywhere.js index 3ca0132..bf27315 100644 --- a/Js/anywhere.js +++ b/Js/anywhere.js @@ -4,11 +4,14 @@ */ 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); + 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); }; - r=l[Math.floor(Math.random()*l.length)].href; - console.log(r); - document.location.href=r; + if (l.length>0) r = l[Math.floor(Math.random()*l.length)].href; + document.location.href = r; + return; })(); \ No newline at end of file diff --git a/Js/anywhere.min.js b/Js/anywhere.min.js index 62a7d01..2c621a6 100644 --- a/Js/anywhere.min.js +++ b/Js/anywhere.min.js @@ -1 +1 @@ -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})(); \ No newline at end of file +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