presence.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. const presence = new Presence({
  2. clientId: "807591728759570453",
  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/Binance/assets/logo.png",
  9. startTimestamp: browsingTimestamp,
  10. details: "Viewing Page:",
  11. };
  12. if (window.location.hostname === "www.binance.com") {
  13. if (window.location.pathname.includes("/markets"))
  14. presenceData.state = "Markets";
  15. else if (window.location.pathname.includes("/my/dashboard"))
  16. presenceData.state = "Dashboard";
  17. else if (window.location.pathname.includes("/my/payment"))
  18. presenceData.state = "Payment";
  19. else if (window.location.pathname.includes("/my/security"))
  20. presenceData.state = "Security";
  21. else if (window.location.pathname.includes("/my/coupon"))
  22. presenceData.state = "Reward Center";
  23. else if (window.location.pathname.includes("/my/task"))
  24. presenceData.state = "Task Center";
  25. else if (window.location.pathname.includes("/my/settings"))
  26. presenceData.state = "Settings";
  27. else if (window.location.pathname.includes("/activity/referral"))
  28. presenceData.state = "Referral";
  29. else if (window.location.pathname.includes("/my/wallet/account/main"))
  30. presenceData.state = "Main Wallet";
  31. else if (window.location.pathname.includes("/my/wallet/account/margin"))
  32. presenceData.state = "Margin Wallet";
  33. else if (window.location.pathname.includes("/my/wallet/account/futures"))
  34. presenceData.state = "Futures Wallet";
  35. else if (window.location.pathname.includes("/my/wallet/account/c2c"))
  36. presenceData.state = "P2P Wallet";
  37. else if (window.location.pathname.includes("/my/wallet/account/saving"))
  38. presenceData.state = "Earn Wallet";
  39. else if (window.location.pathname.includes("/my/wallet/account/mining"))
  40. presenceData.state = "Pool Wallet";
  41. else if (window.location.pathname.includes("/my/wallet"))
  42. presenceData.state = "Wallet";
  43. else if (window.location.pathname.includes("/pos"))
  44. presenceData.state = "Locked Staking";
  45. else if (window.location.pathname.includes("/defi-staking"))
  46. presenceData.state = "DeFi Staking";
  47. else if (window.location.pathname.includes("/broker"))
  48. presenceData.state = "Broker";
  49. else if (window.location.pathname.includes("/about"))
  50. presenceData.state = "About";
  51. else if (window.location.pathname.includes("/career"))
  52. presenceData.state = "Binance Careers";
  53. else if (window.location.pathname.includes("/press"))
  54. presenceData.state = "Binance Press Center";
  55. else if (window.location.pathname.includes("/community"))
  56. presenceData.state = "Binance Community";
  57. else if (window.location.pathname.includes("/earn"))
  58. presenceData.state = "Binance Earn";
  59. else if (window.location.pathname.includes("/blog"))
  60. presenceData.state = "Binance Blog";
  61. else if (window.location.pathname.includes("/support"))
  62. presenceData.state = "Binance Support";
  63. else if (window.location.pathname.includes("/terms"))
  64. presenceData.state = "Terms of Use";
  65. else if (window.location.pathname.includes("/privacy"))
  66. presenceData.state = "Privacy Policy";
  67. else if (window.location.pathname.includes("/leveraged-tokens"))
  68. presenceData.state = "Leveraged Tokens";
  69. else if (window.location.pathname.includes("/loan"))
  70. presenceData.state = "Crypto Loans";
  71. else if (window.location.pathname.includes("/stock-token/trade")) {
  72. presenceData.details = "Trading Stock Tokens:";
  73. presenceData.state = document
  74. .querySelector("div.css-vurnku > h1")
  75. .textContent.trim();
  76. } else if (window.location.pathname.includes("/stock-token"))
  77. presenceData.state = "Stock Tokens";
  78. else if (window.location.pathname.includes("/swap/liquidity"))
  79. presenceData.state = "Liquid Swap";
  80. else if (window.location.pathname.includes("/futuresng-activity/battle"))
  81. presenceData.state = "Futures Battle";
  82. else if (
  83. window.location.pathname.includes("/futuresng-activity/leaderboard")
  84. )
  85. presenceData.state = "Futures Leaderboard";
  86. else if (window.location.pathname.includes("/multipleChart"))
  87. presenceData.details = "Viewing Charts...";
  88. else if (window.location.pathname.includes("/convert")) {
  89. presenceData.details = "Converting Crypto:";
  90. presenceData.state = `${document
  91. .querySelectorAll("div.css-9wgib6")[0]
  92. .textContent.trim()} to ${document
  93. .querySelectorAll("div.css-9wgib6")[1]
  94. .textContent.trim()}`;
  95. } else if (window.location.pathname.includes("/trade")) {
  96. const tradeLeverage = document
  97. .querySelector("div.css-t7ggbb > span")
  98. ?.textContent?.trim();
  99. switch (new URLSearchParams(window.location.search).get("type")) {
  100. case "spot":
  101. presenceData.details = "Trading on Spot:";
  102. break;
  103. case "isolated":
  104. presenceData.details = `Trading on Isolated ${tradeLeverage}:`;
  105. break;
  106. case "cross":
  107. presenceData.details = `Trading on Cross ${tradeLeverage}:`;
  108. break;
  109. default:
  110. presenceData.details = "Trading:";
  111. break;
  112. }
  113. presenceData.state = document
  114. .querySelector("div.css-t7ggbb > div.css-mzoqhr > h1")
  115. .textContent.trim();
  116. } else if (
  117. window.location.pathname.includes("/futures") ||
  118. window.location.pathname.includes("/delivery")
  119. ) {
  120. presenceData.details = `Futures Trading on ${document
  121. .querySelector("div.css-1kk0gzs > a:nth-child(2)")
  122. .textContent.trim()}:`;
  123. presenceData.state = `${document
  124. .querySelector("div.css-1wd9czp > h1")
  125. .textContent.trim()} ${document
  126. .querySelector("div.css-1wd9czp > div > h1")
  127. .textContent.trim()}`;
  128. } else presenceData.details = "Browsing...";
  129. } else if (window.location.hostname.startsWith("voptions"))
  130. presenceData.state = "Vanilla Options";
  131. else if (window.location.hostname.startsWith("cloud"))
  132. presenceData.state = "Binance Cloud";
  133. else if (window.location.hostname.startsWith("pool"))
  134. presenceData.state = "Binance Pool";
  135. else if (window.location.hostname.startsWith("academy"))
  136. presenceData.state = "Binance Academy";
  137. else if (window.location.hostname.startsWith("launchpad"))
  138. presenceData.state = "Binance Launchpad";
  139. else if (window.location.hostname.startsWith("research"))
  140. presenceData.state = "Binance Research";
  141. else presenceData.details = "Browsing...";
  142. presence.setActivity(presenceData);
  143. });