diff --git a/websites/P/Psychonaut Wiki/metadata.json b/websites/P/Psychonaut Wiki/metadata.json new file mode 100644 index 000000000000..84bfb4b00b04 --- /dev/null +++ b/websites/P/Psychonaut Wiki/metadata.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.16", + "apiVersion": 1, + "author": { + "id": "538604507064696832", + "name": "talon2" + }, + "service": "Psychonaut Wiki", + "altnames": [ + "PsychonautWiki" + ], + "description": { + "en": "PsychonautWiki is an encyclopedia that documents all aspects of psychonautic theory from an evidence-based perspective. It provides education, encourages safe practices, and emphasizes that substances should not be abused. Do not do drugs." + }, + "url": "psychonautwiki.org", + "regExp": "^https?[:][/][/]([a-z0-9-]+[.])*psychonautwiki[.]org[/]", + "version": "1.0.0", + "logo": "https://i.imgur.com/GPxHYOV.png", + "thumbnail": "https://i.imgur.com/QwNGXcq.png", + "color": "#808080", + "category": "other", + "tags": [ + "drugs", + "harm-reduction", + "psychonaut" + ] +} diff --git a/websites/P/Psychonaut Wiki/presence.ts b/websites/P/Psychonaut Wiki/presence.ts new file mode 100644 index 000000000000..baf9ffc966eb --- /dev/null +++ b/websites/P/Psychonaut Wiki/presence.ts @@ -0,0 +1,53 @@ +const browsingTimestamp = Math.floor(Date.now() / 1000) + +const presence = new Presence({ + clientId: '1432152324163502130', +}) + +presence.on('UpdateData', async () => { + const { pathname, search } = document.location + const params = new URLSearchParams(search) + + let articleName: string | null = null + + // /w/index.php?title=ArticleName + if (params.has('title')) { + articleName = decodeURIComponent(params.get('title')!) + .replace(/_/g, ' ') + .trim() + } + // /wiki/ArticleName + else if (pathname.startsWith('/wiki/')) { + articleName = decodeURIComponent(pathname.slice(6)) + .replace(/_/g, ' ') + .trim() + } + + const action = params.get('action') + const isEditing + = params.has('veaction') + || action === 'edit' + || action === 'submit' + + const presenceData: PresenceData = { + largeImageKey: 'https://i.imgur.com/GPxHYOV.png', + startTimestamp: browsingTimestamp, + } + + if (isEditing) { + presenceData.details = articleName + ? `Editing article "${articleName}"` + : 'Editing article' + } + else if (pathname === '/wiki/Main_Page') { + presenceData.details = 'Browsing the Main Page' + } + else if (articleName) { + presenceData.details = `Browsing the article "${articleName}"` + } + else { + presenceData.details = 'Browsing the Wiki' + } + + presence.setActivity(presenceData) +})