User:OneTwoThreeFall/global.js

/*jslint indent:2, browser:true */ /*global $, jQuery, mw, importArticles */

/* --- */ /* -- helper things -- */

function addLinkParam(element, param, value, replace) { var newlink, noadd, link = element.href.split('#');

if (link[0].indexOf('?') === -1) { param = '?' + param; } else if (link[0].indexOf(param) === -1) { param = '&' + param; } else if (replace === true) { noadd = true; link[0] = link[0].replace(param + '=' + mw.util.getParamValue(param, link[0]), param + '=' + value); } else { return; }

if (link[1] === undefined) { link[1] = ''; } else { link[1] = '#' + link[1]; }

if (noadd === true) { newlink = link[0] + link[1]; } else { newlink = link[0] + param + '=' + value + link[1]; } $(element).attr('href', newlink); }

/* -- */ /* -- things to do -- */

importArticles({ type: 'script',  articles: [    'u:dev:CacheCheck/code.js',    'u:dev:NullEditButton/code.js',    'u:dev:RevealAnonIP/usercode.js',    'u:dev:NoImageLightbox/code.js',    'u:dev:MassNullEdit/code.js',    'u:dev:DisplayTimer/code.js'  ] });

// use uncyclopedia's vector style for monobook w/ fixes if (mw.config.get('skin') === 'monobook') { importArticles({   type: 'style',    articles: [      'u:uncyclopedia:MediaWiki:Uncyclopedia.css',      'u:community:User:OneTwoThreeFall/monobook-vector-fixes.css'    ]  }); // move edit links to after header $('.editsection').each(function {    $(this).css({'float': 'none', 'padding-left': '1em', 'display': 'inline'}).parent.append(this);  }); }

// if 'useskin' parameter exists, set it as a cookie var customSkin = mw.util.getParamValue('useskin'); if (customSkin !== null) { $.cookie('useskin', customSkin, {   domain: mw.config.get('wgCookieDomain'),    path: mw.config.get('wgCookiePath')  }); }

// disable redirect links $('.mw-redirect, .allpagesredirect a').each(function {  addLinkParam(this, 'redirect', 'no'); });

// no redirect when moving files if (mw.config.get('wgPageName').indexOf('Special:MovePage/File:') !== -1) { $('#wpLeaveRedirect').removeAttr('checked'); }

// add 'used templates' link in wide-mode edit panel $(window).load(function {  $('.text-links').clone(true).css('display', 'none').appendTo('.checkboxes').find('a').html('Used templates'); });

// link to S:RC in 'Recent Wiki Activity' rail module if (mw.config.get('skin') === 'oasis') { $('.WikiaRail').on('afterLoad.rail', function {    $('#WikiaRecentActivity a[title="Special:WikiActivity"]').html('Wiki Activity &gt;').after(' Recent Changes &gt;');  }); } else if (mw.config.get('skin') === 'venus') { $('#recentWikiActivity a[title="Special:WikiActivity"]').html('Wiki Activity').after(' Recent Changes'); }

// quick prefix search w/ namespace function getPrefixLI(ns, nsname) { return ' Prefix search (' + (nsname || ns) + ')'; } if (mw.config.get('wgNamespaceNumber') !== -1) { if (mw.config.get('skin') === 'oasis') { $(getPrefixLI('0', 'Main')).appendTo('.tools-menu'); } else if (mw.config.get('skin') === 'monobook') { $(getPrefixLI('0', 'Main')).appendTo('#p-tb ul'); } }

// add 'contributions' and 'watchlist' to accountnav - originally from c:dev:AdvancedOasisUI $('#AccountNavigation > li > ul.subnav > li:has(a[data-id="preferences"])').after('My watchlistMy contributions');