User:Novem Linguae/Scripts/PreviousNames.js

//

/* -

$(async function {	/*	async function getWikicode(title) {		let api = new mw.Api;		let params = {			"action": "parse",			"page": title,			"prop": "wikitext",			"format": "json",		};		let result = await api.post(params);		if ( result['error'] ) return '';		let wikicode = result['parse']['wikitext']['*'];		return wikicode;	}	*/

function shouldRunOnThisPage(title) { // don't run when not viewing articles let action = mw.config.get('wgAction'); if ( action != 'view' ) return false; // don't run when viewing diffs let isDiff = mw.config.get('wgDiffNewId'); if ( isDiff ) return false; let isDeletedPage = ( ! mw.config.get('wgCurRevisionId') ); if ( isDeletedPage ) return false; // Only run in userspace let namespace = mw.config.get('wgNamespaceNumber'); let isUserspace = ( [2].includes(namespace) ); if ( ! isUserspace ) return false;

// Only run on user pages if ( title.includes('/') ) { return false; }

return true; }

let title = mw.config.get('wgPageName'); // includes namespace, underscores instead of spaces if ( ! shouldRunOnThisPage(title) ) return;

let previousNamesArray = []; if ( previousNamesArray === [] ) { previousNamesString = previousNamesArray.join(', '); let html = ' Previous names: ' + previousNamesString + ' '; $('#contentSub').before(html); } });

//