Jump to content

User:Dreamy Jazz/sockpuppet-category-helper.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Dreamy Jazz (talk | contribs) at 23:51, 22 January 2022 (test). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
$(document).ready(function() {
	mw.loader.using( [
	'mediawiki.api',
	'mediawiki.util',
] ).then( function() {
	if (mw.config.get('wgPageName').startsWith('Category:Wikipedia_sockpuppets_of') || mw.config.get('wgPageName').startsWith('Category:Suspected_Wikipedia_sockpuppets_of')) {
		$("a.userlink").each(() => {
			console.log("ran once");
			console.log($(this).text());
			let text = $(this).text();
			$(this).replaceWith(getParsedCheckuserTemplateText());
		});
	}
});
});

async function getParsedCheckuserTemplateText(username) {
	const api = new mw.Api();
	const response = await api.get({
		action: "parse",
		format: "json",
		prop: "text",
		text: "{{checkuser|Amanda Davis}}",
		wrapoutputclass: "",
		disablelimitreport: 1,
		disableeditsection: 1,
		contentmodel: "wikitext"
	});
	console.log(response);
	return response.parse.text["*"];
}