User:GerritH/global.js

// Buttons if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "https://upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png", "speedTip": "Weiterleitung", "tagOpen": "#REDIRECT ", "tagClose": "" }; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "https://upload.wikimedia.org/wikipedia/commons/0/05/Button_Anf%C3%BChrung.png", "speedTip": "Anführungszeichen", "tagOpen": "„", "tagClose": "“" }; } //window.DiscordIntegratorLoaded = true; window.AjaxCommentDeleteConfig = {vocab:{linkText:"Delete"},fastDelete:"Clean-up"}; window.anchoredRollbackBot = true; window.PRAoptions = {editSummary: 'Automatic page link update'}; importArticles({   type: 'script',    articles: [    'u:dev:AjaxCommentDelete/code.js',    'u:dev:AnchoredRollback/code.js', //  'u:dev:PageRenameAuto-update/code.js',    'u:dev:View_Source/code.js',    'u:dev:WLHEditLinks/code.js',    'u:dev:ProtectionIcons.js',    'u:dev:RevealAnonIP/code.js',    'u:dev:PortableCSSPad/code.js',    'u:dev:AjaxPatrol/code.js',    'u:dev:RecentChangesMultiple/code.2.js',    'u:dev:AjaxBatchDelete/code.2.js',    'u:dev:MassProtect/code.js',    'u:dev:RedirectManagement/code.js',    'u:dev:AllPagesHideRedirect/code.js',    'u:dev:CacheCheck/code.js',    'u:dev:QuickDiff/code.js',    'u:dev:QuickDelete/code.js',    'u:dev:WHAM/code.2.js',    'u:dev:SearchSuggest/code.js',    'u:dev:FindAndReplace/code.js',    'u:dev:ListFiles/code.js', //  'u:dev:FileUsageAuto-update/code.js',    'u:dev:CategoryRenameAuto-update/code.js',    'u:dev:ColoredColors/code.js',    'u:dev:UnifiedControlPanel.js', 'u:dev:JWB/load.js', 'u:community:User:AmonFatalis/Interwiki.js', 'u:community:User:AmonFatalis/ShowUserGroupsFork.js', 'u:community:User:AmonFatalis/UserRegistration.js', 'u:community:User:AmonFatalis/MassUserRightsFork.js' ] }); importScriptURI('//internal-vstf.fandom.com/wiki/User:AmonFatalis/scripts.js?action=raw&ctype=text/javascript&templates=expand'); importScriptURI('//internal-vstf.fandom.com/index.php?title=MediaWiki:CU.js&action=raw&ctype=text/javascript'); if (wgCanonicalSpecialPageName === 'Contributions') {   importStylesheetURI('http://internal-vstf.fandom.com/index.php?title=MediaWiki:NiceButtons.css&action=raw&ctype=text/css');    var usernamej2 = $('input[name="target"]').val,        usernamej  = usernamej2.replace(/_/g,'+');    if(usernamej.match(/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/)) {        $('#contentSub >a:first').before("" + usernamej + "");    } } if (wgNamespaceNumber !== wgNamespaceIds.special && wgNamespaceNumber !== wgNamespaceIds.thread && wgNamespaceNumber !== wgNamespaceIds.board_thread && wgNamespaceNumber !== wgNamespaceIds.message_wall && wgNamespaceNumber !== wgNamespaceIds.topic) { //based on dev.fandom.com/?oldid=119591 $('.page-header__contribution-buttons').prepend("" +               "" +                "" +                "Delete " +                "" +                "" +                "" +                "   "); } //AjaxFastDelete by Grunny, original by Splarka, later modified by uberfuzzy and Grunny. Update by KockaAdmiralac window.fdButtons = [ {summary:'Veralteten Import gelöscht', label:'Default-Import'}, {summary:'Cleanup', label:'Cleanup'}, {summary:'Löschantrag', label:'Löschantrag'} ]; (function($) {   "use strict";    if (typeof window.wkAjaxFastDelete !== 'undefined') {        return false;    }    window.wkAjaxFastDelete = {        version: '2.2',        init: function {            if (wgNamespaceNumber === -1 || !window.fdButtons) {                return;            }            var deleteButtons = '';                    deleteButtons = fdButtons.map(function(b) { var sum = b.summary; return '' + b.label + ''; });               if ($('.UserProfileActionButton').exists) {                    $('.UserProfileActionButton .wikia-menu-button .WikiaMenuElement').append(deleteButtons);                } else {                    $('.page-header__contribution-buttons .wds-button-group .wds-dropdown__content .notwds-ul').append(deleteButtons);                }            if($('a[data-id="fastdelete"]').length) {                $('a[data-id="fastdelete"]').click(function { wkAjaxFastDelete.ajaxDeleteAPage($(this).attr('data-summary')); });           }        },        ajaxDeleteAPage: function(deleteReason) {            var url =  wgServer + wgScriptPath + '/api.php?action=query&prop=info&intoken=delete&titles=' + encodeURIComponent(wgPageName) + '&format=json';            $.getJSON(url, function(data) { var editToken = data.query.pages[wgArticleId].deletetoken, url = wgServer + wgScriptPath + '/api.php?action=delete&title=' + encodeURIComponent(wgPageName) + '&reason=' + encodeURIComponent( deleteReason) + '&format=json&token=' + encodeURIComponent(editToken); $.post( url, function {                   document.location.reload;                }); });       }    };    $(document).ready(wkAjaxFastDelete.init); }(jQuery));

// Bypass Special:InfoboxBuilder by Nanaki if ($('.template-classification-type-text').data('type') == 'infobox') $('#ca-edit').attr('href', function(a) {   return this.href + '&useeditor=source'; }); if (window.location.pathname.indexOf('InfoboxBuilder') != -1) { var lname = window.location.pathname.split('InfoboxBuilder/')[1]; location.replace(document.URL.replace(window.location.href.split('/wiki/')[1],'Template:' + lname + '?action=edit&useeditor=source')); }

// Based on kocka.fandom.com/wiki/MediaWiki:AjaxThreadDelete/code.js?oldid=446 by User:KockaAdmiralac $(function{ if(wgNamespaceNumber !== wgNamespaceIds.thread && wgNamespaceNumber !== wgNamespaceIds.board_thread && wgNamespaceNumber !== wgNamespaceIds.message_wall) return;	var api = new mw.Api,	config = window.AjaxThreadDeleteConfig || {fastDelete: "true"};	$("Delete").insertAfter("a.permalink");	$(".AjaxThreadDeleteButton").click(function(e){ var superParent = $(e.currentTarget).closest(".SpeechBubble"); function deleteThread{ api.post({				action: 'delete',				pageid: superParent.data.id,				reason: ("Clean-up"),				bot: true,				token: mw.user.tokens.get('editToken')			}).done(function(d){				if(!d.error) $("[data-id=" + superParent.data.id + "]").slideToggle;				else new BannerNotification(("Fail") + ": " + d.error.code, 'error').show;			}).fail(function(d) { new BannerNotification(("Fail"), 'error').show; }); }    if(config.fastDelete) deleteThread; }); });

// based on dev.fandom.com/wiki/MediaWiki:LastEdited/code.js?oldid=59536 var lastEdited = { extend: function(obj) { obj = obj || {}; for (var i = 1; i < arguments.length; i++) { if (!arguments[i]) { continue; }               for (var key in arguments[i]) { if (arguments[i].hasOwnProperty(key)) { obj[key] = arguments[i][key]; }               }            }            return obj; },       title: mw.config.get('wgPageName'), id: mw.config.get('wgArticleId'), i18n: { de: { lastEdited: '$1 $2', changes: 'changes', link: 'link', undo: 'undo', cancel: 'cancel' }       },        canRollback: /(bureaucrat|sysop|helper|vstf|staff|content-moderator|rollback)/.test(mw.config.get('wgUserGroups').join(' ')), get: function(options) { var serialized = []; for (var i in options) { serialized.push(mw.util.wikiUrlencode(i) + '=' + mw.util.wikiUrlencode(options[i])); }           serialized = '?' + serialized.join('&'); var xhr = new XMLHttpRequest; xhr.open('GET', mw.util.wikiScript('api') + serialized, true); xhr.onload = function { if (xhr.status == 200) { var response = JSON.parse(xhr.responseText); if (response.query.pages['-1']) { return; }                   lastEdited.add(response.query.pages[lastEdited.id].revisions); }           };            xhr.send; },       add: function(data) { if (!data[1]) return; var prev = data[1]; data = data[0]; var html = '  '; if (lastEdited.options.position.element && lastEdited.options.position.method) { if (lastEdited.options.position.method == 'append') { var div = document.createElement('div'); div.innerHTML = html; html = div.firstChild; lastEdited.options.position.element.appendChild(html); } else if (lastEdited.options.position.method == 'prepend') { lastEdited.options.position.element.children[0].insertAdjacentHTML('beforeBegin', html); }                   } else { if (document.querySelector('#PageHeader .page-header__title')) { var div = document.createElement('div'); div.innerHTML = html; html = div.firstChild; document.querySelector('#PageHeader .page-header__title').appendChild(html); mw.util.addCSS('#lastEdited { line-height: normal; font-size: 12.5px; font-weight: normal; margin-top: 6px; }'); } else { document.getElementsByClassName('UserProfileActionButton')[0].insertAdjacentHTML('afterEnd', html); }                   } var time = ' '; if (lastEdited.options.time == 'timestamp') { var date = new Date(data.timestamp).toString; if (lastEdited.options.timezone && lastEdited.options.timezone == 'UTC') { date = new Date(data.timestamp).toUTCString; }               time = date.slice(0, 3) + ', ' + date.slice(4, 15) + ', ' + date.slice(16, 24); }           var apath = mw.config.get('wgArticlePath').replace('$1',''), user = mw.util.wikiUrlencode(data.user); user = '' + data.user + '</a>'; html = lastEdited.i18n.lastEdited.replace(/\$1/g, '<img id="lastEdited-avatar"/>' + user).replace(/\$2/g, ' | ' + time +'</a>'); if (lastEdited.options.size) { var bytes = data.size - prev.size, span = document.createElement('span'); if (Math.abs(bytes) > 500) { span.style.fontWeight = 'bold'; }               span.style.color = bytes > 0 ? '#006500' : '#8b0000'; if (bytes === 0) { span.style.color = '#aaaaaa'; }               span.innerHTML = '(' + (bytes > 0 ? '+' : '') + bytes.toString.replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ')'; html += ' | ' + data.size + ' Bytes ' + span.outerHTML; }           if (data.minor === '') { html += ' K '; }           if (lastEdited.options.comment && data.parsedcomment) { if (data.parsedcomment.indexOf('Created page with') > -1) { html += ' – Seite erstellt'; } else { html += ' – ' + data.parsedcomment; }           }            document.getElementById('lastEdited').innerHTML = html; if (lastEdited.options.avatar) { var xhr = new XMLHttpRequest; xhr.open('GET', '/api/v1/User/Details?ids=' + data.userid + '&size=' + lastEdited.options.avatarsize, true); xhr.onload = function { if (xhr.status == 200) { var avatar = document.getElementById('lastEdited-avatar'); avatar.setAttribute('src', JSON.parse(xhr.responseText).items[0].avatar); avatar.setAttribute('height', lastEdited.options.avatarsize); avatar.setAttribute('width', lastEdited.options.avatarsize); avatar.insertAdjacentHTML('afterEnd', ' '); }               };                xhr.send; }           jQuery('.timeago').timeago; if (document.getElementById('lastEdited-diff-link')) { document.getElementById('lastEdited-diff-link').addEventListener('click', function {                   require(['wikia.ui.factory'], function(ui) { ui.init(['modal']).then(function(modal) {                           var config = {                                vars: {                                    id: 'lastEdited-diff',                                    size: 'large',                                    title: lastEdited.i18n.changes + ': ' + lastEdited.title.replace(/_/g, ' '),                                    content: ' ',                                    buttons: [{                                        vars: {                                            value: lastEdited.i18n.cancel,                                            data: [{                                                key: 'event',                                                value: 'close'                                            }]                                        }                                    }, {                                        vars: { value: lastEdited.i18n.link, classes: ['normal', 'primary'], data: [{ key: 'event', value: 'link' }]                                       }                                    }, {                                        vars: { value: lastEdited.i18n.undo, classes: ['normal', 'primary'], data: [{ key: 'event', value: 'undo' }]                                       }                                    }]                                }                            };                            if (lastEdited.canRollback && mw.config.get('wgUserName') !== data.user) { config.vars.buttons.push({                                   vars: {                                        value: 'Rollback',                                        classes: ['normal', 'primary'],                                        data: [{                                            key: 'event',                                            value: 'rollback'                                        }]                                    }                                }); }                           modal.createComponent(config, function(diffModal) {                                diffModal.bind('link', function { diffModal.trigger('close'); window.open('/?diff=' + data.diff.to, '_blank'); });                               diffModal.bind('undo', function { diffModal.trigger('close'); window.open(apath + mw.util.wikiUrlencode(lastEdited.title) + '?action=edit&undoafter=' + data.diff.from + '&undo=' + data.diff.to, '_blank'); });                               diffModal.bind('rollback', function { var xhr = new XMLHttpRequest; xhr.open('POST', mw.util.wikiScript('api') + '?action=rollback&title=' + mw.util.wikiUrlencode(lastEdited.title) + '&user=' + mw.util.wikiUrlencode(data.user) + '&token=' + mw.util.wikiUrlencode(data.rollbacktoken) + '&format=json', true); xhr.onload = function { if (xhr.status == 200) { var response = JSON.parse(xhr.responseText); if (!response.error) { window.location.reload; }                                       }                                    };                                    xhr.send; });                               mw.loader.using(['mediawiki.action.history.diff'], function { diffModal.show; });                           });                        });                    });                });            }        },        init: function {            lastEdited.options = lastEdited.extend({ avatar: false, avatarsize: 15, size: true, diff: true, comment: true, time: 'timeago', position: { element: '', method: '' },               namespaces: { include: [], exclude: [] },               pages: [] }, window.lastEdited);           var allowed = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 110, 111, 112, 118, 828, 829, 1202];            if (lastEdited.options.namespaces.include && lastEdited.options.namespaces.include.constructor == Array) {                for (var i in lastEdited.options.namespaces.include) {                    allowed.push(lastEdited.options.namespaces.include[i]);                }            }            if (lastEdited.options.namespaces.exclude && lastEdited.options.namespaces.exclude.constructor == Array) {                allowed = allowed.filter(function(elem) { return lastEdited.options.namespaces.exclude.indexOf(elem) < 0; });           }            lastEdited.allowed = allowed;            lastEdited.i18n = (lastEdited.options.lang && typeof lastEdited.options.lang == 'string') ? lastEdited.extend(lastEdited.i18n.en, lastEdited.i18n[lastEdited.options.lang]) : lastEdited.extend(lastEdited.i18n.en, lastEdited.i18n.de);            if ( !mw.util.getParamValue('diff') && !mw.util.getParamValue('oldid') && lastEdited.allowed.indexOf(mw.config.get('wgNamespaceNumber')) > -1 && !(lastEdited.options.pages.indexOf(lastEdited.title) > -1) && !mw.config.get('wgIsMainPage') && !window.lastEditedLoaded ) {               window.lastEditedLoaded = true;                var query = {                    action: 'query',                    titles: lastEdited.title,                    prop: 'revisions',                    rvprop: 'timestamp|user|userid|size|parsedcomment|flags',                    rvlimit: 2,                    rvdiffto: 'prev',                    format: 'json'                };                if (lastEdited.canRollback) {                    query.rvtoken = 'rollback';                }                mw.util.addCSS( '#lastEdited-diff-changes .diff-marker {' + 'width: auto;' + '}' +                   '#lastEdited-diff-changes td {' + 'width: 50%;' + 'padding: 5px;' + '}'               );                lastEdited.get(query);            }        }    };    lastEdited.init; });
 * (function {

$('#globalNavigation').addClass('wds-search-is-active');

// based on dev.fandom.com/wiki/MediaWiki:QQX/code.js $(function { var qstring = (window.location.search) ? '&' : '?',    li1 = mw.html.element('li', {id: 'uen'}, new mw.html.Raw(mw.html.element('a', {href: (window.location.href).replace(/#.*/, ) + qstring + 'uselang=en',}, ('en')))),    li1b = mw.html.element('li', {id: 'ude'}, new mw.html.Raw(mw.html.element('a', {href: (window.location.href).replace(/#.*/, ) + qstring + 'uselang=de',}, ('de')))),    li2 = mw.html.element('li', {id: 'mob'}, new mw.html.Raw(mw.html.element('a', {href: (window.location.href).replace(/#.*/, ) + qstring + 'useskin=mercury',}, ('mercury')))),    li3 = mw.html.element('li', {id: 'mca'}, new mw.html.Raw(mw.html.element('a', {href: (window.location.href).replace(/#.*/, ) + qstring + 'mcache=writeonly',}, ('writeonly'))));    if(mw.config.get('wgUserLanguage') === 'en') {        $('.tools').append(li1b); } else { $('.tools').append(li1); }   $('.tools').append(li2); $('.tools').append(li3); });

(function($, mw) { var c = mw.config.get([ 'wgUserName', 'wgPageName', 'wgBlankImgUrl', 'wgCanonicalSpecialPageName', 'wgArticlePath', 'wgScriptPath', 'wgTitle', 'wgAction', 'wgCanonicalNamespace', 'wgNamespaceNumber', 'wgUserGroups', 'wgCityId','wgSiteName' ]), blorp = c.wgScriptPath + '/wiki/', escapedPage = encodeURIComponent(c.wgPageName), href, link; $('#globalNavigation').prepend(' ' + c.wgSiteName + ' (' + c.wgCityId + ') '); // Treat non-existing category pages like articles (dev.fandom.com/?oldid=89378) $('.newcategory').addClass('new'); // Adds RC and Purge buttons to glbal nav, based on dev.fandom.com/?oldid=95865 (function  { if (window.amonsnavbuttonsLoaded) { return; }   window.amonsnavbuttonsLoaded = true; $('body').append('Purge</a>'); $('body').append('RC</a>'); $('#customPurgeButton').click(function {            $.get('?action=purge', function  { location.reload(true); });           });    $('#customRCButton').attr('href', blorp + 'Special:RecentChanges'); }); // Turn add-new-page into Random page link   $('.wds-community-header__wiki-buttons a[data-tracking="add-new-page"]').attr({href: blorp + 'Special:Random', title: 'Zufällige Seite', 'data-tracking': 'random-page'}); // Turn WikiActivity into WikiAnalytics shortcut    $('.wds-community-header__wiki-buttons a[data-tracking="wiki-activity"]').attr({href: blorp + 'Special:Analytics', title: 'WikiAnalytics', 'data-tracking': 'wiki-analytics'}); // Turn Admin dashboard into Wikifactory shortcut    $('.wds-community-header__wiki-buttons a[data-tracking="admin-dashboard"]').attr({href: blorp + 'Special:WikiFactory', title: 'WikiFactory', 'data-tracking': 'wiki-factory', target: '_new'}); //Add contribs link to globalnav avatar $('.wds-global-navigation .wds-avatar .wds-avatar__image').click(function  { window.location.href = blorp + 'Special:Contributions/' + c.wgUserName; }); //Add links to toolbar if (wgNamespaceNumber !== wgNamespaceIds.special && wgNamespaceNumber !== wgNamespaceIds.thread && wgNamespaceNumber !== wgNamespaceIds.board_thread && wgNamespaceNumber !== wgNamespaceIds.message_wall && wgNamespaceNumber !== wgNamespaceIds.topic) {   $('Subpages</a></li>')    .insertBefore('.WikiaBarWrapper .tools-menu li:first'); } $('Multiwiki Title Finder</a></li>' + 'Global.css</a></li>' + 'Global.js</a></li>' + 'Mypage/wikia.css</a></li>' + 'Mypage/common.js</a></li>' + '<li><a href="' + blorp + 'MediaWiki:ImportJS">MediaWiki:ImportJS</a></li>' + '<li><a href="' + blorp + 'Special:JSPages">JSPages</a></li>' + '<li><a href="' + blorp + 'MediaWiki:Common.js">MediaWiki:Common.js</a></li>' + '<li><a href="' + blorp + 'MediaWiki:Wiki-navigation?action=edit">MediaWiki:Wiki-navigation</a></li>' + '<li><a href="' + blorp + 'MediaWiki:Recentchangestext?action=history">MediaWiki:Recentchangestext?</a></li>' + '<li><a href="' + blorp + 'Special:Watchlist/raw">Watchlist/raw</a></li>' + '<li><a href="' + blorp + 'Special:SpecialPages">SpecialPages</a></li>' + '<li><a href="' + blorp + 'Special:DoubleRedirects">DoubleRedirects</a></li>' + '<li><a href="' + blorp + 'Special:AllPages">AllPages</a></li>' + '<li><a href="' + blorp + 'Special:PrefixIndex">PrefixIndex</a></li>' + '<li><a href="' + blorp + 'Special:WikiFeatures">WikiFeatures</a></li>' + '<li><a target="_new" href="' + blorp + 'Special:WikiFactory">WikiFactory</a></li>' + '<li><a href="' + blorp + 'Special:ListGroupRights">ListGroupRights</a></li>' + '<li><a href="' + blorp + 'Special:Log/rights">Log/rights</a></li>' + '<li><a href="' + blorp + 'Special:WhatLinksHere/' + c.wgPageName + '">WhatLinksHere</a></li>')   .insertBefore('.WikiaBarWrapper .tools-menu li:first'); // based on script by Gguigui1 $(function { var page = mw.config.get('wgPageName'); var specialpage = mw.config.get('wgCanonicalSpecialPageName'); var name = page.split('/')[1]; var name2 = (wgTitle == "Contributions") ? window.location.href.substring(window.location.href.lastIndexOf("/")+1) : wgTitle; if (specialpage === "Contributions" && page.split('.').length != 4) { $('.tabs-container > ul.tabs').append(       '<li><a href="' + blorp + 'Special:UserRights/' + name + '" title="Special:UserRights">UserRights</a></li>' +        '<li><a href="https://community.fandom.com/wiki/Special:LookupUser/' + name + '" title="Special:LookupUser">Global</a></li>' +        '<li><a href="' + blorp + 'Special:Editcount/' + name + '" title="Special:Editcount">Editcount</a></li>'); } else { $('.tabs-container > ul.tabs').append(       '<li><a href="' + blorp + 'Special:UserRights/' + name2 + '" title="Special:UserRights">UserRights</a></li>' +        '<li><a href="https://community.fandom.com/wiki/Special:LookupUser/' + name2 + '" title="Special:LookupUser">Global</a></li>' +        '<li><a href="' + blorp + 'Special:Editcount/' + name2 + '" title="Special:Editcount">Editcount</a></li>'); } }); $('div.wds-community-header__wiki-buttons.wds-button-group > div > div.wds-dropdown__content.wds-is-not-scrollable.wds-is-right-aligned > ul').prepend('<li><a href="' + c.wgScriptPath + '/announcements">Announcement</a></li>'); // Add more tools $('.tools').append('<li><a href="' + blorp + 'Special:ListUsers">users</a></li>' + '<li><a href="' + blorp + 'Special:ListAdmins">sysops</a></li>' + '<li><a href="' + blorp + 'Special:CSS">CSS</a></li>' + '<li><a href="https://community.fandom.com/wiki/Special:InterwikiEdit">IWE</a></li>' + '<li><a href="' + blorp + 'Special:Random" accesskey="r">Random</a></li>'); /* Create an edit link on Special:MovePage for easy redirecting */ if (c.wgCanonicalSpecialPageName == "Movepage") { href = $('fieldset').find('a').attr('href') + '?action=edit',  link = ' <a href="'+href+'">(Bearbeiten)</a>';  $('#mw-movepage-table').find('a').first.after(link); } /* Unchecks redirects when moving */ if (c.wgCanonicalSpecialPageName == "Movepage") { $('#wpLeaveRedirect').removeAttr('checked'); } /* Create move link on Special:ListFiles for users' files listed */ if (c.wgCanonicalSpecialPageName == "Listfiles" && c.wgPageName.split('/').length === 2) { $('.TablePager_col_img_name').each(function {   link = ' (<a href="' + c.wgScriptPath + '/Special:MovePage/File:' + $(this).find('a').first.text + '">move</a>)';     $(this).append(link);  }); } }) (this.jQuery, this.mediaWiki);