User:PetraMagna/HotCat.js: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
press shift + enter to save
shift and + to enter into edit mode in NS File; no need to touch the mouse now
 
Line 1,354: Line 1,354:
DEL = 46,
DEL = 46,
IME = 229;
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 = {
CategoryEditor.prototype = {
Line 1,573: Line 1,584:
}
}
if (save_button) {
if (save_button) {
clickAddButton();
// automatically click the add button
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();
}
}
}
}, 100);
}, 100);
Line 2,694: Line 2,697:
}
}
}; // end CategoryEditor.prototype
}; // 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() {
function initialize() {
Line 2,832: Line 2,842:
}
}
is_rtl = ( is_rtl === 'rtl' );
is_rtl = ( is_rtl === 'rtl' );
}
if (mw.config.get("wgNamespaceNumber") === 6) {
window.addEventListener("keyup", (event) => {
if (event.shiftKey && event.keyCode === 187) {
startEditing();
}
})
}
}
}
}