-
-
Save astrolemonade/01405e0bea1a0fcfb0d498bee0637752 to your computer and use it in GitHub Desktop.
YouTube mass unsubscribe
This file contains hidden or 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) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment