User:GraemeL/monobook.js

Source: Wikipedia, the free encyclopedia.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* <nowiki> */

/////////////////////////////////////////////////////////////////////////////////////////////
// Started with code blatently stolen from [[User:Bmicomp/monobook.js]].
// Modified to use test-n, test2-n and test3-n. Remember to put the article title in the tag.
// See [[User:Drini]] for information on the -n templates.
// Menu tabs and some other functions stolen from [[User:alphax]]
//   Requires additions to monobook.css for menu tabs to work

// [[User:Lupin/popups.js]] - please include this line 
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
simplePopups=true;
popupAdminLinks=true;
popupStructure='menus';

// Add [[Wikipedia:Twinkle|Twinkle]].
importScript('User:AzaToth/twinkle.js');
TwinkleConfig = {
    userTalkPageMode                :       'tab',
    showSharedIPNotice              :       false,
    summaryAd                       :       "",
    deletionSummaryAd               :       "",
    protectionSummaryAd             :       "",
    watchRevertedPages              :       [],
    watchWarnings                   :       false
};

// Add Status changer.
importScript('User:Misza13/statusChanger.js');
statusChangerConfig = {
  statusList : [ 'in', 'busy', 'around', 'out' ],
};

// AfD addition
importScript('Wikipedia:WikiProject User scripts/Scripts/AutoAFD.js');

// Add close afd function because I'm too stupid to remember how to do it manually.
importScript('Wikipedia:WikiProject User scripts/Scripts/CloseAFD.js');

// Call function to load when needed.
if (window.addEventListener) window.addEventListener("load",myLoadFuncs,false);
else if (window.attachEvent) window.attachEvent("onload",myLoadFuncs);
else
{
    window.previousLoadFunction = window.onload;
    window.onload = function()
    {
        window.previousLoadFunction();
        myLoadFuncs();
    }
}

// Load custom functions.
function myLoadFuncs()
{
// Add more toolbox links
 addToolBoxLinks();
// Add navbar links
 addNavBarLinks()
}



/**** Add generic tab ****/

function addlilink(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = name;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

// Add more personal links to the tollbox section.
function addToolBoxLinks()
{
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/Wikipedia:Template messages/User_talk_namespace', 'Talk templates', '');
    addlilink(tb, '/wiki/Wikipedia:List of Discussion Templates', 'Discussion templates', '');
    addlilink(tb, '/wiki/Wikipedia:Template_messages', 'Templates', '');
    addlilink(tb, '/wiki/WP:CSD', 'SD criteria', '');
    addlilink(tb, '/wiki/Special:Log', 'Log', '');
    addlilink(tb, '/wiki/Special:Log/delete', 'Delete log', '');
    addlilink(tb, '/wiki/Special:Log/block', 'Block log', '');
    addlilink(tb, '/wiki/Special:Ipblocklist', 'IPBlocklist', '');
    addlilink(tb, '/wiki/Category:Requests for unblock', 'Unblock requests', '');
    addlilink(tb, '/wiki/Category:Wikipedia spam cleanup', 'Spam cleanup', '');
    addlilink(tb, '/wiki/Special:Linksearch', 'Link Search', '');
}

function addNavBarLinks()
{   
    var navbar = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
    var afdtime = new Date();
    var months = ['January', 'February', 'March', 'April', 'May', 'June',
        'July', 'August', 'September', 'October', 'November', 'December'];
    addlilink(navbar, '/wiki/Wikipedia:Articles_for_deletion/Log/' + afdtime.getUTCFullYear()
        + '_' + months[afdtime.getUTCMonth()] + '_' + afdtime.getUTCDate(), 'Todays AfD', '');
    afdtime.setUTCDate(afdtime.getUTCDate() - 5);
    addlilink(navbar, '/wiki/Wikipedia:Articles_for_deletion/Log/' + afdtime.getUTCFullYear()
        + '_' + months[afdtime.getUTCMonth()] + '_' + afdtime.getUTCDate(), '5-day old AfD', '');
    var username=document.getElementById("pt-userpage").textContent;
    addlilink(navbar, '/wiki/User:XLinkBot/RevertList', 'XLinkBot revert list', '');
    addlilink(navbar, '/wiki/User:XLinkBot/RevertList requests/log', 'XLinkBot list log', '');
}

addOnloadHook(function () {
    var x;
    if (!(x = document.getElementById('ca-edit') )) return;
    var url;
    if (!(url = x.getElementsByTagName('a')[0] )) return;
    if (!(url = url.href )) return;
    var y = mw.util.addPortletLink('p-cactions', url+"&section=0", '0', 'ca-edit-0',
                           'Edit the lead section of this page', '0', x.nextSibling);
 
    y.className = x.className;  // steal classes from the the edit tab...
    x.className = 'istalk';     // ...and make the edit tab have no right margin
 
    // exception: don't steal the "selected" class unless actually editing section 0:
    if (/(^| )selected( |$)/.test(y.className)) {
        if (!document.editform || !document.editform.wpSection
            || document.editform.wpSection.value != "0") {
            y.className = y.className.replace(/(^| )selected( |$)/g, "$1");
            x.className += ' selected';
        }
    }
});

/*
// addPurge
addOnloadHook(function () {
    var hist; var url;
    if (!(hist = document.getElementById('ca-history') )) return;
    if (!(url = hist.getElementsByTagName('a')[0] )) return;
    if (!(url = url.href )) return;
    mw.util.addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),
                   'purge', 'ca-purge', 'Purge server cache for this page', '0');
});
*/

// Add [[WP:Reflinks]] launcher in the toolbox on left
addOnloadHook(function () {
 mw.util.addPortletLink(
  "p-tb",     // toolbox portlet
  "http://toolserver.org/~dispenser/cgi-bin/webreflinks.py/" + mw.config.get('wgPageName') 
   + "?client=script&citeweb=on&overwrite=&limit=20&lang=" + mw.config.get('wgContentLanguage'),
  "Reflinks"  // link label
)});

// Add Reference generator in the toolbox on left
addOnloadHook(function () {
 mw.util.addPortletLink(
  "p-tb",
   "http://toolserver.org/~magnus/makeref.php",
   "Ref generator"
)});

/* </nowiki> */