Working as of last edit to this page
Adapted from https://gist.github.com/astamicu/eb351ce10451f1a51b71a1287d36880f
Jump to the code if you don't care about the preamble
Quickly remove videos from your watch history - search for videos, topics, creators you want to remove from your history to make them less likely to show up in your recommendations so you don't have to nuke or reset your recommendations. (YouTube's recommendation algorthmn works, mostly, on the videos in your History, Liked and Watch Later lists). It makes them less likely to show up, but I've found that sometimes not entirely especially if you watch related creators
Unlike the original, it doesn't intervals - you can nuke the entire visable list at once as the button is not hidden behind a meatball menu
However, the history doesn't load like a playlist, so you can only delete a max of 20 video at a time. This means you'll have to rerun the search query, delete again, search etc until you get "This list has no videos" (See here for an example of what that looks like). You don't need to refresh the page each time, and while it's much more of a manual process than the original script, at least you don't have to wait for each element to be clicked as videos are removed instantly.
YouTube has a funny little bug that causes this:
As you can see, there is supposed to be a video there but it's not rendered. This is fine - you can still use run the code to remove the videos, it's just not rendering correctly. You can remove all, re-run the search (without needing to refresh), see the same glitched page, rinse and repeat until you get:
Be aware: much like the original script, non-english users will need to change "Remove from watch history" to what YouTube uses for your localization.
var things = document.evaluate(
'//*[@aria-label="Remove from watch history"]',
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);
for (var i = 0; i < things.snapshotLength; i++) {
things.snapshotItem(i).click();
}
javascript: (() => { var things = document.evaluate('//*[@aria-label="Remove from watch history"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0; i < things.snapshotLength; i++) { things.snapshotItem(i).click(); }})();