MediaWiki:Common.js
MediaWiki interface page
More actions
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);
});