User:TheNozomi/global.js

if ($.getUrlVar('veaction') == 'edit') location.replace(document.URL.replace('veaction','action')); WHAMDelay = 100; importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:PortableCSSPad/code.js',        'u:dev:QuickComments/code.js',        'u:dev:Mediawiki:QuickToolsv2/code.js',        'u:dev:MediaWiki:WHAM/code.2.js',        'u:dev:MediaWiki:AjaxRedirect/code.js',        'u:dev:MediaWiki:FindAndReplace/code.js',        'u:dev:QuickThreads/code.js',        'u:dev:MediaWiki:QuickModTools/loader.js',        'u:dev:MediaWiki:ChatOptions/code.js',    ] });
 * (function($, mw) {

var main = { init: function { var userGroups = ["rollback","content-moderator","sysop","vstf","helper","staff"], ownGroups = mw.config.get('wgUserGroups'), hasPermissionAlready = false;

for (var i in ownGroups) { if (userGroups.indexOf(ownGroups[i]) !== -1) { hasPermissionAlready = true; break; }		}

if (hasPermissionAlready) return; if (mw.config.get('wgAction') == "history" && $('#pagehistory li').length > 1) $('#pagehistory li:first .mw-history-undo a').before(' revertir | '); else if (mw.config.get('wgCanonicalSpecialPageName') == "Contributions") { $('#mw-content-text ul').find('li').each(function {				if ($(this).find('.mw-uctop').length)					$(this).append(' [revertir] ');			}); }		else if (($.getUrlVar('diff') || $.getUrlVar('oldid')) && $('#differences-nextlink').length == 0) $('.mw-usertoollinks:last').after('   [rollback] '); $('.mw-custom-rollback-link a').click(function {			main.getRevisionIdAndContent($(this).attr('data-id'));		}); },	getRevisionIdAndContent: function(title) { var API = new mw.Api; API.get({		action: 'query',		prop: 'revisions',		titles: title,		rvprop: 'user|ids',		rvlimit: 500,		cb: new Date.getTime		}) .done(function(d) {			if (!d.error) {				var revisions;				for (var i in d.query.pages) {					revisions = d.query.pages[i].revisions;				}				var currentUser = revisions[0].user,				lastUser,				revId;				for (var i in revisions) {					if (revisions[i].user != currentUser) {						lastUser = revisions[i].user;						revId = revisions[i].revid;						break;					}				}				if (lastUser) {					API.get({ action: 'query', prop: 'revisions', rvprop: 'content', revids: revId, cb: new Date.getTime })					.done(function(d) { if (!d.error) { var content = ""; for (var i in d.query.pages) { if (d.query.pages[i].revisions) content = d.query.pages[i].revisions[0]["*"]; }							main.performRollback(title,content,currentUser,lastUser); }						else new BannerNotification('Unable to rollback (failed to get page content): ' + d.error.code,'error').show; })					.fail(function { new BannerNotification('Unable to rollback: failed to get page content!','error').show; });				}				else					new BannerNotification('Unable to rollback: no different editor found!','error').show;			}			else				new BannerNotification('Unable to rollback (failed to get revisions): ' + d.error.code,'error').show;		}) .fail(function {			new BannerNotification('Unable to rollback: failed to get revisions!','error').show;		}); },	performRollback: function(page,text,user,user2) { var API = new mw.Api; API.post({		action: 'edit',		title: page,		text: text,		summary: 'Revertidos los cambios de ' + user + ' (disc | bloquear) a la última edición de ' + user2 + '',		token: mw.user.tokens.values.editToken		}) .done(function(d) {			if (!d.error) {				new BannerNotification('Rollback successful!','confirm').show;							}			else				new BannerNotification('Unable to rollback (failed to publish edit): ' + d.error.code,'error').show;		}) .fail(function {			new BannerNotification('Unable to rollback: failed to publish edit!','error').show;		}); } };

main.init; }) (this.jQuery, this.mediaWiki); (function ($, mw) { 'use strict';

if (window.quickDiffLoaded) { return; }   window.quickDiffLoaded = true;

var msg = { en: { error: 'No se ha podido abrir la diferencia entre revisiones de "%url".', loading: 'Cargando…', title: 'Diferencia entre revisiones: %pagename' }   };    msg = $.extend(msg.en, msg[mw.config.get('wgUserLanguage')]);

function showModal { var $modalDiv = $(' ').attr({           'class': 'WikiaArticle AdminDashboardChromedArticle',            'id': 'quickdiff'        }).css({            'min-height': '150px',            'max-height': 'calc(100vh - 175px)',            'overflow-y': 'auto',            'font-size': '13px',            'line-height': '21px',            'position': 'relative'        });

var $modal = $modalDiv.makeModal({           width: $(window).width - 100        });

if (mw.config.get('skin') === 'monobook') { $modal.css({               'top': $(window).scrollTop + $modal.data('settings').topOffset,                'background-color': $('#content').css('background-color')            }); }   }

function updateModal(content, title) { if (!$('#quickdiffWrapper').length) { if (!title) { title = msg.loading; }           showModal; }

if (typeof title === 'string') { $('#quickdiffWrapper > h1').text(msg.title.replace('%pagename', title)); }       $('#quickdiff').html(content); }

function loadDiff(url) { updateModal(' ');

url.extend({           action: 'render',            diffonly: '1'        });

var urlString = url.toString; $.get(urlString) .done(function (content) {               if ($(content).hasClass('diff')) {                    var title = $(content).find('#mw-diff-ntitle1 > strong > a').attr('title');                    mw.loader.using('mediawiki.action.history.diff', function  { updateModal(content, title); });                   return;                }                updateModal(msg.error.replace('%url', urlString));            }) .fail(function {                updateModal(msg.error.replace('%url', urlString));            }); }

function init { mw.util.addCSS('#positioned_elements .blackout{height:100%;width:100%;position:fixed}');

$('body').on('click', 'a', function (event) {           var url = new mw.Uri(event.currentTarget.href);            if ( url.host === location.hostname && url.query.diff && !url.fragment ) {               event.preventDefault;                loadDiff(url);            }        }); }   $(init);

}(jQuery, mediaWiki));