Wikipedia:WikiProject User scripts/Scripts/Unwatch: Difference between revisions

Content deleted Content added
fix syntax
doesn't work :-( — replace with version that does
Line 1:
// This script adds an "unwatch" link to each entry in your watchlist. <pre><nowiki>
<pre>
 
addOnloadHook( function () {
// Add Unwatch to watch list
if (window.___location.href.indexOf("Special:Watchlist")! == -1) {return;
// from [[User:Matthewmayer/monobook.js]]
 
addOnloadHook( function () {
// this is all tag soup, we just have to wade through it :-(
if (window.___location.href.indexOf("Special:Watchlist")!=-1) {
//correct page,look for soh4 retrievefollowed watchlistby itemsdiv
var itemsheadings = document.getElementById('bodyContentcontent').getElementsByTagName('lih4');
 
for (var i = 0; i <items headings.length; i++) {
//what is the title of this page?
var div = pagename=itemsheadings[i].getElementsByTagName('a')[0].titlenextSibling;
while (div && div.nodeType == 3) div = div.nextSibling; // skip text nodes
//create 'unwatch' element
if (!div || unwatchelt=documentdiv.createElementtagName.toLowerCase() != 'adiv') continue;
 
unwatchelt.setAttribute('href','/w/index.php?title='+pagename+'&action=unwatch');
var pagename = "";
unwatchelt.setAttribute('title','Unwatch '+pagename);
for (var node = div.firstChild; node; node = node.nextSibling) {
unwatchelt.appendChild(document.createTextNode('(unwatch)'));
 
//add the 'unwatch' element
//what isgrab the title of thisthe first link on each page?line
items[i].appendChild(unwatchelt);
if (!pagename && node.tagName && node.tagName.toLowerCase() == 'a')
}
pagename = node.title;
if (pagename && node.tagName && node.tagName.toLowerCase() == 'br')
pagename = "";
 
// add the (unwatch) link after diff and hist (look for distinctive text node)
if (pagename && node.nodeType == 3 && node.nodeValue == ") . . ") {
var unwatch = document.createElement('a');
unwatch.href = "/w/index.php?title=Special:Watchlist&action=submit&remove=1&id[]="+encodeURIComponent(pagename);
unwatchelt unwatch.setAttribute('title',' = "Unwatch '"+pagename);
unwatchelt unwatch.appendChild(document.createTextNode('("unwatch)'"));
div.insertBefore(document.createTextNode("; "), node);
div.insertBefore(unwatch, node);
}
}
// XXX: might want to double check that pagename is null here, but I'll ignore it for now
}
});
);
 
// </nowiki></pre>