presence.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const presence = new Presence({
  2. clientId: "642119548803219466",
  3. }),
  4. browsingTimestamp = Math.floor(Date.now() / 1000);
  5. presence.on("UpdateData", async () => {
  6. const presenceData: PresenceData = {
  7. largeImageKey:
  8. "https://cdn.rcd.gg/PreMiD/websites/F/FlipAnim/assets/logo.png",
  9. startTimestamp: browsingTimestamp,
  10. };
  11. if (document.location.hostname === "flipanim.com") {
  12. if (document.location.pathname === "/") {
  13. presenceData.details = "Viewing home page";
  14. presenceData.smallImageKey = Assets.Writing;
  15. } else if (document.location.pathname.includes("/anim")) {
  16. presenceData.details = "Viewing anim:";
  17. presenceData.state = `${
  18. document.querySelector("#mainDivActive > div:nth-child(6) > div")
  19. .textContent
  20. } by: ${
  21. document.querySelector(
  22. "#mainDivActive > div:nth-child(10) > div:nth-child(2) > div.anim_author > a:nth-child(1)"
  23. ).textContent
  24. }`;
  25. presenceData.smallImageKey = Assets.Reading;
  26. } else if (document.location.pathname.includes("/profile")) {
  27. presenceData.details = "Viewing profile of:";
  28. presenceData.state = document.querySelector(
  29. "#mainDivActive > div:nth-child(4) > div.profileAvatar > div.text_normal"
  30. ).textContent;
  31. presenceData.smallImageKey = Assets.Reading;
  32. }
  33. }
  34. if (presenceData.details) presence.setActivity(presenceData);
  35. else presence.setActivity();
  36. });