From a5ed126116dd446c1d476622eb90bdf653d4df52 Mon Sep 17 00:00:00 2001 From: joerkig <44418429+joerkig@users.noreply.github.com> Date: Sun, 26 Nov 2023 20:44:02 +0100 Subject: [PATCH] fix(Character.AI): add /chat (#7766) --- websites/C/Character.AI/metadata.json | 2 +- websites/C/Character.AI/presence.ts | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/websites/C/Character.AI/metadata.json b/websites/C/Character.AI/metadata.json index b23fb20c1d44..2f253e38d494 100644 --- a/websites/C/Character.AI/metadata.json +++ b/websites/C/Character.AI/metadata.json @@ -12,7 +12,7 @@ "beta.character.ai", "character.ai" ], - "version": "1.0.1", + "version": "1.0.2", "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Character.AI/assets/logo.png", "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Character.AI/assets/thumbnail.png", "color": "#242525", diff --git a/websites/C/Character.AI/presence.ts b/websites/C/Character.AI/presence.ts index 18fc2eeaf866..334a21d74062 100644 --- a/websites/C/Character.AI/presence.ts +++ b/websites/C/Character.AI/presence.ts @@ -16,12 +16,13 @@ presence.on("UpdateData", async () => { presence.getSetting("time"), presence.getSetting("buttons"), ]), + { pathname, href, origin } = document.location, button = { label: "View Page", - url: document.location.href, + url: href, }; - switch (document.location.pathname.split("/")[1]) { + switch (pathname.split("/")[1]) { case "": { presenceData.details = "Browsing Homepage"; break; @@ -34,6 +35,13 @@ presence.on("UpdateData", async () => { presenceData.buttons = [button]; break; } + case "chat": { + presenceData.details = "Chatting with"; + presenceData.state = + document.querySelector(".chattitle")?.childNodes[1]?.textContent; + presenceData.buttons = [button]; + break; + } case "feed": { presenceData.details = "Browsing feed"; break; @@ -41,10 +49,7 @@ presence.on("UpdateData", async () => { case "post": { presenceData.details = "Viewing post"; presenceData.state = document.querySelector( - `a[href^='${document.location.href.replace( - document.location.origin, - "" - )}']` + `a[href^='${href.replace(origin, "")}']` ).textContent; presenceData.buttons = [button]; break;