MediaWiki:Common.js: Difference between revisions
MediaWiki interface page
More actions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
document.addEventListener('DOMContentLoaded', function () { | document.addEventListener('DOMContentLoaded', function () { | ||
const | // 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); | |||
}); | }); | ||
Revision as of 03:01, 8 November 2025
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);
});