I'd like to make a tampermonkey script that randomly redirects to websites without repeating. Once all the websites have been viewed, I want there to be an alert that notifies that the script is finished.
I've used the script from here (How to redirect to one out of given set of sites?) but it repeats the websites.
How should I go about with this?
// ==UserScript==
// @name Cat slideshow
// @match https://i.imgur.com/homOZTh.jpg
// @match https://i.imgur.com/NMDCQtA.jpg
// @match https://i.imgur.com/iqm9LoG.jpg
// ==/UserScript==
var urlsToLoad = [
'https://i.imgur.com/homOZTh.jpg',
'https://i.imgur.com/NMDCQtA.jpg',
'https://i.imgur.com/iqm9LoG.jpg',
];
setTimeout (GotoRandomURL, 4000);
function GotoRandomURL () {
var numUrls = urlsToLoad.length;
var urlIdx = urlsToLoad.indexOf (location.href);
if (urlIdx >= 0) {
urlsToLoad.splice (urlIdx, 1);
numUrls--;
}
urlIdx = Math.floor (Math.random () * numUrls);
location.href = urlsToLoad[urlIdx];
}