User:Mbimmler/monobook.js

//

// en:User:Lupin/popups.js

importScript('User:Lupin/popupsdev.js');

popupDelay = 0.3 popupAdminLinks = false popupShortcutKeys = true popupRedlinkRemoval = true popupMaxWidth = 350 popupInitialWidth = false popupLiveOptions = true

//Interiot's javascript edit counter if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) { mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript'); }

function addLink(where, url, name, id, title, key, after){ //* where is the id of the toolbar where the button should be added; //  i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb". //   //* url is the URL which will be called when the button is clicked. //  javascript: urls can be used to do more complex things. //   //* name is what will appear as the name of the button.

//   //* id is the id of the button; it's best to define one. //  Use a prefix to make sure its unique. Optional. //   //* title is the tooltip title that gives a longer description //  of the button; if you define a accesskey, mention it here. Optional. //   //* key is the char you want for the accesskey. Optional. //   //* after is the id of the button you want to follow this one. Optional. //   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); var tabs = document.getElementById(where).getElementsByTagName('ul')[0]; if(after) { tabs.insertBefore(li,document.getElementById(after)); } else { 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; }

// addPurge addOnloadHook( function {   var x = document.getElementById('ca-history');    if(!x) return;    if(x.children) x = x.children[0].href;    else x = x.childNodes[0].href;    addLink("p-cactions", x.replace(/=history/, "=purge"), 'purge', 'ca-purge', 'Purge the internal  cache for this page', 0); });

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; }

function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); }

// addLastDiff addOnloadHook(function {    z=document.getElementById("content").childNodes;    for (var n=0;n<z.length;n++) {       if (z[n].className=="firstHeading") {        var pname=z[n].textContent;      }    }    var l=addTab("http://en.wikipedia.org/w/index.php?title=" + pname + "&diff=cur&oldid=prev", 'last', '');    l.lastChild.title="Show most recent diff"; });

//Please leave the following line //user:Where/usertabs addOnloadHook(function {  if (document.title.search("/") != -1 || document.title.search("- History -") != -1) { //no subpages or history      return;   }   if (document.title.indexOf("User:") == 0 || document.title.indexOf("User talk:") == 0) {      username_a = document.URL.match(/:.*:(.*)/);      username=username_a[1];      addTab("http://en.wikipedia.org/wiki/Special:Contributions/" + username, "contrib", "ca-contrib", "contribs", "");      addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=move&user=" + username, "page moves", "ca-pagemoves", "page moves", "");      addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=" + username, "block log", "ca-blog", "blog", "");      addTab("http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=enwiki_p&user=" + username, "edit count", "ca-kate", "kate", "");   } });

function talkpageplus {   var talkpagelink = document.getElementById('ca-talk'); if (talkpagelink.className == 'new') {       talkpagelink.firstChild.href += '&section=new'; } }

addOnloadHook(talkpageplus); // adds a 'logs for this page' link to the navigation bar // if the page is a user's page, talk page or subpage, the link will go to logs for the user instead // if the page is a special page, then no link is displayed

addOnloadHook(function {

// get page title var pagetitleRe=/[^:]*:\/\/en\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?#]*)/; ptitle = pagetitleRe.exec(decodeURI(location.href))[2].split('_').join(' '); // if this is a user, show the logs for the user rather than the page if( (window.location.href.indexOf("User:") != -1) || (window.location.href.indexOf("User_talk:") != -1) ) { regDropSubpages = /[User|User_talk]:([^&?\/]*)[\/]?.*/; user = regDropSubpages.exec(ptitle)[1]; url = "http://en.wikipedia.org/w/index.php?title=Special%3ALog&user=" + user; } else if(window.location.href.indexOf("Special:") != -1) { // don't display link for special pages return; } else { url = "http://en.wikipedia.org/w/index.php?title=Special%3ALog&page=" + ptitle; } tabs = document.getElementById('p-tb').getElementsByTagName('ul')[0]; l = addlilink(tabs, url, "Logs", "pt-logs");

});

//

addOnloadHook(function {    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); } });

//

// Add time to your monobook "personal menu" list at the very top of the page. // Created by User:Mathwiz2020 // //  Indicate where you would like the time to appear: //   pt-userpage, pt-mytalk, pt-preferences, //   pt-watchlist, pt-mycontris, pt-logout // gsTimeInsertBefore = ''; // leave blank to append after "logout" // function makeTime { var li = document.createElement( 'li' ); li.id = 'pt-time';

var mySpan = document.createElement( 'span' ); mySpan.appendChild( document.createTextNode( '00:00:00' ) );

li.appendChild( mySpan );

if ( ! gsTimeInsertBefore ) { // append to end (right) of list document.getElementById( 'pt-logout' ).parentNode.appendChild( li ); } else { var before = document.getElementById( gsTimeInsertBefore ); before.appendChild( li, before ); } doTime = window.setTimeout("getTime", 1000); }

addOnloadHook( makeTime );

function getTime { var time = new Date; var hours = time.getUTCHours; if (hours < 10) { hours = "0" + hours; } var minutes = time.getUTCMinutes; if (minutes < 10) { minutes = "0" + minutes; } var seconds = time.getUTCSeconds; if (seconds < 10) { seconds = "0" + seconds; } var currentTime = hours + ":" + minutes + ":" + seconds; document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 8, currentTime); doTime = window.setTimeout("getTime", 1000); }

//