User:.jun/global.js

require(['wikia.window', 'mw'], function(context, mw) {   document.getElementsByClassName('wds-global-navigation__search-input')[0].addEventListener('blur', function(elem) { if (!elem.srcElement.value) { document.getElementById('globalNavigation').classList.remove('wds-search-is-active'); }   });    if (mw.config.get('wgCanonicalSpecialPageName') == 'Recentchanges') {        Array.prototype.forEach.call(document.querySelectorAll('.rc-conntent a'), function(elem) { if (elem.getAttribute('href') !== '#') { elem.setAttribute('target', '_blank'); }       });    }    context.ajaxCallAgain = context.ajaxCallAgain || [];    context.ajaxCallAgain.push(function { Array.prototype.forEach.call(document.querySelectorAll('.rc-conntent a'), function(elem) {           if (elem.getAttribute('href') !== '#') {                elem.setAttribute('target', '_blank');            }        }); });   context.ajaxPages = ['Special:RecentChanges', 'Special:WikiActivity'],    context.ajaxRefresh = 30000;    Array.prototype.forEach.call(document.querySelectorAll('a[data-canonical="wikiactivity"]'), function(elem) { elem.href = '/wiki/Special:Recentchanges'; elem.innerHTML = 'Recent changes'; });   var links = {        debug: 'debug=true',        nocss: 'useusercss=0',        nojs: 'useuserjs=0',        qqx: 'uselang=qqx',        vector: 'useskin=vector',        mercury: 'useskin=mercury',        monobook: 'useskin=monobook'    },        parent = document.getElementsByClassName('wds-global-navigation__links-and-search')[0];    for (var i = 0; i < parent.childNodes.length; i++) {        if (parent.childNodes[i].classList && parent.childNodes[i].classList.value !== 'wds-global-navigation__search') {            parent.removeChild(parent.childNodes[i]);        }    }    for (i in links) {        if (links.hasOwnProperty(i)) {            var elem = document.createElement('a');            elem.href = mw.config.get('wgArticlePath').replace(/\$1/g, mw.config.get('wgPageName') + (!!context.location.search ? (!(context.location.search.indexOf(links[i]) > -1) ? (context.location.search + '&' + links[i]) : context.location.search) : ('?' + links[i])) + (!!context.location.hash ? context.location.hash : ''));           elem.className = 'wds-global-navigation__link';            elem.innerHTML = i;            parent.insertBefore(elem, parent.firstChild);        }    }    var persistentParameterList = ['useskin', 'uselang', 'usesitecss', 'usesitejs', 'useusercss', 'useuserjs', 'usevector'];    mw.util.addCSS( '#source-code, #source-toc {' + 'font-family: monaco, monospace !important;' + '}' +       '#source-code > a {' + 'color: ' + context.getComputedStyle(document.getElementsByTagName('a')[0]).color + ' !important;' + 'font-weight: bold;' + '}'   );    importArticles({ type: 'script', articles: [ 'u:dev:AjaxRC/code.js', 'u:dev:PersistentParameters/code.js', 'u:dev:LastEdited/code.js', 'u:dev:QuickDiff/code.js', 'u:dev:View_Source/code.js' ]   }); });