Skip to content

Instantly share code, notes, and snippets.

@swapnilraj
Last active August 29, 2017 10:07
Show Gist options
  • Save swapnilraj/51e65c471ae6ed660902908185a4fe3a to your computer and use it in GitHub Desktop.
Save swapnilraj/51e65c471ae6ed660902908185a4fe3a to your computer and use it in GitHub Desktop.
Javascript snippet to get the name of subscriptions and channel links on Youtube.
(() => {
let subs = Array.from(document.querySelectorAll('#sections > ytd-guide-subscriptions-section-renderer > div#container > ytd-guide-entry-renderer')).map(
e => `${e.querySelector('span.title').innerText} - ${e.querySelector('a').href}`,
);
if (subs.length === 0) {
subs = Array.from(document.querySelectorAll('#guide-channels > li.guide-channel')).map(
e => `${e.querySelector('span.display-name').innerText} - ${e.querySelector('a').href}`,
);
}
const subList= JSON.stringify(subs, undefined, 2);
console.log(subList)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment