Last active
March 10, 2024 13:01
-
-
Save itsazzad/c1d86c5db86258ca129554a7b9ed92a7 to your computer and use it in GitHub Desktop.
YouTube mass unsubscribe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Go to the following link in your YouTube: https://www.youtube.com/feed/channels | |
// Scroll the page all the way down until you reach the very last subscribed channel in your list | |
const DELAY = 100; | |
const delay = ms => new Promise(res => setTimeout(res, ms)); | |
const list = document.querySelectorAll("#grid-container > ytd-channel-renderer"); | |
for (let index = 0; index < list.length; index++) { | |
console.log("") | |
console.log(index, list.length - index) | |
const sub = list[index]; | |
sub.scrollIntoView(); | |
console.log(sub.querySelector("ytd-channel-name").innerText); | |
console.log(sub.querySelector("#notification-preference-button").innerText); | |
const preferences = Array.from(sub.querySelectorAll("#notification-preference-button button")); | |
const subscribed = preferences.find(el => { | |
return el.textContent.includes("Subscribed"); | |
}); | |
if (subscribed) { | |
subscribed.click(); | |
await delay(DELAY); | |
} | |
const services = Array.from(document.querySelectorAll("#items > ytd-menu-service-item-renderer")); | |
const unsubscribe = services.find(el => { | |
return el.textContent.includes("Unsubscribe"); | |
}); | |
if (unsubscribe) { | |
unsubscribe.click(); | |
await delay(DELAY); | |
} | |
const confirm = document.querySelector("#confirm-button button"); | |
if (confirm) { | |
confirm.click(); | |
await delay(DELAY); | |
} | |
console.log(sub.querySelector("#subscribe-button").innerText) | |
} |
thanks for the script, on line 23, I replaced "#confirm-button > a" with "#confirm-button button" and it worked.
Thanks, I have updated the code.
Note:
Type 'allow pasting' before entering the script to disable paste protection in Chrome dev tools.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for the script,
on line 23, I replaced "#confirm-button > a" with "#confirm-button button" and it worked.