Jump to content

User:Isaac/monobook.js

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Isaac (talk | contribs) at 18:49, 18 September 2010 (friendly config). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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.
/* <pre><nowiki> */
 
/**
 * Monobook scripts by Alphax and others
 * Dual licensed under the GFDL and GPL
*/
 
/**** Twinkle ****/
importScript('User:AzaToth/twinkle.js');


/**** Friendly ****/
importScript('User:Ioeth/friendly.js');

if( typeof( FriendlyConfig ) == 'undefined' ) FriendlyConfig = {}; // DO NOT REMOVE THIS LINE - ALL FRIENDLY SETTINGS AFTER THIS
FriendlyConfig.clockStyle			=	"static";
FriendlyConfig.quickWelcomeMode			=	"semiauto";
FriendlyConfig.quickWelcomeTemplate		=	"Welcome";
FriendlyConfig.summaryAd			=	" using [[WP:FRIENDLY|Friendly]]";
FriendlyConfig.talkbackHeading			=	"== Talkback ==";
FriendlyConfig.topWelcomes			=	false;
FriendlyConfig.watchTaggedPages			=	true;
FriendlyConfig.watchWelcomes			=	true;

/**** Add navigation popups ****/
 
//[[User:Lupin/popups.js]] - please include this line 
importScript('User:Lupin/popups.js');

// customisations = see [[Wikipedia:Tools/Navigation popups]] for more
popupDelay = 0.7;
popupHideDelay = 0.3;
popupFixRedirs = true;
popupRedirAutoClick = 'wpPreview';
popupFixDabs = true;
popupStructure = 'menus';
 
/**** Lupin Edit Counter ****/
importScript('User:Lupin/editcount.js');
popupEditCounterTool='custom';
popupEditCounterUrl='http://en.wikipedia.org/wiki/User:$1?ectarget=$1';

/**** Live RC filter ****/
// [[User:Lupin/recent2.js]] - please include this line
importScript('User:Lupin/recent2.js');
 
/**** Initialise on window load and load custom functions ****/
 
addOnloadHook(function() {
    addEditSection0();
    changeLinks();
    addToolBoxLinks();
    googleSearch();
    if (document.forms.editform) 
    {
        addPortletLink('p-cactions', 'javascript:wpTextboxReplace()', 'Replace', 'ca-replace',
                       'Regexp replace for the edit window', 'R', document.getElementById('ca-history'));
    }
});

function wpTextboxReplace()
{
    var s = prompt("Search regexp:");
    if(s){
        var r = prompt("Replace /"+s+"/ with:");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "mg"), r);
    }
}

function addEditSection0()
{
    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 = 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';
        }
    }
}
 
/**** Make the top links look better ****/
 
function changeLinks()
{
    if(!document.getElementById) return;
    // remove the "my" bits
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'talk';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'preferences';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'watchlist';
    document.getElementById('pt-mycontris').firstChild.innerHTML = 'contributions';
}
 
/**** Add links to the toolbox ****/
 
function addToolBoxLinks()
{
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];

    addlilink(tb, '/wiki/Wikipedia:Template_messages/User_talk_namespace', 'Talk messages', ''); 
    addlilink(tb, '/wiki/Special:Newpages', 'New pages', '');
    addlilink(tb, '/wiki/Special:Shortpages', 'Short pages', '');
    addlilink(tb, '/wiki/Special:Log', 'Logs', '');
    addlilink(tb, '/wiki/User:St.isaac/monobook.js', 'Monobook.js', '');
    addlilink(tb, '/wiki/User:St.isaac/Sandbox', 'My sandbox', '');
    addlilink(tb, '/wiki/WP:ICT', 'Image Copyright tags', '');
}

function addlilink(node, href, text, id, tooltip, accesskey) {
        // the code below is mostly copied from addPortletLink()

        var link = document.createElement( "a" );
        link.appendChild( document.createTextNode( text ) );
        link.href = href;

        var item = document.createElement( "li" );
        item.appendChild( link );
        if ( id ) item.id = id;
        if ( accesskey ) {
                link.setAttribute( "accesskey", accesskey );
                tooltip += " ["+accesskey+"]";
        }
        if ( tooltip ) {
                link.setAttribute( "title", tooltip );
        }
        updateTooltipAccessKeys( new Array( link ) );
        node.appendChild( item );
        return item;
}

 
function googleSearch() 
{
  document.getElementById('searchform').action = 'http://www.google.com/search'; 
  document.getElementById('searchInput').name = 'q'; 
  document.getElementById('searchGoButton').name = 'btnG'; 
  document.getElementById('mw-searchButton').name = 'btnI'; 
  document.getElementById('searchGoButton').value = 'G'; 
  document.getElementById('mw-searchButton').value = 'Lucky!'; 
  var enwp = document.createElement('input');
  enwp.id = 'as_sitesearch';
  enwp.name = 'as_sitesearch';
  enwp.value = 'en.wikipedia.org';
  enwp.type = 'hidden';
  document.getElementById('searchform').appendChild(enwp);
}

if (wgAction == 'history') //add a link to call histComb.js
addOnloadHook(function(){
 var pagehis = document.getElementById('pagehistory');
 if (!pagehis) return;
 var lnk = document.createElement('a');
 lnk.style.marginLeft = '10px';
 lnk.href = '#';
 lnk.appendChild(document.createTextNode('Improve…'));
 lnk.onclick=function(){this.parentNode.removeChild(this);importScript('User:Alex_Smotrov/histcomb.js')}
 pagehis.parentNode.insertBefore(lnk, pagehis);
})

/* </nowiki></pre> */