Unsubscribe from all your YouTube channels

Need to unsubscribe from all your YouTube channel subscriptions in just one click?

Here is how to do it:

  1. Follow the link – https://www.youtube.com/feed/channels.
  2. Open the browser console with the F12 key.
  3. Select “Console”.
  4. Copy and paste the below code:

/**
* Youtube bulk unsubsribe fn.
* Wrapping this in an IIFE for browser compatibility.
*/
(async function iife() {
// This is the time delay after which the “unsubscribe” button is “clicked”; Tweak to your liking!
var UNSUBSCRIBE_DELAY_TIME = 2000

/**
* Delay runner. Wraps `setTimeout` so it can be `await`ed on.
* @param {Function} fn
* @param {number} delay
*/
var runAfterDelay = (fn, delay) => new Promise((resolve, reject) => {
setTimeout(() => {
fn()
resolve()
}, delay)
})


// Get the channel list; this can be considered a row on the page.
var channels = Array.from(document.getElementsByTagName(`ytd-channel-renderer`))
console.log(`${channels.length} channels found.`)

var ctr = 0
for (const channel of channels) {
// Get the subscribe button and trigger a “click”
channel.querySelector(`[aria-label^=’Unsubscribe from’]`).click()
await runAfterDelay(() => {
// Get the dialog container…
document.getElementsByTagName(`yt-confirm-dialog-renderer`)[0]
// and find the confirm button…
.querySelector(`#confirm-button`)
// and “trigger” the click!
.click()
console.log(`Unsubscribed ${ctr + 1}/${channels.length}`)
ctr++
}, UNSUBSCRIBE_DELAY_TIME)
}
})()

     

    Done!

Leave a Reply

Your email address will not be published. Required fields are marked *