User:Tollens/common.js

This is an old revision of this page, as edited by Tollens (talk | contribs) at 04:08, 11 October 2024 (temp). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScript('User:BrandonXLF/NullEdit.js'); // [[User:BrandonXLF/NullEdit.js]]

(function () {
	$.when(mw.loader.using(["mediawiki.util"]), $.ready).done(function () {
		mw.util.addPortletLink(
			"p-personal",
			mw.util.getUrl("User:Tollens/Dashboard"),
			"Dashboard",
			"pt-dashboard",
			"View the dashboard",
			null,
			"#pt-preferences"
		);
		mw.util.addPortletLink(
			"p-personal",
			mw.util.getUrl("Special:ShortPages"),
			"Short Pages",
			"pt-shortpages",
			"View the list of short pages",
			null,
			"#pt-preferences"
		);
		mw.util.addPortletLink(
			"p-personal",
			mw.util.getUrl("Special:PendingChanges"),
			"Pending Changes",
			"pt-pendingchanges",
			"View the list of edits awaiting review",
			null,
			"#pt-preferences"
		);
	});

	const currentPage = mw.config.get("wgPageName");
	const currentNamespace = mw.config.get("wgCanonicalNamespace");

	if (currentPage === "User:Tollens/common.js") {
		const toggleLink = document.createElement("a");
		toggleLink.href = "#";
		toggleLink.textContent = "Toggle dev mode";
		toggleLink.onclick = () => {
			localStorage.setItem(
				"TollensDevMode",
				localStorage.getItem("TollensDevMode") === "true" ? "false" : "true"
			);
			location.reload();
			return false;
		};

		const separator = document.createElement("span");
		separator.textContent = " – ";

		document.getElementById("firstHeading").appendChild(separator);
		document.getElementById("firstHeading").appendChild(toggleLink);
	}

	if (!currentPage.includes("/")) {
		if (currentNamespace === "User" || currentNamespace === "User_talk") {
			const fullAddition = document.createElement("span");
			const contribsLink = document.createElement("a");
			contribsLink.href =
				"https://en.wikipedia.org/wiki/Special:Contributions/" +
				currentPage.substring(currentPage.indexOf(":") + 1);
			contribsLink.textContent = "contribs";
			fullAddition.appendChild(document.createTextNode(" ("));
			fullAddition.appendChild(contribsLink);
			fullAddition.appendChild(document.createTextNode(")"));

			document.getElementById("firstHeading").appendChild(fullAddition);
		}
	}

	if (localStorage.getItem("TollensDevMode") === "true") {
		const devModeWarningSpan = document.createElement("span");
		devModeWarningSpan.style.setProperty("color", "#ff0000", "important");
		devModeWarningSpan.textContent = "DEV MODE: ";
		document.getElementById("firstHeading").prepend(devModeWarningSpan);

		for (let linkElement of document.getElementsByTagName("link")) {
			if (
				linkElement.rel === "stylesheet" &&
				linkElement.href &&
				linkElement.href.includes("user.styles") &&
				linkElement.href.includes("Tollens")
			)
				linkElement.remove();
		}

		mw.loader.load("http://localhost:5500/Code/Userscripts/localFileToRead.js"); // Import the local dev js file
		const link = document.createElement("link");
		link.rel = "stylesheet";
		link.href = "http://localhost:5500/Code/Userstyles/localFileToRead.css"; // Import the local dev css file
		document.head.appendChild(link);

		console.warn("%cDEV MODE ENABLED", "font-size: 3em; font-weight: bold;");
	} else {
		importScript("User:Tollens/subnetContribs.js"); // Backlink: [[User:Tollens/subnetContribs.js]]
		importScript("User:Tollens/watchUser.js"); // Backlink: [[User:Tollens/watchUser.js]]
		importScript("User:Tollens/longCommenter.js"); // Backlink: [[User:Tollens/longCommenter.js]]

		importScript("User:Terasail/Edit Request Tool.js"); // Backlink: [[User:Terasail/Edit Request Tool.js]]
		importScript("User:Awesome Aasim/xfdvote.js"); // Backlink: [[User:Awesome Aasim/xfdvote.js]]
		importScript('User:SD0001/deleted-metadata-link.js'); // [[User:SD0001/deleted-metadata-link.js]]
		importScript("User:Enterprisey/cv-revdel.js"); // Backlink: [[User:Enterprisey/cv-revdel.js]]
		importScript("User:Fred_Gandt/confirmLogout.js"); // Backlink: [[User:Fred_Gandt/confirmLogout.js]]
	}
})();