Skip to content

Instantly share code, notes, and snippets.

@dataserver
Created September 28, 2020 21:21
Show Gist options
  • Save dataserver/f14f8c7d3130a3885a1c5765921cd269 to your computer and use it in GitHub Desktop.
Save dataserver/f14f8c7d3130a3885a1c5765921cd269 to your computer and use it in GitHub Desktop.
2020 September - Remove Youtube likes
// SOURCE: https://webapps.stackexchange.com/questions/90238/delete-all-videos-on-my-liked-videos-youtube-automatic-playlist
// visit: https://www.youtube.com/playlist?list=LL
// open console, copy + paste
// obs: deleted videos just wont disappear from youtube...
// scroll down the list as much as possible because the default list size is just 100.
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function deleteLikedVideos() {
'use strict';
var items = document.querySelectorAll('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('paper-listbox.style-scope.ytd-menu-popup-renderer').lastElementChild) {
document.querySelector('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();
@dataserver
Copy link
Author

dataserver commented Feb 10, 2022

Update

  • change to querySelectorAll

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

async function deleteLikedVideos() {
    'use strict';
    var items = document.querySelectorAll('#primary ytd-playlist-video-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