User:Sheep81/monobook.js

// 1) ADD UNWATCH LINKS:

addOnloadHook(function {    if (!wgCanonicalSpecialPageName || wgCanonicalSpecialPageName != "Watchlist") return;    if (!document.forms[0] || !document.forms[0].namespace) return;

//var query_prefix = "title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=submit&remove=1&id[]="; var query_prefix = "action=unwatch&title=";

// get list of all links in content: var links = document.getElementById('content').getElementsByTagName('a');

// make a static copy of the nodelist and lose the original for speed // while we're at it, prune the uninteresting links from the list var linksCopy = new Array ; for (var i = 0; i < links.length; i++) { if (/[?&]action=history([&#]|$)/.test(links[i].href)) linksCopy.push(links[i]); }   links = linksCopy;

for (var i = 0; i < links.length; i++) { // create unwatch link and append it after history link var unwatch = document.createElement('a'); unwatch.href = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/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);

// insert a delimiter between the two links var delim = links[i].previousSibling; delimText = (delim.nodeType == 3 ? delim.nodeValue : ""); // kluge to handle case where "diff" is unlinked delim = document.createTextNode(delimText.replace(/^.*diff/, "")); links[i].parentNode.insertBefore(delim, unwatch); } });

//

// 2) Add navigation links // User:Jsimlo/shortcuts.js document.write(' '); function shortcutsInit  {  shortcutsAddLink ('My sandbox', 'User:Sheep81/Sandbox');  shortcutsAddLink ('My other sandbox', 'User:Sheep81/SandboxDos');  shortcutsAddLink ('My to-do list', 'User:Sheep81/ToDoList');  shortcutsAddLink ('My monobook.css', 'User:Sheep81/monobook.css');  shortcutsAddLink ('My monobook.js', 'User:Sheep81/monobook.js');  shortcutsAddLink ('WikiProject Dinosaurs', 'WP:DINO'); }

// 3) Translate language links importScript('User:Tra/sidebartranslate.js'); //User:Tra/sidebartranslate.js