diff --git a/websites/A/AnimeVault/metadata.json b/websites/A/AnimeVault/metadata.json new file mode 100644 index 000000000000..737100948e06 --- /dev/null +++ b/websites/A/AnimeVault/metadata.json @@ -0,0 +1,40 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.17", + "apiVersion": 1, + "author": { + "id": "1521564654491402330", + "name": "bunbongonvl" + }, + "service": "AnimeVault", + "description": { + "en": "Watch Anime and movies with AI Japanese subtitle learning and Watch Party rooms.", + "vi": "Xem phim Anime và phim chất lượng cao tích hợp phòng xem chung và hỗ trợ học tiếng Nhật AI." + }, + "url": "bunbongonvl.online", + "regExp": "^https?[:][/][/]([a-z0-9-]+[.])*bunbongonvl[.]online[/]", + "version": "1.0.0", + "logo": "https://files.catbox.moe/ghuz3s.png", + "thumbnail": "https://files.catbox.moe/854obg.png", + "color": "#060810", + "category": "anime", + "tags": [ + "anime", + "movies", + "japanese", + "watchparty" + ], + "settings": [ + { + "id": "timestamps", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/A/AnimeVault/presence.ts b/websites/A/AnimeVault/presence.ts new file mode 100644 index 000000000000..41895ae799a4 --- /dev/null +++ b/websites/A/AnimeVault/presence.ts @@ -0,0 +1,158 @@ +import { ActivityType, Assets, getTimestamps } from 'premid' + +const presence = new Presence({ + clientId: '1521564654491402330', +}) + +enum ActivityAssets { + Logo = 'https://files.catbox.moe/ghuz3s.png', +} + +const browsingTimestamp = Math.floor(Date.now() / 1000) + +presence.on('UpdateData', async () => { + const { pathname, href } = document.location + const video = document.querySelector('video') + + const [showButtons, showTimestamps] = await Promise.all([ + presence.getSetting('buttons'), + presence.getSetting('timestamps'), + ]) + + const presenceData: PresenceData = { + type: ActivityType.Watching, + largeImageKey: ActivityAssets.Logo, + largeImageText: 'AnimeVault - bunbongonvl.online', + } + + if (showTimestamps) { + presenceData.startTimestamp = browsingTimestamp + } + + const pageFirstTitle = document.title ? (document.title.split('-')[0]?.trim() ?? '') : '' + + switch (true) { + case pathname.startsWith('/xem/'): { + const heading = document.querySelector('h1')?.textContent?.trim() || '' + const cleanTitle = heading.replace(/^(?:Xem Phim|Phim)\s+/i, '') || pageFirstTitle + + presenceData.details = cleanTitle || 'Đang xem phim' + + if (video && !Number.isNaN(video.duration) && video.duration > 0) { + if (showTimestamps) { + [presenceData.startTimestamp, presenceData.endTimestamp] = getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) + } + + if (video.paused) { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Tạm dừng' + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + else { + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Đang phát' + } + } + else { + presenceData.state = 'Đang tải trình phát...' + } + + if (showButtons) { + presenceData.buttons = [ + { + label: 'Cùng Xem Phim Này', + url: href, + }, + ] + } + break + } + + case pathname.startsWith('/xem-chung/'): { + const roomTitle = document.querySelector('.wp-room-header h1')?.textContent?.trim() || 'Phòng chiếu VIP' + presenceData.details = 'Phòng Xem Chung' + presenceData.state = roomTitle + + if (video && !Number.isNaN(video.duration) && video.duration > 0) { + if (showTimestamps) { + [presenceData.startTimestamp, presenceData.endTimestamp] = getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) + } + + if (video.paused) { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Tạm dừng' + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + else { + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Đang phát' + } + } + + if (showButtons) { + presenceData.buttons = [ + { + label: 'Tham Gia Phòng Chiếu', + url: href, + }, + ] + } + break + } + + case pathname === '/xem-chung': { + presenceData.details = 'Sảnh Xem Chung' + presenceData.state = 'Tìm kiếm phòng chiếu' + break + } + + case pathname.startsWith('/quiz'): { + presenceData.details = 'Luyện Tập Tiếng Nhật AI' + presenceData.state = 'Quiz từ vựng Anime' + break + } + + case pathname.startsWith('/lich-chieu'): { + presenceData.details = 'Lịch Chiếu Anime' + presenceData.state = 'Xem lịch phát sóng' + break + } + + case pathname.startsWith('/phim/'): { + const movieTitle = document.querySelector('h1')?.textContent?.trim() || pageFirstTitle + presenceData.details = 'Thông tin phim' + presenceData.state = movieTitle || 'Chi tiết tác phẩm' + + if (showButtons) { + presenceData.buttons = [ + { + label: 'Xem Chi Tiết Phim', + url: href, + }, + ] + } + break + } + + default: { + presenceData.details = 'Khám phá kho phim' + presenceData.state = 'Trang chủ' + break + } + } + + if (!showTimestamps) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + + presence.setActivity(presenceData) +})