User:Nug/monobook.js

function chooseBox( id, arr ) { return arr.indexOf( id ) == -1 ? 'p-cactions' : 'p-tb'; } importScript('User:AzaToth/twinkle.js'); TwinkleConfig = { toolboxButtons: ["tw-prod", "tw-csd", "tw-csd-reason", "tw-rpp", "tw-since", "tw-sincemine","tw-lastdiff"], userTalkPageMode               :       'blank', summaryAd: '' }; importScript('User:Sander Säde/pagesCreated.js'); importScript('User:Sander Säde/quickpreview.js'); importScript('User:Gerbrant/edit/linksInDiff.js'); importScript('User:Omegatron/monobook.js/addlink.js'); //User:Omegatron/monobook.js/addlink.js importScript('User:Dr_pda/prosesize.js'); //User:Dr_pda/prosesize.js //testing editcounter $(doQuickCount); function doQuickCount { if (mw.config.get('wgPageName') == "Special:Contributions") { var name = document.getElementById("contentSub").getElementsByTagName("a"); var rname = name[0].innerHTML; if (rname == "Talk") rname = document.getElementById("contentSub").innerHTML.split(" ")[1]; //IP's   var cnteraj = sajax_init_object(null); cnteraj.open("GET", 'http://en.wikipedia.org/w/query.php?what=contribcounter&'+     'titles=User:'+rname+'&format=xml', true); cnteraj.onreadystatechange = function {     if(cnteraj.readyState != 4) return; document.getElementById("contentSub").innerHTML = 'Edit count for ' + rname.fontcolor("Green").bold + ": " + cnteraj.responseText.split(" ")[1].split(" ")[0].fontcolor("Maroon").bold + " " + document.getElementById("contentSub").innerHTML; };   cnteraj.send(null); } } $(estRelated); function estRelated { if (document.URL.indexOf('Special:Watchlist') == -1) return; estaj=sajax_init_object(null); estaj.open("GET", "http://en.wikipedia.org/w/index.php?title=Special:Recentchangeslinked&target=User:Sander_S%C3%A4de/WPEarticles&hideminor=0&days=7&limit=100", true); estaj.onreadystatechange = function {   if(estaj.readyState != 4) return; sPage = estaj.responseText; document.getElementById("contentSub").innerHTML += " " + sPage.substring(sPage.indexOf(" "), sPage.indexOf(' ') - 25); }; estaj.send(null); } importScript('User:Lupin/popups.js'); popupDelay=0.3; popupHideDelay=0.1; popupImages=false; importScript('User:^demon/csd.js'); //AzaThoth's twinkle script /* Enable cleanup tab if appropriate */ $(function { addOnloadHook(shortenEdit); }); /* This will add an [edit] link for the first section * of all pages except preview pages and the main page * by User:Pile0nades */ // Add an [edit] link to pages $(function {  // if this is preview page or generated page, stop  if( document.getElementById("wikiPreview") || document.getElementById("histlegend‎") || document.getElementById("difference‎") || document.getElementById("watchdetails") || document.getElementById("ca-viewsource") || window.location.href.indexOf("/wiki/Special:") != -1 ) {   if(window.location.href.indexOf("&action=edit&section=0") != -1) {      document.getElementById("wpSummary").value = "/* Lede */  ";    }    return;  };  // get the page title  var pageTitle = mw.config.get('wgPageName');  // create div and set innerHTML to link  var divContainer = document.createElement("div");  divContainer.innerHTML = ' [edit] ';  // insert divContainer into the DOM below the h1  if(window.location.href.indexOf("&action=edit") == -1) {    document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);  } }); /* Add link to toolbar for block log */ function addContribs(username) { addTool("http://en.wikipedia.org/w/index.php?title=Special:Log&type=block&page=" + username, "Block log", "Foo3", "Foo4", "Foo5"); } $(function { if (document.title.indexOf("User:") != -1 )   {    var UNindex = document.title.indexOf("- Wikipedia, the free encyclopedia");     var username = document.title.substring(0,UNindex);    if ( username.indexOf("/") != -1)     {   username = username.substring(0,username.indexOf("/")); }     addOnloadHook(addContribs(username));}  if (document.title.indexOf("User talk:") != -1 )   {    var UNindex = document.title.indexOf("- Wikipedia, the free encyclopedia");     var username = "User:" + document.title.substring(10,UNindex);    if ( username.indexOf("/") != -1)     {   username = username.substring(0,username.indexOf("/")); }     addOnloadHook(addContribs(username));} }); function shortenEdit { var tab = document.getElementById('ca-edit'); if (tab == null) return; if ( typeof(tab) != 'undefined') { var tab = document.getElementById('ca-edit').getElementsByTagName('a')[0]; tab.replaceChild(document.createTextNode("edit"), tab.firstChild); tab = document.getElementById('ca-talk').getElementsByTagName('a')[0]; tab.replaceChild(document.createTextNode("talk"), tab.firstChild); } var tab = document.getElementById('ca-history'); if (tab == null) return; if ( typeof(tab) != 'undefined') { var tab = document.getElementById('ca-history').getElementsByTagName('a')[0]; tab.replaceChild(document.createTextNode("hist"), tab.firstChild); } var tab = document.getElementById('ca-protect'); if (tab == null) return; if ( typeof(tab) != 'undefined') { var tab = document.getElementById('ca-protect').getElementsByTagName('a')[0]; tab.replaceChild(document.createTextNode("prot"), tab.firstChild); } var tab = document.getElementById('ca-delete'); if (tab == null) return; if ( typeof(tab) != 'undefined') { var tab = document.getElementById('ca-delete').getElementsByTagName('a')[0]; tab.replaceChild(document.createTextNode("rm"), tab.firstChild); } var tab = document.getElementById('ca-move'); if (tab == null) return; if ( typeof(tab) != 'undefined') { var tab = document.getElementById('ca-move').getElementsByTagName('a')[0]; tab.replaceChild(document.createTextNode("mv"), tab.firstChild); } } /* Add link to toolbox*/ function addTool(url, name, id, title, key){ var tabs = document.getElementById('p-tb').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); } /* Add Tab */ function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); } /* Add Personal */ function addPersonal(url, name, id, title, key){ var tabs = document.getElementById('p-personal').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); } /* Add LI to a UL */ function addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); if(id) {       if(key && title) {           ta[id] = [key, title]; }       else if(key) {           ta[id] = [key, '']; }       else if(title) {           ta[id] = ['', title]; }   }    // re-render the title and accesskeys from existing code in wikibits.js    akeytt; return li; } /* Bypass ISBN page to go straight to amazon */ function externISBN { for (var i = 0; i < document.links.length; i++) {              if( document.links[i].href.match(/isbn=(.*)/) ) { document.links[i].href='http://www.amazon.com/gp/search/ref=sr_adv_b/?search-alias=stripbooks&field-isbn='+RegExp.$1; }   } } $(externISBN); /* add unwatch links to watchlist */ $(function {    // Check if we're on the watchlist    if (!mw.config.get('wgCanonicalSpecialPageName') || mw.config.get('wgCanonicalSpecialPageName') != "Watchlist")       return;    if (!document.forms[0] || !document.forms[0].namespace) return;    // Unwatch links go back to watchlist with "Removing requested items     // from watchlist..." message  //  var query_prefix = "title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=submit&remove=1&id[]=";    // ...or...    // Unwatch links go to "Removed from watchlist" page    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); } }); // // WATCHLIST SORTER // Taken from User:Misza13 and edited by me to work with unwatch links // Also fixed sorting of namespaces and made the ul's have class=special function addNamespaceWL(newday, namespace) {       hdr = document.createElement('h5');        hdr.innerHTML = namespace;        newday.appendChild(hdr);        namespacesub = document.createElement('ul');        namespacesub.setAttribute("class", "special");         newday.appendChild(namespacesub);          return hdr; } $(function { if (location.href.indexOf('Special:Watchlist') == -1) return; //Are we on a watchlist? //days = document.getElementById('bodyContent').getElementsByTagName('ul'); //Hell knows how it works - found in "Dive into Greasemonkey" // - from original coder days = document.evaluate( "//ul[@class='special']", document, null,                      XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,  null); for (d = 0; d < days.snapshotLength; d++) { //For each day day = days.snapshotItem(d); newday = document.createElement('div'); //This will replace the old listing //add the main namespaces in order so they are sorted correctly //additional namespaces will be created at the bottom when they are encountered //change the order here to whatever you like addNamespaceWL(newday, "Main"); addNamespaceWL(newday, "Talk"); addNamespaceWL(newday, "Wikipedia talk"); addNamespaceWL(newday, "User talk"); addNamespaceWL(newday, "User"); while ((diffs = day.getElementsByTagName('li')).length > 0) { //Are there any diffs left? //Try to extract the namespace As = diffs[0].getElementsByTagName('a'); // if you don't have the unwatch links, replace As[3] with As[2], etc.       if (As[0].innerHTML == 'diff') { pagename = As[3].innerHTML; } else { pagename = As[2].innerHTML; }       if (pagename.indexOf(':') == -1) namespace = 'Main'; else namespace = pagename.split(':')[0]; //This will fail for articles which contain ":" in name hdrs = newday.getElementsByTagName('h5'); //Get the list of namespace headers hdr = null; for (j=0; j<hdrs.length; j++) //Find the header if (hdrs[j].innerHTML==namespace) { hdr = hdrs[j]; break; }       if (hdr==null) { //Not found? Make a new one! hdr = addNamespaceWL(newday, namespace); }       hdr.nextSibling.appendChild(diffs[0]); //Move the diff }   newday.appendChild(document.createElement('hr')); //For readablility day.parentNode.replaceChild(newday,day); } }); // //importScript('User:Jayvdb/welcome.js'); /* importScript('User:Sander Säde/tagwpe.js'); TagWPEConfig = { OpenAfter: false }; importScript('User:Sander Säde/allest4test.js'); importScript('User:Sander Säde/assess.js'); importScript('User:Sander Säde/redirects.js'); importScript('User:Sander Säde/viewsource.js');