diff --git a/websites/M/mistwarp/metadata.json b/websites/M/mistwarp/metadata.json new file mode 100644 index 000000000000..dc61b420fed9 --- /dev/null +++ b/websites/M/mistwarp/metadata.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.16", + "apiVersion": 1, + "author": { + "id": "603952506330021898", + "name": "mistium" + }, + "service": "mistwarp", + "description": { + "en": "MistWarp is a mod of Turbowarp made by Mistium intended for people who just want to squeeze that little bit more out of scratch." + }, + "url": "warp.mistium.com", + "regExp": "^https?[:][/][/]([a-z0-9-]+[.])*warp[.]mistium[.]com[/]", + "version": "1.0.0", + "logo": "https://raw.githubusercontent.com/MistWarp/.github/refs/heads/main/logo.png", + "thumbnail": "https://raw.githubusercontent.com/MistWarp/.github/refs/heads/main/thumbnail.png", + "color": "#d399e5", + "category": "other", + "tags": [ + "scratch", + "editor", + "turbowarp" + ] +} diff --git a/websites/M/mistwarp/presence.ts b/websites/M/mistwarp/presence.ts new file mode 100644 index 000000000000..1c2e7a74cf02 --- /dev/null +++ b/websites/M/mistwarp/presence.ts @@ -0,0 +1,50 @@ +const presence = new Presence({ + clientId: '1458217703742378044', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) + +enum ActivityAssets { + Logo = 'https://raw.githubusercontent.com/MistWarp/.github/refs/heads/main/logo.png', +} + +function handleEditor(presenceData: PresenceData) { + const projectTitleInput = document.querySelector('[class*="title-field"]') + const projectTitle = projectTitleInput?.value?.trim() + + if (projectTitle) { + presenceData.details = `currently editing: ${projectTitle}` + } +} + +function handleProject(presenceData: PresenceData) { + const projectTitle = document.querySelector('[class^="author-info_project-title_"]')?.textContent + + if (projectTitle) { + presenceData.details = `currently playing: ${projectTitle}` + } + // add a button + presenceData.buttons = [ + { + label: 'View Project', + url: window.location.href, + }, + ] +} + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: ActivityAssets.Logo, + startTimestamp: browsingTimestamp, + } + + const location = new URL(window.location.href) + + if (location.pathname.includes('/editor')) { + handleEditor(presenceData) + } + else if (location.hash.startsWith('#')) { + handleProject(presenceData) + } + + presence.setActivity(presenceData) +})