User:Dixtosa/missing translations.js

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

//Description: inserts a random word from [[User:Ungoliant MMDCCLXIV/missing translations]] type of lists to the left of "pt-userpage".

$(() => {
	function loadData(){
		if (localStorage[missingURL] === undefined)
			return $.get(mw.util.wikiScript('index'), {
				action: 'raw',
				title: missingURL
			}, function(response) {
				localStorage[missingURL] = response;
				return response;
			});
		else
			return Promise.resolve(localStorage[missingURL]);
	}
	
	let missingLink = "User:Ungoliant MMDCCLXIV/missing translations";
	let missingLang = "ka";
	let missingURL = missingLink + "/" + missingLang;

	loadData(missingURL).then(data => {
		let rnd = Math.floor(Math.random() * 3000);
		let rnd_term = $.trim(data.split("# ")[rnd]).replace ("[[", "").replace ("]]", "");
		let link_rnd_term = rnd_term.replace("(", "").replace(")", "").replace("(", "").replace(/\d/g, "");
		mw.util.addPortletLink('p-personal', mw.util.getUrl(link_rnd_term), rnd_term, 'pt-missing', "0idea", "", "#pt-kaRecentChanges");
		$("[title=0idea]").css({color:"red"}); //LOL
	});
});