12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- const presence = new Presence({
- clientId: "630570838084812801",
- });
- const enum Assets {
- Logo = "https://cdn.rcd.gg/PreMiD/websites/W/wikiHow/assets/logo.png",
- }
- presence.on("UpdateData", async () => {
- const path = document.location.pathname,
- topic = document.querySelector("#section_0"),
- category = document.querySelector("#article > div.wh_block > h1");
- if (topic && topic.textContent !== "") {
- const author =
- document.querySelector("#sp_expert_name") ||
- document.querySelector("#sp_expert_team"),
- date = document.querySelector("#expert_coauthor > p");
- return presence.setActivity({
- details: topic.textContent,
- state: `by ${
- author && author.textContent !== "" ? author.textContent : "unknown"
- }${
- date && date.textContent !== ""
- ? ` (${date.textContent.replace("Updated: ", "")})`
- : ""
- } `,
- largeImageKey: Assets.Logo,
- smallImageKey: Assets.Logo,
- smallImageText: decodeURIComponent(document.location.href),
- startTimestamp: Math.floor(Date.now() / 1000),
- });
- }
- if (category && category.textContent !== "") {
- return presence.setActivity({
- details: "Viewing a category:",
- state: category.textContent,
- largeImageKey:
- "https://cdn.rcd.gg/PreMiD/websites/W/wikiHow/assets/logo.png",
- smallImageKey: Assets.Logo,
- smallImageText: decodeURIComponent(document.location.href),
- startTimestamp: Math.floor(Date.now() / 1000),
- });
- }
- if (path === "/index.php") {
- // Note that I (EGGSY) didn't work on this part, I don't know if it's working on the main site but I'm sure it doesn't work on Spanish version.
- const newTopic = document.querySelectorAll(".firstHeading")[0]
- ? document.querySelectorAll(".firstHeading")[0].textContent
- : null;
- return presence.setActivity({
- details: "Editing/Writing How to",
- state: `Topic: ${newTopic ?? "Unknown."} `,
- largeImageKey:
- "https://cdn.rcd.gg/PreMiD/websites/W/wikiHow/assets/logo.png",
- smallImageKey: Assets.Logo,
- smallImageText: decodeURIComponent(document.location.href),
- startTimestamp: Math.floor(Date.now() / 1000),
- });
- }
- if (path === "/wikiHowTo") {
- const searching = document.location.search
- .replace("?search=", "")
- .split("+")
- .join(" ");
- return presence.setActivity({
- details: "Searching for:",
- state: `${searching[0].toUpperCase() + searching.slice(1).toLowerCase()}`,
- largeImageKey:
- "https://cdn.rcd.gg/PreMiD/websites/W/wikiHow/assets/logo.png",
- smallImageKey: Assets.Logo,
- smallImageText: "Searching...",
- startTimestamp: Math.floor(Date.now() / 1000),
- });
- }
- return presence.setActivity({
- details: "Viewing a page:",
- state: "Homepage",
- largeImageKey:
- "https://cdn.rcd.gg/PreMiD/websites/W/wikiHow/assets/logo.png",
- smallImageKey: Assets.Logo,
- startTimestamp: Math.floor(Date.now() / 1000),
- });
- });
|