Skip to content

Instantly share code, notes, and snippets.

@abigsmall
Created January 24, 2022 05:17
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save abigsmall/b0f38831a8a132321e70b6b4797f3dbd to your computer and use it in GitHub Desktop.
Save abigsmall/b0f38831a8a132321e70b6b4797f3dbd to your computer and use it in GitHub Desktop.
// I re-typed what I saw in reference 3 below,
// went to Liked videos page on YouTube[1] while logged in,
// pasted that into browser dev tools console (Google Chrome Version 97.0.4692.99 (Official Build) (x86_64)),
// pressed enter, and it seemed to do its thing, for the most part
// (when I refreshed the page, there was still 1 video remaining).
// [1] as of 2022-01-23 that’s at https://www.youtube.com/playlist?list=LL
// context: https://twitter.com/QiaochuYuan/status/1485164256970510340
// references:
// 1. https://www.quora.com/How-can-I-delete-all-liked-YouTube-videos-at-once/answer/Zeeshan-Arshad-34
// 2. https://twitter.com/gene_minkov/status/1485179092991365123
// 3. https://twitter.com/QiaochuYuan/status/1485438430720905219
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function deleteLikedVideos() {
'use strict';
var items = document.querySelectorAll('ytd-playlist-video-renderer ytd-menu-renderer > yt-icon-button.dropdown-trigger > button[aria-label]');
var out;
for (var i = 0; i < items.length; i++) {
items[i].click();
out = setTimeout(function () {
if (document.querySelector('tp-yt-paper-listbox.style-scope.ytd-menu-popup-renderer').lastElementChild) {
document.querySelector('tp-yt-paper-listbox.style-scope.ytd-menu-popup-renderer').lastElementChild.click();
}
}, 100);
await sleep(500); // sleep cause browser can not handle the process
clearTimeout(out);
}
}
deleteLikedVideos();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment