diff --git a/websites/U/uwowocosplay/metadata.json b/websites/U/uwowocosplay/metadata.json new file mode 100644 index 000000000000..41c1da765a27 --- /dev/null +++ b/websites/U/uwowocosplay/metadata.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.10", + "author": { + "id": "202740603790819328", + "name": "aimslut" + }, + "service": "Uwowocosplay", + "description": { + "en": "Uwowo is a professional cosplay costume brand focusing on the high quality anime and game costumes and wigs with affordable price." + }, + "url": "uwowocosplay.com", + "matches": [ + "*://uwowocosplay.com/*" + ], + "version": "1.0.0", + "logo": "https://i.imgur.com/U2EMMgC.jpeg", + "thumbnail": "https://i.imgur.com/6091d7r.png", + "color": "#f17174", + "category": "other", + "tags": [ + "cosplay", + "cosplaying", + "costumes", + "anime" + ] +} \ No newline at end of file diff --git a/websites/U/uwowocosplay/presence.ts b/websites/U/uwowocosplay/presence.ts new file mode 100644 index 000000000000..47b6b5bc212e --- /dev/null +++ b/websites/U/uwowocosplay/presence.ts @@ -0,0 +1,87 @@ +const presence = new Presence({ + clientId: "1216150866122244096", + }), + browsingTimestamp = Math.floor(Date.now() / 1000); +const enum Assets { + Logo = "https://i.imgur.com/U2EMMgC.jpeg", +} +presence.on("UpdateData", async () => { + const presenceData: PresenceData = { + details: "Uwowo Cosplay Homepage", + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + }, + { pathname, href } = document.location; + switch (pathname.replace("/en-de", "").trim()) { + case "/": { + presenceData.details = "Browsing the Homepage"; + break; + } + case "/en-de": { + presenceData.details = "Browsing the Homepage"; + break; + } + case "/collections/shop-all": { + presenceData.details = "Browsing the shop"; + break; + } + case "/cart": { + presenceData.details = "Viewing their cart"; + break; + } + case "/account": { + presenceData.details = "Viewing their account"; + break; + } + default: { + presenceData.details = getStyle(pathname); + break; + } + } + if (pathname.startsWith("/products/")) setProduct(presenceData, href); + + presence.setActivity(presenceData); +}); + +function getStyle(pathname: string) { + const path = pathname.split("/collections/")[1]; + if (path !== null) { + return `Browsing the ${path} Collection` + .split("-") + .join(" ") + .replace("Collections", "") + .trim(); + } else return "Unknown Page"; +} + +function setProduct(presenceData: PresenceData, href: string) { + const product = document + // replace everything before Uwowo and remove the word "Costume" in regex + .querySelector(".h2.product-single__title") + ?.textContent?.replace(/.*Uwowo/, "") + ?.replace(/Costume/g, ""); + presenceData.details = `Viewing ${ + product + ?.split(" ") + ?.slice(0, product?.split(" ").length / 2) + ?.join(" ") ?? "Unknown product" + }`; + presenceData.state = + product + ?.split(" ") + ?.slice(product?.split(" ")?.length / 2) + ?.join(" ") ?? ""; + presenceData.buttons = [ + { + label: "View Cosplay", + url: href, + }, + ]; + + presenceData.largeImageKey = + document + .querySelector('[property="og:image"]') + ?.content?.split("?")?.[0] ?? Assets.Logo; + if (presenceData.largeImageKey !== Assets.Logo) + presenceData.smallImageKey = Assets.Logo; +}