Tip of the Day
The green tongs button at the bottom of the screen opens the crafting interface.

MediaWiki:Gadget-TranslatedTabTitle.js

From Walkscape Walkthrough

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/**
 * Gadget: TranslatedTabTitle
 * Updates the browser tab title to match the visible page heading.
 * Works on all namespaces and translated pages.
 */
(function () {
  var SITE_SUFFIX = '- The Walkscape Wiki';

  function computeTitle() {
    var $h = $('#firstHeading, .firstHeading, .mw-first-heading, .mw-page-title-main').first();
    var t = $h.text().trim();
    if (!t) return;

    var current = document.title;
    var base = t;

    if (!current.startsWith(base)) {
      document.title = base + SITE_SUFFIX;
    } else if (!current.endsWith(SITE_SUFFIX)) {
      document.title = current + SITE_SUFFIX;
    }
  }

  // Run when the DOM is ready
  $(computeTitle);

  // Re-run when MediaWiki reloads content dynamically
  mw.hook('wikipage.content').add(computeTitle);

  // Also observe heading changes
  var h = document.getElementById('firstHeading');
  if (h && window.MutationObserver) {
    new MutationObserver(function () { computeTitle(); })
      .observe(h, { childList: true, characterData: true, subtree: true });
  }
})();