Unsubscribe YouTube Channels

Just I finished cleaning up my kitchen then I suddenly wanted to clean my subscribed youtube channels as well. Turns out I subscribed to 3200+ channels. Go to channels feed page and keep scrolling to the bottom (hold ⌘-↓) to the end of it. Save the page. You can save your channels feed page as HTML ⌘-S and use Ruby’s Nokogiri to backup all channel names you have subscribed:

html = Nokogiri::HTML.parse IO.read("~/Downloads/subscribed.html")
html.css(".ytd-channel-name+tp-yt-paper-tooltip").
  map(&:text).
  map(&:strip).
  join("\n")

Then paste the following code to your browser console to unsubscribe all your channels. It takes number of channels*1.2 seconds to complete 😅

let i = 0;
setInterval(unsubscribeAll, 1200)

function unsubscribeAll () {
  const channels = document.getElementsByClassName("ytd-subscribe-button-renderer")

  if (i < channels.length) {
    let channel = channels[i]
    channel.click()

    setTimeout(function () {
      document.getElementById("confirm-button").click()
    }, 500)

    setTimeout(function () {
      channels[i].parentNode.removeChild(channels[i])
    }, 500)
  }

  i++;

  console.log(i + " unsubscribed")
  console.log(channels.length + " remaining")
}