123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- const presence = new Presence({
- clientId: "799629862620758046",
- });
- async function getStrings() {
- return presence.getStrings(
- {
- play: "general.playing",
- pause: "general.paused",
- browsing: "general.browsing",
- live: "general.live",
- searching: "general.search",
- viewMovie: "general.viewMovie",
- watchingMovie: "general.watchingMovie",
- watchingSeries: "general.watchingSeries",
- watchMovie: "general.buttonViewMovie",
- watchSeries: "general.buttonViewSeries",
- },
- await presence.getSetting<string>("lang").catch(() => "en")
- );
- }
- let strings: Awaited<ReturnType<typeof getStrings>>,
- oldLang: string = null;
- presence.on("UpdateData", async function () {
- const presenceData: PresenceData = {
- largeImageKey:
- "https://cdn.rcd.gg/PreMiD/websites/J/Joyn/assets/logo.jpg",
- },
- newLang = await presence.getSetting<string>("lang").catch(() => "en"),
- setting = {
- timeRemaining: await presence.getSetting<boolean>("timeRemaining"),
- showButtons: await presence.getSetting<boolean>("showButtons"),
- },
- urlpath = window.location.pathname.split("/"),
- video: HTMLVideoElement = document.querySelector("div video");
- if (oldLang !== newLang || !strings) {
- oldLang = newLang;
- strings = await getStrings();
- }
- if (
- document.location.hostname === "www.joyn.de" ||
- document.location.hostname === "joyn.de"
- ) {
- if (document.querySelector(".lk71lm-0.htJLsh")) {
- presenceData.details = strings.searching;
- presenceData.state =
- document.querySelector<HTMLInputElement>(".search-input").value;
- } else if (
- (urlpath[1] === "" || document.location.pathname.includes("/#home")) &&
- urlpath[2] !== ""
- )
- presenceData.details = strings.browsing;
- else {
- switch (urlpath[1]) {
- case "compilation": {
- const compilation = document.querySelector(".artLogo");
- presenceData.details = "Viewing Compilation:";
- if (compilation)
- presenceData.state = (compilation as HTMLImageElement).alt;
- if (!compilation)
- presenceData.state = document.querySelector(".hXdaOG").textContent;
- if (setting.showButtons) {
- presenceData.buttons = [
- {
- label: "Watch Compilation",
- url: `https://www.joyn.de/compilation/${urlpath[2]}`,
- },
- ];
- }
- break;
- }
- case "filme": {
- const film = document.querySelector(".artLogo");
- presenceData.details = strings.viewMovie;
- if (film) presenceData.state = (film as HTMLImageElement).alt;
- if (!film)
- presenceData.state = document.querySelector(".hXdaOG").textContent;
- if (setting.showButtons) {
- presenceData.buttons = [
- {
- label: strings.watchMovie,
- url: `https://www.joyn.de/filme/${urlpath[2]}`,
- },
- ];
- }
- break;
- }
- case "serien": {
- const serie = document.querySelector(".artLogo");
- presenceData.details = "Viewing Series:";
- if (serie) presenceData.state = (serie as HTMLImageElement).alt;
- if (!serie)
- presenceData.state = document.querySelector(".hXdaOG").textContent;
- if (setting.showButtons) {
- presenceData.buttons = [
- {
- label: strings.watchSeries,
- url: `https://www.joyn.de/serien/${urlpath[2]}`,
- },
- ];
- }
- break;
- }
- default:
- if (
- urlpath[1] !== "play" &&
- (document.location.pathname.includes("/serien") ||
- document.location.pathname.includes("/filme") ||
- document.location.pathname.includes("/sport"))
- )
- presenceData.details = strings.browsing;
- else if (urlpath[1] === "channels") {
- presenceData.details = strings.browsing;
- presenceData.state = document.querySelector(".bISbKZ").textContent;
- } else if (urlpath[1] === "play" && urlpath[2] === "filme") {
- presenceData.details = document.title.replace(
- "streamen | Joyn",
- ""
- );
- presenceData.state = "Movie";
- if (!video.paused) {
- if (setting.timeRemaining) {
- [presenceData.startTimestamp, presenceData.endTimestamp] =
- presence.getTimestampsfromMedia(video);
- }
- presenceData.smallImageKey = Assets.Play;
- presenceData.smallImageText = strings.play;
- } else {
- presenceData.smallImageKey = Assets.Pause;
- presenceData.smallImageText = strings.pause;
- }
- if (setting.showButtons) {
- presenceData.buttons = [
- {
- label: strings.watchMovie,
- url: `https://www.joyn.de/filme/${urlpath[3]}`,
- },
- ];
- }
- } else if (urlpath[1] === "play" && urlpath[2] === "serien") {
- presenceData.details = document.title.replace("streamen", "");
- presenceData.state = "Series";
- if (!video.paused) {
- if (setting.timeRemaining) {
- [presenceData.startTimestamp, presenceData.endTimestamp] =
- presence.getTimestampsfromMedia(video);
- }
- presenceData.smallImageKey = Assets.Play;
- presenceData.smallImageText = strings.play;
- } else {
- presenceData.smallImageKey = Assets.Pause;
- presenceData.smallImageText = strings.pause;
- }
- if (setting.showButtons) {
- presenceData.buttons = [
- {
- label: strings.watchSeries,
- url: `https://www.joyn.de/serien/${urlpath[3]}`,
- },
- ];
- }
- } else if (urlpath[1] === "play" && urlpath[2] === "trailer") {
- presenceData.details = document.title.replace("Trailer | Joyn", "");
- presenceData.state = "Trailer";
- if (!video.paused) {
- if (setting.timeRemaining) {
- [presenceData.startTimestamp, presenceData.endTimestamp] =
- presence.getTimestampsfromMedia(video);
- }
- presenceData.smallImageKey = Assets.Play;
- presenceData.smallImageText = strings.play;
- } else {
- presenceData.smallImageKey = Assets.Pause;
- presenceData.smallImageText = strings.pause;
- }
- } else if (urlpath[1] === "play" && urlpath[2] === "live-tv") {
- presenceData.details = document.title.replace(
- "im Livestream anschauen | Joyn",
- ""
- );
- presenceData.state = "Live-TV";
- presenceData.smallImageKey = Assets.Live;
- presenceData.smallImageText = strings.live;
- if (setting.showButtons) {
- presenceData.buttons = [
- {
- label: "Watch show",
- url: window.location.href,
- },
- ];
- }
- } else if (urlpath[1] === "play" && urlpath[2] === "compilation") {
- presenceData.details = document.title.replace("| Joyn", "");
- presenceData.state = "Compilation";
- if (!video.paused) {
- if (setting.timeRemaining) {
- [presenceData.startTimestamp, presenceData.endTimestamp] =
- presence.getTimestampsfromMedia(video);
- }
- presenceData.smallImageKey = Assets.Play;
- presenceData.smallImageText = strings.play;
- } else {
- presenceData.smallImageKey = Assets.Pause;
- presenceData.smallImageText = strings.pause;
- }
- if (setting.showButtons) {
- presenceData.buttons = [
- {
- label: "Watch Compilation",
- url: `https://www.joyn.de/compilation/${urlpath[3]}`,
- },
- ];
- }
- } else if (urlpath[1] === "play" && urlpath[2] === "sport") {
- presenceData.details = document.querySelector(
- ".metadataWrapper .metadataTitle"
- ).textContent;
- presenceData.state = "Sport";
- if (!video.paused) {
- if (setting.timeRemaining) {
- [presenceData.startTimestamp, presenceData.endTimestamp] =
- presence.getTimestampsfromMedia(video);
- }
- presenceData.smallImageKey = Assets.Play;
- presenceData.smallImageText = strings.play;
- } else {
- presenceData.smallImageKey = Assets.Pause;
- presenceData.smallImageText = strings.pause;
- }
- if (setting.showButtons) {
- presenceData.buttons = [
- {
- label: "Watch sports show",
- url: window.location.href,
- },
- ];
- }
- } else if (urlpath[1] === "collections" && urlpath[2]) {
- presenceData.details = "Viewing Collection:";
- presenceData.state = document.querySelector(
- "h1.sc-eqamei-0.cdfQp"
- )?.textContent;
- } else {
- switch (urlpath[1]) {
- case "mein-account": {
- if (urlpath[2] === "details") {
- presenceData.details = "My Account";
- presenceData.state = "Details";
- } else presenceData.details = "My Account";
- break;
- }
- case "abo": {
- if (urlpath[2] === "bezahlung") {
- presenceData.details = "My Account";
- presenceData.state = "Payment method";
- } else if (urlpath[2] === "rechnung") {
- presenceData.details = "My Account";
- presenceData.state = "Bills";
- } else {
- presenceData.details = "My Account";
- presenceData.state = "Membership";
- }
- break;
- }
- case "fsk": {
- presenceData.details = "My Account";
- presenceData.state = "FSK Settings";
- break;
- }
- case "ueber-joyn": {
- presenceData.details = "About Joyn";
- break;
- }
- case "jugendschutz": {
- presenceData.details = "Youth protection";
- break;
- }
- case "datenschutz": {
- presenceData.details = "Privacy policy";
- break;
- }
- case "agb":
- {
- presenceData.details = "Terms of service";
- // No default
- }
- break;
- }
- }
- }
- }
- }
- if (presenceData.details) presence.setActivity(presenceData);
- else presence.setActivity();
- });
|