Jump to content

MediaWiki:Common.js: Difference between revisions

From RedFlag – Archiv
Created page with "Any JavaScript here will be loaded for all users on every page load.: mw.loader.using('mediawiki.util').then(function () { const title = document.querySelector('.mw-page-title-main'); if (!title) return; // Text des Titels holen const text = title.textContent; const index = text.indexOf(':'); // Wenn kein Doppelpunkt vorhanden, nichts tun if (index === -1) return; // Linken und rechten Teil trennen const left = text.slice(0, index + 1).trim();..."
 
(No difference)

Latest revision as of 11:41, 11 October 2025

/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using('mediawiki.util').then(function () {
  const title = document.querySelector('.mw-page-title-main');
  if (!title) return;

  // Text des Titels holen
  const text = title.textContent;
  const index = text.indexOf(':');

  // Wenn kein Doppelpunkt vorhanden, nichts tun
  if (index === -1) return;

  // Linken und rechten Teil trennen
  const left = text.slice(0, index + 1).trim();
  const right = text.slice(index + 1).trim();

  // Durch <br> ersetzen
  title.innerHTML = `${left}<br>${right}`;
});