presence.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. const presence = new Presence({
  2. clientId: "647443051819565076",
  3. });
  4. presence.on("UpdateData", async () => {
  5. const path = window.location.hash.substr(1),
  6. presenceData: PresenceData = {
  7. largeImageKey:
  8. "https://cdn.rcd.gg/PreMiD/websites/H/Horizon%20GO/assets/logo.jpg",
  9. };
  10. if (path === "action=watch") {
  11. presenceData.state = `Channel: ${document
  12. .querySelector(
  13. "div.player-linear-bottom-bar__channelstrip:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2)"
  14. )
  15. .getAttribute("title")}`;
  16. presenceData.details = `Watching: ${
  17. document.querySelector(
  18. "div.player-linear-bottom-bar__channelstrip:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(4) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1)"
  19. ).textContent
  20. }`;
  21. } else if (path.includes("offset")) {
  22. presenceData.state = `Video: ${document.title}`;
  23. presenceData.details = `Watching: ${
  24. document.querySelector(".player-ui-bottom-bar-controls__main-info")
  25. .textContent
  26. }`;
  27. } else presenceData.details = "Browsing homepage.";
  28. presence.setActivity(presenceData);
  29. });