Created
September 15, 2021 21:16
-
-
Save greenweb/268f361477c5ddf4c49fc018703e870a to your computer and use it in GitHub Desktop.
Youtube bulk unsubsribe fn
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
/** | |
* Youtube bulk unsubsribe fn. | |
* Wrapping this in an IIFE for browser compatibility. | |
*/ | |
(async function iife() { | |
// This is the time delay after which the "unsubscribe" button is "clicked"; Tweak to your liking! | |
var UNSUBSCRIBE_DELAY_TIME = 2000 | |
/** | |
* Delay runner. Wraps `setTimeout` so it can be `await`ed on. | |
* @param {Function} fn | |
* @param {number} delay | |
*/ | |
var runAfterDelay = (fn, delay) => new Promise((resolve, reject) => { | |
setTimeout(() => { | |
fn() | |
resolve() | |
}, delay) | |
}) | |
// Get the channel list; this can be considered a row in the page. | |
var channels = Array.from(document.getElementsByTagName(`ytd-channel-renderer`)) | |
console.log(`${channels.length} channels found.`) | |
var ctr = 0 | |
for (const channel of channels) { | |
// Get the subsribe button and trigger a "click" | |
channel.querySelector(`[aria-label^='Unsubscribe from']`).click() | |
await runAfterDelay(() => { | |
// Get the dialog container... | |
document.getElementsByTagName(`yt-confirm-dialog-renderer`)[0] | |
// and find the confirm button... | |
.querySelector(`#confirm-button`) | |
// and "trigger" the click! | |
.click() | |
console.log(`Unsubsribed ${ctr + 1}/${channels.length}`) | |
ctr++ | |
}, UNSUBSCRIBE_DELAY_TIME) | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unsubscribe from YouTube Channels One at a Time
If you have lost interest in a YouTube channel, there are several ways to unsubscribe.
Clicking on one of the channel’s videos and clicking the gray “Subscribe” button to unsubscribe.
Clicking on the channel’s homepage and doing the same process as above.
Going to your Subscriptions page, choosing “Manage,” and unsubscribing to the listing.
Heading to your “Manage” page and running a script to bulk delete all subscriptions.
You probably already know how to unsubscribe YouTube channels one by one, and know that it is very time-consuming. But, did you know you can go to the YouTube subscription manager and see all the channels you are subscribed to?
View Your Existing YouTube Subscriptions List by doing the following:
You can now scroll through all of your subscriptions here and decide which ones you want to keep watching and which ones you want to get rid of. This method is excellent for YouTube users who are selective about their subscriptions and don’t want to lose all of them.
Because of the confirmation pop-ups, the manual unsubscribe process still requires many clicks depending on the number of channels that you follow. If you want a better solution, try the methods below.
Mass Unsubscribe from All YouTube Channels
The following method allows you to mass-unsubscribe from all the YouTube Channels you follow. Remember that you will need to subscribe again to the ones you still enjoy. It might be a good idea to write down their names and URLs, so you don’t forget about them.
Bulk unsubscribing from YouTube requires you to run a script, but don’t worry, this method was tried, tested, and verified. Plus, you don’t need to install any potentially harmful third-party program on your computer.
Follow these steps to mass unsubscribe: