Skip to content

Instantly share code, notes, and snippets.

@viveknaskar
Created February 17, 2022 16:06
Show Gist options
  • Save viveknaskar/b5f71e19dbdf430454f811e609ee8eeb to your computer and use it in GitHub Desktop.
Save viveknaskar/b5f71e19dbdf430454f811e609ee8eeb to your computer and use it in GitHub Desktop.
A script that can be executed to unsubscribe all the YouTube channels at once.
var i = 0;
var count = document.querySelectorAll(
"ytd-channel-renderer:not(.ytd-item-section-renderer)"
);
myTimer();
function myTimer() {
if (count == 0) return;
el = document.querySelector(".ytd-subscribe-button-renderer");
el.click();
setTimeout(function () {
var unSubBtn = document.getElementById("confirm-button").click();
i++;
count--;
console.log("channel " + i + " unsubscribed");
setTimeout(function () {
el = document.querySelector("ytd-channel-renderer");
el.parentNode.removeChild(el);
myTimer();
}, 250);
}, 250);
}
@ffaw
Copy link

ffaw commented Mar 4, 2022

Great bro, ty

@fabianski7
Copy link

the button id I think may be something that varies by region, for me it was subscribe-button

@tasnuva1
Copy link

Thanks for the script.

@viveknaskar
Copy link
Author

Thanks for the script.

Glad, it worked for you.

@viveknaskar
Copy link
Author

the button id I think may be something that varies by region, for me it was subscribe-button

Oh, I didn't know that. I think YouTube (just like other apps) localizes their web apps in accordance to different countries. Thank you for letting me know.

@viveknaskar
Copy link
Author

Great bro, ty

Glad, it was useful.

@tasnuva1
Copy link

This one is working. First, you have to go to the bottom of the page and then open up the console.

@thorrrr
Copy link

thorrrr commented Oct 27, 2022

This ran through everything said i was unsubscribed took about 20 min for 600 subs. Said it was successful but back in YouTube they are all still showing as subscribed. I have tried logging out and in and clear cache but all still showing not 1 removed????

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment