-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const iframe = new iFrame(); | ||
|
||
iframe.on("UpdateData", async () => { | ||
let video: HTMLVideoElement; | ||
|
||
if (document.querySelector(".jw-video")) | ||
video = document.querySelector(".jw-video"); | ||
else if (document.querySelector(".html5-video-container")) | ||
video = document.querySelector(".html5-video-container > video"); | ||
|
||
if (video && !isNaN(video.duration)) { | ||
iframe.send({ | ||
iframeVideo: { | ||
iFrameVideo: true, | ||
currTime: video.currentTime, | ||
dur: video.duration, | ||
paused: video.paused, | ||
}, | ||
}); | ||
} | ||
}); | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"$schema": "https://schemas.premid.app/metadata/1.12", | ||
"apiVersion": 1, | ||
"author": { | ||
"id": "354233941550694400", | ||
"name": "kuriel." | ||
}, | ||
"service": "Pi Fansubs", | ||
"description": { | ||
"en": "PiFansubs is a free brazilian streaming site where you can watch subtitled bls content.", | ||
"pt": "PiFansubs é um site de streaming gratuito onde você pode assistir a conteúdos bls legendados.", | ||
"pt_BR": "PiFansubs é um site de streaming gratuito onde você pode assistir a conteúdos bls legendados." | ||
}, | ||
"url": [ | ||
"pifansubs.club", | ||
"www.pifansubs.club" | ||
], | ||
"version": "1.0.0", | ||
"logo": "https://i.imgur.com/RNFFxad.jpeg", | ||
"thumbnail": "https://i.imgur.com/sGD1G3v.png", | ||
"color": "#00be08", | ||
"category": "videos", | ||
"tags": [ | ||
"series", | ||
"movies" | ||
], | ||
"iframe": true, | ||
"iFrameRegExp": "blsplayer[.]com|csst[.]online|pifansubs[.]club" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
const presence = new Presence({ | ||
clientId: "1329883342132351058", | ||
}), | ||
strings = presence.getStrings({ | ||
playing: "general.playing", | ||
paused: "general.paused", | ||
searchFor: "general.searchFor", | ||
viewHome: "general.viewHome", | ||
viewGenre: "general.viewGenre", | ||
viewPage: "general.viewPage", | ||
viewSeries: "general.viewSeries", | ||
viewMovie: "general.viewMovie", | ||
buttonViewSeries: "general.buttonViewSeries", | ||
buttonViewEpisode: "general.buttonViewEpisode", | ||
buttonWatchMovie: "general.buttonWatchMovie", | ||
viewCategory: "general.viewCategory", | ||
}), | ||
browsingTimestamp = Math.floor(Date.now() / 1000); | ||
|
||
const enum Assets { | ||
Logo = "https://i.imgur.com/RNFFxad.jpeg", | ||
} | ||
|
||
let iFrameVideo: boolean, currentTime: number, duration: number; | ||
|
||
interface IFrameData { | ||
iframeVideo: { | ||
iFrameVideo: boolean; | ||
currTime: number; | ||
dur: number | null; | ||
}; | ||
} | ||
|
||
presence.on("iFrameData", (data: IFrameData) => { | ||
if (data.iframeVideo.dur) { | ||
({ iFrameVideo } = data.iframeVideo); | ||
currentTime = data.iframeVideo.currTime; | ||
duration = data.iframeVideo.dur; | ||
} | ||
}); | ||
|
||
function textContent(tags: string) { | ||
return document.querySelector(tags)?.textContent?.trim(); | ||
} | ||
|
||
function getImage(tags: string) { | ||
return document.querySelector<HTMLImageElement>(tags)?.src ?? Assets.Logo; | ||
} | ||
|
||
presence.on("UpdateData", async () => { | ||
const { pathname, href, search } = document.location, | ||
path = pathname.split("/"), | ||
presenceData: PresenceData = { | ||
largeImageKey: Assets.Logo, | ||
startTimestamp: browsingTimestamp, | ||
details: (await strings).viewHome, | ||
type: ActivityType.Watching, | ||
}; | ||
|
||
switch (path[1]) { | ||
case "release": { | ||
presenceData.details = "Vendo lançamentos de:"; | ||
presenceData.state = textContent(".heading-archive"); | ||
break; | ||
} | ||
case "genre": { | ||
presenceData.details = (await strings).viewGenre; | ||
presenceData.state = textContent(".heading-archive"); | ||
break; | ||
} | ||
case "series-de-tv": { | ||
if (path[2] && path[2] !== "page") { | ||
presenceData.details = (await strings).viewSeries; | ||
presenceData.state = textContent( | ||
".sheader > div:nth-child(2) > h1:nth-child(1)" | ||
); | ||
presenceData.largeImageKey = getImage(".poster > img:nth-child(1)"); | ||
presenceData.buttons = [ | ||
{ | ||
label: (await strings).buttonViewSeries, | ||
url: href, | ||
}, | ||
]; | ||
} else presenceData.details = "Explorando Séries"; | ||
break; | ||
} | ||
case "filmes": { | ||
if (path[2] && path[2] !== "page") { | ||
presenceData.details = (await strings).viewMovie; | ||
presenceData.state = textContent( | ||
".sheader > div:nth-child(2) > h1:nth-child(1)" | ||
); | ||
presenceData.largeImageKey = getImage(".poster > img:nth-child(1)"); | ||
if (iFrameVideo && !isNaN(duration)) { | ||
[presenceData.startTimestamp, presenceData.endTimestamp] = | ||
presence.getTimestamps( | ||
Math.floor(currentTime), | ||
Math.floor(duration) | ||
); | ||
presenceData.smallImageKey = Assets.Play; | ||
presenceData.smallImageText = (await strings).playing; | ||
} else { | ||
presenceData.smallImageKey = Assets.Pause; | ||
presenceData.smallImageText = (await strings).paused; | ||
} | ||
presenceData.buttons = [ | ||
{ | ||
label: (await strings).buttonWatchMovie, | ||
url: href, | ||
}, | ||
]; | ||
} else presenceData.details = "Explorando Filmes"; | ||
break; | ||
} | ||
case "episodios": { | ||
if (path[2] && path[2] !== "page") { | ||
const match = textContent(".epih1").match(/(\d+)x(\d+)/); | ||
|
||
presenceData.details = (await strings).viewSeries; | ||
presenceData.state = textContent(".epih1").replace(/: (\d+)x(\d+)/, ""); | ||
presenceData.largeImageKey = getImage( | ||
".mark-1 > div:nth-child(1) > img:nth-child(1)" | ||
); | ||
presenceData.largeImageText = match | ||
? `Season ${match[1]}, Episode ${match[2]}` | ||
: textContent(".epih1"); | ||
if (iFrameVideo && !isNaN(duration)) { | ||
[presenceData.startTimestamp, presenceData.endTimestamp] = | ||
presence.getTimestamps( | ||
Math.floor(currentTime), | ||
Math.floor(duration) | ||
); | ||
presenceData.smallImageKey = Assets.Play; | ||
presenceData.smallImageText = (await strings).playing; | ||
} else { | ||
presenceData.smallImageKey = Assets.Pause; | ||
presenceData.smallImageText = (await strings).paused; | ||
} | ||
presenceData.buttons = [ | ||
{ | ||
label: (await strings).buttonViewEpisode, | ||
url: href, | ||
}, | ||
]; | ||
} else presenceData.details = "Explorando Episódios"; | ||
break; | ||
} | ||
case "avisos-e-informacoes": { | ||
presenceData.details = (await strings).viewPage; | ||
presenceData.state = "Avisos"; | ||
break; | ||
} | ||
case "category": { | ||
presenceData.details = (await strings).viewCategory; | ||
presenceData.state = textContent( | ||
".content > header:nth-child(1) > h1:nth-child(1)" | ||
).replace("Category Archives: ", ""); | ||
break; | ||
} | ||
default: { | ||
if (search) { | ||
presenceData.details = (await strings).searchFor; | ||
presenceData.state = decodeURI(search.split("=")[1]).replaceAll( | ||
"+", | ||
" " | ||
); | ||
} else if (path[1].length >= 1) { | ||
presenceData.details = (await strings).viewPage; | ||
presenceData.state = textContent(".titl"); | ||
} | ||
break; | ||
} | ||
} | ||
presence.setActivity(presenceData); | ||
}); |