Difference between revisions of "MediaWiki:Common.js"
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
+ | document.addEventListener("DOMContentLoaded", function () { | ||
+ | var loginButton = document.querySelector("#pt-login a"); // Adjust if needed | ||
+ | if (loginButton) { | ||
+ | var currentPage = encodeURIComponent(mw.config.get('wgPageName')); | ||
+ | |||
+ | // Only modify the login button if the page is in a restricted namespace | ||
+ | var restrictedNamespaces = ["Ana", "Internal"]; // Add your private namespaces here | ||
+ | var namespace = mw.config.get('wgCanonicalNamespace'); | ||
+ | |||
+ | if (restrictedNamespaces.includes(namespace)) { | ||
+ | loginButton.href = "/index.php?title=Special:UserLogin&returnto=" + currentPage; | ||
+ | } | ||
+ | } | ||
+ | }); |
Latest revision as of 07:48, 22 February 2025
/* Any JavaScript here will be loaded for all users on every page load. */ document.addEventListener("DOMContentLoaded", function () { var loginButton = document.querySelector("#pt-login a"); // Adjust if needed if (loginButton) { var currentPage = encodeURIComponent(mw.config.get('wgPageName')); // Only modify the login button if the page is in a restricted namespace var restrictedNamespaces = ["Ana", "Internal"]; // Add your private namespaces here var namespace = mw.config.get('wgCanonicalNamespace'); if (restrictedNamespaces.includes(namespace)) { loginButton.href = "/index.php?title=Special:UserLogin&returnto=" + currentPage; } } });