Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active May 28, 2023 01:58
Show Gist options
  • Save wilmoore/e42ebdfed996c319b62a6e306c581050 to your computer and use it in GitHub Desktop.
Save wilmoore/e42ebdfed996c319b62a6e306c581050 to your computer and use it in GitHub Desktop.
YouTube Unsubscribe (YTUNSUB)
(async function iife() {
const UNSUBSCRIBE_DELAY_TIME = 2000
const runAfterDelay = (fn, delay) => new Promise((resolve, reject) => {
setTimeout(() => {
fn();
resolve()
}, delay)
})
const channels = Array.from(document.getElementsByTagName(`ytd-channel-renderer`))
console.log(`${channels.length} channels found.`)
const ctr = 0
for (const channel of channels) {
channel.querySelector(`[aria-label^='Unsubscribe from']`).click()
await runAfterDelay(() => {
document.querySelector('[aria-label="Unsubscribe"]').click()
console.log(`Unsubsribed ${ctr + 1}/${channels.length}`)
ctr++
}, UNSUBSCRIBE_DELAY_TIME)
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment