User:JoeyDay/monobook.js
From Homestar Runner Wiki
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Mozilla / Firefox: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac)
- Safari: press Cmd-Option-E
- IE: hold Ctrl while clicking Refresh, or press Ctrl-F5
- Konqueror: simply click the Reload button, or press F5
- Opera users may need to completely clear their cache in Tools→Preferences.
// Create "my links" sidebar box function myLinksBox () { // Create div#p-mylinks var myLinks = document.createElement('div'); myLinks.id = 'p-mylinks'; myLinks.className = 'portlet'; // Create h5 and append to div#p-mylinks var h5 = document.createElement('h5'); h5.appendChild(document.createTextNode('My Links')); myLinks.appendChild(h5); // Create div.pBody and append to div#p-mylinks var pBody = document.createElement('div'); pBody.className = 'pBody'; myLinks.appendChild(pBody); // Create ul and append to div.pBody var ul = document.createElement('ul'); pBody.appendChild(ul); // Append div#p-mylinks to sidebar just before external links box var sidebar = document.getElementById('column-one'); sidebar.insertBefore(myLinks, document.getElementById('p-ext')); // Populate the actual links addLink("p-mylinks", "/index.php/Category:To_be_deleted", "To be deleted", "n-tobedeleted", "Articles to be deleted."); addLink("p-mylinks", "/index.php/Category:Articles_to_be_merged", "To be merged", "n-tobemerged", "Articles to be merged."); addLink("p-mylinks", "/index.php/Special:BrokenRedirects", "Broken redirects", "n-brokenredirects", "The list of broken redirects."); addLink("p-mylinks", "/index.php/Special:DoubleRedirects", "Double redirects", "n-doubleredirects", "The list of double redirects."); addLink("p-mylinks", "/index.php?limit=5000&title=Special%3ARecentchanges&namespace=8", "Interface changes", "n-interfacechanges", "The list of recent interface changes."); addLink("p-mylinks", "/index.php/Special:Log/move", "Moved pages", "n-movedpages", "The list of recently moved pages."); addLink("p-mylinks", "/index.php/Special:Log/newusers", "New users", "n-newusers", "The list of new users."); addLink("p-mylinks", "/index.php/Special:Renameuser", "Rename user", "n-renameuser", "Rename a user."); } // Modify my talk link and add additional user page and talk links for GrapeNuts function modPersonalMenu() { var mytalk = document.getElementById('pt-mytalk'); mytalk.firstChild.firstChild.data = 'Talk'; mytalk.insertBefore(document.createTextNode("("), mytalk.firstChild); mytalk.appendChild(document.createTextNode("·")); var mycontribs = document.createElement('a'); mycontribs.href = '/index.php/Special:Contributions/JoeyDay'; mycontribs.appendChild(document.createTextNode('Edits')); mytalk.appendChild(mycontribs); mytalk.appendChild(document.createTextNode(")")); addLink("p-personal", "/index.php/User talk:GrapeNuts", "Talk", "pt-gntalk", "GrapeNuts' talk page.", "", "pt-preferences"); var gntalk = document.getElementById('pt-gntalk'); gntalk.insertBefore(document.createTextNode("("), gntalk.firstChild); gntalk.appendChild(document.createTextNode("·")); var gncontribs = document.createElement('a'); gncontribs.href = '/index.php/Special:Contributions/GrapeNuts'; gncontribs.appendChild(document.createTextNode('Edits')); gntalk.appendChild(gncontribs); gntalk.appendChild(document.createTextNode(")")); addLink("p-personal", "/index.php/User:GrapeNuts", "GrapeNuts", "pt-grapenuts", "GrapeNuts' user page.", "", "pt-gntalk"); var mycontris = document.getElementById('pt-mycontris'); mycontris.parentNode.removeChild(mycontris); var myprefs = document.getElementById('pt-preferences'); myprefs.parentNode.removeChild(myprefs); addLink("p-personal", "/index.php/Special:Preferences", "Preferences", "pt-preferences", "My preferences", "", "pt-logout"); } // Add UTC time just below the "personal menu" list at the top of the page. // Created by Wikipedia:User:Mathwiz2020, modified by User:JoeyDay // 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 currentTime = hours + ":" + minutes document.getElementById('pt-time').childNodes[0].childNodes[0].replaceData(0, 5, currentTime); doTime = window.setTimeout("getTime()", 1000); } function makeTime() { var div = document.createElement( 'div' ); div.id = 'pt-time'; var mySpan = document.createElement( 'span' ); mySpan.appendChild( document.createTextNode( '00:00 UTC' ) ); div.appendChild( mySpan ); document.getElementById( 'globalWrapper' ).parentNode.appendChild( div ); doTime = window.setTimeout("getTime()", 1000); } // Add purge tab to action tabs function addPurge () { var x = document.getElementById('ca-history'); if(!x) return; if(x.children) x = x.children[0].href; else x = x.childNodes[0].href; if (document.getElementById('ca-delete')) { addLink("p-cactions", x.replace(/=history/, "=purge"), 'Purge', 'ca-purge', 'Purge the internal cache for this page [alt-p]', 'p', 'ca-delete'); } else if (document.getElementById('ca-move')) { addLink("p-cactions", x.replace(/=history/, "=purge"), 'Purge', 'ca-purge', 'Purge the internal cache for this page [alt-p]', 'p', 'ca-move'); } else if (document.getElementById('ca-watch')) { addLink("p-cactions", x.replace(/=history/, "=purge"), 'Purge', 'ca-purge', 'Purge the internal cache for this page [alt-p]', 'p', 'ca-watch'); } else { addLink("p-cactions", x.replace(/=history/, "=purge"), 'Purge', 'ca-purge', 'Purge the internal cache for this page [alt-p]', 'p', 'ca-unwatch'); } } // Enables adding links to the interface just about anywhere. // // * 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. // function addLink (where, url, name, id, title, key, after) { 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; } //--- Execute all functions ---// function doEverything () { myLinksBox(); modPersonalMenu(); makeTime(); addPurge(); } if (window.addEventListener) { window.addEventListener("load", doEverything, false); } else if (window.attachEvent) { window.attachEvent("onload", doEverything); }