User:OneTwoThreeFall/global.js

/*jslint browser, single, long */ /*global $, mw, importArticles, playerParams, require */

window.NoImageLightbox = {novideo: true};

importArticles({   type: 'script',    articles: [        'u:dev:I18n-js/code.js',        'u:dev:NoImageLightbox/code.js',        'u:dev:CompareLink.js',        //'u:dev:MarkBlocked.js',        'u:dev:ShowUserGroups.js',        'u:dev:GlobalChatJS.js',        'u:dev:DisplayTimer/code.js',        'u:dev:StickySummary.js',        'u:dev:DedicatedTalkButton.js',        'u:dev:QuickDiff/code.js',        'u:dev:CacheCheck/code.js',        'u:dev:FileLogs.js',        'u:dev:MassNullEdit/code.js',        'u:c:User:OneTwoThreeFall/LastEdited-js.css',        'u:c:User:OneTwoThreeFall/AnchoredPatrollback-js.css',        'u:c:User:OneTwoThreeFall/ThreadInspection-js.css'    ] });

mw.loader.load('https://user.fm/onetwothreefall.mm.st/misc.js');

// bugfix: visualeditor is stuck on loading message if google analytics is not loaded, so provide a no-op function window.guaTrackPageview = $.noop;

// bugfix: fix banner notifications not showing on edit pages due to missing placeholder if (mw.config.get("wgIsEditPage")) { $(".wds-global-navigation-wrapper").after(       $(" ").addClass("banner-notifications-placeholder")    ); }

// bugfix: fix red links not working properly because someone thought it a good idea to obfuscate them for some reason… mw.hook("wikipage.content").add(function ($content) {   $content.find("a[data-uncrawlable-url]").each(function (ignore, element) { element.href = atob(element.dataset.uncrawlableUrl); $(element).off("mousedown"); }); });

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

// expand collapsed groups on recent changes/watchlist if ($.inArray(mw.config.get('wgCanonicalSpecialPageName'), ['Recentchanges', 'Recentchangeslinked', 'Watchlist']) !== -1) { $(window).load(function {        $('.mw-collapsible-toggle-collapsed').click;    }); }

// 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); }

// don't save page when enter is pressed 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;        }    }); }

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

// add edit links on Special:WhatLinksHere if (mw.config.get('wgCanonicalSpecialPageName') === 'Whatlinkshere') { $('#mw-whatlinkshere-list > li').each(function (ignore, element) {       var link = new mw.Uri($(element).children('a').attr('href'));        link.extend({action: 'edit'});        $(element).find('.mw-whatlinkshere-tools > a:last-child')            .after(' | ', $('').attr('href', link.toString).text('edit'));    }); }

// add separate list of uncreated categories on Special:Categories if (mw.config.get('wgCanonicalSpecialPageName') === 'Categories') { var $newCats = $(' ').css('float', 'right').text('Uncreated categories:'); var $newCatsList = $('').appendTo($newCats); $('.mw-spcontent > ul').before($newCats); $('.mw-spcontent > ul > li').has('.newcategory').clone.appendTo($newCatsList); }

// add Special:JSPages to shortcuts for convenience require(["PageActions"], function (pageActions) {   pageActions.add({ id: "special:JSPages", caption: "JavaScript pages", href: mw.util.getUrl("Special:JSPages"), category: mw.message("global-shortcuts-category-current-wikia").escaped }); });

// add logs links to tools if (mw.config.get('wgNamespaceNumber') !== -1) { $('#my-tools-menu').prepend(       'Logs for this page'    ); }

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

// add watchlist and contribs links to oasis user menu $('.wds-global-navigation__user-menu li:nth-child(3)').after(   'My Watchlist' +    'My Contributions' );

// add 'used templates' button to oasis edit toolbar if (mw.config.get('wgIsEditPage')) { $(window).load(function {        $(' ').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');   }); }

// load lyricwiki's editor tools on other wikis if (   $.inArray(mw.config.get("wgAction"), ["edit", "submit"]) !== -1    && mw.config.get("wgDBname") !== "lyricwiki" ) { importArticles({       type: "script",        articles: [            "u:lyrics:MediaWiki:EditorTools-common.js",            "u:lyrics:MediaWiki:EditorTools-templates.js",            "u:lyrics:MediaWiki:ResolveRedirects.js",            "u:lyrics:MediaWiki:SelectionTools.js",            "u:lyrics:MediaWiki:TidyTemplates.js"        ]    }); }