Tip of the Day
Make sure you equip your items to get their effects, most don't work from inventory alone.
MediaWiki:Gadget-TranslatedTabTitle.js: Difference between revisions
From Walkscape Walkthrough
mNo edit summary |
mNo edit summary |
||
| Line 5: | Line 5: | ||
*/ | */ | ||
(function () { | (function () { | ||
var SITE_SUFFIX = ' | var SITE_SUFFIX = '- The Walkscape Wiki'; | ||
function computeTitle() { | function computeTitle() { | ||
Latest revision as of 00:48, 28 November 2025
/**
* 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 });
}
})();
