User:Adrian M. H./monobook.js

From Wikipedia, the free encyclopedia

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.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
/* <pre><nowiki> */
 
// Speedy deletion tags //
importScript('User:AzaToth/morebits.js');
importScript('User:AzaToth/twinklespeedy.js');
importScript('User:AzaToth/twinklexfd.js');
TwinkleConfig = {
        markSpeedyPagesAsMinor          :       false,
        openUserTalkPageOnSpeedyDelete  :       [ ],
        watchSpeedyPages                :       [ 'g1', 'g2', 'g3', 'g4', 'g5', 'g7', 'g10', 'g11', 'g12', 'a1', 
'a3', 'a7', 'r1', 'r2', 'u1', 'u3', 't1' ], 
};
 
// External link behaviour //
addOnloadHook(function() {
    var alinks = document.getElementsByTagName("a");
    var tablink;
    for (var i = 0, leng = alinks.length; i < leng; i++) {
        tablink = alinks[i];
        if (/\bexternal\b/.test(tablink.className) && tablink.href.indexOf("http://en.wikipedia.org") != 0)
            tablink.target = "_tab";
    }
});
 
// Interwiki link behaviour //
addOnloadHook(function() {
    var alinks = document.getElementsByTagName("a");
    var tablink;
    for (var i = 0, leng = alinks.length; i < leng; i++) {
        tablink = alinks[i];
        if (/\bextiw\b/.test(tablink.className) && tablink.href.indexOf("http://en.wikipedia.org") != 0)
            tablink.target = "_tab";
    }
});
 
// Default limitation of "What Links Here" to mainspace only //
addOnloadHook(function(){
 var ln = document.getElementById('t-whatlinkshere');
 if (!ln) return;
 ln.firstChild.href = ln.firstChild.getAttribute('href', 2) + '?namespace=0';
});
 
// User:Anomie/fix-tab-text.js //
addOnloadHook(function(){
    var fix=function(id, text){
        var el=document.getElementById(id);
        if(!el) return;
        for(el=el.firstChild; el && el.nodeName!='A'; el=el.nextSibling);
        if(!el) return;
        while(el.firstChild) el.removeChild(el.firstChild);
        el.appendChild(document.createTextNode(text));
    }
    fix('ca-edit', 'edit');
    fix('ca-addsection', '+');
    fix('pt-userpage', 'home');
    fix('pt-watchlist', 'watchlist');
    fix('pt-mycontris', 'contributions');
    fix('pt-preferences', 'preferences');
});
 
// Navigation links //
addOnloadHook(function() {
addPortletLink('p-navigation','/wiki/Category:Categories','Categories','t-categories','Category:Categories');
});
 
// Interaction links //
addOnloadHook(function() {
addPortletLink('p-interaction','/wiki/Wikipedia:Signpost','Signpost','t-signpost','Wikipedia:Signpost');
});
 
// Toolbox links //
addOnloadHook(function() {
addPortletLink('p-tb','/wiki/Special:Logs','Other logs','t-logs','Special:Logs');
});
 
// Page-specific log link //
if (wgNamespaceNumber >= 0)
addOnloadHook(function(){
 addPortletLink('p-tb', wgServer+wgScript+'?title=Special:Log&page='+wgPageName,
 'Page logs', 't-pagelog', 'Logs for this page', '', document.getElementById('t-upload'))
})
 
// Personal links //
addOnloadHook(function() {
addPortletLink('p-personal','/wiki/User:Adrian M. H./Directory','Links','pt-links','Link directory','l',
document.getElementById('pt-preferences'));
});
addOnloadHook(function() {
addPortletLink('p-personal','/wiki/Special:Log?user=Adrian M. H.','log','pt-log','Log of my actions','',document.getElementById('pt-logout'));
});
 
// Purge tab //
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;
    addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),
                   'purge', 'ca-purge', 'Purge server cache for this page', '0');
});
 
// Customised version of toolbar clock //
function liveClock()
{
 
	liveClock.node = addPortletLink( 'p-personal', wgServer + wgScriptPath + '/index.php?title=' + wgPageName + '&action=purge', '', 'utcdate' );
 
	showTime();
}
addOnloadHook(liveClock)
 
function showTime()
{
 
	var dateNode = liveClock.node;
	if( !dateNode ) {
		return;
	}
    var now = new Date();
	var hh = now.getUTCHours();
	var mm = now.getUTCMinutes();
	var ss = now.getUTCSeconds();
	var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm ) + ':' + ( ss < 10 ? '0' + ss : ss );
	dateNode.firstChild.replaceChild( document.createTextNode( time ), dateNode.firstChild.firstChild );
 
    window.setTimeout(showTime, 1000);
}
 
// Ref buttons in edit toolbar //
importScript('User:Mr.Z-man/refToolbar.js');
 
/*</nowiki></pre>*/