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>
▲addOnloadHook( function () {
// this is all tag soup, we just have to wade through it :-(
▲ if (window.___location.href.indexOf("Special:Watchlist")!=-1) {
//what is the title of this page?▼
var div =
while (div && div.nodeType == 3) div = div.nextSibling; // skip text nodes
if (!div ||
var pagename = "";
unwatchelt.setAttribute('title','Unwatch '+pagename);▼
for (var node = div.firstChild; node; node = node.nextSibling) {
unwatchelt.appendChild(document.createTextNode('(unwatch)'));▼
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);
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>
|