7
If you have had a youtube account for a long time, and before you became privacy conscious, you might want to delete all of your youtube likes and favourites.
I was able to find the following code to delete liked video, which needs to be executed in the console in the liked videos playlist:
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();
I didn't find a way to do the same for the favourites, so I came up with my own, which also needs to be run in the console from the favourites videos playlist. You might need to change the text Supprimer de Favoris
to what the button in the UI says in your language.
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function deleteFavourites() {
'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 () {
var items2 = document.querySelectorAll('paper-listbox.style-scope.ytd-menu-popup-renderer > ytd-menu-service-item-renderer > paper-item');
for (var j = 0; j < items2.length; j++){
if(items2[j].textContent.includes("Supprimer de Favoris")){
items2[j].click();
}
}
}, 100);
await sleep(200); // sleep cause browser can not handle the process
clearTimeout(out);
}
}
deleteFavourites();
I ran this and it started flagging all videos as inappropriate.