V3 unsubscribe script

(async function batchUnsubscribeWithScroll(limit = 1000, delay = 2000) { const sleep = (ms) => new Promise((res) => setTimeout(res, ms)); let unsubscribed = 0;
let lastHeight = 0;
let scrollAttempts = 0;

async function scrollToBottom() {
while (scrollAttempts < 10) {
window.scrollTo(0, document.body.scrollHeight);
await sleep(2000);
const newHeight = document.body.scrollHeight;
if (newHeight === lastHeight) {
scrollAttempts++;
} else {
scrollAttempts = 0;
lastHeight = newHeight;
}
}
console.log(“✅ Finished scrolling.”);
}

async function unsubscribeVisible() {
const channels = Array.from(document.querySelectorAll(‘ytd-channel-renderer’)); for (const channel of channels) {
if (unsubscribed >= limit) return;
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();
unsubscribed++;
console.log(`Unsubscribed ${unsubscribed}/${limit}`); await sleep(delay);
}
}
}
}

await scrollToBottom();
await unsubscribeVisible();
console.log(`🎉 Done. Total unsubscribed: ${unsubscribed}`); })();

Leave a comment