User:ToBeFree/suffusionofyellow-abusecontribs-fork-temp.js

// User:Suffusion of Yellow/abusecontribs.js

// Work in progress. Use at your own risk

$.when(mw.loader.using(["mediawiki.util", "mediawiki.api"]), $.ready).then(function {	async function check(name) {		let result = await (new mw.Api).get( { action : "query", list : "usercontribs", ucuser : name, uclimit : 50, ucend : Math.floor(Date.now / 1000) - 86400, ucprop : "tags|timestamp" });

if (result.query.usercontribs.length == 0) return "none";

for (let c of result.query.usercontribs) if (!c.tags.includes("mw-reverted")) return "live";

return "reverted"; }

async function run(e) { e.preventDefault;

for(let line of mw.util.$content.find('ul li')) { let cl = $(line).find('[href*="Special:Contributions"]');

if (cl.length) { let match = cl[0].href.match(/Special:Contributions\/(.*)/);

if (match) { result = await check(match[1]); if (result == "live") $(line).css("background-color", "#f99"); else if (result == "reverted") $(line).css("background-color", "#bf9"); else $(line).css("background-color", "#9fd"); }			}		}	}	if (mw.config.get('wgCanonicalSpecialPageName') == "AbuseLog") { $(mw.util.addPortletLink( "p-tb", "#",           "Live edits", 't-livedits', "Check for live edits within the past day" )).click(run); } });