User:PetraMagna/HotCat.js: Difference between revisions

shift and + to enter into edit mode in NS File; no need to touch the mouse now
(always autocommit)
(shift and + to enter into edit mode in NS File; no need to touch the mouse now)
 
(3 intermediate revisions by the same user not shown)
Line 1,354:
DEL = 46,
IME = 229;
function clickAddButton() {
const add_buttons = document.querySelectorAll("#mw-normal-catlinks a[title='Add a new category']");
if (add_buttons.length == 0) {
return;
}
const add_button = add_buttons[add_buttons.length - 1]
if (add_button) {
add_button.click();
}
}
 
CategoryEditor.prototype = {
Line 1,563 ⟶ 1,574:
 
// Handle return explicitly, to override the default form submission to be able to check for ctrl
if ( key === RET ) return self.accept( evt );{
const result = self.accept( evt );
 
// if save_button exists, we are in multiinput mode
setTimeout(function() {
const save_button = document.querySelector("#mw-normal-catlinks input[value='Save']");
if (evt.shiftKey && save_button) {
save_button.click();
return;
}
if (save_button) {
clickAddButton();
}
}, 100);
return result;
}
// Inhibit default behavior of ESC (revert to last real input in FF: we do that ourselves)
return ( key === ESC ) ? evtKill( evt ) : true;
Line 2,673 ⟶ 2,697:
}
}; // end CategoryEditor.prototype
 
// Added by PetraMagna: auto start editing with a keypress
function startEditing() {
const several_button = document.querySelector("#catlinks a[title='Modify several categories']");
several_button.click();
clickAddButton();
}
 
function initialize() {
Line 2,811 ⟶ 2,842:
}
is_rtl = ( is_rtl === 'rtl' );
}
if (mw.config.get("wgNamespaceNumber") === 6) {
window.addEventListener("keyup", (event) => {
if (event.shiftKey && event.keyCode === 187) {
startEditing();
}
})
}
}