User:SvickTest/vector.js
function handywatch() {
cont = confirm("Add all pages listed to your watchlist?");
if (!cont) { return; }
superconf = confirm("Continue without any prompting?");
var allLinks, thisLink, ready;
counter = 0;
allLinks = document.getElementsByTagName('a');
ready = false;
for (var i = 0; i < allLinks.length; i++) {
thisLink = allLinks[i];
if (ready) {
if (thisLink.href.indexOf('http://en.wikipedia.org/wiki/') != -1) {
if (thisLink.href == 'http://en.wikipedia.org/wiki/Wikipedia:Redirects_for_discussion/Log') { alert("Finished! " + counter + " pages added."); return; }
counter = counter + 1;
oldref = thisLink.href;
thisLink.href = oldref.replace(/http:\/\/en.wikipedia.org\/wiki\//, 'http://en.wikipedia.org/w/index.php?action=watch&title=');
req = new XMLHttpRequest();
req.open('GET', thisLink.href, false);
req.send(null);
if(req.status == 200) {
if (!superconf && !confirm("done " + oldref.replace(/http:\/\/en.wikipedia.org\/wiki\//, '') + " (number " + counter + ") Continue?")) { return; }
} else { alert("error " + thisLink.href); }
}
} else {
if (thisLink.href == 'http://en.wikipedia.org/wiki/Wikipedia:Redirects_for_discussion') { ready = true; }
}
} //for
} //function
if (document.title.indexOf('Wikipedia:Redirects for discussion/Log') == 0)
if (window.addEventListener)
window.addEventListener('load', handywatch, false);
else if (window.attachEvent)
window.attachEvent('onload', handywatch);