diff --git a/websites/M/meow.camera/metadata.json b/websites/M/meow.camera/metadata.json new file mode 100644 index 000000000000..3b1699ce8fc0 --- /dev/null +++ b/websites/M/meow.camera/metadata.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.10", + "author": { + "id": "189682724334862336", + "name": "azuretst" + }, + "service": "meow.camera", + "description": { + "en": "meow.camera is an alternative viewer for feeders from the Hello Street Cat / JieMao (街猫) app." + }, + "url": "meow.camera", + "matches": [ + "*://meow.camera/*" + ], + "version": "1.0.0", + "logo": "https://i.postimg.cc/GhMJx6PB/logo.png", + "thumbnail": "https://i.postimg.cc/GhshXyGk/Screenshot-1.jpg", + "color": "#000000", + "category": "videos", + "tags": [ + "cats", + "livestream", + "video" + ] +} \ No newline at end of file diff --git a/websites/M/meow.camera/presence.ts b/websites/M/meow.camera/presence.ts new file mode 100644 index 000000000000..606750c547e6 --- /dev/null +++ b/websites/M/meow.camera/presence.ts @@ -0,0 +1,52 @@ +const presence = new Presence({ + clientId: "1219194850767929374", +}); +let browsingTimestamp = Math.floor(Date.now() / 1000); + +const enum Assets { + Logo = "https://i.postimg.cc/GhMJx6PB/logo.png", +} + +presence.on("UpdateData", async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + }; + + presenceData.details = document.querySelector(".feeder-title").textContent; + presenceData.state = getStats(); + setTimestamps(document.querySelector("video"), presenceData); + presenceData.buttons = [ + { + label: "View Feeder", + url: document.location.href, + }, + ]; + presence.setActivity(presenceData); +}); + +function getStats(): string { + let stats = ""; + const snack = document.querySelector("[title='Snack stock']"), + kibble = document.querySelector("[title='Kibble stock']"), + temp = document.querySelector("[title='Feeder temperature']"); + + if (!snack || !kibble || !temp) return stats; + + stats = `🍪: ${snack.textContent === "" ? "🚫" : snack.textContent} | 🍿: ${ + kibble.textContent === "" ? "🚫" : kibble.textContent + } | 🌡️: ${temp.textContent === "" ? "🚫" : temp.textContent} `; + + return stats; +} + +function setTimestamps( + element: HTMLVideoElement, + presenceData: PresenceData +): void { + if (element.paused) { + delete presenceData.startTimestamp; + browsingTimestamp = Math.floor(Date.now() / 1000); + presenceData.smallImageKey = Assets.Pause; + } else presenceData.smallImageKey = Assets.Live; +}