(async function unsubscribeBatch(limit = 100, delay = 2000) { const sleep = (ms) => new Promise((res) => setTimeout(res, ms)); const channels = Array.from(document.querySelectorAll(‘ytd-channel-renderer’));
console.log(`Found ${channels.length} channels. Attempting to unsubscribe from up to ${limit}.`);
let count = 0;
for (const channel of channels) {
if (count >= limit) break;
const button = channel.querySelector(‘[aria-label^=”Unsubscribe from”]’); if (button) {
button.click();
await sleep(500);
const confirm = document.querySelector(‘yt-confirm-dialog-renderer #confirm-button’); if (confirm) {
confirm.click();
console.log(`Unsubscribed ${count + 1}/${limit}`);
count++;
await sleep(delay);
}
}
}
console.log(`Finished unsubscribing from ${count} channels.`); })();