presence.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. const presence = new Presence({
  2. clientId: "846071986902925312",
  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/N/Nekopost/assets/logo.png",
  9. startTimestamp: browsingTimestamp,
  10. };
  11. if (document.location.pathname.includes("/manga")) {
  12. if (document.location.pathname.includes("/manga/")) {
  13. if (document.querySelector("head > title").textContent.includes("Ch")) {
  14. presenceData.details = `Manga :${
  15. document.querySelector("head > title").textContent.split("-")[1]
  16. }!`;
  17. presenceData.state = document
  18. .querySelector("head > title")
  19. .textContent.split(" ")[0];
  20. presenceData.smallImageKey = Assets.Reading;
  21. } else {
  22. presenceData.details = `Manga :${
  23. document.querySelector("head > title").textContent
  24. }!`;
  25. presenceData.smallImageKey = Assets.Search;
  26. }
  27. } else {
  28. presenceData.details = "กำลังเลือก Manga";
  29. presenceData.smallImageKey = Assets.Search;
  30. }
  31. } else if (document.location.pathname.includes("/novel")) {
  32. if (document.location.pathname.includes("/novel/")) {
  33. if (document.querySelector("head > title").textContent.includes("Ch")) {
  34. presenceData.details = `Novel :${
  35. document.querySelector("head > title").textContent.split("-")[1]
  36. }!`;
  37. presenceData.state = document
  38. .querySelector("head > title")
  39. .textContent.split(" ")[0];
  40. presenceData.smallImageKey = Assets.Reading;
  41. } else {
  42. presenceData.details = `Novel :${
  43. document.querySelector("head > title").textContent
  44. }!`;
  45. presenceData.smallImageKey = Assets.Search;
  46. }
  47. } else {
  48. presenceData.details = "กำลังเลือก Novel";
  49. presenceData.smallImageKey = Assets.Search;
  50. }
  51. } else if (document.location.pathname.includes("/comic")) {
  52. if (document.location.pathname.includes("/comic/")) {
  53. if (document.querySelector("head > title").textContent.includes("Ch")) {
  54. presenceData.details = `Comic :${
  55. document.querySelector("head > title").textContent.split("-")[1]
  56. }!`;
  57. presenceData.state = document
  58. .querySelector("head > title")
  59. .textContent.split(" ")[0];
  60. presenceData.smallImageKey = Assets.Reading;
  61. } else {
  62. presenceData.details = `Comic :${
  63. document.querySelector("head > title").textContent
  64. }!`;
  65. presenceData.smallImageKey = Assets.Search;
  66. }
  67. } else {
  68. presenceData.details = "กำลังเลือก Original Comic";
  69. presenceData.smallImageKey = Assets.Search;
  70. }
  71. } else if (document.location.pathname.includes("/fiction")) {
  72. if (document.location.pathname.includes("/fiction/")) {
  73. if (document.querySelector("head > title").textContent.includes("Ch")) {
  74. presenceData.details = `ONovel :${
  75. document.querySelector("head > title").textContent.split("-")[1]
  76. }!`;
  77. presenceData.state = document
  78. .querySelector("head > title")
  79. .textContent.split(" ")[0];
  80. presenceData.smallImageKey = Assets.Reading;
  81. } else {
  82. presenceData.details = `ONovel :${
  83. document.querySelector("head > title").textContent
  84. }!`;
  85. presenceData.smallImageKey = Assets.Search;
  86. }
  87. } else {
  88. presenceData.details = "กำลังเลือก Original Novel";
  89. presenceData.smallImageKey = Assets.Search;
  90. }
  91. } else if (document.location.pathname.includes("/explore")) {
  92. presenceData.details = "กำลังเลือก Project";
  93. presenceData.smallImageKey = Assets.Search;
  94. } else if (document.location.pathname === "/") {
  95. presenceData.details = "กำลังหา...";
  96. presenceData.smallImageKey = Assets.Search;
  97. }
  98. presence.setActivity(presenceData);
  99. });