User:Joko2468/common.js: Difference between revisions – Wikipedia

From Wikipedia, the free encyclopedia

Content deleted Content added


Line 27: Line 27:

}

}

});

});

// Remove only the Watchlist button in Vector 2022+

(function() {

function removeWatchlistButton() {

// Desktop: li containing a link with the hover title

const desktop = document.querySelector(‘#p-personal li a[title=”The list of pages you are monitoring for changes”]’);

if (desktop && desktop.parentElement) {

desktop.parentElement.remove();

}

// Mobile: li in the mobile personal toolbar

const mobile = document.querySelector(‘#mw-mf-personal li a[title=”The list of pages you are monitoring for changes”]’);

if (mobile && mobile.parentElement) {

mobile.parentElement.remove();

}

}

// Try immediately

removeWatchlistButton();

// Retry in case it is dynamically loaded

const interval = setInterval(() => {

removeWatchlistButton();

}, 500);

// Stop retrying after 10 seconds

setTimeout(() => clearInterval(interval), 10000);

})();


Revision as of 23:43, 9 November 2025

// Change "Edit source" button text to "Edit"
mw.hook('wikipage.editsection').add(function($editSectionLinks) {
    $editSectionLinks.each(function() {
        var $link = $(this);
        if ($link.text().trim() === 'Edit source') {
            $link.text('Edit');
        }
    });
});

// Disable the Vector 2022 scroll animation / sticky header
mw.hook('wikipage.content').add(function() {
    // Remove the scroll event that animates the header
    if (window.vectorScroll) {
        window.vectorScroll.disconnect();
    }

    // Remove sticky class from body
    document.body.classList.remove('vector--page-header-sticky');

    // Reset header styles
    const header = document.getElementById('mw-head-base');
    if (header) {
        header.style.position = 'static';
        header.style.transform = 'none';
        header.style.transition = 'none';
    }
});

// Remove only the Watchlist button in Vector 2022+
(function() {
    function removeWatchlistButton() {
        // Desktop: li containing a link with the hover title
        const desktop = document.querySelector('#p-personal li a[title="The list of pages you are monitoring for changes"]');
        if (desktop && desktop.parentElement) {
            desktop.parentElement.remove();
        }

        // Mobile: li in the mobile personal toolbar
        const mobile = document.querySelector('#mw-mf-personal li a[title="The list of pages you are monitoring for changes"]');
        if (mobile && mobile.parentElement) {
            mobile.parentElement.remove();
        }
    }

    // Try immediately
    removeWatchlistButton();

    // Retry in case it is dynamically loaded
    const interval = setInterval(() => {
        removeWatchlistButton();
    }, 500);

    // Stop retrying after 10 seconds
    setTimeout(() => clearInterval(interval), 10000);
})();

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top