User:User56225108/global.js

// AllPagesHideRedirect - Adds a "Hide/Show Redirects" button to Special:AllPages that hides pages that are redirects. // View Source - View the wikitext (source code) of any page without reloading it. // WhatLinksHere - See what pages link to or transclude the current page, using the WhatLinksHere special page.

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:AllPagesHideRedirect/code.js',        'u:dev:MediaWiki:View_Source/code.js',        'u:dev:MediaWiki:WhatLinksHere/code.js'    ] });

window.AjaxUndoPrompt = true;

// AJAX Undo - Undo any edit without manually reviewing and saving it. Simply add a reason and the edit will be undone.

//    'use strict'; if (window.AjaxUndoLoaded) { return; }   window.AjaxUndoLoaded = true;
 * (function ($, mw) {

var conf = mw.config.get([       'wgArticlePath',        'wgAction',        'wgVersion'    ]);

if (!(window.dev && dev.i18n && dev.i18n.loadMessages)) { importArticle({           type: 'script',            article: 'u:dev:MediaWiki:I18n-js/code.js'        }); }

var i18n, api;

function msg(message) { return i18n.msg(message).plain; }

function undoEdit { var $this = $(this), url = $this.data.url, page = $this.data.page, undoId = /&undo=([^&]*)/.exec(url)[1], summaryPromise, defaultSummary = window.AjaxUndoSummary || '';

if (window.AjaxUndoPrompt) { summaryPromise = OO.ui.prompt(msg('summaryprompt'), {               textInput: {                    value: defaultSummary                }            }); } else { summaryPromise = $.Deferred; summaryPromise.resolve(defaultSummary); }

summaryPromise.then(function(summary) {           if (summary === null) {                return;            }            $this.html( $(' ')                   .attr({                        src: 'https://images.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif',                        alt: msg('undoing'),                        border: '0'                    }) .css('vertical-align', 'baseline') );           return api.post({ action: 'edit', title: page, notminor: '1', undo: undoId, summary: summary === '' ? undefined : summary, token: mw.user.tokens.get('csrfToken') || mw.user.tokens.get('editToken') });       }).then(function (data) {            if (!data) {                return;            }            if (data.edit && data.edit.result === 'Success') {                $this.text(msg('undone'));                        location.reload;            } else {                $this.text(msg('error'));

alert(data.error && data.error.code === 'undofailure' ?                   data.error.info :                    msg('unknownerror')                ); }       });    }

function createUndoLink(url) { var uri = new mw.Uri(url); return $('', {           href: '#ajaxundo',            'data-url': url,            'data-page': decodeURIComponent( uri.query && uri.query.title || uri.path.substring(                       conf.wgArticlePath                            .replace('$1', '')                            .length                    ) ),           text: msg('buttontext'),            click: undoEdit,            title: msg('undotitle'),        }); }

function init(i18nData) { i18n = i18nData; api = new mw.Api; if (conf.wgAction === 'history' && $('.mw-history-undo > a').length) { $('.mw-history-undo > a').each(function {                var $this = $(this),                    url = $(this).attr( 'href' ),                    $link = createUndoLink(url);

$this.parent.after(' | ', $link); });       } else if ($('table.diff').length && mw.util.getParamValue('diff') !== undefined) {            var $undoLink = $('table.diff').find('.diff-ntitle > #mw-diff-ntitle1 a:last'),                url = $undoLink.attr('href'),                $link = createUndoLink(url);

$undoLink.parent.append('(', $link, ')'); }       mw.hook('quickdiff.ready').add(function {            var $undoLink = $('#quickdiff-modal table.diff').find('.diff-ntitle > #mw-diff-ntitle1 a:last'),                url = $undoLink.attr('href'),                $link = createUndoLink(url);

$undoLink.parent.append('(', $link, ')'); });   }

mw.hook('dev.i18n').add(function(i18no) {       $.when( i18no.loadMessages('AjaxUndo'), mw.loader.using([               'mediawiki.api',                'mediawiki.user',                'mediawiki.util',                'mediawiki.Uri',                'oojs-ui-windows'            ]) ).then(init);   }); }(jQuery, mediaWiki)); //