MediaWiki:Common.js: Difference between revisions

From Kshatriya Wiki
mNo edit summary
Tag: Reverted
mNo edit summary
Tag: Reverted
Line 11: Line 11:
gtag('config', 'G-5MQXEFVQBE');
gtag('config', 'G-5MQXEFVQBE');


// For Vector 2022: Hide "View history" and "Recent changes" for anonymous users
///try
$(function () {
$(function () {
    // Only apply for anonymous (not logged-in) users
     if (!mw.config.get('wgUserName')) {
     if (!mw.config.get('wgUserName')) {
         // Hide "View history" tab
         // Hide "View history" tab in Vector 2022
         $('[data-vector-tab="ca-history"]').hide();
         const historyTab = document.querySelector('[data-vector-tab="ca-history"]');
        if (historyTab) {
            historyTab.style.display = 'none';
        }


         // Hide "Recent changes" from sidebar and other locations
         // Hide all "Recent changes" links (sidebar, top menu, etc.)
         $('a[title="Special:RecentChanges"]').closest('li').hide();
         document.querySelectorAll('a[title="Special:RecentChanges"]').forEach(el => {
            el.style.display = 'none';
        });
     }
     }
});
});

Revision as of 16:48, 28 June 2025

/* Any JavaScript here will be loaded for all users on every page load. */
// Google Analytics for GA4 (G-5MQXEFVQBE)
var gtagScript = document.createElement("script");
gtagScript.src = "https://www.googletagmanager.com/gtag/js?id=G-5MQXEFVQBE";
gtagScript.async = true;
document.head.appendChild(gtagScript);

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-5MQXEFVQBE');

///try
$(function () {
    // Only apply for anonymous (not logged-in) users
    if (!mw.config.get('wgUserName')) {
        // Hide "View history" tab in Vector 2022
        const historyTab = document.querySelector('[data-vector-tab="ca-history"]');
        if (historyTab) {
            historyTab.style.display = 'none';
        }

        // Hide all "Recent changes" links (sidebar, top menu, etc.)
        document.querySelectorAll('a[title="Special:RecentChanges"]').forEach(el => {
            el.style.display = 'none';
        });
    }
});