Bulk Unsubscribe from YouTube Channels Using a Script
Table of Contents
Disclaimer
- Use this script responsibly: This script automates the process of unsubscribing from channels, which is normally a manual task on YouTube.
- Test before bulk running: Always test the script on a few channels first to ensure it’s working as expected.
- Browser-based: This script is designed to work in the browser, preferably Chrome.
Steps to Run the Script
1. Open Your Browser
- Open Google Chrome or any browser with a developer console.
- Go to YouTube’s Subscription Management Page. This page lists all the channels you’ve subscribed to.
2. Open the Developer Console
To access the developer console:
- On Windows or Linux: Press
Ctrl + Shift + J
- On Mac: Press
Cmd + Option + J
3. Copy and Paste the Script
Once the developer console is open, copy and paste the following JavaScript into it, then press Enter
:
(async function iife() {
var UNSUBSCRIBE_DELAY_TIME = 2000; // Time delay after each unsubscribe operation
var RETRY_LIMIT = 3; // Maximum retry attempts for unsubscribing
var BATCH_LIMIT = 10; // Number of unsubscribes before a longer pause
var randomDelay = () => Math.floor(Math.random() * 1000) + 1000; // Random delay to mimic human behavior
var wait = (delay) =>
new Promise((resolve) => setTimeout(resolve, delay));
// Get the channel list
var channels = Array.from(
document.querySelectorAll(
"ytd-subscription-notification-toggle-button-renderer-next > yt-button-shape > button"
)
);
console.log(`${channels.length} channels found.`);
var ctr = 0;
for (const channel of channels) {
let retryCount = 0;
let success = false;
while (retryCount < RETRY_LIMIT && !success) {
try {
// Click the unsubscribe button
channel.click();
await wait(100);
document
.querySelector("#items > ytd-menu-service-item-renderer:nth-child(4)")
.click();
await wait(800);
document.querySelector("#confirm-button > yt-button-shape > button > yt-touch-feedback-shape").click();
await wait(UNSUBSCRIBE_DELAY_TIME);
console.log(`Unsubscribed ${ctr + 1}/${channels.length}`);
ctr++;
success = true; // Unsubscribe was successful
} catch (e) {
retryCount++;
console.error(`Error unsubscribing from channel ${ctr + 1}. Attempt ${retryCount}`);
await wait(1000); // Wait before retrying
}
}
if (!success) {
console.error(`Failed to unsubscribe from channel ${ctr + 1} after ${RETRY_LIMIT} attempts.`);
}
// Batch control: longer pause after every BATCH_LIMIT unsubscribes
if (ctr % BATCH_LIMIT === 0) {
console.log(`Taking a break after ${BATCH_LIMIT} unsubscribes...`);
await wait(randomDelay() + 5000); // Longer delay between batches
}
await wait(randomDelay()); // Random delay before next unsubscribe
}
})();
How the Script Works:
- Channel Detection: It searches for all the “unsubscribe” buttons on the page and stores them in an array.
- Automation Loop: For each channel, the script clicks the “unsubscribe” button, waits for confirmation, and then confirms the unsubscribe action.
Here is the screenshot from my browser: - Delay: The script has a delay of 2 seconds (
2000ms
) between each unsubscribe to avoid triggering any rate-limiting mechanisms on YouTube’s side. You can adjust this delay based on your preference.
Customization:
- Unsubscribe Delay: Modify the
UNSUBSCRIBE_DELAY_TIME
to set how long the script should wait between unsubscribing from channels. Increasing this delay can make the script less suspicious to YouTube. - Logging: The script logs the progress to the console, showing how many channels have been unsubscribed.
Check out more related topics here – http://immigrants101.com/category/resources/
Final Thoughts
This script allows you to bulk unsubscribe from YouTube channels in just a few clicks, saving you hours of manual labor. However, be cautious with bulk actions, as YouTube might detect unusual activity and flag your account for automated behavior. Always run the script in moderation and check the results before proceeding further.