Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js

MediaWiki interface page
Revision as of 03:01, 8 November 2025 by Polaris (talk | contribs)

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.
document.addEventListener('DOMContentLoaded', function () {
    // Citizen search button
    const citizenToggle = document.querySelector('.citizen-search-toggle');

    // Hotkey version (optional, keep it)
    document.addEventListener('keydown', function (e) {
        if (e.altKey && e.shiftKey && e.key.toLowerCase() === 'f') {
            e.preventDefault();
            if (citizenToggle) citizenToggle.click();
        }
    });

    // Insert a visible UI button into the page
    const btn = document.createElement('div');
    btn.className = 'custom-search-btn';
    btn.textContent = 'Search';
    btn.addEventListener('click', function () {
        if (citizenToggle) citizenToggle.click();
    });

    // Add it at the top of every page content
    const content = document.querySelector('#content, .mw-body');
    if (content) content.prepend(btn);
});