User:Novem Linguae/Scripts/PurgeButton.js

//

// isolating this until I can debug it. Then I'll add it to NPPLinks.js

mw.loader.using( ['mediawiki.util', 'mediawiki.api'] ).then( function {        return; // this code doesn't work because `require` is not available here.	// this code borrowed from https://www.mediawiki.org/wiki/API:Purge	var request = require('request').defaults({jar: true}),		url = "https://en.wikipedia.org/w/api.php";

function purge(title) { var params = { action: "purge", titles: title, format: "json" };

request.post({ url: url, form: params }, function (error, res, body) {			if (error) {				return;			}			console.log(body);		}); }	// end borrowed code

function escapeDoubleQuotes(input) { return input.replace(/"/g, '&quot;');	}

let pageName = mw.config.get('wgPageName'); // has underscores instead of spaces. has namespace prefix let underscores = encodeURIComponent(pageName);

let links = `Purge (for orphan check)`; // using this ugly monstrosity because mw.util.addPortletLink does not support adding entire menus, and the parent script needs to add a menu $('#p-navigation').after(`									 Purge Test 									`+links+`					`); });

//