User:OneTwoThreeFall/global.js

/*jslint browser */ /*global window, $, mw, importArticles, ace, WikiaEditor, GlobalTriggers, playerParams, RevealAnonIP */

window.RevealAnonIP = {}; window.NoImageLightbox = {novideo: true}; window.pseudoVector = { addContributionsTab: true, blacklist: ['community.wikia.com'] };

importArticles({   type: 'script',    articles: [        'u:dev:CacheCheck/code.js',        'u:dev:RevealAnonIP/code.js',        'u:dev:NoImageLightbox/code.js',        'u:dev:CompareLink.js',        'u:dev:DisplayTimer/code.js',        'u:dev:QuickDiff/code.js',        'u:dev:MonobookHighlight.js',        'u:dev:Pseudo-Vector.js',        'u:c:User:OneTwoThreeFall/SwitchSkin-js.css',        'u:c:User:OneTwoThreeFall/MassNullEdit.modified-js.css',        'u:c:User:OneTwoThreeFall/LastEdited.modified-js.css',        'u:c:User:OneTwoThreeFall/UnsafeScripts.modified-js.css'    ] });

// custom edit buttons if (mw.toolbar) { mw.toolbar.addButton(       '//images.wikia.nocookie.net/central/images/c/c8/Button_redirect.png',        'Redirect',        '#REDIRECT ',        '',        'Target'    ); }

// disable redirect links $('.mw-redirect, .allpagesredirect > a').each(function (ignore, element) {   var link = new mw.Uri(element.href);    link.extend({ redirect: 'no' });   element.href = link.toString; });

// don't save page when pressing 'enter' in summary box - credit to User:Ciencia Al Poder if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) { $('#wpSummary').keypress(function (event) {       if (event.which === 13) {            return false;        }    }); }

// don't leave redirect when moving files if (   mw.config.get('wgCanonicalSpecialPageName') === 'Movepage' &&    mw.config.get('wgRelevantPageName').indexOf(mw.config.get('wgFormattedNamespaces')[6] + ':') === 0 ) { $('#wpLeaveRedirect').prop('checked', false); }

// add clear reason button to the delete page if (mw.config.get('wgAction') === 'delete') { $('#wpReason').after(' \u232b '); $('#wpClearReason').click(function {        $('#wpReason').val('').focus;    }); }

// add prefix search + page log links to tools menu if (mw.config.get('wgNamespaceNumber') !== -1) { var extraLinks = 'Prefix search' + 'Logs for this page'; if (mw.config.get('skin') === 'oasis') { $('#my-tools-menu').prepend(extraLinks); } else { $('#p-tb > .pBody > ul').append(extraLinks); } }

// add watchlist and contribs links to oasis user menu $('.user-menu > li:has(a[data-id="preferences"])') .after(       'My watchlist' +        'My contributions'    );

// add button to unhide removed messages on thread pages $('.removed-info').append('Show '); $('.showremovedmessage').click(function (event) {   $(event.target).closest('.message-removed').removeClass('hide'); });

// move edit + talk buttons into oasis header $('#WikiaPageHeader > .header-container > .header-title > h1') .after($('#WikiaPageHeader > .comments').css('margin', '2px 10px 0')) .after($('#WikiaPageHeader > .wikia-button')) .after($('#WikiaPageHeader > .wikia-menu-button')) .after($('#WikiaPageHeader > .view-source'));

// add direct link on youtube video file pages if (window.playerParams && playerParams.provider === 'youtube') { var $ytLink = $('') .attr('href', 'https://youtube.com/watch?v=' + playerParams.jsParams.videoId) .text(mw.config.get('wgTitle')); $('.video-provider').prepend($ytLink, ' – '); $('[id^="youtubeVideoPlayer"]').attr('style', ''); }

// stop classification popup on template save in oasis if (mw.config.get('wgIsEditPage')) { // …in ace editor window.enableTemplateClassificationEditorPlugin = false; // …in source editor (rather hacky, but whatever) GlobalTriggers.bind('WikiaEditorReady', function {        try {            WikiaEditor.getInstance.events.save[0].fn = function  {                return true;            };        } catch (ignore) {}    }); }

// code editor tweaks function codeEditorTweaks { var aceEditor = ace.edit('editarea'); aceEditor.setTheme('ace/theme/solarized_dark'); aceEditor.setOptions({       dragDelay: 20,       // quicker drag mode        printMargin: true,   // margin at 80 chars across        showInvisibles: true // show spaces/tabs/newlines as symbols    }); // fix syntax highlighting on '-js.css' pages if (mw.config.get('wgPageName').slice(-7) === '-js.css') { aceEditor.getSession.setMode('ace/mode/javascript'); } } if (window.ace) { // wait 3s and hope ace is loaded by then window.setTimeout(codeEditorTweaks, 3000); }

// run after page is completely loaded $(window).load(function {

// pre-open grouped items in recent changes and watchlist if ($.inArray(mw.config.get('wgCanonicalSpecialPageName'), ['Recentchanges', 'Watchlist']) !== -1) { $('.mw-collapsible-toggle-collapsed').click; }

// add 'used templates' button to edit toolbar in oasis if (mw.config.get('wgIsEditPage')) { $(' ').attr({           'onclick': $('.tmpl_listused > a').attr('onclick'),            'src': '//images.wikia.nocookie.net/central/images/4/43/Button-template.png',            'title': $('.tmpl_listused > a').text        }).appendTo('#cke_toolbar_source_1'); }

// sometimes RevealAnonIP doesn't load in time... window.setTimeout(RevealAnonIP.reveal, 3000);

});