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;	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').find('li').each(function { if (!this.textContent.match(/spam/i)) this.style.display = checked ? 'none' : null; });								},							},							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').find('li').each(function {			if (!this.textContent.match(/spam/i)) this.style.display = checked ? 'none' : null;		}); }); });