The Unsubscribe Script

Since Youtube makes it nearly impossible for you to clear your subscription list from all the junk, I have provided this simple little code to help.

Go to Youtube on a desktop, go to your subscriptions.  Scroll down to the bottom of the page, right-click on an empty area of the screen, click “inspect” to open the developer’s console.

Make sure the “Console” tab is active, scroll to the bottom of the code until you see the final “>” symbol.  Paste this code into the console and click Enter.

The code will run a script which will unsubscribe from all your subscriptions.  Though you will see confirmation dialogs, you do not have to use them.  You will see them all clear.

Wait until the script stops and refresh the page.

Share this code with your friends.

  * 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!
  * 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(() => {
     }, delay)

  // Get the channel list; this can be considered a row in 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 subsribe button and trigger a "click"
     channel.querySelector(`[aria-label^='Unsubscribe from']`).click()
    await runAfterDelay(() => {
       // Get the dialog container...
         // and find the confirm button...
         // and "trigger" the click!
       console.log(`Unsubsribed ${ctr + 1}/${channels.length}`)

Leave a comment