MediaWiki:Gadget-EditShortcut.js
Jump to navigation
Jump to search
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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
(function() {
// Check if the current namespace is the main namespace (0) or custom namespace (7000) and the current action is not 'edit'
if ((mw.config.get('wgNamespaceNumber') === 0 || mw.config.get('wgNamespaceNumber') === 7000) && mw.config.get('wgAction') !== 'edit') {
document.addEventListener('keydown', function(event) {
// Check if the pressed key is 'e' and no modifier keys are pressed, and the search input is not focused
if (event.key === 'e' && !event.altKey && !event.ctrlKey && !event.shiftKey && !event.metaKey && document.activeElement.id !== 'searchInput') {
// Prevent the default action to avoid any unwanted behavior
event.preventDefault();
// Redirect to the "edit source" URL
window.location.href = mw.util.getUrl(mw.config.get('wgPageName'), { action: 'edit' });
}
});
}
})();