User:DannyS712 test/filters.js

// Install with: // // or with //  // // If forking this script, please note my contributions / give me credit // $(function { var FL_config = {	name: 'Filter links.js',	version: 1.2,	debug: true }; mw.loader.using( 'mediawiki.util', function { $(document).ready( function {     	var page = mw.config.get('wgPageName');    	if (page && page === 'Special:AbuseLog'){    		FilterLinks;    	}    } ); } ); function FilterLinks{	var filters = get_filters(1);	var entries = $('li');	var description, filter_id;	if (FL_config.debug) console.log( entries );	entries.each( function { if (this.innerHTML.indexOf('triggered an edit filter') > -1){ if (FL_config.debug) console.log( this.innerText ); description = this.innerText.replace(/.*?Filter description: /, ''); description = description.replace(/ \(diff\)/, ''); if (FL_config.debug) console.log( description ); for (var iii = 0; iii < filters.length; iii++){ if (description === filters[iii].description){ filter_id = filters[iii].id; if (FL_config.debug) console.log( filters[iii]); this.innerHTML = this.innerHTML.replace(/triggered an edit filter/, 'triggered private filter ' + filter_id + ''); }			}		}	}); } function get_filters( start ){	var scriptUrl = mw.config.get( 'wgScriptPath' ) + '/api.php';	var getter = {       action: 'query',        list: 'abusefilters',        abfshow: 'private',        abflimit: 'max',        abfprop: 'id|description',        abfstartid: start,        format: 'json',        formatversion: 2    };    var result = null;	$.ajax({ url: scriptUrl, type: 'get', data: getter, dataType: 'json', async: false, success: function( response ) { if (FL_config.debug) console.log( response ); result = response.query.abusefilters; if (response.continue){ result = result.concat( get_filters( response.continue.abfstartid) ); }			if (FL_config.debug) console.log( result ); } 	});	return result; } }); //