Skip to content

Commit 1ac6450

Browse files
authored
feat(AnimeciX): add iframe support (#9334)
1 parent 3c41286 commit 1ac6450

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

websites/A/AnimeciX/iframe.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const iframe = new iFrame()
2+
3+
iframe.on('UpdateData', async () => {
4+
const video = document.querySelector('video')
5+
6+
if (video) {
7+
const data = {
8+
currentTime: video.currentTime,
9+
paused: video.paused,
10+
duration: video.duration,
11+
}
12+
iframe.send(data)
13+
}
14+
})

websites/A/AnimeciX/metadata.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"animecix.net",
2121
"anm.cx"
2222
],
23-
"version": "1.0.2",
23+
"version": "1.0.3",
2424
"logo": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeciX/assets/logo.png",
2525
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/A/AnimeciX/assets/thumbnail.jpeg",
2626
"color": "#b6eafd",
@@ -30,5 +30,7 @@
3030
"dizi",
3131
"turkish",
3232
"movie"
33-
]
33+
],
34+
"iframe": true,
35+
"iFrameRegExp": "https?:\\/\\/anm\\.cx\\/secure\\/best-video\\?.*|https?:\\/\\/tau-video\\.xyz\\/embed\\/.*|https?:\\/\\/ok\\.ru\\/videoembed\\/.*|https?:\\/\\/drive\\.google\\.com\\/file\\/d\\/.*|https?:\\/\\/uqload\\.io\\/.*|https?:\\/\\/doodstream\\.com\\/e\\/.*"
3436
}

websites/A/AnimeciX/presence.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ActivityType, Assets } from 'premid'
1+
import { ActivityType, Assets, getTimestamps } from 'premid'
22

33
const presence = new Presence({
44
clientId: '1336362292622655569',
@@ -10,6 +10,20 @@ enum Images {
1010
SettingsICO = 'https://cdn.rcd.gg/PreMiD/websites/A/AnimeciX/assets/0.png',
1111
}
1212

13+
interface iframeData {
14+
duration: number
15+
currentTime: number
16+
paused: boolean
17+
}
18+
let video: iframeData | null = null
19+
20+
presence.on('iFrameData', (data: unknown) => {
21+
if (data) {
22+
video = data as iframeData
23+
updatePresence()
24+
}
25+
})
26+
1327
function observeDOMChanges(callback: () => void) {
1428
new MutationObserver(() => {
1529
callback()
@@ -44,6 +58,18 @@ function updatePresence() {
4458
?.textContent || 'Loading'
4559
presenceData.state = document.querySelector('.episode-number')?.textContent || 'Loading'
4660

61+
if (video) {
62+
presenceData.smallImageKey = video.paused
63+
? Assets.Pause
64+
: Assets.Play
65+
presenceData.smallImageText = video.paused ? 'Duraklatıldı' : 'Oynatılıyor';
66+
67+
[presenceData.startTimestamp, presenceData.endTimestamp] = getTimestamps(video.currentTime, video.duration)
68+
69+
if (video.paused)
70+
delete presenceData.endTimestamp
71+
}
72+
4773
// EPİSODES PAGE
4874
}
4975
else if (

0 commit comments

Comments
 (0)