Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Anime Sama): add privacy mode && feat(Voiranime) : add multilanguage, privacy mode and show buttons settings #8837

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion websites/A/Anime Sama/iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const iframe = new iFrame();

iframe.on("UpdateData", async () => {
const video = document.querySelector<HTMLVideoElement>("video");
if (!isNaN(video?.duration)) {
if (video && !isNaN(video.duration)) {
iframe.send({
currentTime: video.currentTime,
duration: video.duration,
Expand Down
24 changes: 18 additions & 6 deletions websites/A/Anime Sama/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"$schema": "https://schemas.premid.app/metadata/1.11",
"apiVersion": 1,
"author": {
"name": "RisingSunLight",
"id": "240521747852558347"
"name": "Atom Skully",
"id": "671037171611729920"
},
"contributors": [
{
"name": "Atom Skully",
"id": "671037171611729920"
"name": "RisingSunLight",
"id": "240521747852558347"
}
],
"service": "Anime Sama",
Expand All @@ -17,7 +17,7 @@
"fr": "Votre site de streaming préféré pour vos animes et scans sans pubs."
},
"url": "anime-sama.fr",
"version": "1.1.9",
"version": "1.2.0",
"logo": "https://cdn.rcd.gg/PreMiD/websites/A/Anime%20Sama/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/A/Anime%20Sama/assets/thumbnail.png",
"color": "#0063c0",
Expand All @@ -30,14 +30,26 @@
"vostfr"
],
"iframe": true,
"iFrameRegExp": ".*((sendvid)|(sibnet)|(myvi)).*",
"iFrameRegExp": ".*",

Check warning on line 33 in websites/A/Anime Sama/metadata.json

View workflow job for this annotation

GitHub Actions / Presence Validator

Presence (Anime Sama) has metadata.iFrameRegExp set to '.*', please change this if possible
"settings": [
{
"id": "buttons",
"title": "Show Buttons",
"icon": "fas fa-compress-arrows-alt",
"value": true
},
{
"id": "privacy",
"title": "Privacy Mode",
"icon": "fad fa-user-secret",
"value": false
},
{
"id": "timestamps",
"title": "Show Timestamps",
"icon": "fad fa-stopwatch",
"value": true
},
{
"id": "cover",
"title": "Show Cover",
Expand Down
79 changes: 56 additions & 23 deletions websites/A/Anime Sama/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ const enum Assets {
Logo = "https://cdn.rcd.gg/PreMiD/websites/A/Anime%20Sama/assets/logo.png",
}

interface IFrameData {
duration: number;
currentTime: number;
paused: boolean;
}

let duration: number,
currentTime: number,
paused = true;
let video = {
duration: 0,
currentTime: 0,
paused: true,
};

presence.on("iFrameData", (data: IFrameData) => {
({ duration, currentTime, paused } = data);
});
presence.on(
"iFrameData",
(data: { duration: number; currentTime: number; paused: boolean }) => {
if (data?.duration) video = data;
}
);

presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
Expand All @@ -34,16 +33,22 @@ presence.on("UpdateData", async () => {
},
{ pathname, href } = document.location,
pathArr = pathname.split("/"),
[showButtons, showCover] = await Promise.all([
[showButtons, privacyMode, showTimestamps, showCover] = await Promise.all([
presence.getSetting<boolean>("buttons"),
presence.getSetting<boolean>("privacy"),
presence.getSetting<boolean>("timestamps"),
presence.getSetting<boolean>("cover"),
]);

if (Object.keys(staticPages).includes(pathArr[1]) && pathArr.length <= 3)
if (Object.keys(staticPages).includes(pathArr[1]) && pathArr.length <= 3) {
presenceData.details = staticPages[pathArr[1]];
else if (pathArr.length === 4) {
if (privacyMode) presenceData.details = "Navigue...";
} else if (pathArr.length === 4) {
const pageTitle = document.querySelector(
"h2.border-slate-500"
)?.textContent;
presenceData.details =
document.querySelector("h2.border-slate-500")?.textContent === "Anime"
pageTitle === "Anime"
? "Regarde la page de l'anime"
: "Regarde la page du manga";
presenceData.state = document
Expand All @@ -53,6 +58,13 @@ presence.on("UpdateData", async () => {
presenceData.largeImageKey =
document.querySelector<HTMLMetaElement>("[property='og:image']")
?.content ?? Assets.Logo;
if (privacyMode) {
delete presenceData.state;
presenceData.details =
pageTitle === "Anime"
? "Regarde la page d'un anime"
: "Regarde la page d'un manga";
}
} else if (document.querySelector<HTMLSelectElement>("#selectEpisodes")) {
const season = document.querySelector("#avOeuvre").textContent,
selectEps = document.querySelector<HTMLSelectElement>("#selectEpisodes"),
Expand All @@ -61,21 +73,33 @@ presence.on("UpdateData", async () => {
presenceData.details = `Regarde ${
document.querySelector("#titreOeuvre").textContent
}`;
const [startTimestamp, endTimestamp] = presence.getTimestamps(
video.currentTime,
video.duration
);
presenceData.state = `${season ? `${season} - ` : ""}${
selectEps.options[selectEps.selectedIndex].value
}`;

presenceData.buttons = [{ label: "Voir l'Anime", url: href }];
presenceData.smallImageKey = Assets.Pause;
presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play;
presenceData.smallImageText =
selectLecteur.options[selectLecteur.selectedIndex].value;
presenceData.largeImageKey =
document.querySelector<HTMLMetaElement>("[property='og:image']")
?.content ?? Assets.Logo;
if (!paused) {
[presenceData.startTimestamp, presenceData.endTimestamp] =
presence.getTimestamps(currentTime, duration);
presenceData.smallImageKey = Assets.Play;
[presenceData.startTimestamp, presenceData.endTimestamp] = [
startTimestamp,
endTimestamp,
];
if (video.paused) {
delete presenceData.startTimestamp;
delete presenceData.endTimestamp;
}
if (privacyMode) {
delete presenceData.state;
delete presenceData.smallImageKey;
presenceData.details = "Regarde un anime";
}
} else {
const selectChapitres =
Expand All @@ -94,10 +118,19 @@ presence.on("UpdateData", async () => {
presenceData.largeImageKey =
document.querySelector<HTMLMetaElement>("[property='og:image']")
?.content ?? Assets.Logo;
if (privacyMode) {
delete presenceData.state;
delete presenceData.smallImageKey;
presenceData.details = "Lit un manga";
}
}

if (!showButtons) delete presenceData.buttons;
if (!showCover) presenceData.largeImageKey = Assets.Logo;
if (!showButtons || privacyMode) delete presenceData.buttons;
if (!showTimestamps) {
delete presenceData.startTimestamp;
delete presenceData.endTimestamp;
}
if (!showCover || privacyMode) presenceData.largeImageKey = Assets.Logo;
if (presenceData.details) presence.setActivity(presenceData);
else presence.setActivity();
});
28 changes: 25 additions & 3 deletions websites/V/Voiranime/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"$schema": "https://schemas.premid.app/metadata/1.11",
"apiVersion": 1,
"author": {
"name": "Kozou",
"id": "379362415428632576"
"name": "Atom Skully",
"id": "671037171611729920"
},
"contributors": [
{
Expand All @@ -13,6 +13,10 @@
{
"name": "RisingSunLight",
"id": "240521747852558347"
},
{
"name": "Kozou",
"id": "379362415428632576"
}
],
"service": "Voiranime",
Expand All @@ -24,7 +28,7 @@
},
"url": "voiranime.com",
"regExp": "([a-z0-9-]+[.])*voiranime[.]com[/]",
"version": "2.1.11",
"version": "2.2.0",
"logo": "https://cdn.rcd.gg/PreMiD/websites/V/Voiranime/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/V/Voiranime/assets/thumbnail.png",
"color": "#1a1920",
Expand All @@ -35,11 +39,29 @@
"french"
],
"iframe": true,
"iFrameRegExp": ".*",

Check warning on line 42 in websites/V/Voiranime/metadata.json

View workflow job for this annotation

GitHub Actions / Presence Validator

Presence (Voiranime) has metadata.iFrameRegExp set to '.*', please change this if possible
"settings": [
{
"id": "lang",
"multiLanguage": true
},
{
"id": "privacy",
"title": "Privacy Mode",
"icon": "fad fa-user-secret",
"value": false
},
{
"id": "timestamps",
"title": "Show Timestamps",
"icon": "fad fa-stopwatch",
"value": true
},
{
"id": "buttons",
"title": "Show Buttons",
"icon": "fas fa-compress-arrows-alt",
"value": true
}
]
}
Loading
Loading