Skip to content

Instantly share code, notes, and snippets.

@gukandrew
Created July 2, 2022 18:50
Show Gist options
  • Save gukandrew/0623de7963a86d583d0fd5ca06874741 to your computer and use it in GitHub Desktop.
Save gukandrew/0623de7963a86d583d0fd5ca06874741 to your computer and use it in GitHub Desktop.
YouTube Download all subscriptions

YouTube Download all subscriptions

** Scripts tested in Firefox only!

Dump subscriptions to file

Log in into your account. Go to https://www.youtube.com/feed/channels and scroll down to load all subscriptions

function download(filename, text) {
    var element = document.createElement('a');
    element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
    element.setAttribute('download', filename);

    element.style.display = 'none';
    document.body.appendChild(element);

    element.click();

    document.body.removeChild(element);
}

var content = $$('#info-section .channel-link').map((e) => `${e.querySelectorAll("yt-formatted-string#text")[0].innerText} | ${e.href}`).join("\n")
download("subscriptions.md", content)

Unsubscribe from all channels

Log in into your account.

Go to https://www.youtube.com/feed/channels and scroll down to load all subscriptions

var elements = $$('#info-section')
for (let i = 0; i < elements.length; i++) {
    const element = elements[i];
    setTimeout(() => {
        element.querySelector("tp-yt-paper-button").click()
     
        setTimeout(() => $('ytd-popup-container .yt-confirm-dialog-renderer yt-button-renderer#confirm-button').click(), 200);
    }, 500 * i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment