Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
if (mw.config.get('wgPageName') === "User:Magog_the_Ogre/xdomain") {
    var topWindow = window.top;
    addEventListener("message", function (e) {
        "use strict";

        var VALID_ORIGINS = [
                "http://tools.wmflabs.org",
                "https://tools.wmflabs.org",
                /* for personal debugging */
                "http://192.168.56.20",
                "http://localhost",
                "http://magog.toolforge.org",
                "https://magog.toolforge.org"
            ],
            originSource = e.origin || "",
            originMatches = VALID_ORIGINS.some(function (validOrigin) {
                return originSource.indexOf(validOrigin) === 0;
            }),
            pages = e.data,
            api = new mw.Api(),
            MAX_AJAX_CHUNKS = 10,
            openCount = 0,
            /**
             * @type Array<() => {}>
             */
            waiting = [];

        function postMessage(message) {
            topWindow.postMessage(message, originSource);
        }

        if (!originMatches || !topWindow) {
            return;
        }

        if (typeof pages !== "object") {
            return;
        }
        function next() {
            if (waiting[0]) {
                waiting.shift()();
            }
        }

        $.each(pages, function (page, reason) {
            waiting.push(function () {
                openCount++;
                api.postWithEditToken({
                    title: page,
                    reason: reason,
                    action: "delete"
                }).always(function(response, error) {
                    if (response && response.delete) {
                        postMessage({
                            page: page,
                            status: "success"
                        });
                    } else {
                        postMessage({
                            page: page,
                            status: "error",
                            message: error.error && error.error.info || error
                        });
                    }
                    openCount--;
                    next();
                });
            });
            if (openCount < MAX_AJAX_CHUNKS) {
                next();
            }
        });
    });
   
    topWindow.postMessage("ping", "*");
}

if (navigator.userAgent.indexOf("Android") == -1)
{
  importScript('User:Lupin/recent2.js');
  importScript('User:AWeenieMan/furme.js');
  importScript("User:MGA73/nowcommonsreview.js");
}

//adapted from User:Stefan2/common.js
if (mw.config.get( 'wgNamespaceNumber' ) === 6) 
{
  $.when(mw.loader.using( ["mediawiki.util"] ), $.ready.promise).then(function() {
    mw.util.addPortletLink("p-cactions", "//tools.wmflabs.org/magog/fileinfo.php?project=en.wikipedia&information=1&authordate=1&license=1&fields=1&src="+ mw.config.get( 'wgTitle' ), "File info");
    mw.util.addPortletLink("p-cactions", "//tools.wmflabs.org/magog/oldver.php?project=en.wikipedia&src="+ mw.config.get( 'wgTitle' ), "Old versions");
  });
}


/***************************************************************
 *     added from User:Writ_Keeper/Scripts/massRollback.js     *
 **************************************************************/
//Mass rollback function
//Written by John254 and modified/rewritten by Writ Keeper; original is at https://en.wikipedia.org/wiki/User:John254/mass_rollback.js
//Adapted from User:Mr.Z-man/rollbackSummary.js
//Instructions: Selecting the "rollback all" tab when viewing a user's contributions history
//will open all rollback links displayed there. (Use with caution)
 
function rollbackEverythingWKMR() {
	$("a[href*='action=rollback']").each(function(ind, el)
	{
		window.open(el.href, "_blank");
	});
}

$.when(mw.loader.using( ["mediawiki.util"] ), $.ready.promise).then(function() {
    if(mw.config.get("wgCanonicalSpecialPageName") === "Contributions" && $("span.mw-rollback-link").length) {
        mw.util.addPortletLink('p-cactions', 'javascript:rollbackEverythingWKMR()', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here");
    }
    if (mw.config.get('wgAction') === 'delete') {
		$("#wpReason").focus();
    }
    
	if ($("#wpReason").val() && mw.util.getParamValue("fromNowCommons")) {
		$("#mw-filedelete-submit").click();
	}

var ids = [];
function toggle(id) {
	for (var i = 0; i < ids.length; i++) {
		if (ids[i] === id) {
			ids.splice(i, 1);
			return false;
		}
	}
	ids.push(id);
	return true;
}
function updateLinks() {
	$(".mto-go").attr("href", mw.config.get("wgScript") + "?title=Special:RevisionDelete&type=oldimage&target=" + 
		window.encodeURIComponent(mw.config.get("wgPageName")) + "&ids=" + ids.join(","));
}
$(".mw-revdelundel-link > a").replaceWith(function() {
	
	var $a = $(this);
	var href = $a.attr("href");
	var id = href.substring(href.lastIndexOf("=") + 1);
	
	var div = $("<span/>").append($("<a>Multi</a>").click(function() {
		$(this).closest("tr").css("background-color", toggle(id) ? "#f4e097" : "");
		updateLinks();
	})).append(" | ").append("<a class=\"mto-go\" target=\"_blank\">change visibility</a>");
	
	return div[0];
});
updateLinks();

});