User:OwenBlacker/common.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
mw.loader.load("/w/index.php?title=User:Michael Schönitzer (WMDE)/timezoneconverter.js&action=raw&bcache=1&maxage=86400&ctype=text/javascript");
mw.loader.load('https://www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=text/javascript'); // [[mw:User:Remember the dot/Syntax highlighter]]

function AddTranslationLinks()
{
	var trslCfgLi = document.createElement("li");
	trslCfgLi.setAttribute("id", "t--translate");
	var trslCfgLink = document.createElement("a");
	trslCfgLink.setAttribute("href",
		"/w/index.php?title=Special:PageTranslation&do=mark&target="
		+ encodeURIComponent(RLCONF.wgPageName));
	trslCfgLink.appendChild(document.createTextNode("🌐 Translation config"));
	trslCfgLi.appendChild(trslCfgLink);
	
	var pageLangLi = document.createElement("li");
	pageLangLi.setAttribute("id", "t--pagelang");
	var pageLangLink = document.createElement("a");
	pageLangLink.setAttribute("href",
		"/wiki/Special:PageLanguage/" + RLCONF.wgPageName);
	pageLangLink.appendChild(document.createTextNode("🌐 Set page lang"));
	pageLangLi.appendChild(pageLangLink);

	$("#t-info").after(pageLangLi);
	$("#t-info").after(trslCfgLi);
	console.log("AddTranslationLinks loaded after #t-info");
}

function AddCrossWikiActivityLinks()
{
	if (RLCONF.wgCanonicalNamespace !="User") return;
	var username = (RLCONF.wgTitle.indexOf("/") == -1)
		? RLCONF.wgTitle
		: RLCONF.wgTitle.substring(0, RLCONF.wgTitle.lastIndexOf('/'));
	
	var xwikiLi = document.createElement("li");
	xwikiLi.setAttribute("id", "t--crosswiki");
	var xwikiLink = document.createElement("a");
	xwikiLink.setAttribute("href",
		"https://meta2.toolforge.org/crossactivity/" + encodeURIComponent(username));
	xwikiLink.appendChild(document.createTextNode("🤹 Edit dates & privs"));
	xwikiLi.appendChild(xwikiLink);
	
	var contribsLi = document.createElement("li");
	contribsLi.setAttribute("id", "t--guc");
	var contribsLink = document.createElement("a");
	contribsLink.setAttribute("href",
		"https://guc.toolforge.org/?by=date&user=" + encodeURIComponent(username));
	contribsLink.appendChild(document.createTextNode("⏳ Edits timeline"));
	contribsLi.appendChild(contribsLink);
	
	var globalLi = document.createElement("li");
	globalLi.setAttribute("id", "t--stalktoy");
	var globalLink = document.createElement("a");
	globalLink.setAttribute("href",
		"https://meta2.toolforge.org/stalktoy/" + encodeURIComponent(username));
	globalLink.appendChild(document.createTextNode("📈 Edit counts & pies"));
	globalLi.appendChild(globalLink);
	
	var caLi = document.createElement("li");
	caLi.setAttribute("id", "t--centralauth");
	var caLink = document.createElement("a");
	caLink.setAttribute("href",
		"/wiki/Special:CentralAuth/" + encodeURIComponent(username));
	caLink.appendChild(document.createTextNode("🤹 CentralAuth acct info"));
	caLi.appendChild(caLink);
	
	var userPagesLi = document.createElement("li");
	userPagesLi.setAttribute("id", "t--userpages");
	var userPagesLink = document.createElement("a");
	userPagesLink.setAttribute("href",
		"https://meta2.toolforge.org/userpages/" + encodeURIComponent(username));
	userPagesLink.appendChild(document.createTextNode("👥 Userpages index"));
	userPagesLi.appendChild(userPagesLink);

	$("#t-contributions").after(userPagesLi);
	$("#t-contributions").after(caLi);
	$("#t-contributions").after(globalLi);
	$("#t-contributions").after(contribsLi);
	$("#t-contributions").after(xwikiLi);
	console.log("AddCrossWikiActivityLinks loaded after #t-contributions");
}

$(AddTranslationLinks);
$(AddCrossWikiActivityLinks);

mw.loader.load( 'https://en.wikipedia.org/w/load.php?modules=ext.gadget.dark-mode-toggle&only=scripts' );