User:Suffusion of Yellow/FilterDebugger.js

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.
//<nowiki>
/* jshint esversion: 11, esnext: false */
/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
var __webpack_exports__ = {};
/* globals $, mw */


switch (mw.config.get('wgCanonicalSpecialPageName')) {
case 'Blankpage':
	if (mw.config.get('wgPageName').match(/^[^/] \/filterdebug(?:\/|$)/i)) {
		let supported = false, error;

		try {
			supported = (new Function("return null?.x ?? (/(?<=\\p{L})a/u).test('ba')"))();
		} catch (e) {
			error = e;
		}

		if (!supported) {
			$('#mw-content-text')
				.text(`Sorry, but your browser (${navigator.userAgent}) is too old to support FilterDebugger: ${error ? error : "unknown error"}`);

			break;
		}

		Promise.all([
			 false ?
				0 :
				mw.loader.getScript("https://en.wikipedia.org/w/index.php?title=User:Suffusion_of_Yellow/fdb-core.js&action=raw&ctype=text/javascript"),
			mw.loader.using([
				'mediawiki.util',
				'mediawiki.api',
				'mediawiki.language.months',
				'ext.codeEditor.ace',
				'ext.abuseFilter.ace',
				'vue',
			]),
			$.ready
		]).then(r => ( false ? 0 : window.FilterDebugger.setup()));
	}
	break;
case 'AbuseLog':
	$(async() => {
		if ($('[name=wpSearchFilter]').length) {
			let params = {
				filter: $('[name=wpSearchFilter]').val(),
				user: $('[name=wpSearchUser]').val(),
				title: $('[name=wpSearchTitle]').val(),
				start: $('[name=wpSearchPeriodStart]').val(),
				end: $('[name=wpSearchPeriodEnd]').val()
			};
			let url = "/wiki/Special:BlankPage/FilterDebug/mode/abuselog";

			for (let [key, value] of Object.entries(params)) {
				if (typeof value == 'string' && value.trim().length)
					url  = `/${key}/${mw.util.wikiUrlencode(value.trim())}`;
			}

			mw.util.addPortletLink('p-cactions', url, "Debug");
		}

		let localized = "Special:AbuseFilter";

		if (mw.config.get('wgContentLanguage') != 'en') {
			await mw.loader.using(['mediawiki.api']);

			let response = await (new mw.Api()).get({
				action: "query",
				titles: localized,
				maxage: 86400 // Not likely to change very often
			});

			localized = mw.util.wikiUrlencode(response.query.normalized[0].to);
		}

		let idRegexp = new RegExp(localized   "\\/examine\\/log\\/(\\d )$");

		for (let link of $('a[href*="'   localized   '/examine/log"]')) {
			let id = link.href.match(idRegexp);
			if (id) {
				$(link).after(" | ", $("<a></a>", {
					text: "debug",
					href: "/wiki/Special:BlankPage/FilterDebug/logid/"   id[1]
				}));
			}
		}
	});
	break;
case 'AbuseFilter':
	$(() => {
		let id = mw.config.get('wgPageName').match(/\/(\d )/);
		if (id)
			mw.util.addPortletLink(
				'p-cactions',
				"/wiki/Special:BlankPage/FilterDebug/filter/"   id[1],
				"Debug"
			);

		$(".mw-abusefilter-navigation a").last().after(" | ", $("<a></a>", {
			text: "More debugging tools",
			href: "/wiki/Special:BlankPage/FilterDebug"
		}));
	});
	break;
}


/******/ })()
;//</nowiki>