Skip to content

Instantly share code, notes, and snippets.

@shortland
Created March 6, 2019 04:37
Show Gist options
  • Select an option

  • Save shortland/76d7d5cc94f1fb5f67dc3e78a5a6bcd1 to your computer and use it in GitHub Desktop.

Select an option

Save shortland/76d7d5cc94f1fb5f67dc3e78a5a6bcd1 to your computer and use it in GitHub Desktop.
Mass auto-unsub from YouTube
// adapted & updated from: https://stackoverflow.com/questions/48874382/how-to-unsubscribe-from-all-the-youtube-channels-at-once/48874466#48874466
var i = 0;
var myVar = setInterval(myTimer, 1000);
function myTimer () {
console.log("here we go!");
var els = document.getElementById("grid-container").getElementsByClassName("ytd-expanded-shelf-contents-renderer");
if (i < els.length) {
els[i].querySelector("[aria-label^='Unsubscribe from']").click();
setTimeout(function () {
var unSubBtn = document.getElementById("confirm-button").click();
}, 1000);
setTimeout(function () {
try {
els[i].parentNode.removeChild(els[i]);
} catch (err) {
alert("Error... Please refresh this page and start over");
}
}, 1000);
}
i++;
console.log(i + " unsubscribed successfully");
console.log(els.length + " remaining");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment