diff --git a/websites/W/Websim/metadata.json b/websites/W/Websim/metadata.json new file mode 100644 index 000000000000..626abb0c3f9a --- /dev/null +++ b/websites/W/Websim/metadata.json @@ -0,0 +1,38 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.11", + "apiVersion": 1, + "author": { + "id": "1255528657058009088", + "name": "gwashark" + }, + "service": "Websim", + "description": { + "en": "Websim.ai is an AI-powered platform that allows users to generate and explore a simulated version of the internet." + }, + "url": "websim.ai", + "version": "1.0.0", + "logo": "https://i.imgur.com/zDNmRxT.png", + "thumbnail": "https://i.imgur.com/9U7mrjE.png", + "color": "#38bdf8", + "category": "other", + "tags": [ + "websim","ai" + ], + "settings": [ + { + "id": "showButtons", + "title": "Show Buttons", + "icon": "fas fa-toggle-on", + "value": true + }, + { + "id": "btnPrivacy", + "title": "Buttons Privacy", + "icon": "fas fa-user-secret", + "value": true, + "if": { + "showButtons": true + } + } + ] +} \ No newline at end of file diff --git a/websites/W/Websim/presence.ts b/websites/W/Websim/presence.ts new file mode 100644 index 000000000000..05cbe539dd91 --- /dev/null +++ b/websites/W/Websim/presence.ts @@ -0,0 +1,74 @@ +const presence = new Presence({ + clientId: "1315383978878046411", + }), + browsingTimestamp = Math.floor(Date.now() / 1000); + +presence.on("UpdateData", async () => { + const [showButtons, btnPrivacy] = await Promise.all([ + presence.getSetting("showButtons"), + presence.getSetting("btnPrivacy"), + ]), + presenceData: PresenceData = { + startTimestamp: browsingTimestamp, + largeImageKey: "https://i.imgur.com/zDNmRxT.png", + }, + path = document.location.pathname; + + if (path === "/") presenceData.details = "Browsing the homepage."; + else if (path === "/fyp") { + presenceData.details = "Browsing the FYP."; + if (showButtons) { + presenceData.buttons = [ + { + label: "View FYP", + url: "https://websim.ai/fyp", + }, + ]; + } + } else if (path.startsWith("/@")) { + const upath = path.substring(2).split("/"), + username = upath[0]; + if (upath.length === 2) { + presenceData.details = `Viewing ${document.title}`; + presenceData.state = `By ${username}`; + if (showButtons) { + presenceData.buttons = [ + { + label: "View Project", + url: `https://websim.ai/@${username}/${upath[1]}`, + }, + ]; + } + } else { + presenceData.details = `Viewing ${username}'s profile.`; + if (showButtons) { + presenceData.buttons = [ + { + label: "View Profile", + url: `https://websim.ai/@${username}`, + }, + ]; + } + } + } else if (path.startsWith("/p/")) { + const projPath = path.substring(3).split("/"); + presenceData.details = `Viewing ${document.title}`; + presenceData.state = `${projPath[1] ? `Revision #${projPath[1]}` : ""}`; + if (showButtons) { + presenceData.buttons = [ + { + label: "View Project", + url: `https://websim.ai/p/${projPath[0]}`, + }, + ]; + if (!btnPrivacy) { + presenceData.buttons.push({ + label: "View Revision", + url: `https://websim.ai/p/${projPath[0]}/${projPath[1]}`, + }); + } + } + } + + presence.setActivity(presenceData); +});