Created
March 4, 2018 18:30
-
-
Save arifhp86/b0ed80102157d3a1d7759e64414beb69 to your computer and use it in GitHub Desktop.
Open all link of webpage in few seconds interval
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
(function($) { | |
var links = [], time, index = 0, un = ['account', 'youtube', '#', 'javascript'], openWindow; | |
function isNotUn(text) { | |
for(var i = 0; i < un.length; i++) { | |
var pttrn = new RegExp(un[i]); | |
if(pttrn.test(text)) return false; | |
} | |
return true; | |
} | |
$('a').each(function(i, item) { | |
itemLink = $(item).attr('href'); | |
if(itemLink && isNotUn(itemLink) && links.indexOf(itemLink) === -1) { | |
links.push(itemLink); | |
} | |
}); | |
function open() { | |
time = setTimeout(function() { | |
if(undefined != openWindow) openWindow.close(); | |
openWindow = window.open(links[index]); | |
index += 1; | |
if(index+1 < links.length) | |
open(); | |
}, 15000); | |
} | |
open(); | |
})(jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment