User:Writ Keeper/Scripts/g10viewer.js

mw.hook("wikipage.content").add( function {	if($("#delete-criterion").text == "G10")	{		var blankBox = $('td.mbox-text>a[href$="Wikipedia:Deletion_policy#Courtesy_blanking"]').parent;		blankBox.html(blankBox.html + " [show page] ");		$("#g10ViewerButton").click(function {			mw.loader.using(["mediawiki.api"]).then(function 			{				const api = new mw.Api;				if($("#g10Viewer").length == 0)				{					var params = 					{						action: 'query',						prop: 'revisions',						titles: mw.config.get("wgPageName"),						rvlimit: '2',						rvprop: 'ids',						format: 'json'					};					api.get(params).done(function(data) {						var revid = data.query.pages[mw.config.get("wgArticleId")].revisions[1].revid; params = {							action: 'parse', oldid: revid, format:'json' };						api.get(params).done(function(data) 						{							blankBox.parents("table.ombox-notice").after(" "+data.parse.text['*'] + " ");							$("#g10ViewerButton").text("[hide page]");						}); });				}				else if($("#g10ViewerButton").text == "[show page]")				{					$("#g10Viewer").show;					$("#g10ViewerButton").text("[hide page]");				}				else if($("#g10ViewerButton").text == "[hide page]")				{					$("#g10Viewer").hide;					$("#g10ViewerButton").text("[show page]");				}			}); });	} });