MediaWiki:Gadget-BypassCommonJS.js

From Angelina Jordan Wiki
Revision as of 15:07, 7 November 2025 by Most2dot0 (talk | contribs) (lets do it nothing)

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.
( function () {
/* do nothing 
    'use strict';
    // This gadget's job:
    // 1) when enabled it reloads once so the Common.js guard sees the new preference
    // 2) provide a personal-tools toggle link for convenience (optional)
    var gadgetKey = 'gadget-BypassCommonJS';
    function isEnabled() {
        try { return mw && mw.user && mw.user.options && mw.user.options.get && mw.user.options.get(gadgetKey); }
        catch (e) { return false; }
    }

    // If gadget is enabled, reload once to let MediaWiki:Common.js pick up the pref.
    // Avoid reload loops by checking a URL marker.
    if ( isEnabled() ) {
        if ( location.search.indexOf('bypassApplied=1') === -1 ) {
            // Add a short notification then reload with marker
            if ( mw && mw.notification ) mw.notification.notify('BypassCommonJS enabled. Reloading to apply bypass.');
            // Use replaceState + reload to avoid polluting history
            var url = new URL(location.href);
            url.searchParams.set('bypassApplied', '1');
            location.replace(url.href);
            return;
        } else {
            // Remove marker to keep URLs clean on next navigation
            try {
                var url2 = new URL(location.href);
                url2.searchParams.delete('bypassApplied');
                history.replaceState({}, '', url2.href);
            } catch (e) {}
        }
    }

    // Optional: add a quick toggle link into personal tools to open Preferences → Gadgets
    mw.loader.using('mediawiki.util').then(function () {
        if ( mw.util && mw.util.addPortletLink && document.getElementById('pt-bypassprefs') === null ) {
            mw.util.addPortletLink('p-personal', mw.util.getUrl('Special:Preferences#mw-prefsection-gadgets'), 'Bypass prefs', 'pt-bypassprefs', 'Open gadget preferences (toggle BypassCommonJS)');
        }
    });
*/
})();