User:Thundercraft5/common.js

/* jshint esversion: 5, forin: true, immed: true, indent: 4, latedef: true, newcap: true, noarg: true, undef: true, undef: true, unused: true, browser: true, jquery: true, onevar: true, eqeqeq: true, multistr: true, maxerr: 999999, -W082, -W084 /* global mw */

// AF log filtering $(function {	if (mw.config.get('wgPageName') !== 'Special:AbuseLog') return;	var checked;	addFilter;	mw.util.addCSS('.hidden { display: none !important; }');	function addFilter {		$('.mw-specialpage-summary').after($(' ', {			html: [				$(' ', { text: "Filters" }),				$(' ', { html: [ $(' ', {							type: "checkbox",							name: "toggleSpamFilters",							id: "AF-filter-checkbox-toggleSpamFilters",							checked: !['undefined', 'null'].includes(typeof(checked)) ? checked : false,							on: {								change: function {									checked = this.checked;									mw.util.$content.children('ul')[0].querySelectorAll('li').forEach(function(el) { if (!el.textContent.match(/spam/i)) el.classList.toggle('hidden'); });								},							},							css: {								cursor: "pointer",							},						}), $(' ', {							type: "checkbox",							for: "AF-filter-checkbox-toggleSpamFilters",							id: "AF-filter-label-toggleSpamFilters",							text: "Show only possible spam hits",							css: {								cursor: "pointer",							},						}), ],				}),			],		}));	}	window.ajaxCallAgain = window.ajaxCallAgain || [];	window.ajaxCallAgain.push(addFilter, function { mw.util.$content.children('ul')[0].querySelectorAll('li').forEach(function(el) {			if (!el.textContent.match(/spam/i)) el.classList.toggle('hidden');		}); }); });