User:OneTwoThreeFall/global.js

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

var currentSkin = mw.config.get('skin');

function getURLParam(param, url) { var results = new RegExp('[\?&;]' + param + '=([^&;#]*)').exec(url || window.location.search); if (results === null){ return null; } else { return results[1] || 0; } }

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 + '=' + getURLParam(param, link[0]), param + '=' + value); } else { return; }

if (typeof link[1] !== 'undefined') { link[1] = '#' + link[1]; } else { 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'  ] });

// use uncyclopedia's vector style for monobook w/ tweaks if (currentSkin === 'monobook') { importArticles({   type: 'style',    article: 'u:uncyclopedia:MediaWiki:Uncyclopedia.css'  }); $('.editsection').each(function {    $(this).css({"float": "none", "padding-left": "1em", "display": "inline", "color": "#555"}).parent.append(this);  }); $(" #pt-wall-notifications .prehide{visibility:inherit;} .portlet h5{border:none;} #p-wikicities-nav{display:none;} div#content{border-color:#A7D7F9;} fieldset{border-width:1px!important;} #firstHeading{margin-top:0;} h2{padding-top:20px;} .editsection::before,.editsection::after{content:\"\";} #catlinks{border:1px solid #AAA;} #footerlinks{float:right;} ").appendTo("body"); }

// persist the 'useskin' parameter var customSkin = getURLParam('useskin'); if (customSkin !== null) { $('a:not(.external)').each(function {    addLinkParam(this, 'useskin', customSkin);  }); }

// 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 (currentSkin === 'oasis') { $('.WikiaRail').on('afterLoad.rail', function {    $('#WikiaRecentActivity a[title="Special:WikiActivity"]').html('Wiki Activity &gt;').after(' Recent Changes &gt;');  }); } else if (currentSkin === '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 (currentSkin === 'oasis') { $(getPrefixLI('0', 'Main')).appendTo('.tools-menu'); } else if (currentSkin === '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');

// UTC time on right of oasis toolbar or monobook personal bar w/ purge option - originally from c:dev:DisplayTimer jQuery(function ($) { var $parent = $(''),    $node = $('<a title="Purge current page cache" href="' + mw.util.getUrl(mw.config.get('wgPageName'), {action: 'purge'}) + '"/>').appendTo($parent);

function updateDate { $node.text(new Date.toUTCString.replace('GMT', 'UTC').slice(5)); }

if (currentSkin === 'oasis') { $parent.css({"float": "right", "border": "0", "margin-right": "10px"}).appendTo('.tools'); } else if (currentSkin === 'monobook') { $parent.css('text-transform', 'none').appendTo('#p-personal ul'); } updateDate; window.setInterval(updateDate, 1000); $parent = null; });