diff --git a/websites/S/SAKURA/metadata.json b/websites/S/SAKURA/metadata.json new file mode 100644 index 000000000000..a3f9cdfef305 --- /dev/null +++ b/websites/S/SAKURA/metadata.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.17", + "apiVersion": 1, + "author": { + "name": "Foxy", + "id": "1064801165201641592" + }, + "service": "SAKURA", + "description": { + "en": "Displays what anime or cartoon you are watching on SAKURA.", + "fr": "Affiche l'anime ou le dessin animé que vous regardez sur SAKURA." + }, + "url": "sakura.thefoxy.me", + "regExp": "^https?[:][/][/](([a-z0-9-]+[.])*sakura[.]thefoxy[.]me|localhost)(:\\d{1,5})?([/]|$)", + "version": "1.0.0", + "logo": "https://sakura.thefoxy.me/icon-512.png", + "thumbnail": "https://sakura.thefoxy.me/banner.png", + "color": "#FF2D55", + "category": "anime", + "tags": [ + "anime", + "cartoons", + "streaming", + "manga" + ] +} diff --git a/websites/S/SAKURA/presence.ts b/websites/S/SAKURA/presence.ts new file mode 100644 index 000000000000..1ee9f844c004 --- /dev/null +++ b/websites/S/SAKURA/presence.ts @@ -0,0 +1,59 @@ +import { ActivityType } from 'premid' + +const presence = new Presence({ + clientId: '1568341036894523432', +}) + +presence.on('UpdateData', async () => { + const el = document.getElementById('premid-presence') + if (el) { + const details = el.getAttribute('data-details') + const state = el.getAttribute('data-state') + const largeImage = el.getAttribute('data-large-image') + const largeText = el.getAttribute('data-large-text') + const smallImage = el.getAttribute('data-small-image') + const smallText = el.getAttribute('data-small-text') + const start = el.getAttribute('data-start') + const end = el.getAttribute('data-end') + const buttonLabel = el.getAttribute('data-button-label') + const buttonUrl = el.getAttribute('data-button-url') + + if (details) { + const isBrowsing + = !end + && (state?.includes('Parcourt') + || state?.includes('Cherche') + || state?.includes('Explore') + || state?.includes('Consulte')) + + const activity: any = { + type: isBrowsing ? ActivityType.Playing : ActivityType.Watching, + details, + state: state || undefined, + largeImageKey: largeImage || 'https://sakura.thefoxy.me/icon.png', + largeImageText: largeText || 'SAKURA', + smallImageKey: smallImage || 'https://sakura.thefoxy.me/icon.png', + smallImageText: smallText || 'SAKURA', + } + + if (start) + activity.startTimestamp = Math.floor(Number(start)) + if (end) + activity.endTimestamp = Math.floor(Number(end)) + + if (buttonLabel && buttonUrl && buttonUrl.startsWith('http')) { + activity.buttons = [ + { + label: buttonLabel.slice(0, 32), + url: buttonUrl, + }, + ] + } + + presence.setActivity(activity) + return + } + } + + presence.clearActivity() +}) diff --git a/websites/S/SAKURA/tsconfig.json b/websites/S/SAKURA/tsconfig.json new file mode 100644 index 000000000000..1a04cb0284e1 --- /dev/null +++ b/websites/S/SAKURA/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist/" + } +}