Delete A Lot Of WordPress Tags

Posted at

No Need To Directly Access The DB Or Execute Any SQL Commands (Although It Would Be A Lot Faster...)

Edit a post, open the developer-panel,
switch to "console" and execute this code to delete 15 tags at once.. ;)

Really just a dirty dirty way :))


var x = document.querySelectorAll('.tagchecklist .ntdelbutton');
x[0].focus(); x[0].click();
x[1].focus(); x[1].click();
x[2].focus(); x[2].click();
x[3].focus(); x[3].click();
x[4].focus(); x[4].click();
x[5].focus(); x[5].click();
x[6].focus(); x[6].click();
x[7].focus(); x[7].click();
x[8].focus(); x[8].click();
x[9].focus(); x[9].click();
x[10].focus(); x[10].click();
x[11].focus(); x[11].click();
x[12].focus(); x[12].click();
x[13].focus(); x[13].click();
x[14].focus(); x[14].click();
x[15].focus(); x[15].click();


Deleting them all is kind-of weird: since querying for elements and "deleting" the current element actively changes the list of elements,
we can use the initial query to count roughly how much element were left, looping and querying the first element and removing it -
- keeping querying and removing a single element while the main loop "just checks if there are any still existing".
- it will take just few minutes for couple of hundreds of tags, and the window might hang for a bit (don't kill it.. just keep on waiting :/)
and at the end of the run you'll have 100% tag-free post :]

here is it.. plus an alternative for the click method before.

function emu_click_new(target){
if("object" !== typeof target) return;
target.dispatchEvent(
new MouseEvent("click", { screenX: 0 /*MouseEvent [https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent] */
, screenY: 0
, clientX: 0
, clientY: 0
, ctrlKey: false
, shiftKey: false
, altKey: false
, metaKey: false
, button: 0 /*left button */
, buttons: 0 /*no sticky press */
, view: self /*UIEventInit [https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/UIEvent] */
, bubbles: true /*EventInit [https://developer.mozilla.org/en-US/docs/Web/API/Event/Event] */
, cancelable: true
, scoped: false
, composed: false
}
)
);
}

document.querySelectorAll('.tagchecklist .ntdelbutton').forEach(function(e){
setTimeout(function(){
e = document.querySelector('.tagchecklist .ntdelbutton');
emu_click_new(e);
}, 100);
});