presence.ts 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. const presence = new Presence({
  2. clientId: "636588416854917130",
  3. }),
  4. browsingTimestamp = Math.floor(Date.now() / 1000);
  5. let title: HTMLElement, search: HTMLElement;
  6. presence.on("UpdateData", async () => {
  7. const presenceData: PresenceData = {
  8. largeImageKey:
  9. "https://cdn.rcd.gg/PreMiD/websites/0-9/1337x/assets/logo.png",
  10. startTimestamp: browsingTimestamp,
  11. };
  12. if (
  13. document.location.pathname === "/" ||
  14. document.location.pathname === "/home/"
  15. )
  16. presenceData.details = "Viewing home page";
  17. else if (document.location.pathname.includes("/movie-library"))
  18. presenceData.details = "Viewing the movie library";
  19. else if (document.location.pathname.includes("/series-library"))
  20. presenceData.details = "Viewing the series library";
  21. else if (document.location.pathname.includes("/new-episodes"))
  22. presenceData.details = "Viewing the latest episodes";
  23. else if (document.location.pathname.includes("/top-100"))
  24. presenceData.details = "Viewing the top 100";
  25. else if (document.location.pathname.includes("/trending"))
  26. presenceData.details = "Viewing what's trending";
  27. else if (document.location.pathname.includes("/cat/Anime/"))
  28. presenceData.details = "Viewing Anime torrents";
  29. else if (document.location.pathname.includes("/sub/")) {
  30. title = document.querySelector(
  31. "body > main > div > div > div.box-info.trending > div > h1"
  32. );
  33. presenceData.details = "Viewing:";
  34. presenceData.state = title.textContent;
  35. } else if (document.location.pathname.includes("/cat/Apps/"))
  36. presenceData.details = "Viewing Apps Torrents";
  37. else if (document.location.pathname.includes("/cat/Documentaries/"))
  38. presenceData.details = "Viewing Documentaries Torrents";
  39. else if (document.location.pathname.includes("/cat/Games/"))
  40. presenceData.details = "Viewing Games Torrents";
  41. else if (document.location.pathname.includes("/cat/Movies/"))
  42. presenceData.details = "Viewing Movies Torrents";
  43. else if (document.location.pathname.includes("/cat/Music/"))
  44. presenceData.details = "Viewing Music Torrents";
  45. else if (document.location.pathname.includes("/cat/Other/"))
  46. presenceData.details = "Viewing Other Torrents";
  47. else if (document.location.pathname.includes("/cat/TV/"))
  48. presenceData.details = "Viewing TV Torrents";
  49. else if (document.location.pathname.includes("/cat/XXX/"))
  50. presenceData.details = "Viewing XXX Torrents";
  51. else if (document.location.pathname.includes("/upload"))
  52. presenceData.details = "Uploading something...";
  53. else if (document.location.pathname.includes("/rules")) {
  54. presenceData.details = "Reading the rules";
  55. presenceData.smallImageKey = Assets.Reading;
  56. } else if (document.location.pathname.includes("/contact")) {
  57. presenceData.details = "Writing to 1337x";
  58. presenceData.smallImageKey = Assets.Writing;
  59. } else if (document.location.pathname.includes("/about")) {
  60. presenceData.details = "Reading about 1337x";
  61. presenceData.smallImageKey = Assets.Reading;
  62. } else if (document.location.pathname.includes("/torrent/")) {
  63. presenceData.details = "Viewing torrent:";
  64. title = document.querySelector(
  65. "body > main > div > div > div > div.box-info-heading.clearfix > h1"
  66. );
  67. presenceData.state = title.textContent;
  68. } else if (document.location.pathname.includes("/search")) {
  69. search = document.querySelector(
  70. "body > main > div > div > div > div.box-info-heading.clearfix > h1 > span"
  71. );
  72. presenceData.details = "Searching for:";
  73. presenceData.state = search.textContent;
  74. presenceData.smallImageKey = Assets.Search;
  75. }
  76. if (presenceData.details) presence.setActivity(presenceData);
  77. else presence.setActivity();
  78. });