User:Kajk/monobook.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
The accompanying .css page for this skin is at User:Kajk/monobook.css. |
//***********************************************************************
// Unwatch
// source: en:Wikipedia:WikiProject User scripts/Scripts
//
// This script adds an "unwatch" link to each entry in your watchlist. This version
// works regardless of whether you have the "Enhanced recent changes" option
// selected in your user preferences. By default the links take you back to your
// watchlist. If you'd prefer them to take you to a "Removed from watchlist" page
// like the unwatch links at the top of the watched pages, uncomment the second line
// in the function.
//***********************************************************************
function unwatch() {
var query_prefix = "title=Special:Watchlist&action=submit&remove=1&id[]=";
//var query_prefix = "action=unwatch&title=";
if (window.location.href.indexOf("Special:Watchlist") == -1) {
return;
}
var links = document.getElementById('content').getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
if (links[i].href.substring(links[i].href.length-15) != '&action=history')
continue;
var unwatch = document.createElement('a');
unwatch.href = "/w/index.php?" + query_prefix + encodeURIComponent(links[i].title);
unwatch.title = "Unwatch "+links[i].title;
unwatch.appendChild(document.createTextNode("unwatch"));
links[i].parentNode.insertBefore(unwatch, links[i].nextSibling);
// kluge to handle case where "diff" is unlinked:
var delim = links[i].previousSibling;
delim = (delim.nodeType == 3 ? delim.nodeValue : "");
links[i].parentNode.insertBefore(document.createTextNode(delim.replace(/^.*diff/, "")), unwatch);
}
};
addOnloadHook(unwatch);