presence.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. const presence = new Presence({
  2. clientId: "711393222252822539",
  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/B/Bungie/assets/logo.png",
  9. startTimestamp: browsingTimestamp,
  10. },
  11. path = document.location.pathname;
  12. if (
  13. window.location.hostname === "bungie.net" ||
  14. window.location.hostname === "www.bungie.net"
  15. )
  16. presenceData.details = "Viewing the Bungie.net Homepage";
  17. else if (window.location.hostname === "comics.bungie.net")
  18. presenceData.details = "Readig Destiny Comics";
  19. switch (path) {
  20. case "/7/en/Destiny/NewLight": {
  21. presenceData.details = "Looking at Destiny Two NewLight";
  22. break;
  23. }
  24. case "/7/en/Destiny/Shadowkeep": {
  25. presenceData.details = "Checking out Destiny Two Shadowkeep";
  26. break;
  27. }
  28. case "/7/en/Destiny/Forsaken": {
  29. presenceData.details = "Checking out Destiny Two Forsaken";
  30. break;
  31. }
  32. case "/7/en/Seasons/SeasonOfTheWorthy": {
  33. presenceData.details = "Checking out Destiny Two Season of the Worthy";
  34. break;
  35. }
  36. case "/7/en/Seasons/SeasonOfDawn": {
  37. presenceData.details = "Checking out Destiny Two Season of Dawn";
  38. break;
  39. }
  40. case "/7/en/Seasons/SeasonOfTheUndying": {
  41. presenceData.details = "Checking out Destiny Two Season of the Undying";
  42. break;
  43. }
  44. default:
  45. if (path.includes("/en/Explore/Detail/News/")) {
  46. presenceData.details = `Reading ${
  47. document.querySelector("#article-container > h1").textContent
  48. }`;
  49. } else if (path === "/en/News")
  50. presenceData.details = "Cheking out news from Bungie";
  51. else if (path === "/en/ClanV2/Chat") {
  52. presenceData.details = `Looking at thier clan: ${document
  53. .querySelector(
  54. "#clanSideBar > div.container-left.customScroll.customScrollOff > a > div.compact-clanidentity-containter > div.clanNameContainer > h2"
  55. )
  56. .textContent.replace("<span>", "")
  57. .replace("</span>", "")}`;
  58. } else if (path.includes("/en/Forums/Topics")) {
  59. presenceData.details = `Looking at ${
  60. document.querySelector("head > title").textContent
  61. }`;
  62. } else if (path.includes("/en/Forums/Post/")) {
  63. presenceData.details = `Looking at: ${
  64. document.querySelector("#topicPost > div > div.threadMeta > div > h1")
  65. .textContent
  66. }By: ${
  67. document.querySelector(
  68. "#topicPost > div > div.threadMeta > div > div > div.authorMeta > a"
  69. ).textContent
  70. }`;
  71. } else if (path.includes("/en/ClanV2/MyClans"))
  72. presenceData.details = "Looking at the clans they are apart of";
  73. else if (path.includes("/en/ClanV2/Index")) {
  74. presenceData.details = `Concerding joining clan ${document.querySelector(
  75. "#mainContent > div.darkThemeContent.grid.full-screen > div > div.container_bodyContent.customScroll > div.header > div.clanIdentity > h1"
  76. )}`;
  77. } else if (path.includes("/en/ClanV2/Fireteam"))
  78. presenceData.details = "Checking out the available fireteams";
  79. else if (path.includes("/en/ClanV2/PublicFireteam")) {
  80. presenceData.details = `Interested in in fireteam ${
  81. document.querySelector(
  82. "#clan-container > div > div > div > div > div.activity-header > h2"
  83. ).textContent
  84. }`;
  85. } else if (path.includes("en/Groups/SuggestedGroups"))
  86. presenceData.details = "Looking at the groups Bungie suggested to them";
  87. else if (path.includes("en/Groups/MyGroups"))
  88. presenceData.details = "Searching for groups";
  89. else if (path.includes("en/Groups/Popular"))
  90. presenceData.details = "Looking at the groups they're apart of";
  91. else if (path.includes("/en/Groups/Search"))
  92. presenceData.details = "Searching for groups";
  93. else if (path.includes("/en/Groups/Chat")) {
  94. presenceData.details = `Interested/Joined group ${
  95. document.querySelector("#groupName").textContent
  96. }`;
  97. } else if (path.includes("/en/Community/Creations"))
  98. presenceData.details = "Looking at the creations the community made";
  99. else if (path.includes("/en/Community/Detail")) {
  100. presenceData.details = `Looking at ${
  101. document.querySelector(
  102. "#mainContent > div.community-detail-header > div > div > div.community-details.flex > div.title"
  103. ).textContent
  104. } By: ${
  105. document.querySelector(
  106. "#mainContent > div.community-detail-header > div > div > div.community-meta > span:nth-child(1) > a"
  107. ).textContent
  108. }`;
  109. } else if (path === "/en/Help")
  110. presenceData.details = "Getting help from Bungie";
  111. else if (path === "/en/Support")
  112. presenceData.details = "Getting help from Bungie";
  113. else if (path.includes("/en/Help/Index")) {
  114. presenceData.details = `Helpful ${
  115. document.querySelector("#searchValue").textContent
  116. }`;
  117. } else if (path.includes("/en/Help/Article/")) {
  118. presenceData.details = `Reading ${
  119. document.querySelector(
  120. "#mainContent > div.content_main > div.container_help.grid > div.container_helpContent.grid-col-9.grid-col-9-medium.grid-col-12-mobile > div.content_help > div > div.HelpItemTitle"
  121. ).textContent
  122. }`;
  123. } else if (path.includes("/en/guide/destiny2")) {
  124. presenceData.details = `Reading ${
  125. document.querySelector("#guide-container > div.header > h1")
  126. .textContent
  127. }`;
  128. } else if (path.includes("/en/Help/Troubleshoot")) {
  129. presenceData.details = `Reading ${
  130. document.querySelector(
  131. "#mainContent > div.content_main > div.container_help.grid > div.container_helpContent.grid-col-9.grid-col-9-medium.grid-col-12-mobile > div.troubleshootStep > h3"
  132. ).textContent
  133. }`;
  134. } else if (path.includes("/en/Support/Troubleshoot")) {
  135. presenceData.details = `Reading ${
  136. document.querySelector(
  137. "#mainContent > div.content_main > div.container_help.grid > div.container_helpContent.grid-col-9.grid-col-9-medium.grid-col-12-mobile > div.troubleshootStep > h3"
  138. ).textContent
  139. }`;
  140. }
  141. }
  142. if (presenceData.details) presence.setActivity(presenceData);
  143. else presence.setActivity();
  144. });