User:MacGyverMagic/monobook.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.

If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
//-------------------BASIC SCRIPTS ---------------------------------
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;
}

// ***********Add LI link-script***********

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

// ***********addlimenu***********

function addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = '';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}

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

// ***********addToolboxLink script***********
function addToolboxLink(url, name, id){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
//    addlilink(tb, url, name, id);
      addlilink(tb, '/wiki/Special:Newpages', 'New pages', '');
      addlilink(tb, '/wiki/Special:Log', 'Logs', '');   
}

//***********Replace function***********

function replace()
{
    var s = prompt("Search regexp?");
    if(s){
        var r = prompt("Replace regexp?");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "g"), r);
    }
}

//-------------------BASIC SCRIPTS END HERE---------------------------------

importScript('User:Ais523/highlightmyname2.js'); //[[User:Ais523/highlightmyname2.js]]
importScript('User:Ais523/catwatch.js'); //[[User:Ais523/catwatch.js]]

importScript('User:Tra/sidebartranslate.js'); // Translates sidebar languages.

importScript('User:MacGyverMagic/nssearch.js'); //namspace searching

//Own copies of scripts.
//importScript('wikipath'); //comment

importScript('User:MacGyverMagic/block.js'); // own block tabs
importScript('User:MacGyverMagic/purge.js'); //adds purge tab to the top.
importScript('User:MacGyverMagic/autoafd.js'); //AutoAFD script.
importScript('User:MacGyverMagic/time.js'); //displays time (UTC) and date in top bar.
importScript('User:MacGyverMagic/extrabuttons.js'); //adds buttons to edit interface.
importScript('User:MacGyverMagic/newusers.js'); //adds links to new user log.
importScript('User:MacGyverMagic/section0.js'); //section 0 tab instead of link.



 // [[User:Jsimlo/shortcuts.js]]
 document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Jsimlo/shortcuts.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
 function shortcutsInit ()
 {
 
  shortcutsAddLink ('Navigation shortcuts', 'Wikipedia:Tools/Navigation shortcuts');
 
 }



//Script that highlights links to redirect pages green
// [[User:Dschwen/highlightredirects.js]] - please include this line 
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Dschwen/highlightredirects.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//Quick Preview button
importScript('User:Alex_Smotrov/qpreview.js'); //[[User talk:Alex Smotrov/qpreview.js]]
qPreviewKey = '`'; // accesskey for QPreview button ('~' by default)
qPreviewName = 'QPreview'; // name on the button

//Lupin's Popup navigation script - [[Wikipedia:Tools/Navigation_popups]]
// [[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>');

popupAdminLinks=true;
popupStructure='fancy2';
popupFixRedirs=true;
popupFixDabs=true;

//End of popup navigational script.

//*****************************************************************************************
//***************************** Special Loading Section ***********************************
//*****************************************************************************************

window.onload = Main;

function Main()
{
 addToolboxLink();
}