Resources

Bulk Unsubscribe from YouTube Channels Using a Script

Bulk Unsubscribe from YouTube Channels

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

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 – https://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.

Avatar

Yadwinder - Immigrants101

About Author

Yadwinder (Inder) is a personal blogger from Canada. Before migrating to Canada, he spent 11 years in New Zealand. Professionally, he is an IT Consultant with Bachelors Degree in Digital Technology. While he is juggling between his day job and blogging, he is the main author on this website. He is passionate about technology and helping new immigrants.

Leave a comment

Your email address will not be published. Required fields are marked *

You may also like

About this site
Resources

About this site

This site is dedicated to help all those who are moving from any country to Canada in a hope better
About Canada : Geography, Seasons and Provinces
Resources

About Canada : Geography, Seasons and Provinces

Canada is the second largest country on earth, covering an area of 10 million square kilometres (3.9 million square miles).