Skip to content

Instantly share code, notes, and snippets.

@agentcooper
Last active August 11, 2023 00:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agentcooper/40caf33737057d215cdb892652a65b5b to your computer and use it in GitHub Desktop.
Save agentcooper/40caf33737057d215cdb892652a65b5b to your computer and use it in GitHub Desktop.
Save YouTube subscriptions

Open https://www.youtube.com/feed/channels, open JS console.

Save as Markdown list

console.log(
  Array.from(document.querySelectorAll("ytd-channel-renderer"))
    .map((item) => ({
      title: item.querySelector("#text-container").textContent.trim(),
      url: item.querySelector("#main-link").href,
    }))
    .map(({ title, url }) => `- [${title}](${url})`)
    .join("\n")
);

Save as JSON array

console.log(
  JSON.stringify(
    Array.from(document.querySelectorAll("ytd-channel-renderer")).map(
      (item) => ({
        title: item.querySelector("#text-container").textContent.trim(),
        url: item.querySelector("#main-link").href,
      })
    ),
    null,
    2
  )
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment