Difference between revisions of "MediaWiki:Common.js"
(Created page with "→Any JavaScript here will be loaded for all users on every page load.: var shiftWindow = function() { scrollBy(0, -60) }; if (location.hash) shiftWindow(); window.addEven...") |
|||
(One intermediate revision by one other user not shown) | |||
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')); | ||
− | var | + | // Only modify the login button if the page is in a restricted namespace |
− | if ( | + | 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; } } });