MediaWiki:Common.js: Difference between revisions

Created page with "Any JavaScript here will be loaded for all users on every page load.: mw.hook('wikipage.content').add(function () { console.log("[Language Menu] Script started"); var path = mw.config.get("wgPageName"); console.log("[Language Menu] Current path:", path); var currentLang = ''; var base = path; var langs = ['pt', 'en', 'es']; // Detecta idioma pelo sufixo langs.forEach(function (lang) { var suffix = '/' + lang; if (path.toLowerCase().endsWit..."
 
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
mw.hook('wikipage.content').add(function () {
mw.hook('wikipage.content').add(function () {
   console.log("[Language Menu] Script started");
   console.log("[Language Menu] Script started");
Line 64: Line 63:
   console.log("[Language Menu] Rewriting content links for:", currentLang);
   console.log("[Language Menu] Rewriting content links for:", currentLang);


   document.querySelectorAll('#mw-content-text a[href^="/"]').forEach(function (link) {
   //document.querySelectorAll('#mw-content-text a[href^="/"]').forEach(function (link) {
  document.querySelectorAll('a[href^="/doc/"]').forEach(function (link) {
     if (link.classList.contains('lang-menu-link')) return; // ignora menu de idiomas
     if (link.classList.contains('lang-menu-link')) return; // ignora menu de idiomas