-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |