Skip to content

Instantly share code, notes, and snippets.

@MrMarble
Created May 10, 2021 09:03
Show Gist options
  • Select an option

  • Save MrMarble/140d21d15e85c491ea809831bf7bfce9 to your computer and use it in GitHub Desktop.

Select an option

Save MrMarble/140d21d15e85c491ea809831bf7bfce9 to your computer and use it in GitHub Desktop.

Revisions

  1. MrMarble created this gist May 10, 2021.
    23 changes: 23 additions & 0 deletions getFollowed.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    "use strict";

    function getFollowed() {
    const dom = document.querySelector("div[aria-label='Canales que sigo']");
    const key = Object.keys(dom).find((key) =>
    key.startsWith("__reactInternalInstance$")
    );
    const react = dom[key];
    if (react == null) return;

    const walk = (obj, max = 30) => {
    if (obj.key === "FOLLOWED_SECTION") {
    return {
    offline: obj.memoizedProps.section.videoConnections,
    online: obj.memoizedProps.section.streams
    };
    }

    if (--max > 0) return walk(obj.return);
    };

    return walk(react);
    }