User:Tollens/common.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
The accompanying .css page for this skin is at User:Tollens/common.css. |
(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);
// Disable user stylesheets (global.css/common.css/vector.css, all of them)
// Needs to be done repeatedly because we have no way of knowing how many are loaded or if they've been loaded yet
let disableAttempts = 0;
let disableSSInterval = setInterval(() => {
for (let sheet of document.styleSheets) {
if (sheet.href && sheet.href.includes("user.styles") && sheet.href.includes("Tollens"))
sheet.disabled = true;
}
disableAttempts++;
if (disableAttempts >= 10) clearInterval(disableSSInterval);
}, 500);
mw.loader.load("http://localhost:5500/Code/localFileToRead.js"); // Import the local dev file
console.warn("%cDEV MODE ENABLED", "font-size: 3em; font-weight: bold;");
} else {
importScript("User:Terasail/Edit Request Tool.js"); // Backlink: [[User:Terasail/Edit Request Tool.js]]
importScript("User:Enterprisey/cv-revdel.js"); // Backlink: [[User:Enterprisey/cv-revdel.js]]
importScript("User:Tollens/subnetContribs.js"); // Backlink: [[User:Tollens/subnetContribs.js]]
importScript("User:Fred_Gandt/confirmLogout.js"); // Backlink: [[User:Fred_Gandt/confirmLogout.js]]
importScript("User:Awesome Aasim/xfdvote.js"); // Backlink: [[User:Awesome Aasim/xfdvote.js]]
importScript("User:Tollens/watchUser.js"); // Backlink: [[User:Tollens/watchUser.js]]
importScript("User:Tollens/longCommenter.js"); // Backlink: [[User:Tollens/longCommenter.js]]
}
})();