User:PetraMagna/HotCat.js: Difference between revisions

Content deleted Content added
m auto "click" add button after enter is pressed in edit box
shift and + to enter into edit mode in NS File; no need to touch the mouse now
 
(2 intermediate revisions by the same user not shown)
Line 1,354:
DEL = 46,
IME = 229;
function clickAddButton() {
const add_buttonadd_buttons = document.querySelectorquerySelectorAll("#mw-normal-catlinks a[title='Add a new category']");
if (add_buttons.length == 0) {
return;
}
const add_button = add_buttons[add_buttons.length - 1]
add_button.clickif (add_button); {
add_button.click();
}
}
 
CategoryEditor.prototype = {
Line 1,566 ⟶ 1,577:
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) {
// automatically add a new add button
save_button.click();
const add_button = document.querySelector("#mw-normal-catlinks a[title='Add a new category']");
if (add_button) { return;
add_button.click();
}
} if (save_button) {
clickAddButton();
}
}, 100);
return result;
}
Line 2,684 ⟶ 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,822 ⟶ 2,842:
}
is_rtl = ( is_rtl === 'rtl' );
}
if (mw.config.get("wgNamespaceNumber") === 6) {
window.addEventListener("keyup", (event) => {
if (event.shiftKey && event.keyCode === 187) {
startEditing();
}
})
}
}