diff --git a/websites/J/JUKE/metadata.json b/websites/J/JUKE/metadata.json index 7aac526c8802..1384801e10a3 100644 --- a/websites/J/JUKE/metadata.json +++ b/websites/J/JUKE/metadata.json @@ -1,34 +1,34 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "QkeleQ10", - "id": "807917674477649943" - }, - "contributors": [ - { - "name": "STEPHAN", - "id": "183233556150091776" - } - ], - "service": "JUKE", - "description": { - "en": "JUKE is a Dutch radio channel collection site. JUKE is a Talpa Network company.", - "nl": "JUKE is een verzamelingssite voor radiostations. JUKE is een merk van Talpa Network." - }, - "url": "juke.nl", - "version": "2.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/JUKE/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/JUKE/assets/thumbnail.png", - "color": "#38af85", - "category": "music", - "tags": [ - "juke", - "talpa", - "radio", - "music", - "muziek", - "free", - "gratis" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "QkeleQ10", + "id": "807917674477649943" + }, + "contributors": [ + { + "name": "STEPHAN", + "id": "183233556150091776" + } + ], + "service": "JUKE", + "description": { + "en": "JUKE is a Dutch radio channel collection site. JUKE is a Talpa Network company.", + "nl": "JUKE is een verzamelingssite voor radiostations. JUKE is een merk van Talpa Network." + }, + "url": "juke.nl", + "version": "2.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/JUKE/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/JUKE/assets/thumbnail.png", + "color": "#38af85", + "category": "music", + "tags": [ + "juke", + "talpa", + "radio", + "music", + "muziek", + "free", + "gratis" + ] +} diff --git a/websites/J/JUKE/presence.ts b/websites/J/JUKE/presence.ts index 302e2202b6b6..1c8675e0cefa 100644 --- a/websites/J/JUKE/presence.ts +++ b/websites/J/JUKE/presence.ts @@ -1,53 +1,58 @@ const presence = new Presence({ - clientId: "811305223783448627", -}); + clientId: '811305223783448627', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/J/JUKE/assets/logo.png", - buttons: [{ label: "Radio luisteren", url: document.location.href }], - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/JUKE/assets/logo.png', + buttons: [{ label: 'Radio luisteren', url: document.location.href }], + } - if (document.querySelector("span[class*=eC-title]")) { - presenceData.details = document - .querySelector("span[class*=eC-title]") - .textContent.replace("De ", "de ") - .replace("Het ", "het ") - .replace("&", "&"); - if (document.querySelector("span[class*=eC-subtitle]")) { - presenceData.state = document - .querySelector("span[class*=eC-subtitle]") - .textContent.replace("De ", "de ") - .replace("Het ", "het ") - .replace("&", "&"); - } - } + if (document.querySelector('span[class*=eC-title]')) { + presenceData.details = document + .querySelector('span[class*=eC-title]') + ?.textContent + ?.replace('De ', 'de ') + .replace('Het ', 'het ') + .replace('&', '&') + if (document.querySelector('span[class*=eC-subtitle]')) { + presenceData.state = document + .querySelector('span[class*=eC-subtitle]') + ?.textContent + ?.replace('De ', 'de ') + .replace('Het ', 'het ') + .replace('&', '&') + } + } - if (!presenceData.details) { - presenceData.details = "Bladert op JUKE.nl"; - presenceData.state = `Pagina '${document.title - .replace(" |", "|") - .split("|")[0] - .replace( - "JUKE - Luister nu jouw favoriete radiozenders, non-stop muziek en podcasts!", - "Home" - )}'`; - } + if (!presenceData.details) { + presenceData.details = 'Bladert op JUKE.nl' + presenceData.state = `Pagina '${document.title + .replace(' |', '|') + .split('|')[0] + .replace( + 'JUKE - Luister nu jouw favoriete radiozenders, non-stop muziek en podcasts!', + 'Home', + )}'` + } - if (document.querySelector("rect")) { - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Wordt afgespeeld"; - presenceData.buttons = [ - { label: "Ook radio luisteren", url: document.location.href }, - ]; - } else if (document.querySelector("[class*=spinner]")) { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = "Wordt geladen"; - } else if (document.querySelector("polygon")) { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = "Gepauzeerd"; - } + if (document.querySelector('rect')) { + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Wordt afgespeeld' + presenceData.buttons = [ + { label: 'Ook radio luisteren', url: document.location.href }, + ] + } + else if (document.querySelector('[class*=spinner]')) { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Wordt geladen' + } + else if (document.querySelector('polygon')) { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Gepauzeerd' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/J/Jackbox/@types/index.d.ts b/websites/J/Jackbox/@types/index.d.ts index e132c290f731..fd56b77ce6ff 100644 --- a/websites/J/Jackbox/@types/index.d.ts +++ b/websites/J/Jackbox/@types/index.d.ts @@ -1,41 +1,41 @@ interface Game { - name: string; - logo: string; - getPresenceData: ( - params: GameCallbackParams - ) => Promise | PresenceData; + name: string + logo: string + getPresenceData: ( + params: GameCallbackParams + ) => Promise | PresenceData } interface GamePlayerState { - playerName?: string; - username?: string; - playerInfo?: { - username?: string; - }; - state?: string; - status?: string; - kind?: string; - category?: string; - prompt?: { - text?: string; - html?: string; - }; - entryId?: string; - choiceId?: string; - responseKey?: string; - placeholder?: string; - choiceType?: string; - classes?: string[]; - [x: string]: unknown; + playerName?: string + username?: string + playerInfo?: { + username?: string + } + state?: string + status?: string + kind?: string + category?: string + prompt?: { + text?: string + html?: string + } + entryId?: string + choiceId?: string + responseKey?: string + placeholder?: string + choiceType?: string + classes?: string[] + [x: string]: unknown } interface GameInfoState { - name?: string; + name?: string } interface GameCallbackParams { - playerState: GamePlayerState; - infoState: GameInfoState; - tag: string; - presence: Presence; + playerState: GamePlayerState + infoState: GameInfoState + tag: string + presence: Presence } diff --git a/websites/J/Jackbox/games/Party Pack 1/drawful.ts b/websites/J/Jackbox/games/Party Pack 1/drawful.ts index 8d5f8bd2e4ed..1c96c66afdd7 100644 --- a/websites/J/Jackbox/games/Party Pack 1/drawful.ts +++ b/websites/J/Jackbox/games/Party Pack 1/drawful.ts @@ -1,55 +1,55 @@ -export const name = "Drawful"; -export const logo = "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/0.png"; +export const name = 'Drawful' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/0.png' export function getPresenceData(): PresenceData { - const currentGamePage = document.querySelector( - ".drawful-page:not(.pt-page-off)" - ), - { classList, id } = currentGamePage; - switch (true) { - case classList.contains("state-lobby"): { - return { state: "Waiting in lobby" }; - } - case classList.contains("state-lyingdone"): - case classList.contains("state-nothing"): - case classList.contains("state-drawing-done"): { - return { state: "Waiting" }; - } - case classList.contains("state-round"): { - return { state: currentGamePage.querySelector("span").textContent }; - } - case classList.contains("state-drawing-sent"): { - return { state: "Waiting for other players to finish drawing" }; - } - case classList.contains("state-enterlie"): { - return { state: "Entering a lie" }; - } - case classList.contains("state-chooselie"): { - return { state: "Looking for the truth" }; - } - case classList.contains("state-chooselikes"): { - return { state: "Liking lies" }; - } - case classList.contains("state-liereceived"): { - return { state: "Waiting for other players to enter lies" }; - } - case classList.contains("state-notchoosing"): { - return { state: "Waiting for other players to discover the truth" }; - } - case classList.contains("state-draw"): { - return { state: "Drawing something" }; - } - case classList.contains("state-audience-choose"): { - return { state: "Choosing a lie" }; - } - case id === "state-ugc": { - return { state: "Creating a custom game" }; - } - case classList.contains("state-audience"): { - return { state: "In the audience" }; - } - default: { - return {}; - } - } + const currentGamePage = document.querySelector( + '.drawful-page:not(.pt-page-off)', + )! + const { classList, id } = currentGamePage + switch (true) { + case classList.contains('state-lobby'): { + return { state: 'Waiting in lobby' } + } + case classList.contains('state-lyingdone'): + case classList.contains('state-nothing'): + case classList.contains('state-drawing-done'): { + return { state: 'Waiting' } + } + case classList.contains('state-round'): { + return { state: currentGamePage.querySelector('span')?.textContent } + } + case classList.contains('state-drawing-sent'): { + return { state: 'Waiting for other players to finish drawing' } + } + case classList.contains('state-enterlie'): { + return { state: 'Entering a lie' } + } + case classList.contains('state-chooselie'): { + return { state: 'Looking for the truth' } + } + case classList.contains('state-chooselikes'): { + return { state: 'Liking lies' } + } + case classList.contains('state-liereceived'): { + return { state: 'Waiting for other players to enter lies' } + } + case classList.contains('state-notchoosing'): { + return { state: 'Waiting for other players to discover the truth' } + } + case classList.contains('state-draw'): { + return { state: 'Drawing something' } + } + case classList.contains('state-audience-choose'): { + return { state: 'Choosing a lie' } + } + case id === 'state-ugc': { + return { state: 'Creating a custom game' } + } + case classList.contains('state-audience'): { + return { state: 'In the audience' } + } + default: { + return {} + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 1/drawful2.ts b/websites/J/Jackbox/games/Party Pack 1/drawful2.ts index 5aedcfe9f551..00a0fd78b398 100644 --- a/websites/J/Jackbox/games/Party Pack 1/drawful2.ts +++ b/websites/J/Jackbox/games/Party Pack 1/drawful2.ts @@ -1,9 +1,9 @@ import { - logo as drawfulLogo, - getPresenceData as drawfulUpdateData, -} from "./drawful"; + logo as drawfulLogo, + getPresenceData as drawfulUpdateData, +} from './drawful' -export const name = "Drawful 2"; -export const logo = drawfulLogo; +export const name = 'Drawful 2' +export const logo = drawfulLogo -export const getPresenceData = drawfulUpdateData; +export const getPresenceData = drawfulUpdateData diff --git a/websites/J/Jackbox/games/Party Pack 1/drawful2international.ts b/websites/J/Jackbox/games/Party Pack 1/drawful2international.ts index a0dbdd5f4a59..5e58e880d809 100644 --- a/websites/J/Jackbox/games/Party Pack 1/drawful2international.ts +++ b/websites/J/Jackbox/games/Party Pack 1/drawful2international.ts @@ -1,9 +1,9 @@ import { - logo as drawfulLogo, - getPresenceData as drawfulUpdateData, -} from "./drawful"; + logo as drawfulLogo, + getPresenceData as drawfulUpdateData, +} from './drawful' -export const name = "Drawful 2 International"; -export const logo = drawfulLogo; +export const name = 'Drawful 2 International' +export const logo = drawfulLogo -export const getPresenceData = drawfulUpdateData; +export const getPresenceData = drawfulUpdateData diff --git a/websites/J/Jackbox/games/Party Pack 1/lieswatter.ts b/websites/J/Jackbox/games/Party Pack 1/lieswatter.ts index 3a2ab0586393..a5bae4e8e327 100644 --- a/websites/J/Jackbox/games/Party Pack 1/lieswatter.ts +++ b/websites/J/Jackbox/games/Party Pack 1/lieswatter.ts @@ -1,14 +1,15 @@ -export const name = "Lie Swatter"; -export const logo = "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/1.png"; +export const name = 'Lie Swatter' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/1.png' export function getPresenceData(): PresenceData { - const { classList } = document.querySelector( - ".lieswatter-page:not(.pt-page-off)" - ); - if (classList.contains("state-lobby")) return { state: "Waiting in lobby" }; - else if (classList.contains("state-answer")) - return { state: "Swatting lies" }; - else if (classList.contains("state-nothing")) - return { state: "Waiting for other players" }; - return {}; + const { classList } = document.querySelector( + '.lieswatter-page:not(.pt-page-off)', + )! + if (classList.contains('state-lobby')) + return { state: 'Waiting in lobby' } + else if (classList.contains('state-answer')) + return { state: 'Swatting lies' } + else if (classList.contains('state-nothing')) + return { state: 'Waiting for other players' } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 1/wordspud.ts b/websites/J/Jackbox/games/Party Pack 1/wordspud.ts index 65b15d88750a..d4b1c41ee381 100644 --- a/websites/J/Jackbox/games/Party Pack 1/wordspud.ts +++ b/websites/J/Jackbox/games/Party Pack 1/wordspud.ts @@ -1,37 +1,37 @@ -export const name = "Word Spud"; -export const logo = "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/2.png"; +export const name = 'Word Spud' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/2.png' export function getPresenceData(): PresenceData { - const { classList } = document.querySelector( - ".wordspud-page:not(.pt-page-off)" - ); - switch (true) { - case classList.contains("state-waiting"): { - return { state: "Waiting in lobby" }; - } - case classList.contains("state-startbutton"): { - return { state: "Waiting for other players to join" }; - } - case classList.contains("state-writing"): { - return { state: "Writing something" }; - } - case classList.contains("state-vote"): { - return { state: "Voting on a word" }; - } - case classList.contains("state-vote-wait"): { - return { state: "Being judged" }; - } - case classList.contains("state-nothing"): { - return { state: "Waiting" }; - } - case classList.contains("state-voted"): { - return { state: "Waiting for other players to vote" }; - } - case classList.contains("state-gameover"): { - return { state: "Game over" }; - } - default: { - return {}; - } - } + const { classList } = document.querySelector( + '.wordspud-page:not(.pt-page-off)', + )! + switch (true) { + case classList.contains('state-waiting'): { + return { state: 'Waiting in lobby' } + } + case classList.contains('state-startbutton'): { + return { state: 'Waiting for other players to join' } + } + case classList.contains('state-writing'): { + return { state: 'Writing something' } + } + case classList.contains('state-vote'): { + return { state: 'Voting on a word' } + } + case classList.contains('state-vote-wait'): { + return { state: 'Being judged' } + } + case classList.contains('state-nothing'): { + return { state: 'Waiting' } + } + case classList.contains('state-voted'): { + return { state: 'Waiting for other players to vote' } + } + case classList.contains('state-gameover'): { + return { state: 'Game over' } + } + default: { + return {} + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 1/ydkj2015.ts b/websites/J/Jackbox/games/Party Pack 1/ydkj2015.ts index cfa01b632ab1..36a70acbf7f3 100644 --- a/websites/J/Jackbox/games/Party Pack 1/ydkj2015.ts +++ b/websites/J/Jackbox/games/Party Pack 1/ydkj2015.ts @@ -1,12 +1,13 @@ -export const name = "You Don't Know Jack 2015"; -export const logo = "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/3.png"; +export const name = 'You Don\'t Know Jack 2015' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/3.png' export function getPresenceData(): PresenceData { - const { classList } = document.querySelector( - ".ydkj-page:not(.pt-page-off)" - ); - if (classList.contains("state-default")) return { state: "Waiting in lobby" }; - else if (classList.contains("state-jack-attack")) - return { state: "Playing Jack Attack" }; - return {}; + const { classList } = document.querySelector( + '.ydkj-page:not(.pt-page-off)', + )! + if (classList.contains('state-default')) + return { state: 'Waiting in lobby' } + else if (classList.contains('state-jack-attack')) + return { state: 'Playing Jack Attack' } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 10/awshirt2.ts b/websites/J/Jackbox/games/Party Pack 10/awshirt2.ts index a0201dfac1ca..9e5e00eb8b66 100644 --- a/websites/J/Jackbox/games/Party Pack 10/awshirt2.ts +++ b/websites/J/Jackbox/games/Party Pack 10/awshirt2.ts @@ -1,53 +1,52 @@ -import { uploadFile } from "../../util"; +import { uploadFile } from '../../util' -export const name = "Tee-K.O. 2"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/43.png"; +export const name = 'Tee-K.O. 2' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/43.png' -let lastImage: string, - lastImageTime = 0; +let lastImage: string +let lastImageTime = 0 export async function getPresenceData({ - playerState, - presence, + playerState, + presence, }: GameCallbackParams): Promise { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "postGame": { - return { state: "Viewing the results" }; - } - case "assembling": { - return { state: "Assembling a T-Shirt" }; - } - case "remaking": { - return { state: "Deciding whether to remake a T-Shirt" }; - } - case "drawing": { - const now = Date.now(); - if (now - lastImageTime > 2000) { - const canvas = document.querySelector("canvas"); - lastImageTime = now; - lastImage = await uploadFile( - canvas.toDataURL("image/png"), - logo, - presence - ); - } - return { - state: "Drawing a T-Shirt image", - largeImageKey: lastImage, - }; - } - case "writing": { - return { state: "Writing a T-Shirt slogan" }; - } - case "voting": { - return { state: "Voting for a T-Shirt" }; - } - default: { - return { state: "Waiting" }; - } - } + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'postGame': { + return { state: 'Viewing the results' } + } + case 'assembling': { + return { state: 'Assembling a T-Shirt' } + } + case 'remaking': { + return { state: 'Deciding whether to remake a T-Shirt' } + } + case 'drawing': { + const now = Date.now() + if (now - lastImageTime > 2000) { + const canvas = document.querySelector('canvas')! + lastImageTime = now + lastImage = await uploadFile( + canvas.toDataURL('image/png'), + logo, + presence, + ) + } + return { + state: 'Drawing a T-Shirt image', + largeImageKey: lastImage, + } + } + case 'writing': { + return { state: 'Writing a T-Shirt slogan' } + } + case 'voting': { + return { state: 'Voting for a T-Shirt' } + } + default: { + return { state: 'Waiting' } + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 10/nopus-opus.ts b/websites/J/Jackbox/games/Party Pack 10/nopus-opus.ts index f3c75dacdb6a..ad3bff1e9e62 100644 --- a/websites/J/Jackbox/games/Party Pack 10/nopus-opus.ts +++ b/websites/J/Jackbox/games/Party Pack 10/nopus-opus.ts @@ -1,87 +1,84 @@ -import { getSVGImageData, uploadFile } from "../../util"; +import { getSVGImageData, uploadFile } from '../../util' -export const name = "Dodo Re Mi"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/44.png"; +export const name = 'Dodo Re Mi' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/44.png' function getAvatarImageData(): Promise { - return getSVGImageData(document.querySelector(".avatar")); + return getSVGImageData(document.querySelector('.avatar')!) } export async function getPresenceData({ - playerState, - presence, + playerState, + presence, }: GameCallbackParams): Promise { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "credits": { - return { state: "Viewing the credits" }; - } - case "playback": { - return { state: "Listening to the playback" }; - } - case "audienceRecording": - case "recording": { - const instrumentImageData = await getSVGImageData( - document.querySelector(".instrument") - ), - instrumentImage = await uploadFile( - instrumentImageData, - Assets.Question, - presence - ); - return { - state: "Recording a song", - smallImageText: `on ${ - document.querySelector(".instrument-name") - .textContent - }`, - smallImageKey: instrumentImage, - }; - } - case "instrumentSelect": { - const instrumentImageData = await getSVGImageData( - document.querySelector(".selected .instrument") - ), - instrumentImage = await uploadFile( - instrumentImageData, - Assets.Question, - presence - ); - return { - state: "Selecting an instrument", - smallImageText: `on ${ - document.querySelector(".name").textContent - }`, - smallImageKey: instrumentImage, - }; - } - case "scoreboard": { - const avatarImageData = await getAvatarImageData(), - avatarImage = await uploadFile( - avatarImageData, - Assets.Question, - presence - ); - return { - state: "Viewing the scoreboard", - smallImageText: - document.querySelector(".result").textContent, - smallImageKey: avatarImage, - }; - } - case "songSelect": { - return { - state: "Selecting a song", - smallImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/45.png", - smallImageText: document.querySelector(".name").textContent.trim(), - }; - } - default: { - return { state: "Waiting" }; - } - } + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'credits': { + return { state: 'Viewing the credits' } + } + case 'playback': { + return { state: 'Listening to the playback' } + } + case 'audienceRecording': + case 'recording': { + const instrumentImageData = await getSVGImageData( + document.querySelector('.instrument')!, + ) + const instrumentImage = await uploadFile( + instrumentImageData, + Assets.Question, + presence, + ) + return { + state: 'Recording a song', + smallImageText: `on ${ + document.querySelector('.instrument-name') + ?.textContent + }`, + smallImageKey: instrumentImage, + } + } + case 'instrumentSelect': { + const instrumentImageData = await getSVGImageData( + document.querySelector('.selected .instrument')!, + ) + const instrumentImage = await uploadFile( + instrumentImageData, + Assets.Question, + presence, + ) + return { + state: 'Selecting an instrument', + smallImageText: `on ${ + document.querySelector('.name')?.textContent + }`, + smallImageKey: instrumentImage, + } + } + case 'scoreboard': { + const avatarImageData = await getAvatarImageData() + const avatarImage = await uploadFile( + avatarImageData, + Assets.Question, + presence, + ) + return { + state: 'Viewing the scoreboard', + smallImageText: document.querySelector('.result')?.textContent, + smallImageKey: avatarImage, + } + } + case 'songSelect': { + return { + state: 'Selecting a song', + smallImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/45.png', + smallImageText: document.querySelector('.name')?.textContent?.trim(), + } + } + default: { + return { state: 'Waiting' } + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 10/risky-text.ts b/websites/J/Jackbox/games/Party Pack 10/risky-text.ts index 73e1c98fb3e5..1b7f3a2f77f2 100644 --- a/websites/J/Jackbox/games/Party Pack 10/risky-text.ts +++ b/websites/J/Jackbox/games/Party Pack 10/risky-text.ts @@ -1,34 +1,33 @@ -export const name = "FixyText"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/46.png"; +export const name = 'FixyText' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/46.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "postGame": { - return { state: "Viewing the results" }; - } - case "choices": { - return { state: "Choosing a category" }; - } - case "inbox": { - return { state: "Viewing the initial message" }; - } - case "task": { - return { state: "Preparing to write text" }; - } - case "writing": { - return { state: "Writing text chaotically" }; - } - case "favorites": { - return { state: "Voting on their favorite words" }; - } - default: { - return { state: "Waiting" }; - } - } + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'postGame': { + return { state: 'Viewing the results' } + } + case 'choices': { + return { state: 'Choosing a category' } + } + case 'inbox': { + return { state: 'Viewing the initial message' } + } + case 'task': { + return { state: 'Preparing to write text' } + } + case 'writing': { + return { state: 'Writing text chaotically' } + } + case 'favorites': { + return { state: 'Voting on their favorite words' } + } + default: { + return { state: 'Waiting' } + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 10/time-trivia.ts b/websites/J/Jackbox/games/Party Pack 10/time-trivia.ts index 6120483712f3..29dfdf8bd473 100644 --- a/websites/J/Jackbox/games/Party Pack 10/time-trivia.ts +++ b/websites/J/Jackbox/games/Party Pack 10/time-trivia.ts @@ -1,34 +1,33 @@ -export const name = "TimeJinx"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/47.png"; +export const name = 'TimeJinx' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/47.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "postGame": { - return { state: "Viewing the results" }; - } - case "guessing": { - return { - state: `Answering a prompt: "${playerState.prompt}"`, - }; - } - case "sussing": { - return { - state: `Sussing out the impostor: ${playerState.prompt}`, - }; - } - case "choosing": { - return { - state: `Choosing an answer: ${playerState.prompt}`, - }; - } - default: { - return { state: "Waiting" }; - } - } + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'postGame': { + return { state: 'Viewing the results' } + } + case 'guessing': { + return { + state: `Answering a prompt: "${playerState.prompt}"`, + } + } + case 'sussing': { + return { + state: `Sussing out the impostor: ${playerState.prompt}`, + } + } + case 'choosing': { + return { + state: `Choosing an answer: ${playerState.prompt}`, + } + } + default: { + return { state: 'Waiting' } + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 10/us-them.ts b/websites/J/Jackbox/games/Party Pack 10/us-them.ts index 53da0ea538c3..526771afc931 100644 --- a/websites/J/Jackbox/games/Party Pack 10/us-them.ts +++ b/websites/J/Jackbox/games/Party Pack 10/us-them.ts @@ -1,35 +1,34 @@ -export const name = "Hypnotorious"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/48.png"; +export const name = 'Hypnotorious' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/48.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "postGame": { - return { state: "Viewing the results" }; - } - case "choices": { - if (playerState.category === "SKIP") - return { state: "Viewing the tutorial" }; - else return { state: "Choosing the outlier" }; - } - case "role": { - return { state: "Viewing their secret role" }; - } - case "writing": { - return { - state: `Answering a prompt: ${playerState.prompt}`, - }; - } - case "grouping": { - return { state: "Grouping themselves" }; - } - default: { - return { state: "Waiting" }; - } - } + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'postGame': { + return { state: 'Viewing the results' } + } + case 'choices': { + if (playerState.category === 'SKIP') + return { state: 'Viewing the tutorial' } + else return { state: 'Choosing the outlier' } + } + case 'role': { + return { state: 'Viewing their secret role' } + } + case 'writing': { + return { + state: `Answering a prompt: ${playerState.prompt}`, + } + } + case 'grouping': { + return { state: 'Grouping themselves' } + } + default: { + return { state: 'Waiting' } + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 2/auction.ts b/websites/J/Jackbox/games/Party Pack 2/auction.ts index 96b928bb695e..1d797b3e69fc 100644 --- a/websites/J/Jackbox/games/Party Pack 2/auction.ts +++ b/websites/J/Jackbox/games/Party Pack 2/auction.ts @@ -1,29 +1,29 @@ -export const name = "Bidiots"; -export const logo = "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/4.png"; +export const name = 'Bidiots' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/4.png' export function getPresenceData(): PresenceData { - const { id } = document.querySelector( - ".auction-page:not(.pt-page-off)" - ); - switch (id) { - case "state-lobby": { - return { state: "Waiting in lobby" }; - } - case "state-logo": { - return { state: "Watching tutorial" }; - } - case "state-draw": { - return { state: "Creating a piece of art" }; - } - case "state-done-drawing": { - return { state: "Waiting for other players to finish drawing" }; - } - case "state-auction": { - return { state: "Bidding on art" }; - } - case "state-post-game": { - return { state: "Viewing results" }; - } - } - return {}; + const { id } = document.querySelector( + '.auction-page:not(.pt-page-off)', + )! + switch (id) { + case 'state-lobby': { + return { state: 'Waiting in lobby' } + } + case 'state-logo': { + return { state: 'Watching tutorial' } + } + case 'state-draw': { + return { state: 'Creating a piece of art' } + } + case 'state-done-drawing': { + return { state: 'Waiting for other players to finish drawing' } + } + case 'state-auction': { + return { state: 'Bidding on art' } + } + case 'state-post-game': { + return { state: 'Viewing results' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 2/bombintern.ts b/websites/J/Jackbox/games/Party Pack 2/bombintern.ts index 02c751e5b8b0..f7be194aa46d 100644 --- a/websites/J/Jackbox/games/Party Pack 2/bombintern.ts +++ b/websites/J/Jackbox/games/Party Pack 2/bombintern.ts @@ -1,46 +1,46 @@ -export const name = "Bomb Corp"; -export const logo = "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/5.png"; +export const name = 'Bomb Corp' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/5.png' export function getPresenceData(): PresenceData { - const { classList } = document.querySelector( - ".bombintern-page:not(.pt-page-off)" - ); - switch (true) { - case classList.contains("state-lobby"): { - return { state: "Waiting in lobby" }; - } - case classList.contains("state-dayend"): { - return { state: "Day end" }; - } - case classList.contains("state-gameover"): { - return { state: "Game over" }; - } - case classList.contains("state-nothing"): { - return { state: "Waiting" }; - } - case classList.contains("state-message"): { - return { state: "Reading a message" }; - } - case classList.contains("state-smashpuzzle"): { - return { state: "Defusing a smash puzzle bomb" }; - } - case classList.contains("state-wiredbomb"): { - return { state: "Defusing a wired bomb" }; - } - case classList.contains("state-coffeebomb"): { - return { state: "Defusing a coffee bomb" }; - } - case classList.contains("state-filingbomb"): { - return { state: "Defusing a filing bomb" }; - } - case classList.contains("state-keypadbomb"): { - return { state: "Defusing a keypad bomb" }; - } - case classList.contains("state-copierbomb"): { - return { state: "Defusing a copier bomb" }; - } - default: { - return {}; - } - } + const { classList } = document.querySelector( + '.bombintern-page:not(.pt-page-off)', + )! + switch (true) { + case classList.contains('state-lobby'): { + return { state: 'Waiting in lobby' } + } + case classList.contains('state-dayend'): { + return { state: 'Day end' } + } + case classList.contains('state-gameover'): { + return { state: 'Game over' } + } + case classList.contains('state-nothing'): { + return { state: 'Waiting' } + } + case classList.contains('state-message'): { + return { state: 'Reading a message' } + } + case classList.contains('state-smashpuzzle'): { + return { state: 'Defusing a smash puzzle bomb' } + } + case classList.contains('state-wiredbomb'): { + return { state: 'Defusing a wired bomb' } + } + case classList.contains('state-coffeebomb'): { + return { state: 'Defusing a coffee bomb' } + } + case classList.contains('state-filingbomb'): { + return { state: 'Defusing a filing bomb' } + } + case classList.contains('state-keypadbomb'): { + return { state: 'Defusing a keypad bomb' } + } + case classList.contains('state-copierbomb'): { + return { state: 'Defusing a copier bomb' } + } + default: { + return {} + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 2/earwax.ts b/websites/J/Jackbox/games/Party Pack 2/earwax.ts index bf30d7da6280..266667f84702 100644 --- a/websites/J/Jackbox/games/Party Pack 2/earwax.ts +++ b/websites/J/Jackbox/games/Party Pack 2/earwax.ts @@ -1,36 +1,43 @@ -export const name = "Earwax"; -export const logo = "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/6.png"; +export const name = 'Earwax' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/6.png' export function getPresenceData(): PresenceData { - const { id, classList } = document.querySelector( - ".earwax-page:not(.pt-page-off)" - ); - switch (id) { - case "state-lobby": { - return { state: "Waiting in lobby" }; - } - case "state-intro": { - return { state: "Watching tutorial" }; - } - case "state-logo": - case "state-audience-wait": { - return { state: "Waiting" }; - } - default: - if (classList.contains("state-choosing")) - return { state: "Choosing a prompt" }; - else if (classList.contains("state-notchoosing")) - return { state: "Waiting for the judge to choose a prompt" }; - else if (classList.contains("state-notselectingsound")) - return { state: "Waiting for players to choose a sound" }; - else if ( - classList.contains("state-selectingsound") || - id === "state-answer-question-audience" - ) - return { state: "Choosing a sound" }; - else if (classList.contains("state-audience-join")) - return { state: "Joining the audience" }; - else if (id === "state-vote") return { state: "Voting on a sound" }; - } - return {}; + const { id, classList } = document.querySelector( + '.earwax-page:not(.pt-page-off)', + )! + switch (id) { + case 'state-lobby': { + return { state: 'Waiting in lobby' } + } + case 'state-intro': { + return { state: 'Watching tutorial' } + } + case 'state-logo': + case 'state-audience-wait': { + return { state: 'Waiting' } + } + default: + if (classList.contains('state-choosing')) { + return { state: 'Choosing a prompt' } + } + else if (classList.contains('state-notchoosing')) { + return { state: 'Waiting for the judge to choose a prompt' } + } + else if (classList.contains('state-notselectingsound')) { + return { state: 'Waiting for players to choose a sound' } + } + else if ( + classList.contains('state-selectingsound') + || id === 'state-answer-question-audience' + ) { + return { state: 'Choosing a sound' } + } + else if (classList.contains('state-audience-join')) { + return { state: 'Joining the audience' } + } + else if (id === 'state-vote') { + return { state: 'Voting on a sound' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 2/fibbage.ts b/websites/J/Jackbox/games/Party Pack 2/fibbage.ts index bf6c87a2861b..679df3f9baa9 100644 --- a/websites/J/Jackbox/games/Party Pack 2/fibbage.ts +++ b/websites/J/Jackbox/games/Party Pack 2/fibbage.ts @@ -1,61 +1,62 @@ -export const name = "Fibbage XL"; -export const logo = "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/7.png"; +export const name = 'Fibbage XL' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/7.png' export function getPresenceData(): PresenceData { - const currentGamePage = document.querySelector( - ".fibbage-page:not(.pt-page-off)" - ), - { classList } = currentGamePage; - switch (true) { - case classList.contains("state-lobby"): { - return { state: "Waiting in lobby" }; - } - case classList.contains("state-round"): { - return { state: currentGamePage.querySelector("p").textContent }; - } - case classList.contains("state-notchoosing"): { - return { - state: `Waiting for ${ - currentGamePage - .querySelector("span") - .textContent.match(/^(.*?) is picking a category$/)[1] - } to pick a category`, - }; - } - case classList.contains("state-nothing"): { - return { state: "Waiting" }; - } - case classList.contains("state-enterlie"): { - return { state: "Entering a lie" }; - } - case classList.contains("state-lyingdone"): { - return { state: "Lying done" }; - } - case classList.contains("state-liereceived"): { - return { state: "Waiting for other players to enter lies" }; - } - case classList.contains("state-chooselie") || - classList.contains("state-audience-chooselie"): { - return { state: "Finding the truth" }; - } - case classList.contains("state-chooselikes") || - classList.contains("state-audience-chooselikes"): { - return { state: "Liking lies" }; - } - case classList.contains("state-choosing"): { - return { state: "Choosing a category" }; - } - case classList.contains("state-pickbloop"): { - return { state: "Chossing a sound" }; - } - case classList.contains("state-audience-join"): { - return { state: "Joining audience" }; - } - case classList.contains("state-audience-score"): { - return { state: "Viewing audience scores" }; - } - default: { - return {}; - } - } + const currentGamePage = document.querySelector( + '.fibbage-page:not(.pt-page-off)', + )! + const { classList } = currentGamePage + switch (true) { + case classList.contains('state-lobby'): { + return { state: 'Waiting in lobby' } + } + case classList.contains('state-round'): { + return { state: currentGamePage.querySelector('p')?.textContent } + } + case classList.contains('state-notchoosing'): { + return { + state: `Waiting for ${ + currentGamePage + .querySelector('span') + ?.textContent + ?.match(/^(.*?) is picking a category$/)?.[1] + } to pick a category`, + } + } + case classList.contains('state-nothing'): { + return { state: 'Waiting' } + } + case classList.contains('state-enterlie'): { + return { state: 'Entering a lie' } + } + case classList.contains('state-lyingdone'): { + return { state: 'Lying done' } + } + case classList.contains('state-liereceived'): { + return { state: 'Waiting for other players to enter lies' } + } + case classList.contains('state-chooselie') + || classList.contains('state-audience-chooselie'): { + return { state: 'Finding the truth' } + } + case classList.contains('state-chooselikes') + || classList.contains('state-audience-chooselikes'): { + return { state: 'Liking lies' } + } + case classList.contains('state-choosing'): { + return { state: 'Choosing a category' } + } + case classList.contains('state-pickbloop'): { + return { state: 'Chossing a sound' } + } + case classList.contains('state-audience-join'): { + return { state: 'Joining audience' } + } + case classList.contains('state-audience-score'): { + return { state: 'Viewing audience scores' } + } + default: { + return {} + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 2/fibbage2.ts b/websites/J/Jackbox/games/Party Pack 2/fibbage2.ts index 3c4511d09f38..6d6341af276c 100644 --- a/websites/J/Jackbox/games/Party Pack 2/fibbage2.ts +++ b/websites/J/Jackbox/games/Party Pack 2/fibbage2.ts @@ -1,9 +1,9 @@ import { - logo as fibbageLogo, - getPresenceData as fibbageDataGetter, -} from "./fibbage"; + getPresenceData as fibbageDataGetter, + logo as fibbageLogo, +} from './fibbage' -export const name = "Fibbage 2"; -export const logo = fibbageLogo; +export const name = 'Fibbage 2' +export const logo = fibbageLogo -export const getPresenceData = fibbageDataGetter; +export const getPresenceData = fibbageDataGetter diff --git a/websites/J/Jackbox/games/Party Pack 3/awshirt.ts b/websites/J/Jackbox/games/Party Pack 3/awshirt.ts index f4e0cb88cfc8..e540c361372c 100644 --- a/websites/J/Jackbox/games/Party Pack 3/awshirt.ts +++ b/websites/J/Jackbox/games/Party Pack 3/awshirt.ts @@ -1,56 +1,56 @@ -export const name = "Tee K.O."; -export const logo = "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/8.png"; +export const name = 'Tee K.O.' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/8.png' export function getPresenceData(): PresenceData { - const { id } = document.querySelector( - ".awshirt-page:not(.pt-page-off)" - ); - switch (id) { - case "state-lobby": { - return { state: "Waiting in lobby" }; - } - case "state-logo": { - return { state: "Waiting" }; - } - case "state-audience": { - return { state: "In the audience" }; - } - case "state-draw": { - return { state: "Drawing a shirt" }; - } - case "state-drawing-done": { - return { - state: "Waiting for other players to finish drawing their shirt", - }; - } - case "state-input": { - return { state: "Creating taglines" }; - } - case "state-prompts-done": { - return { state: "Waiting for other players to finish their taglines" }; - } - case "state-shirt": { - return { state: "Creating a t-shirt" }; - } - case "state-shirt-done": { - return { state: "Waiting for other players to finish their t-shirts" }; - } - case "state-vote": { - return { state: "Voting on a t-shirt" }; - } - case "state-voting-done": { - return { state: "Waiting for other players to finish voting" }; - } - case "state-audience-suggestions": { - return { state: "Entering a suggestion" }; - } - case "state-answer-question-audience": - case "state-answer-question": { - return { state: "Answering a question" }; - } - case "state-done-answering": { - return { state: "Waiting for other players to finish answering" }; - } - } - return {}; + const { id } = document.querySelector( + '.awshirt-page:not(.pt-page-off)', + )! + switch (id) { + case 'state-lobby': { + return { state: 'Waiting in lobby' } + } + case 'state-logo': { + return { state: 'Waiting' } + } + case 'state-audience': { + return { state: 'In the audience' } + } + case 'state-draw': { + return { state: 'Drawing a shirt' } + } + case 'state-drawing-done': { + return { + state: 'Waiting for other players to finish drawing their shirt', + } + } + case 'state-input': { + return { state: 'Creating taglines' } + } + case 'state-prompts-done': { + return { state: 'Waiting for other players to finish their taglines' } + } + case 'state-shirt': { + return { state: 'Creating a t-shirt' } + } + case 'state-shirt-done': { + return { state: 'Waiting for other players to finish their t-shirts' } + } + case 'state-vote': { + return { state: 'Voting on a t-shirt' } + } + case 'state-voting-done': { + return { state: 'Waiting for other players to finish voting' } + } + case 'state-audience-suggestions': { + return { state: 'Entering a suggestion' } + } + case 'state-answer-question-audience': + case 'state-answer-question': { + return { state: 'Answering a question' } + } + case 'state-done-answering': { + return { state: 'Waiting for other players to finish answering' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 3/fakinit.ts b/websites/J/Jackbox/games/Party Pack 3/fakinit.ts index 17eec868c6e8..9613ce20fdd8 100644 --- a/websites/J/Jackbox/games/Party Pack 3/fakinit.ts +++ b/websites/J/Jackbox/games/Party Pack 3/fakinit.ts @@ -1,41 +1,41 @@ -export const name = "Fakin' It"; -export const logo = "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/9.png"; +export const name = 'Fakin\' It' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/9.png' export function getPresenceData(): PresenceData { - const currentGamePage = document.querySelector( - ".fakinit-page:not(.pt-page-off)" - ), - { classList } = currentGamePage; - switch (true) { - case classList.contains("state-lobby"): { - return { state: "Waiting in lobby" }; - } - case classList.contains("state-nothing"): { - return { state: "Waiting" }; - } - case classList.contains("state-gameplay"): { - return { state: "Following instructions" }; - } - case classList.contains("state-skip-instructions"): { - return { state: "Watching the tutorial" }; - } - case classList.contains("state-categories"): { - return { state: "Choosing a category" }; - } - case classList.contains("state-notchoosing"): { - return { state: "Waiting for a category to be chosen" }; - } - case classList.contains("state-round"): { - return { state: currentGamePage.querySelector("p").textContent }; - } - case classList.contains("state-vote"): { - return { state: "Voting on a player" }; - } - case classList.contains("state-vote-locked"): { - return { state: "Viewing vote results" }; - } - default: { - return {}; - } - } + const currentGamePage = document.querySelector( + '.fakinit-page:not(.pt-page-off)', + )! + const { classList } = currentGamePage + switch (true) { + case classList.contains('state-lobby'): { + return { state: 'Waiting in lobby' } + } + case classList.contains('state-nothing'): { + return { state: 'Waiting' } + } + case classList.contains('state-gameplay'): { + return { state: 'Following instructions' } + } + case classList.contains('state-skip-instructions'): { + return { state: 'Watching the tutorial' } + } + case classList.contains('state-categories'): { + return { state: 'Choosing a category' } + } + case classList.contains('state-notchoosing'): { + return { state: 'Waiting for a category to be chosen' } + } + case classList.contains('state-round'): { + return { state: currentGamePage.querySelector('p')?.textContent } + } + case classList.contains('state-vote'): { + return { state: 'Voting on a player' } + } + case classList.contains('state-vote-locked'): { + return { state: 'Viewing vote results' } + } + default: { + return {} + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 3/pollposition.ts b/websites/J/Jackbox/games/Party Pack 3/pollposition.ts index d778fa90e76f..002ec125159b 100644 --- a/websites/J/Jackbox/games/Party Pack 3/pollposition.ts +++ b/websites/J/Jackbox/games/Party Pack 3/pollposition.ts @@ -1,63 +1,62 @@ -export const name = "Guesspionage"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/10.png"; +export const name = 'Guesspionage' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/10.png' export function getPresenceData(): PresenceData { - const currentGamePage = document.querySelector( - ".pollposition-page:not(.pt-page-off)" - ), - { classList } = currentGamePage; - switch (true) { - case classList.contains("state-lobby"): { - return { state: "Waiting in lobby" }; - } - case classList.contains("state-post-lobby"): { - return { state: "Watching the tutorial" }; - } - case classList.contains("state-nothing"): { - return { state: "Waiting" }; - } - case classList.contains("state-round"): { - return { state: currentGamePage.querySelector("p").textContent }; - } - case classList.contains("state-upordowndone"): - case classList.contains("state-waitforpercentage"): - case classList.contains("state-waitforupordown"): - case classList.contains("state-waitforaudience"): - case classList.contains("state-upordown-sent"): - case classList.contains("state-waitforallpercentages"): { - return { state: "Waiting for other players to decide" }; - } - case classList.contains("state-choosecategory"): { - return { state: "Choosing a category" }; - } - case classList.contains("state-waitforcategory"): { - return { state: "Waiting for a category to be chosen" }; - } - case classList.contains("state-showquestion"): { - return { state: "Viewing a survey prompt" }; - } - case classList.contains("state-chooseupordown"): { - return { state: "Deciding if the true percentage is higher or lower" }; - } - case classList.contains("state-choosemultiple"): { - return { state: "Choosing multiple choices" }; - } - case classList.contains("state-audience-choice-sent") || - classList.contains("state-waitformultiple"): { - return { state: "Waiting for other players to choose their choices" }; - } - case classList.contains("state-audience-wait"): { - return { state: "In the audience" }; - } - case classList.contains("state-audience-chose-option"): { - return { state: "Choosing an option in the audience" }; - } - case classList.contains("state-choosecharacter"): { - return { state: "Choosing a character" }; - } - default: { - return {}; - } - } + const currentGamePage = document.querySelector( + '.pollposition-page:not(.pt-page-off)', + )! + const { classList } = currentGamePage + switch (true) { + case classList.contains('state-lobby'): { + return { state: 'Waiting in lobby' } + } + case classList.contains('state-post-lobby'): { + return { state: 'Watching the tutorial' } + } + case classList.contains('state-nothing'): { + return { state: 'Waiting' } + } + case classList.contains('state-round'): { + return { state: currentGamePage.querySelector('p')?.textContent } + } + case classList.contains('state-upordowndone'): + case classList.contains('state-waitforpercentage'): + case classList.contains('state-waitforupordown'): + case classList.contains('state-waitforaudience'): + case classList.contains('state-upordown-sent'): + case classList.contains('state-waitforallpercentages'): { + return { state: 'Waiting for other players to decide' } + } + case classList.contains('state-choosecategory'): { + return { state: 'Choosing a category' } + } + case classList.contains('state-waitforcategory'): { + return { state: 'Waiting for a category to be chosen' } + } + case classList.contains('state-showquestion'): { + return { state: 'Viewing a survey prompt' } + } + case classList.contains('state-chooseupordown'): { + return { state: 'Deciding if the true percentage is higher or lower' } + } + case classList.contains('state-choosemultiple'): { + return { state: 'Choosing multiple choices' } + } + case classList.contains('state-audience-choice-sent') + || classList.contains('state-waitformultiple'): { + return { state: 'Waiting for other players to choose their choices' } + } + case classList.contains('state-audience-wait'): { + return { state: 'In the audience' } + } + case classList.contains('state-audience-chose-option'): { + return { state: 'Choosing an option in the audience' } + } + case classList.contains('state-choosecharacter'): { + return { state: 'Choosing a character' } + } + default: { + return {} + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 3/quiplash.ts b/websites/J/Jackbox/games/Party Pack 3/quiplash.ts index 974b6a90615c..ccf60364d2eb 100644 --- a/websites/J/Jackbox/games/Party Pack 3/quiplash.ts +++ b/websites/J/Jackbox/games/Party Pack 3/quiplash.ts @@ -1,30 +1,29 @@ -export const name = "Quiplash XL"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/11.png"; +export const name = 'Quiplash XL' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/11.png' export function getPresenceData(): PresenceData { - const { id } = document.querySelector( - ".quiplash-page:not(.pt-page-off)" - ); - switch (id) { - case "state-lobby": { - return { state: "Waiting in lobby" }; - } - case "state-logo": { - return { state: "Watching tutorial" }; - } - case "state-answer-question-audience": { - return { state: "Writing audience quip" }; - } - case "state-answer-question": { - return { state: "Writing quip" }; - } - case "state-done-answering": { - return { state: "Waiting for other players to answer" }; - } - case "state-vote": { - return { state: "Voting" }; - } - } - return {}; + const { id } = document.querySelector( + '.quiplash-page:not(.pt-page-off)', + )! + switch (id) { + case 'state-lobby': { + return { state: 'Waiting in lobby' } + } + case 'state-logo': { + return { state: 'Watching tutorial' } + } + case 'state-answer-question-audience': { + return { state: 'Writing audience quip' } + } + case 'state-answer-question': { + return { state: 'Writing quip' } + } + case 'state-done-answering': { + return { state: 'Waiting for other players to answer' } + } + case 'state-vote': { + return { state: 'Voting' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 3/quiplash2-international.ts b/websites/J/Jackbox/games/Party Pack 3/quiplash2-international.ts index 0d5b9eceb1fb..4f8b3125280c 100644 --- a/websites/J/Jackbox/games/Party Pack 3/quiplash2-international.ts +++ b/websites/J/Jackbox/games/Party Pack 3/quiplash2-international.ts @@ -1,9 +1,9 @@ import { - logo as quiplashLogo, - getPresenceData as quiplashPresenceGetter, -} from "./quiplash"; + logo as quiplashLogo, + getPresenceData as quiplashPresenceGetter, +} from './quiplash' -export const name = "Quiplash 2 International"; -export const logo = quiplashLogo; +export const name = 'Quiplash 2 International' +export const logo = quiplashLogo -export const getPresenceData = quiplashPresenceGetter; +export const getPresenceData = quiplashPresenceGetter diff --git a/websites/J/Jackbox/games/Party Pack 3/quiplash2.ts b/websites/J/Jackbox/games/Party Pack 3/quiplash2.ts index 9715345e46ed..3a24602a7708 100644 --- a/websites/J/Jackbox/games/Party Pack 3/quiplash2.ts +++ b/websites/J/Jackbox/games/Party Pack 3/quiplash2.ts @@ -1,9 +1,9 @@ import { - logo as quiplashLogo, - getPresenceData as quiplashPresenceGetter, -} from "./quiplash"; + logo as quiplashLogo, + getPresenceData as quiplashPresenceGetter, +} from './quiplash' -export const name = "Quiplash 2"; -export const logo = quiplashLogo; +export const name = 'Quiplash 2' +export const logo = quiplashLogo -export const getPresenceData = quiplashPresenceGetter; +export const getPresenceData = quiplashPresenceGetter diff --git a/websites/J/Jackbox/games/Party Pack 3/triviadeath.ts b/websites/J/Jackbox/games/Party Pack 3/triviadeath.ts index 97c96d698695..6cc0949b0b7f 100644 --- a/websites/J/Jackbox/games/Party Pack 3/triviadeath.ts +++ b/websites/J/Jackbox/games/Party Pack 3/triviadeath.ts @@ -1,36 +1,35 @@ -export const name = "Trivia Murder Party"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/12.png"; +export const name = 'Trivia Murder Party' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/12.png' export function getPresenceData(): PresenceData { - const { id } = document.querySelector( - ".triviadeath-page:not(.pt-page-off)" - ); - switch (id) { - case "state-lobby": { - return { state: "Waiting in lobby" }; - } - case "state-logo": { - return { state: "Waiting" }; - } - case "state-make-single-choice": { - return { state: "Answering a single choice question" }; - } - case "state-make-many-choices": { - return { state: "Answering a multiple choice question" }; - } - case "state-enter-single-text": { - return { state: "Answering a text prompt" }; - } - case "state-enter-single-drawing": { - return { state: "Drawing a picture" }; - } - case "state-grid": { - return { state: "Playing a grid game" }; - } - case "state-game-results": { - return { state: "Viewing game results" }; - } - } - return {}; + const { id } = document.querySelector( + '.triviadeath-page:not(.pt-page-off)', + )! + switch (id) { + case 'state-lobby': { + return { state: 'Waiting in lobby' } + } + case 'state-logo': { + return { state: 'Waiting' } + } + case 'state-make-single-choice': { + return { state: 'Answering a single choice question' } + } + case 'state-make-many-choices': { + return { state: 'Answering a multiple choice question' } + } + case 'state-enter-single-text': { + return { state: 'Answering a text prompt' } + } + case 'state-enter-single-drawing': { + return { state: 'Drawing a picture' } + } + case 'state-grid': { + return { state: 'Playing a grid game' } + } + case 'state-game-results': { + return { state: 'Viewing game results' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 4/bracketeering.ts b/websites/J/Jackbox/games/Party Pack 4/bracketeering.ts index 2522f23ff517..604a5a2edcd7 100644 --- a/websites/J/Jackbox/games/Party Pack 4/bracketeering.ts +++ b/websites/J/Jackbox/games/Party Pack 4/bracketeering.ts @@ -1,45 +1,47 @@ -export const name = "Bracketeering"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/13.png"; +export const name = 'Bracketeering' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/13.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - const presenceData: PresenceData = {}; - presenceData.smallImageKey = getComputedStyle( - document.querySelector("#playericon") - ).backgroundImage.match(/^url\("(.*)"\)$/)[1]; - switch (playerState.state) { - case "Lobby": { - presenceData.state = "Waiting in lobby"; - break; - } - case "MakeSingleChoice": { - if (playerState.text === "Press this to skip the tutorial") { - presenceData.state = "Watching the tutorial"; - break; - } else if ( - (playerState.text as string).includes( - "Which answer will get the most votes?" - ) - ) - presenceData.state = "Predicting the most popular answer"; - else if ( - (playerState.text as string).includes( - "Vote for the answer that deserves to win." - ) - ) - presenceData.state = "Voting on an answer"; - break; - } - case "EnterSingleText": { - presenceData.state = "Answering a prompt"; - break; - } - case "Logo": { - presenceData.state = "Waiting"; - break; - } - } - return presenceData; + const presenceData: PresenceData = {} + presenceData.smallImageKey = getComputedStyle( + document.querySelector('#playericon')!, + )?.backgroundImage?.match(/^url\("(.*)"\)$/)?.[1] + switch (playerState.state) { + case 'Lobby': { + presenceData.state = 'Waiting in lobby' + break + } + case 'MakeSingleChoice': { + if (playerState.text === 'Press this to skip the tutorial') { + presenceData.state = 'Watching the tutorial' + break + } + else if ( + (playerState.text as string).includes( + 'Which answer will get the most votes?', + ) + ) { + presenceData.state = 'Predicting the most popular answer' + } + else if ( + (playerState.text as string).includes( + 'Vote for the answer that deserves to win.', + ) + ) { + presenceData.state = 'Voting on an answer' + } + break + } + case 'EnterSingleText': { + presenceData.state = 'Answering a prompt' + break + } + case 'Logo': { + presenceData.state = 'Waiting' + break + } + } + return presenceData } diff --git a/websites/J/Jackbox/games/Party Pack 4/fibbage3.ts b/websites/J/Jackbox/games/Party Pack 4/fibbage3.ts index 163caf295529..92628fd07895 100644 --- a/websites/J/Jackbox/games/Party Pack 4/fibbage3.ts +++ b/websites/J/Jackbox/games/Party Pack 4/fibbage3.ts @@ -1,46 +1,46 @@ -export const name = "Fibbage 3"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/14.png"; +export const name = 'Fibbage 3' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/14.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - const presenceData: PresenceData = {}; - presenceData.smallImageKey = getComputedStyle( - document.querySelector("#playericon") - ).backgroundImage.match(/^url\("(.*)"\)$/)[1]; - switch (playerState.state) { - case "Lobby": { - presenceData.state = "Waiting in lobby"; - break; - } - case "EndShortie": { - presenceData.state = "Waiting for the next prompt"; - break; - } - case "ChooseLike": { - presenceData.state = "Liking responses"; - break; - } - case "ChooseLie": { - presenceData.state = "Looking for the truth"; - break; - } - case "Logo": { - presenceData.state = "Waiting"; - break; - } - case "EnterText": - case "EnterTruth": { - presenceData.state = `Answering a prompt: ${playerState.question}`; - break; - } - case "CategorySelection": { - if (playerState.isChoosing) presenceData.state = "Choosing a category"; - else - presenceData.state = "Waiting for another player to choose a category"; - break; - } - } - return presenceData; + const presenceData: PresenceData = {} + presenceData.smallImageKey = getComputedStyle( + document.querySelector('#playericon')!, + )?.backgroundImage?.match(/^url\("(.*)"\)$/)?.[1] + switch (playerState.state) { + case 'Lobby': { + presenceData.state = 'Waiting in lobby' + break + } + case 'EndShortie': { + presenceData.state = 'Waiting for the next prompt' + break + } + case 'ChooseLike': { + presenceData.state = 'Liking responses' + break + } + case 'ChooseLie': { + presenceData.state = 'Looking for the truth' + break + } + case 'Logo': { + presenceData.state = 'Waiting' + break + } + case 'EnterText': + case 'EnterTruth': { + presenceData.state = `Answering a prompt: ${playerState.question}` + break + } + case 'CategorySelection': { + if (playerState.isChoosing) + presenceData.state = 'Choosing a category' + else + presenceData.state = 'Waiting for another player to choose a category' + break + } + } + return presenceData } diff --git a/websites/J/Jackbox/games/Party Pack 4/monstermingle.ts b/websites/J/Jackbox/games/Party Pack 4/monstermingle.ts index d0f5da25a139..9d9568ef1846 100644 --- a/websites/J/Jackbox/games/Party Pack 4/monstermingle.ts +++ b/websites/J/Jackbox/games/Party Pack 4/monstermingle.ts @@ -1,42 +1,42 @@ -export const name = "Monster Seeking Monster"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/15.png"; +export const name = 'Monster Seeking Monster' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/15.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - const presenceData: PresenceData = {}, - icon = document.querySelector(".chatAvatar.playerIcon"); - if (icon) { - presenceData.smallImageKey = - getComputedStyle(icon).backgroundImage.match(/^url\("(.*)"\)$/)[1]; - } - switch (playerState.state) { - case "Lobby": { - presenceData.state = "Waiting in lobby"; - break; - } - case "MakeSingleChoice": { - if ( - (playerState.text as { blackBox: string })?.blackBox === - "Press this to skip the tutorial..." - ) { - presenceData.state = "Watching the tutorial"; - break; - } - break; - } - case "Logo": { - presenceData.state = "Waiting"; - break; - } - case "chat": { - const mode = (playerState.chat as { mode: string })?.mode; - if (mode === "chat") presenceData.state = "Chatting"; - else if (mode === "browse") presenceData.state = "Browsing messages"; - else presenceData.state = "Choosing a date"; - break; - } - } - return presenceData; + const presenceData: PresenceData = {} + const icon = document.querySelector('.chatAvatar.playerIcon') + if (icon) { + presenceData.smallImageKey = getComputedStyle(icon).backgroundImage.match(/^url\("(.*)"\)$/)?.[1] + } + switch (playerState.state) { + case 'Lobby': { + presenceData.state = 'Waiting in lobby' + break + } + case 'MakeSingleChoice': { + if ( + (playerState.text as { blackBox: string })?.blackBox + === 'Press this to skip the tutorial...' + ) { + presenceData.state = 'Watching the tutorial' + break + } + break + } + case 'Logo': { + presenceData.state = 'Waiting' + break + } + case 'chat': { + const mode = (playerState.chat as { mode: string })?.mode + if (mode === 'chat') + presenceData.state = 'Chatting' + else if (mode === 'browse') + presenceData.state = 'Browsing messages' + else presenceData.state = 'Choosing a date' + break + } + } + return presenceData } diff --git a/websites/J/Jackbox/games/Party Pack 4/overdrawn.ts b/websites/J/Jackbox/games/Party Pack 4/overdrawn.ts index 8c51c0d78499..d53ca2b06122 100644 --- a/websites/J/Jackbox/games/Party Pack 4/overdrawn.ts +++ b/websites/J/Jackbox/games/Party Pack 4/overdrawn.ts @@ -1,40 +1,39 @@ -export const name = "Civic Doodle"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/16.png"; +export const name = 'Civic Doodle' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/16.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.state) { - case "Lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "Draw": { - return { state: "Drawing" }; - } - case "Reaction": { - return { state: "Reacting to the drawings" }; - } - case "MakeSingleChoice": { - switch (playerState.text) { - case "Which player's addition was better?": { - return { state: "Voting for the best addition" }; - } - case "You drew something this round, sit back and relax.": { - return { state: "Waiting for other players to vote" }; - } - case "Which title is best?": { - return { state: "Voting for the best title" }; - } - } - break; - } - case "EnterSingleText": { - return { state: "Entering a title for their drawing" }; - } - } - return {}; + switch (playerState.state) { + case 'Lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'Draw': { + return { state: 'Drawing' } + } + case 'Reaction': { + return { state: 'Reacting to the drawings' } + } + case 'MakeSingleChoice': { + switch (playerState.text) { + case 'Which player\'s addition was better?': { + return { state: 'Voting for the best addition' } + } + case 'You drew something this round, sit back and relax.': { + return { state: 'Waiting for other players to vote' } + } + case 'Which title is best?': { + return { state: 'Voting for the best title' } + } + } + break + } + case 'EnterSingleText': { + return { state: 'Entering a title for their drawing' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 4/survivetheinternet.ts b/websites/J/Jackbox/games/Party Pack 4/survivetheinternet.ts index 9cd4ef7a87bc..34b05b0f81ef 100644 --- a/websites/J/Jackbox/games/Party Pack 4/survivetheinternet.ts +++ b/websites/J/Jackbox/games/Party Pack 4/survivetheinternet.ts @@ -1,53 +1,67 @@ -export const name = "Survive the Internet"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/17.png"; +export const name = 'Survive the Internet' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/17.png' export function getPresenceData(): PresenceData { - const presenceData: PresenceData = {}, - playerIcon = document.querySelector("#playericon"), - currentGamePage = document.querySelector( - "#playerRegion + div" - ), - { classList, textContent } = currentGamePage; - if (playerIcon) { - presenceData.smallImageKey = - getComputedStyle(playerIcon).backgroundImage.match(/^url\("(.*)"\)$/)[1]; - } + const presenceData: PresenceData = {} + const playerIcon = document.querySelector('#playericon') + const currentGamePage = document.querySelector( + '#playerRegion + div', + )! + const { classList, textContent } = currentGamePage + if (playerIcon) { + presenceData.smallImageKey = getComputedStyle(playerIcon).backgroundImage.match(/^url\("(.*)"\)$/)?.[1] + } - if (classList.contains("Lobby")) presenceData.state = "Waiting in lobby"; - else if (classList.contains("Logo")) presenceData.state = "Waiting"; - else if (classList.contains("MakeSingleChoice")) { - if (/the tutorial\.\.\./.test(textContent)) - presenceData.state = "Viewing the tutorial"; - else if ( - /ridiculous\?$/.test( - currentGamePage.querySelector(".aboveBlackBox") - .textContent - ) - ) { - if ( - currentGamePage.querySelector(".makeSingleChoiceDone") - .style.display === "none" - ) - presenceData.state = "Voting for the most ridiculous answer"; - else presenceData.state = "Waiting for other players to vote"; - } else if ( - currentGamePage.querySelector(".aboveBlackBox") - .textContent === "" - ) - presenceData.state = "Answering a photosharing prompt"; - } else if (classList.contains("EnterSingleText")) { - if ( - currentGamePage.querySelector(".enterSingleTextForm") - .style.display === "none" - ) - presenceData.state = "Waiting for other players to answer their prompts"; - else if ( - currentGamePage.querySelector(".finalRoundImage") || - currentGamePage.querySelector(".blackBox:not(.hide)") - ) - presenceData.state = "Twisting another player's response"; - else presenceData.state = "Answering a prompt"; - } - return presenceData; + if (classList.contains('Lobby')) { + presenceData.state = 'Waiting in lobby' + } + else if (classList.contains('Logo')) { + presenceData.state = 'Waiting' + } + else if (classList.contains('MakeSingleChoice')) { + if (/the tutorial\.\.\./.test(textContent ?? '')) { + presenceData.state = 'Viewing the tutorial' + } + else if ( + /ridiculous\?$/.test( + currentGamePage.querySelector('.aboveBlackBox')?.textContent ?? '', + ) + ) { + if ( + currentGamePage.querySelector('.makeSingleChoiceDone') + ?.style + .display === 'none' + ) { + presenceData.state = 'Voting for the most ridiculous answer' + } + else { + presenceData.state = 'Waiting for other players to vote' + } + } + else if ( + currentGamePage.querySelector('.aboveBlackBox') + ?.textContent === '' + ) { + presenceData.state = 'Answering a photosharing prompt' + } + } + else if (classList.contains('EnterSingleText')) { + if ( + currentGamePage.querySelector('.enterSingleTextForm') + ?.style + .display === 'none' + ) { + presenceData.state = 'Waiting for other players to answer their prompts' + } + else if ( + currentGamePage.querySelector('.finalRoundImage') + || currentGamePage.querySelector('.blackBox:not(.hide)') + ) { + presenceData.state = 'Twisting another player\'s response' + } + else { + presenceData.state = 'Answering a prompt' + } + } + return presenceData } diff --git a/websites/J/Jackbox/games/Party Pack 5/patentlystupid.ts b/websites/J/Jackbox/games/Party Pack 5/patentlystupid.ts index 6b1457ffcffb..08dfb5d35fbc 100644 --- a/websites/J/Jackbox/games/Party Pack 5/patentlystupid.ts +++ b/websites/J/Jackbox/games/Party Pack 5/patentlystupid.ts @@ -1,55 +1,54 @@ -export const name = "Patently Stupid"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/18.png"; +export const name = 'Patently Stupid' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/18.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.state) { - case "Lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "MakeSingleChoice": { - const { html } = playerState.prompt; - switch (html) { - case "": { - return { state: "Watching the tutorial" }; - } - case "
Choose an Issue
to base your invention on.
": { - return { state: "Choosing an issue to work on" }; - } - case "
Present your idea!
It's your turn to show off your invention!

Would you like to present your invention, or would you like the game to do it for you?
": { - return { state: "Choosing presentation options" }; - } - case "
Present your idea!
You can control the timing!
(Show elements in any order.)
": { - return { state: "Presenting their invention" }; - } - default: - if (html.startsWith("
Invest in the best!
")) - return { state: "Investing in an invention" }; - else if (/choose an issue.*?to base your invention on/is.test(html)) - return { state: "Choosing the final issue to work on" }; - } - break; - } - case "EnterSingleText": { - const { html } = playerState.prompt; - if (html.startsWith("
Fill in the Blank!
")) - return { state: "Creating a problem" }; - else if (html === "
Write a title
for your invention
") - return { state: "Naming their invention" }; - else if ( - html === "
Write a tagline
for your invention
" - ) - return { state: "Creating a tagline for their invention" }; - break; - } - case "Draw": { - return { state: "Drawing their invention" }; - } - } - return {}; + switch (playerState.state) { + case 'Lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'MakeSingleChoice': { + const { html } = playerState.prompt! + switch (html) { + case '': { + return { state: 'Watching the tutorial' } + } + case '
Choose an Issue
to base your invention on.
': { + return { state: 'Choosing an issue to work on' } + } + case '
Present your idea!
It\'s your turn to show off your invention!

Would you like to present your invention, or would you like the game to do it for you?
': { + return { state: 'Choosing presentation options' } + } + case '
Present your idea!
You can control the timing!
(Show elements in any order.)
': { + return { state: 'Presenting their invention' } + } + default: + if (html?.startsWith('
Invest in the best!
')) + return { state: 'Investing in an invention' } + else if (/choose an issue.*?to base your invention on/is.test(html ?? '')) + return { state: 'Choosing the final issue to work on' } + } + break + } + case 'EnterSingleText': { + const { html } = playerState.prompt! + if (html?.startsWith('
Fill in the Blank!
')) + return { state: 'Creating a problem' } + else if (html === '
Write a title
for your invention
') + return { state: 'Naming their invention' } + else if ( + html === '
Write a tagline
for your invention
' + ) + return { state: 'Creating a tagline for their invention' } + break + } + case 'Draw': { + return { state: 'Drawing their invention' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 5/rapbattle.ts b/websites/J/Jackbox/games/Party Pack 5/rapbattle.ts index 8b33bd637677..06a1e0bbd4a8 100644 --- a/websites/J/Jackbox/games/Party Pack 5/rapbattle.ts +++ b/websites/J/Jackbox/games/Party Pack 5/rapbattle.ts @@ -1,55 +1,56 @@ -export const name = "Mad Verse City"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/19.png"; +export const name = 'Mad Verse City' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/19.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - const presenceData: PresenceData = {}; - presenceData.smallImageKey = getComputedStyle( - document.querySelector("#playericon") - ).backgroundImage.match(/^url\("(.*)"\)$/)?.[1]; - switch (playerState.state) { - case "Lobby": { - presenceData.state = "Waiting in lobby"; - break; - } - case "Logo": { - presenceData.state = "Waiting"; - break; - } - case "MakeSingleChoice": { - const { text, html } = playerState.prompt; - if (text === "Press this button to skip the tutorial...") - presenceData.state = "Skipping the tutorial"; - else if ( - html === "Rapidly press these buttons to make weird stuff happen..." - ) - presenceData.state = "Making weird stuff happen"; - else { - switch (text) { - case "Listen to the RAP": { - presenceData.state = "Listening to the rap"; - break; - } - case "Tap if you think this rhyme is DOPE": { - presenceData.state = "Voting on the rap"; - break; - } - case "Who won this battle??": { - presenceData.state = "Voting on the winner of the battle"; - break; - } - } - } - break; - } - case "EnterSingleText": { - presenceData.state = `Entering a ${ - playerState.prompt.html.match(/\((.+?)\)$/)[1] - }`; - break; - } - } - return presenceData; + const presenceData: PresenceData = {} + presenceData.smallImageKey = getComputedStyle( + document.querySelector('#playericon')!, + ).backgroundImage.match(/^url\("(.*)"\)$/)?.[1] + switch (playerState.state) { + case 'Lobby': { + presenceData.state = 'Waiting in lobby' + break + } + case 'Logo': { + presenceData.state = 'Waiting' + break + } + case 'MakeSingleChoice': { + const { text, html } = playerState.prompt! + if (text === 'Press this button to skip the tutorial...') { + presenceData.state = 'Skipping the tutorial' + } + else if ( + html === 'Rapidly press these buttons to make weird stuff happen...' + ) { + presenceData.state = 'Making weird stuff happen' + } + else { + switch (text) { + case 'Listen to the RAP': { + presenceData.state = 'Listening to the rap' + break + } + case 'Tap if you think this rhyme is DOPE': { + presenceData.state = 'Voting on the rap' + break + } + case 'Who won this battle??': { + presenceData.state = 'Voting on the winner of the battle' + break + } + } + } + break + } + case 'EnterSingleText': { + presenceData.state = `Entering a ${ + playerState.prompt?.html?.match(/\((.+?)\)$/)?.[1] + }` + break + } + } + return presenceData } diff --git a/websites/J/Jackbox/games/Party Pack 5/slingshoot.ts b/websites/J/Jackbox/games/Party Pack 5/slingshoot.ts index 9f75cf02b6c0..f3896f064063 100644 --- a/websites/J/Jackbox/games/Party Pack 5/slingshoot.ts +++ b/websites/J/Jackbox/games/Party Pack 5/slingshoot.ts @@ -1,20 +1,19 @@ -export const name = "Zeeple Dome"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/20.png"; +export const name = 'Zeeple Dome' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/20.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.state) { - case "Lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "Shoot": { - return { state: "Shooting" }; - } - } - return {}; + switch (playerState.state) { + case 'Lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'Shoot': { + return { state: 'Shooting' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 5/splittheroom.ts b/websites/J/Jackbox/games/Party Pack 5/splittheroom.ts index e06170227402..04403c2f661a 100644 --- a/websites/J/Jackbox/games/Party Pack 5/splittheroom.ts +++ b/websites/J/Jackbox/games/Party Pack 5/splittheroom.ts @@ -1,30 +1,29 @@ -export const name = "Split the Room"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/21.png"; +export const name = 'Split the Room' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/21.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.state) { - case "Lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "MakeSingleChoice": { - const { html } = playerState.prompt; - if (html === "Press this to skip the tutorial...") - return { state: "Watching the tutorial" }; - else if (html === "Did this person create an amusing scenario?") - return { state: "Rating the scenario" }; - else if (html.startsWith("For bonus points, which option do you think")) - return { state: "Predicting a player's choice" }; - else return { state: "Responding to a scenario" }; - } - case "EnterSingleText": { - return { state: "Completing a scenario" }; - } - } - return {}; + switch (playerState.state) { + case 'Lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'MakeSingleChoice': { + const { html } = playerState.prompt! + if (html === 'Press this to skip the tutorial...') + return { state: 'Watching the tutorial' } + else if (html === 'Did this person create an amusing scenario?') + return { state: 'Rating the scenario' } + else if (html?.startsWith('For bonus points, which option do you think')) + return { state: 'Predicting a player\'s choice' } + else return { state: 'Responding to a scenario' } + } + case 'EnterSingleText': { + return { state: 'Completing a scenario' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 5/ydkj2018.ts b/websites/J/Jackbox/games/Party Pack 5/ydkj2018.ts index a0c99f5a7948..98b3cc35eacc 100644 --- a/websites/J/Jackbox/games/Party Pack 5/ydkj2018.ts +++ b/websites/J/Jackbox/games/Party Pack 5/ydkj2018.ts @@ -1,34 +1,33 @@ -export const name = "You Don't Know Jack: Full Stream"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/22.png"; +export const name = 'You Don\'t Know Jack: Full Stream' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/22.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.state) { - case "Lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "MakeSingleChoice": { - switch (playerState.roundType) { - case "Shortie": { - return { state: "Answering a short trivia question" }; - } - case "DisOrDat": { - return { state: "Answering a dis-or-dat question" }; - } - case "PlayersChoice": { - return { state: "Choosing a type of question" }; - } - case "JackAttack": { - return { state: "Playing Jack Attack" }; - } - } - break; - } - } - return {}; + switch (playerState.state) { + case 'Lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'MakeSingleChoice': { + switch (playerState.roundType) { + case 'Shortie': { + return { state: 'Answering a short trivia question' } + } + case 'DisOrDat': { + return { state: 'Answering a dis-or-dat question' } + } + case 'PlayersChoice': { + return { state: 'Choosing a type of question' } + } + case 'JackAttack': { + return { state: 'Playing Jack Attack' } + } + } + break + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 6/jokeboat.ts b/websites/J/Jackbox/games/Party Pack 6/jokeboat.ts index 9979fd90d6ef..83d03a330f2b 100644 --- a/websites/J/Jackbox/games/Party Pack 6/jokeboat.ts +++ b/websites/J/Jackbox/games/Party Pack 6/jokeboat.ts @@ -1,53 +1,51 @@ -export const name = "Joke Boat"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/23.png"; +export const name = 'Joke Boat' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/23.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - const presenceData: PresenceData = {}, - icon = document.querySelector("#playericon"); - if (icon) { - presenceData.smallImageKey = - getComputedStyle(icon).backgroundImage.match(/^url\("(.*)"\)$/)?.[1]; - } - switch (playerState.state) { - case "Lobby": { - presenceData.state = "Waiting in lobby"; - break; - } - case "Logo": { - presenceData.state = "Waiting"; - break; - } - case "MakeSingleChoice": { - const { choiceId } = playerState; - if (choiceId === "ChooseCatchphrase") - presenceData.state = "Choosing a catchphrase"; - else if (choiceId.startsWith("Skip")) - presenceData.state = "Watching a tutorial"; - else if (choiceId.startsWith("ChooseSetup")) - presenceData.state = "Choosing a joke setup"; - else if (choiceId.startsWith("ChooseTopic")) - presenceData.state = "Choosing a topic for the joke"; - else if (choiceId.startsWith("ChooseAuthorReady")) - presenceData.state = "Choosing how to tell the joke"; - else if (choiceId === "ChooseJoke") - presenceData.state = "Voting on a joke"; - else if (choiceId === "ChoosePunchUpJoke") - presenceData.state = "Choosing a joke to one-up"; - break; - } - case "EnterSingleText": { - const { entryId, placeholder } = playerState; - if (entryId.startsWith("Topic")) - presenceData.state = `Entering a topic (${placeholder})`; - else if (entryId.startsWith("Punchline")) - presenceData.state = "Creating a punchline"; - else if (entryId === "PunchedUpLine") - presenceData.state = "One-upping a joke"; - break; - } - } - return presenceData; + const presenceData: PresenceData = {} + const icon = document.querySelector('#playericon') + if (icon) { + presenceData.smallImageKey = getComputedStyle(icon).backgroundImage.match(/^url\("(.*)"\)$/)?.[1] + } + switch (playerState.state) { + case 'Lobby': { + presenceData.state = 'Waiting in lobby' + break + } + case 'Logo': { + presenceData.state = 'Waiting' + break + } + case 'MakeSingleChoice': { + const { choiceId } = playerState + if (choiceId === 'ChooseCatchphrase') + presenceData.state = 'Choosing a catchphrase' + else if (choiceId?.startsWith('Skip')) + presenceData.state = 'Watching a tutorial' + else if (choiceId?.startsWith('ChooseSetup')) + presenceData.state = 'Choosing a joke setup' + else if (choiceId?.startsWith('ChooseTopic')) + presenceData.state = 'Choosing a topic for the joke' + else if (choiceId?.startsWith('ChooseAuthorReady')) + presenceData.state = 'Choosing how to tell the joke' + else if (choiceId === 'ChooseJoke') + presenceData.state = 'Voting on a joke' + else if (choiceId === 'ChoosePunchUpJoke') + presenceData.state = 'Choosing a joke to one-up' + break + } + case 'EnterSingleText': { + const { entryId, placeholder } = playerState + if (entryId?.startsWith('Topic')) + presenceData.state = `Entering a topic (${placeholder})` + else if (entryId?.startsWith('Punchline')) + presenceData.state = 'Creating a punchline' + else if (entryId === 'PunchedUpLine') + presenceData.state = 'One-upping a joke' + break + } + } + return presenceData } diff --git a/websites/J/Jackbox/games/Party Pack 6/pushthebutton.ts b/websites/J/Jackbox/games/Party Pack 6/pushthebutton.ts index 7f070d74e65c..5e4d54814801 100644 --- a/websites/J/Jackbox/games/Party Pack 6/pushthebutton.ts +++ b/websites/J/Jackbox/games/Party Pack 6/pushthebutton.ts @@ -1,71 +1,73 @@ -export const name = "Push the Button"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/24.png"; +export const name = 'Push the Button' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/24.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.state) { - case "Lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "SuspicionVote": { - return { state: "Voting on who seems suspicious" }; - } - case "Probe": { - return { state: "Probing their fellow players" }; - } - case "Draw": { - return { state: "In the Drawing Quarters" }; - } - case "AnalyzePlayer": { - return { state: "Using the bioscanner - describing glyphs" }; - } - case "AnalysisReport": { - return { state: "Using the bioscanner - reading report" }; - } - case "MakeSingleChoice": { - const { choiceType, gameInfo, prompt } = playerState, - { activeTest } = gameInfo as { - activeTest: string; - }; - if (choiceType) { - switch (choiceType) { - case "TutorialOptOut": { - return { state: "Choosing whether to skip the tutorial" }; - } - case "ConfirmedIdentity": { - return { state: "Confirming their identity" }; - } - } - } else if (activeTest) { - if (activeTest === "Push The Button") - return { state: "Accusing players" }; - else return { state: `Taking the ${activeTest} test` }; - } else { - const html = prompt?.html; - if ( - html === "You are the Captain. What test would you like to perform?" - ) - return { state: "Choosing a test to perform" }; - else if (/^Select .*?<\/strong> to Test!$/.test(html)) - return { state: "Choosing players to test" }; - } - break; - } - case "EnterSingleText": { - const { activeTest } = playerState.gameInfo as { - activeTest: string; - }; - if (activeTest) return { state: `Taking the ${activeTest} test` }; - break; - } - case "GameOver": { - return { state: `Viewing results - ${playerState.winningRole}s won` }; - } - } - return {}; + switch (playerState.state) { + case 'Lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'SuspicionVote': { + return { state: 'Voting on who seems suspicious' } + } + case 'Probe': { + return { state: 'Probing their fellow players' } + } + case 'Draw': { + return { state: 'In the Drawing Quarters' } + } + case 'AnalyzePlayer': { + return { state: 'Using the bioscanner - describing glyphs' } + } + case 'AnalysisReport': { + return { state: 'Using the bioscanner - reading report' } + } + case 'MakeSingleChoice': { + const { choiceType, gameInfo, prompt } = playerState + const { activeTest } = gameInfo as { + activeTest: string + } + if (choiceType) { + switch (choiceType) { + case 'TutorialOptOut': { + return { state: 'Choosing whether to skip the tutorial' } + } + case 'ConfirmedIdentity': { + return { state: 'Confirming their identity' } + } + } + } + else if (activeTest) { + if (activeTest === 'Push The Button') + return { state: 'Accusing players' } + else return { state: `Taking the ${activeTest} test` } + } + else { + const html = prompt?.html + if ( + html === 'You are the Captain. What test would you like to perform?' + ) + return { state: 'Choosing a test to perform' } + else if (/^Select .*?<\/strong> to Test!$/.test(html ?? '')) + return { state: 'Choosing players to test' } + } + break + } + case 'EnterSingleText': { + const { activeTest } = playerState.gameInfo as { + activeTest: string + } + if (activeTest) + return { state: `Taking the ${activeTest} test` } + break + } + case 'GameOver': { + return { state: `Viewing results - ${playerState.winningRole}s won` } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 6/ridictionary.ts b/websites/J/Jackbox/games/Party Pack 6/ridictionary.ts index ffc30aa6b879..f9185864a803 100644 --- a/websites/J/Jackbox/games/Party Pack 6/ridictionary.ts +++ b/websites/J/Jackbox/games/Party Pack 6/ridictionary.ts @@ -1,82 +1,82 @@ -export const name = "Dictionarium"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/25.png"; +/* eslint-disable regexp/no-super-linear-backtracking */ +export const name = 'Dictionarium' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/25.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - const presenceData: PresenceData = {}; - presenceData.smallImageKey = getComputedStyle( - document.querySelector("#playericon") - ).backgroundImage.match(/^url\("(.*)"\)$/)[1]; - switch (playerState.state) { - case "Lobby": { - presenceData.state = "Waiting in lobby"; - break; - } - case "Logo": { - presenceData.state = "Waiting"; - break; - } - case "MakeSingleChoice": { - switch (playerState.choiceType) { - case "ChooseGameType": { - presenceData.state = "Choosing a game type"; - break; - } - case "ChooseDefinition": { - presenceData.state = `Voting for a definition of ${ - playerState.prompt.html.match(/
(.*?)<\/div>$/)[1] - }`; - break; - } - case "LikeDefinition": { - presenceData.state = "Liking definitions"; - break; - } - case "ChooseSynonym": { - presenceData.state = `Voting for a synonym of ${ - playerState.prompt.html.match(/(.*?)(?:: )?<\/font>$/)[1] - }`; - break; - } - case "LikeSynonym": { - presenceData.state = "Liking synonyms"; - break; - } - case "LikeSentence": { - presenceData.state = "Liking sentences"; - break; - } - case "ChooseSentence": { - presenceData.state = `Voting for a sentence with ${ - playerState.prompt.html.match(/
(.*?)<\/div>$/)[1] - }`; - break; - } - } - break; - } - case "EnterSingleText": { - switch (playerState.entryId) { - case "Definition": { - presenceData.state = `Creating a definition for ${ - playerState.prompt.html.match(/(.*?)<\/font>/)[1] - }`; - break; - } - case "Synonym": { - presenceData.state = `Creating a synonym for ${ - playerState.prompt.html.match(/(.*?)(?:: )?<\/font>/)[1] - }`; - break; - } - case "Sentence": { - presenceData.state = `Creating a sentence using ${playerState.word}`; - break; - } - } - } - } - return presenceData; + const presenceData: PresenceData = {} + presenceData.smallImageKey = getComputedStyle( + document.querySelector('#playericon')!, + ).backgroundImage.match(/^url\("(.*)"\)$/)?.[1] + switch (playerState.state) { + case 'Lobby': { + presenceData.state = 'Waiting in lobby' + break + } + case 'Logo': { + presenceData.state = 'Waiting' + break + } + case 'MakeSingleChoice': { + switch (playerState.choiceType) { + case 'ChooseGameType': { + presenceData.state = 'Choosing a game type' + break + } + case 'ChooseDefinition': { + presenceData.state = `Voting for a definition of ${ + playerState.prompt?.html?.match(/
(.*?)<\/div>$/)?.[1] + }` + break + } + case 'LikeDefinition': { + presenceData.state = 'Liking definitions' + break + } + case 'ChooseSynonym': { + presenceData.state = `Voting for a synonym of ${ + playerState.prompt?.html?.match(/(.*?)(?:: )?<\/font>$/)?.[1] + }` + break + } + case 'LikeSynonym': { + presenceData.state = 'Liking synonyms' + break + } + case 'LikeSentence': { + presenceData.state = 'Liking sentences' + break + } + case 'ChooseSentence': { + presenceData.state = `Voting for a sentence with ${ + playerState.prompt?.html?.match(/
(.*?)<\/div>$/)?.[1] + }` + break + } + } + break + } + case 'EnterSingleText': { + switch (playerState.entryId) { + case 'Definition': { + presenceData.state = `Creating a definition for ${ + playerState.prompt?.html?.match(/(.*?)<\/font>/)?.[1] + }` + break + } + case 'Synonym': { + presenceData.state = `Creating a synonym for ${ + playerState.prompt?.html?.match(/(.*?)(?:: )?<\/font>/)?.[1] + }` + break + } + case 'Sentence': { + presenceData.state = `Creating a sentence using ${playerState.word}` + break + } + } + } + } + return presenceData } diff --git a/websites/J/Jackbox/games/Party Pack 6/rolemodels.ts b/websites/J/Jackbox/games/Party Pack 6/rolemodels.ts index 5127e1297798..bdc2fef443cc 100644 --- a/websites/J/Jackbox/games/Party Pack 6/rolemodels.ts +++ b/websites/J/Jackbox/games/Party Pack 6/rolemodels.ts @@ -1,46 +1,45 @@ -export const name = "Role Models"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/26.png"; +export const name = 'Role Models' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/26.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.state) { - case "Lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "Camera": { - return { state: "Taking a photo of themselves" }; - } - case "Draw": { - return { state: "Drawing a portrait of themselves" }; - } - case "MakeSingleChoice": { - switch (playerState.choiceType) { - case "SkipTutorial": { - return { state: "Watching the tutorial" }; - } - case "Prompt": { - return { state: "Choosing a category" }; - } - case "TagResolution": { - return { state: "Resolving a role conflict" }; - } - case "RoleModelsChoice": { - return { state: "Choosing the role that fits best" }; - } - } - break; - } - case "Sortable": { - return { state: "Assigning roles to players" }; - } - case "EnterSingleText": { - return { state: "Answering a prompt" }; - } - } - return {}; + switch (playerState.state) { + case 'Lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'Camera': { + return { state: 'Taking a photo of themselves' } + } + case 'Draw': { + return { state: 'Drawing a portrait of themselves' } + } + case 'MakeSingleChoice': { + switch (playerState.choiceType) { + case 'SkipTutorial': { + return { state: 'Watching the tutorial' } + } + case 'Prompt': { + return { state: 'Choosing a category' } + } + case 'TagResolution': { + return { state: 'Resolving a role conflict' } + } + case 'RoleModelsChoice': { + return { state: 'Choosing the role that fits best' } + } + } + break + } + case 'Sortable': { + return { state: 'Assigning roles to players' } + } + case 'EnterSingleText': { + return { state: 'Answering a prompt' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 6/triviadeath2.ts b/websites/J/Jackbox/games/Party Pack 6/triviadeath2.ts index 64fe7ca67a03..4b9b51f6d76a 100644 --- a/websites/J/Jackbox/games/Party Pack 6/triviadeath2.ts +++ b/websites/J/Jackbox/games/Party Pack 6/triviadeath2.ts @@ -1,53 +1,53 @@ -export const name = "Trivia Murder Party 2"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/27.png"; +export const name = 'Trivia Murder Party 2' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/27.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.state) { - case "Lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "MakeSingleChoice": { - if (playerState.roundType === "FinalRound") - return { state: "Answering the final trivia questions" }; - else { - switch (playerState.choiceType) { - case "SkipTutorial": { - return { state: "Watching the intro" }; - } - case "Question": { - return { state: "Answering trivia" }; - } - case "Rule": { - return { state: "Playing a rule game" }; - } - case "PostGameChoice": { - return { state: "Choosing a post-game option" }; - } - default: { - return { state: "Playing a death game" }; - } - } - } - } - case "EnterSingleText": { - const { entryId } = playerState; - if (entryId.startsWith("MindMeld")) - return { state: "Playing the mind meld game" }; - else if (entryId === "CreatePassword") - return { state: "Creating a password for the password game" }; - else if (entryId === "Quiplash") - return { state: `Playing Quiplash - ${playerState.prompt.html}` }; - else return { state: "Playing a text death game" }; - } - case "Draw": { - return { state: "Playing a drawing death game" }; - } - } - return {}; + switch (playerState.state) { + case 'Lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'MakeSingleChoice': { + if (playerState.roundType === 'FinalRound') { + return { state: 'Answering the final trivia questions' } + } + else { + switch (playerState.choiceType) { + case 'SkipTutorial': { + return { state: 'Watching the intro' } + } + case 'Question': { + return { state: 'Answering trivia' } + } + case 'Rule': { + return { state: 'Playing a rule game' } + } + case 'PostGameChoice': { + return { state: 'Choosing a post-game option' } + } + default: { + return { state: 'Playing a death game' } + } + } + } + } + case 'EnterSingleText': { + const { entryId } = playerState + if (entryId?.startsWith('MindMeld')) + return { state: 'Playing the mind meld game' } + else if (entryId === 'CreatePassword') + return { state: 'Creating a password for the password game' } + else if (entryId === 'Quiplash') + return { state: `Playing Quiplash - ${playerState.prompt?.html}` } + else return { state: 'Playing a text death game' } + } + case 'Draw': { + return { state: 'Playing a drawing death game' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 7/blanky-blank.ts b/websites/J/Jackbox/games/Party Pack 7/blanky-blank.ts index c6984546bc4c..afc27925655d 100644 --- a/websites/J/Jackbox/games/Party Pack 7/blanky-blank.ts +++ b/websites/J/Jackbox/games/Party Pack 7/blanky-blank.ts @@ -1,48 +1,47 @@ -export const name = "Blather 'Round"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/28.png"; +export const name = 'Blather \'Round' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/28.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.state) { - case "Lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "MakeSingleChoice": { - switch (playerState.choiceType) { - case "skipTutorial": { - return { state: "Watching the tutorial" }; - } - case "password": { - return { state: "Choosing a prompt" }; - } - } - break; - } - case "MakeSentence": { - switch ((playerState.sentence as { type: string }).type) { - case "writing": { - return { state: "Crafting initial sentence" }; - } - case "call": { - return { state: "Crafting a sentence" }; - } - case "response": { - return { state: "Crafting a sentence using players' guesses" }; - } - case "mybad": { - return { state: "Deciding if they should have known the answer" }; - } - } - break; - } - case "EnterSingleText": { - return { state: "Guessing the object" }; - } - } - return {}; + switch (playerState.state) { + case 'Lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'MakeSingleChoice': { + switch (playerState.choiceType) { + case 'skipTutorial': { + return { state: 'Watching the tutorial' } + } + case 'password': { + return { state: 'Choosing a prompt' } + } + } + break + } + case 'MakeSentence': { + switch ((playerState.sentence as { type: string }).type) { + case 'writing': { + return { state: 'Crafting initial sentence' } + } + case 'call': { + return { state: 'Crafting a sentence' } + } + case 'response': { + return { state: 'Crafting a sentence using players\' guesses' } + } + case 'mybad': { + return { state: 'Deciding if they should have known the answer' } + } + } + break + } + case 'EnterSingleText': { + return { state: 'Guessing the object' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 7/everyday.ts b/websites/J/Jackbox/games/Party Pack 7/everyday.ts index ce625c99c585..8df1c1b6e2ff 100644 --- a/websites/J/Jackbox/games/Party Pack 7/everyday.ts +++ b/websites/J/Jackbox/games/Party Pack 7/everyday.ts @@ -1,83 +1,83 @@ -export const name = "The Devils and the Details"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/29.png"; +export const name = 'The Devils and the Details' +export const logo += 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/29.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.state) { - case "Lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "MakeSingleChoice": { - switch (playerState.choiceId) { - case "ChangeCharacter": { - return { state: "Choosing a character" }; - } - default: { - if (playerState.choiceType === "SkipIntro") - return { state: "Watching the intro" }; - else if (playerState.choiceType === "ShowTutorial") - return { state: "Deciding if they want to watch the tutorial" }; - } - } - break; - } - case "CancelerMechanic": { - return { state: "Blocking a member from their selfish task" }; - } - case "TaskList": { - return { state: "Choosing a task" }; - } - case "NothingMechanic": { - return { state: "Doing nothing" }; - } - case "ScrubMechanic": { - return { state: "Scrubbing something" }; - } - case "RotateMechanic": { - return { state: "Rotating something" }; - } - case "TapMechanic": { - return { state: "Tapping something" }; - } - case "SwipeMechanic": { - return { state: "Swiping something" }; - } - case "TravelMechanicParticipant": { - return { state: "Travelling as a passenger" }; - } - case "TravelMechanicCaptain": { - return { state: "Travelling as the driver" }; - } - case "PhoneMechanic": { - return { state: "Calling someone" }; - } - case "DialogMechanic": { - return { state: "Talking to someone" }; - } - case "SearchMechanicCaptain": - case "SearchMechanicParticipant": { - return { state: "Searching for something" }; - } - case "TextMechanicParticipant": { - return { state: "Writing a text" }; - } - case "TextMechanicCaptain": { - return { state: "Reading a text" }; - } - case "InstructionsMechanicCaptain": { - return { state: "Following instructions" }; - } - case "InstructionsMechanicParticipant": { - return { state: "Giving instructions" }; - } - case "HoldMechanic": { - return { state: "Holding something" }; - } - } - return {}; + switch (playerState.state) { + case 'Lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'MakeSingleChoice': { + switch (playerState.choiceId) { + case 'ChangeCharacter': { + return { state: 'Choosing a character' } + } + default: { + if (playerState.choiceType === 'SkipIntro') + return { state: 'Watching the intro' } + else if (playerState.choiceType === 'ShowTutorial') + return { state: 'Deciding if they want to watch the tutorial' } + } + } + break + } + case 'CancelerMechanic': { + return { state: 'Blocking a member from their selfish task' } + } + case 'TaskList': { + return { state: 'Choosing a task' } + } + case 'NothingMechanic': { + return { state: 'Doing nothing' } + } + case 'ScrubMechanic': { + return { state: 'Scrubbing something' } + } + case 'RotateMechanic': { + return { state: 'Rotating something' } + } + case 'TapMechanic': { + return { state: 'Tapping something' } + } + case 'SwipeMechanic': { + return { state: 'Swiping something' } + } + case 'TravelMechanicParticipant': { + return { state: 'Travelling as a passenger' } + } + case 'TravelMechanicCaptain': { + return { state: 'Travelling as the driver' } + } + case 'PhoneMechanic': { + return { state: 'Calling someone' } + } + case 'DialogMechanic': { + return { state: 'Talking to someone' } + } + case 'SearchMechanicCaptain': + case 'SearchMechanicParticipant': { + return { state: 'Searching for something' } + } + case 'TextMechanicParticipant': { + return { state: 'Writing a text' } + } + case 'TextMechanicCaptain': { + return { state: 'Reading a text' } + } + case 'InstructionsMechanicCaptain': { + return { state: 'Following instructions' } + } + case 'InstructionsMechanicParticipant': { + return { state: 'Giving instructions' } + } + case 'HoldMechanic': { + return { state: 'Holding something' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 7/jackbox-talks.ts b/websites/J/Jackbox/games/Party Pack 7/jackbox-talks.ts index 7bc254985242..c2293d7680c2 100644 --- a/websites/J/Jackbox/games/Party Pack 7/jackbox-talks.ts +++ b/websites/J/Jackbox/games/Party Pack 7/jackbox-talks.ts @@ -1,63 +1,65 @@ -export const name = "Talking Points"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/30.png"; +export const name = 'Talking Points' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/30.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.state) { - case "Lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "Camera": { - return { state: "Taking a profile picture" }; - } - case "EnterSingleText": { - const { entryId } = playerState; - if (entryId.startsWith("prompt")) return { state: "Creating topics" }; - else if (entryId === "WriteQuote") - return { state: "Writing a quote about the talk" }; - else if (entryId === "NameAward") return { state: "Naming an award" }; - break; - } - case "Awards": { - return { state: "Giving out their award" }; - } - case "MakeSingleChoice": { - const { classes, choices, prompt } = playerState; - if (prompt.html === "PICK THE TITLE OF THE TALK YOU WILL GIVE") - return { state: "Choosing a talk title" }; - else { - switch (classes[0]) { - case "SkipTutorial": { - return { state: "Watching the tutorial" }; - } - case "Presenter": { - if (prompt.html.startsWith("RATE HOW WELL ")) - return { state: "Rating their assistant" }; - else if (prompt.text === "THANK YOU.") - return { state: "Presenting their talk - thank you" }; - else return { state: "Presenting their talk - preparation" }; - } - case "Assistant": { - if (prompt.html === "PICK THE BEST PICTURE TO REPRESENT THE TALK") - return { state: "Choosing a picture for the talk" }; - else return { state: "Assisting their presenter" }; - } - default: { - if ((choices as { className: string }[])[0].className === "voteUp") - return { state: "Reacting to the speech" }; - } - } - } - break; - } - case "Draw": { - return { state: "Presenting their talk - slide" }; - } - } - return {}; + switch (playerState.state) { + case 'Lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'Camera': { + return { state: 'Taking a profile picture' } + } + case 'EnterSingleText': { + const { entryId } = playerState + if (entryId?.startsWith('prompt')) + return { state: 'Creating topics' } + else if (entryId === 'WriteQuote') + return { state: 'Writing a quote about the talk' } + else if (entryId === 'NameAward') + return { state: 'Naming an award' } + break + } + case 'Awards': { + return { state: 'Giving out their award' } + } + case 'MakeSingleChoice': { + const { classes, choices, prompt } = playerState + if (prompt?.html === 'PICK THE TITLE OF THE TALK YOU WILL GIVE') { + return { state: 'Choosing a talk title' } + } + else { + switch (classes?.[0]) { + case 'SkipTutorial': { + return { state: 'Watching the tutorial' } + } + case 'Presenter': { + if (prompt?.html?.startsWith('RATE HOW WELL ')) + return { state: 'Rating their assistant' } + else if (prompt?.text === 'THANK YOU.') + return { state: 'Presenting their talk - thank you' } + else return { state: 'Presenting their talk - preparation' } + } + case 'Assistant': { + if (prompt?.html === 'PICK THE BEST PICTURE TO REPRESENT THE TALK') + return { state: 'Choosing a picture for the talk' } + else return { state: 'Assisting their presenter' } + } + default: { + if ((choices as { className: string }[])[0].className === 'voteUp') + return { state: 'Reacting to the speech' } + } + } + } + break + } + case 'Draw': { + return { state: 'Presenting their talk - slide' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 7/quiplash3.ts b/websites/J/Jackbox/games/Party Pack 7/quiplash3.ts index 4ff8321df84d..5208f518de53 100644 --- a/websites/J/Jackbox/games/Party Pack 7/quiplash3.ts +++ b/websites/J/Jackbox/games/Party Pack 7/quiplash3.ts @@ -1,58 +1,57 @@ -export const name = "Quiplash 3"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/31.png"; +export const name = 'Quiplash 3' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/31.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - const presenceData: PresenceData = {}; - presenceData.smallImageKey = getComputedStyle( - document.querySelector("#playericon") - ).backgroundImage.match(/^url\("(.*)"\)$/)?.[1]; - switch (playerState.state) { - case "Lobby": { - presenceData.state = "Waiting in lobby"; - break; - } - case "Logo": { - presenceData.state = "Waiting"; - break; - } - case "EnterSingleText": { - presenceData.state = "Answering a prompt"; - break; - } - case "MakeSingleChoice": { - presenceData.state = "Voting for their favorite answer"; - break; - } - case "EnterTextList": { - presenceData.state = "Answering a Thriplash prompt"; - break; - } - default: { - if (playerState.validActions) { - switch ((playerState.validActions as string[]).join(",")) { - case "toggle-visibility,new,load,exit": { - presenceData.state = "In the Custom Content menu"; - break; - } - case "title,close": { - presenceData.state = "Naming a custom Quiplash episode"; - break; - } - case "add,toggle-visibility,close": - case "add,remove,toggle-visibility,done": { - presenceData.state = "Adding prompts to a custom Quiplash episode"; - break; - } - case "submit,unlock,toggle-visibility,play,remove-content,episodes": { - presenceData.state = "Viewing a custom Quiplash episode"; - break; - } - } - } - } - } - return presenceData; + const presenceData: PresenceData = {} + presenceData.smallImageKey = getComputedStyle( + document.querySelector('#playericon')!, + ).backgroundImage.match(/^url\("(.*)"\)$/)?.[1] + switch (playerState.state) { + case 'Lobby': { + presenceData.state = 'Waiting in lobby' + break + } + case 'Logo': { + presenceData.state = 'Waiting' + break + } + case 'EnterSingleText': { + presenceData.state = 'Answering a prompt' + break + } + case 'MakeSingleChoice': { + presenceData.state = 'Voting for their favorite answer' + break + } + case 'EnterTextList': { + presenceData.state = 'Answering a Thriplash prompt' + break + } + default: { + if (playerState.validActions) { + switch ((playerState.validActions as string[]).join(',')) { + case 'toggle-visibility,new,load,exit': { + presenceData.state = 'In the Custom Content menu' + break + } + case 'title,close': { + presenceData.state = 'Naming a custom Quiplash episode' + break + } + case 'add,toggle-visibility,close': + case 'add,remove,toggle-visibility,done': { + presenceData.state = 'Adding prompts to a custom Quiplash episode' + break + } + case 'submit,unlock,toggle-visibility,play,remove-content,episodes': { + presenceData.state = 'Viewing a custom Quiplash episode' + break + } + } + } + } + } + return presenceData } diff --git a/websites/J/Jackbox/games/Party Pack 7/worldchamps.ts b/websites/J/Jackbox/games/Party Pack 7/worldchamps.ts index 3dbd94ce8521..65da0838bdaf 100644 --- a/websites/J/Jackbox/games/Party Pack 7/worldchamps.ts +++ b/websites/J/Jackbox/games/Party Pack 7/worldchamps.ts @@ -1,63 +1,67 @@ -import { uploadFile } from "../../util"; +import { uploadFile } from '../../util' -export const name = "Champ'd Up"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/32.png"; +export const name = 'Champ\'d Up' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/32.png' export async function getPresenceData({ - playerState, - presence, + playerState, + presence, }: GameCallbackParams): Promise { - const presenceData: PresenceData = {}; - presenceData.smallImageKey = getComputedStyle( - document.querySelector("#playericon") - ).backgroundImage.match(/^url\("(.*)"\)$/)?.[1]; - switch (playerState.state) { - case "Lobby": { - presenceData.state = "Waiting in lobby"; - break; - } - case "Logo": { - presenceData.state = "Waiting"; - break; - } - case "MakeSingleChoice": { - const { choiceId } = playerState; - if (choiceId) { - if (choiceId.startsWith("FlipChoice")) - presenceData.state = "Flipping their character"; - } else if (playerState.prompt.html?.startsWith("Who is
")) - presenceData.state = "Voting for the best champion"; - else if ( - playerState.prompt.html?.startsWith( - "Swap your character or keep it in
" - ) - ) - presenceData.state = "Choosing whether to swap their character"; - else presenceData.state = "Watching the tutorial"; - break; - } - case "Draw": { - const { entryId } = playerState; - if (entryId.startsWith("champion")) { - presenceData.state = "Drawing a champion"; - break; - } else if (entryId.startsWith("challenger")) { - const imageLink = - document.querySelector(".imageData")?.src; - if (imageLink) { - presenceData.largeImageKey = await uploadFile( - imageLink, - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/32.png", - presence - ); - } + const presenceData: PresenceData = {} + presenceData.smallImageKey = getComputedStyle( + document.querySelector('#playericon')!, + ).backgroundImage.match(/^url\("(.*)"\)$/)?.[1] + switch (playerState.state) { + case 'Lobby': { + presenceData.state = 'Waiting in lobby' + break + } + case 'Logo': { + presenceData.state = 'Waiting' + break + } + case 'MakeSingleChoice': { + const { choiceId } = playerState + if (choiceId) { + if (choiceId.startsWith('FlipChoice')) + presenceData.state = 'Flipping their character' + } + else if (playerState.prompt?.html?.startsWith('Who is
')) { + presenceData.state = 'Voting for the best champion' + } + else if ( + playerState.prompt?.html?.startsWith( + 'Swap your character or keep it in
', + ) + ) { + presenceData.state = 'Choosing whether to swap their character' + } + else { + presenceData.state = 'Watching the tutorial' + } + break + } + case 'Draw': { + const { entryId } = playerState + if (entryId?.startsWith('champion')) { + presenceData.state = 'Drawing a champion' + break + } + else if (entryId?.startsWith('challenger')) { + const imageLink = document.querySelector('.imageData')?.src + if (imageLink) { + presenceData.largeImageKey = await uploadFile( + imageLink, + 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/32.png', + presence, + ) + } - presenceData.state = "Drawing a challenger"; - break; - } - break; - } - } - return presenceData; + presenceData.state = 'Drawing a challenger' + break + } + break + } + } + return presenceData } diff --git a/websites/J/Jackbox/games/Party Pack 8/apply-yourself.ts b/websites/J/Jackbox/games/Party Pack 8/apply-yourself.ts index 07d2ed40a3cc..3b8b285565cf 100644 --- a/websites/J/Jackbox/games/Party Pack 8/apply-yourself.ts +++ b/websites/J/Jackbox/games/Party Pack 8/apply-yourself.ts @@ -1,35 +1,34 @@ -export const name = "Job Job"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/33.png"; +export const name = 'Job Job' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/33.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "Logo": { - return { state: "Waiting" }; - } - case "writing": { - return { state: "Writing a response" }; - } - case "voting": { - return { state: "Voting for a response" }; - } - case "magnets": { - return { state: "Answering a prompt using magnets" }; - } - case "resumagnets": { - return { state: "Filling out their resumé using magnets" }; - } - case "done": { - return { state: "Waiting for others to finish" }; - } - case "postGame": { - return { state: "Viewing the results" }; - } - } - return {}; + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'Logo': { + return { state: 'Waiting' } + } + case 'writing': { + return { state: 'Writing a response' } + } + case 'voting': { + return { state: 'Voting for a response' } + } + case 'magnets': { + return { state: 'Answering a prompt using magnets' } + } + case 'resumagnets': { + return { state: 'Filling out their resumé using magnets' } + } + case 'done': { + return { state: 'Waiting for others to finish' } + } + case 'postGame': { + return { state: 'Viewing the results' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 8/drawful-animate.ts b/websites/J/Jackbox/games/Party Pack 8/drawful-animate.ts index 4d374a1d305e..306917300b70 100644 --- a/websites/J/Jackbox/games/Party Pack 8/drawful-animate.ts +++ b/websites/J/Jackbox/games/Party Pack 8/drawful-animate.ts @@ -1,37 +1,36 @@ -export const name = "Drawful Animate"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/34.png"; +export const name = 'Drawful Animate' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/34.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "waiting": { - return { state: "Waiting" }; - } - case "drawing": { - if (playerState.prompt.text === "an animation of yourself") - return { state: "Drawing an animation of themselves" }; - else return { state: "Drawing an animation" }; - } - case "writing": { - return { state: "Guessing the original prompt" }; - } - case "liking": { - return { state: "Awarding likes to other's guesses" }; - } - case "choosing": { - return { state: "Looking for the true prompt" }; - } - case "postGame": { - return { state: "Viewing the results" }; - } - case "ugc": { - return { state: "Creating a custom game" }; - } - } - return {}; + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'waiting': { + return { state: 'Waiting' } + } + case 'drawing': { + if (playerState.prompt?.text === 'an animation of yourself') + return { state: 'Drawing an animation of themselves' } + else return { state: 'Drawing an animation' } + } + case 'writing': { + return { state: 'Guessing the original prompt' } + } + case 'liking': { + return { state: 'Awarding likes to other\'s guesses' } + } + case 'choosing': { + return { state: 'Looking for the true prompt' } + } + case 'postGame': { + return { state: 'Viewing the results' } + } + case 'ugc': { + return { state: 'Creating a custom game' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 8/murder-detectives.ts b/websites/J/Jackbox/games/Party Pack 8/murder-detectives.ts index f6a3e9e04329..9507a0c15ed3 100644 --- a/websites/J/Jackbox/games/Party Pack 8/murder-detectives.ts +++ b/websites/J/Jackbox/games/Party Pack 8/murder-detectives.ts @@ -1,57 +1,59 @@ -export const name = "Weapons Drawn"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/35.png"; +export const name = 'Weapons Drawn' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/35.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - const presenceData: PresenceData = {}, - icon = document.querySelector(".header.avatar"), - { kind, prompt } = playerState; - if (icon) { - presenceData.smallImageKey = getComputedStyle( - icon, - ":after" - ).backgroundImage.match(/^url\("(.*)"\)$/)?.[1]; - } - switch (kind) { - case "lobby": { - presenceData.state = "Waiting in lobby"; - break; - } - case "choosing": { - if (prompt.text === "Which case do you want to investigate?") - presenceData.state = "Choosing a case to investigate"; - else if ( - prompt.text === - "[header]WRONG[/header][section]Try again in 5 seconds...[/section]" || - prompt.text === "Choose a guest to target." || - (prompt as string).startsWith("Guess which detective brought ") - ) - presenceData.state = "Murdering guests"; - else if ((prompt as string).startsWith("Who do you think murdered ")) - presenceData.state = "Deciding on the culprit"; - break; - } - case "drawing": { - presenceData.state = "Drawing their weapon clue"; - break; - } - case "inspecting": { - presenceData.state = "Inspecting the killing weapons"; - break; - } - case "writing": { - presenceData.state = "Inviting accomplices"; - break; - } - case "postGame": { - presenceData.state = "Viewing the results"; - break; - } - default: { - presenceData.state = "Waiting"; - } - } - return presenceData; + const presenceData: PresenceData = {} + const icon = document.querySelector('.header.avatar') + const { kind, prompt } = playerState + if (icon) { + presenceData.smallImageKey = getComputedStyle( + icon, + ':after', + ).backgroundImage.match(/^url\("(.*)"\)$/)?.[1] + } + switch (kind) { + case 'lobby': { + presenceData.state = 'Waiting in lobby' + break + } + case 'choosing': { + if (prompt?.text === 'Which case do you want to investigate?') { + presenceData.state = 'Choosing a case to investigate' + } + else if ( + prompt?.text + === '[header]WRONG[/header][section]Try again in 5 seconds...[/section]' + || prompt?.text === 'Choose a guest to target.' + || (prompt as string).startsWith('Guess which detective brought ') + ) { + presenceData.state = 'Murdering guests' + } + else if ((prompt as string).startsWith('Who do you think murdered ')) { + presenceData.state = 'Deciding on the culprit' + } + break + } + case 'drawing': { + presenceData.state = 'Drawing their weapon clue' + break + } + case 'inspecting': { + presenceData.state = 'Inspecting the killing weapons' + break + } + case 'writing': { + presenceData.state = 'Inviting accomplices' + break + } + case 'postGame': { + presenceData.state = 'Viewing the results' + break + } + default: { + presenceData.state = 'Waiting' + } + } + return presenceData } diff --git a/websites/J/Jackbox/games/Party Pack 8/survey-bomb.ts b/websites/J/Jackbox/games/Party Pack 8/survey-bomb.ts index 39c78dcde637..ce04bef11cfe 100644 --- a/websites/J/Jackbox/games/Party Pack 8/survey-bomb.ts +++ b/websites/J/Jackbox/games/Party Pack 8/survey-bomb.ts @@ -1,26 +1,25 @@ -export const name = "The Poll Mine"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/36.png"; +export const name = 'The Poll Mine' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/36.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "waiting": { - return { state: "Waiting" }; - } - case "choices": { - return { state: "Selecting a door" }; - } - case "survey": { - return { state: "Completing survey" }; - } - case "postGame": { - return { state: "Viewing the results" }; - } - } - return {}; + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'waiting': { + return { state: 'Waiting' } + } + case 'choices': { + return { state: 'Selecting a door' } + } + case 'survey': { + return { state: 'Completing survey' } + } + case 'postGame': { + return { state: 'Viewing the results' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 8/the-wheel.ts b/websites/J/Jackbox/games/Party Pack 8/the-wheel.ts index 79d846f77977..ddff932fbb5c 100644 --- a/websites/J/Jackbox/games/Party Pack 8/the-wheel.ts +++ b/websites/J/Jackbox/games/Party Pack 8/the-wheel.ts @@ -1,68 +1,70 @@ -export const name = "The Wheel of Enormous Proportions"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/37.png"; +export const name = 'The Wheel of Enormous Proportions' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/37.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "waiting": { - return { state: "Waiting" }; - } - case "singleTextEntry": { - if (playerState.category === "askTheWheel") { - return { - state: `Asking the wheel a question - '${ - document.querySelector(".input-box textarea") - .value - }'`, - }; - } else return { state: "Answering a question" }; - } - case "choices": { - if (playerState.category === "skip-intro") - return { state: "Watching the tutorial" }; - break; - } - case "tappingList": { - return { state: "Selecting answers" }; - } - case "matching": { - const [a, b] = playerState.headers as string[]; - return { state: `Matching ${a} to ${b}` }; - } - case "placeSlices": { - return { state: "Placing slices" }; - } - case "spin": { - return { state: "Spinning the wheel" }; - } - case "numeric": { - return { - state: `Answering a numeric question - "${playerState.prompt}"`, - }; - } - case "postGame": { - return { state: "Viewing the results" }; - } - case "typingList": { - return { state: "Typing answers" }; - } - case "guessing": { - return { state: "Guessing what the wheel is thinking of" }; - } - case "tappingRapid": { - return { state: "Tapping rapidly" }; - } - case "choosePlayers": { - return { state: "Choosing players" }; - } - case "chooseSlices": { - return { state: "Choosing slices" }; - } - } - return {}; + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'waiting': { + return { state: 'Waiting' } + } + case 'singleTextEntry': { + if (playerState.category === 'askTheWheel') { + return { + state: `Asking the wheel a question - '${ + document.querySelector('.input-box textarea') + ?.value + }'`, + } + } + else { + return { state: 'Answering a question' } + } + } + case 'choices': { + if (playerState.category === 'skip-intro') + return { state: 'Watching the tutorial' } + break + } + case 'tappingList': { + return { state: 'Selecting answers' } + } + case 'matching': { + const [a, b] = playerState.headers as string[] + return { state: `Matching ${a} to ${b}` } + } + case 'placeSlices': { + return { state: 'Placing slices' } + } + case 'spin': { + return { state: 'Spinning the wheel' } + } + case 'numeric': { + return { + state: `Answering a numeric question - "${playerState.prompt}"`, + } + } + case 'postGame': { + return { state: 'Viewing the results' } + } + case 'typingList': { + return { state: 'Typing answers' } + } + case 'guessing': { + return { state: 'Guessing what the wheel is thinking of' } + } + case 'tappingRapid': { + return { state: 'Tapping rapidly' } + } + case 'choosePlayers': { + return { state: 'Choosing players' } + } + case 'chooseSlices': { + return { state: 'Choosing slices' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 9/antique-freak.ts b/websites/J/Jackbox/games/Party Pack 9/antique-freak.ts index c5ec3b1cae63..6bf6b33c1ace 100644 --- a/websites/J/Jackbox/games/Party Pack 9/antique-freak.ts +++ b/websites/J/Jackbox/games/Party Pack 9/antique-freak.ts @@ -1,52 +1,58 @@ -export const name = "Junktopia"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/38.png"; +export const name = 'Junktopia' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/38.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - const { prompt, kind, responseKey } = playerState; - switch (kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "postGame": { - return { state: "Viewing the results" }; - } - case "ranking": { - return { state: "Ranking items" }; - } - case "choosing": { - if (responseKey.startsWith("skip")) - return { state: "Watching the tutorial" }; - else if (responseKey.startsWith("shopping")) - return { state: "Shopping for an item" }; - else if (responseKey.startsWith("presentationChoice")) { - if (prompt.text === "Ready to present?") - return { state: "Preparing to present" }; - else return { state: "Presenting their item" }; - } else if (responseKey.startsWith("reaction")) - return { state: "Reacting to an item" }; - else if (responseKey.startsWith("voting")) - return { state: "Voting on a collection" }; - break; - } - case "fact": { - return { state: "Creating facts about an item" }; - } - case "writing": { - if (prompt.text === "This piece is entitled:") - return { state: "Naming their item" }; - else if ( - prompt.text === - 'Your two items are part of a collection called "[blank][/blank]"' - ) - return { state: "Naming their collection" }; - break; - } - case "waiting": { - return { state: "Waiting" }; - } - } - return {}; + const { prompt, kind, responseKey } = playerState + switch (kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'postGame': { + return { state: 'Viewing the results' } + } + case 'ranking': { + return { state: 'Ranking items' } + } + case 'choosing': { + if (responseKey?.startsWith('skip')) { + return { state: 'Watching the tutorial' } + } + else if (responseKey?.startsWith('shopping')) { + return { state: 'Shopping for an item' } + } + else if (responseKey?.startsWith('presentationChoice')) { + if (prompt?.text === 'Ready to present?') + return { state: 'Preparing to present' } + else return { state: 'Presenting their item' } + } + else if (responseKey?.startsWith('reaction')) { + return { state: 'Reacting to an item' } + } + else if (responseKey?.startsWith('voting')) { + return { state: 'Voting on a collection' } + } + break + } + case 'fact': { + return { state: 'Creating facts about an item' } + } + case 'writing': { + if (prompt?.text === 'This piece is entitled:') { + return { state: 'Naming their item' } + } + else if ( + prompt?.text + === 'Your two items are part of a collection called "[blank][/blank]"' + ) { + return { state: 'Naming their collection' } + } + break + } + case 'waiting': { + return { state: 'Waiting' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 9/fourbage.ts b/websites/J/Jackbox/games/Party Pack 9/fourbage.ts index a17afbf5c328..aec23e75d501 100644 --- a/websites/J/Jackbox/games/Party Pack 9/fourbage.ts +++ b/websites/J/Jackbox/games/Party Pack 9/fourbage.ts @@ -1,44 +1,43 @@ -export const name = "Fibbage 4"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/39.png"; +export const name = 'Fibbage 4' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/39.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "waiting": { - return { state: "Waiting" }; - } - case "choosing": { - switch (playerState.context) { - case "pick-category": { - return { state: "Choosing a category" }; - } - case "pick-truth": { - return { state: "Looking for the truth" }; - } - case "pick-likes": { - return { state: "Awarding likes to other's answers" }; - } - case "final-round-1": - case "final-round-2": { - return { state: "Looking for the truth - Final Round" }; - } - } - break; - } - case "writing": { - return { state: "Writing lies" }; - } - case "voting": { - break; - } - case "postGame": { - return { state: "Viewing the results" }; - } - } - return {}; + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'waiting': { + return { state: 'Waiting' } + } + case 'choosing': { + switch (playerState.context) { + case 'pick-category': { + return { state: 'Choosing a category' } + } + case 'pick-truth': { + return { state: 'Looking for the truth' } + } + case 'pick-likes': { + return { state: 'Awarding likes to other\'s answers' } + } + case 'final-round-1': + case 'final-round-2': { + return { state: 'Looking for the truth - Final Round' } + } + } + break + } + case 'writing': { + return { state: 'Writing lies' } + } + case 'voting': { + break + } + case 'postGame': { + return { state: 'Viewing the results' } + } + } + return {} } diff --git a/websites/J/Jackbox/games/Party Pack 9/htmf.ts b/websites/J/Jackbox/games/Party Pack 9/htmf.ts index 4249ed1cdc80..2294edd2ebcd 100644 --- a/websites/J/Jackbox/games/Party Pack 9/htmf.ts +++ b/websites/J/Jackbox/games/Party Pack 9/htmf.ts @@ -1,75 +1,74 @@ -export const name = "Roomerang"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/40.png"; +export const name = 'Roomerang' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/40.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - const presenceData: PresenceData = {}; - presenceData.smallImageKey = - document.querySelector(".avatar > img")?.src; - switch (playerState.kind) { - case "lobby": { - presenceData.state = "Waiting in lobby"; - break; - } - case "postGame": { - presenceData.state = "Viewing the results"; - break; - } - case "eliminating": { - presenceData.state = "Voting to eliminate a player"; - break; - } - case "choosing": { - if (playerState.prompt.text === "") - presenceData.state = "Voting for a response"; - else if (playerState.round === "firestarter") - presenceData.state = "Choosing a player to burn"; - else if (playerState.round === "finale") - presenceData.state = "Deciding who should win"; - break; - } - case "waiting": { - presenceData.state = "Waiting"; - break; - } - case "writing": { - if (playerState.isGoodbye) - presenceData.state = "Writing a goodbye message"; - else { - switch (playerState.round) { - case "intro": { - presenceData.state = "Writing an introduction"; - break; - } - case "connection": { - presenceData.state = "Writing about a connection"; - break; - } - case "quickie": { - presenceData.state = "Writing an anonymous response"; - break; - } - case "firestarter": { - presenceData.state = "Writing a dramatic response"; - break; - } - case "finale": { - presenceData.state = "Writing a response for the finale"; - break; - } - case "": { - presenceData.state = "Writing a victory speech"; - break; - } - default: { - presenceData.state = "Writing a response"; - } - } - } - break; - } - } - return presenceData; + const presenceData: PresenceData = {} + presenceData.smallImageKey = document.querySelector('.avatar > img')?.src + switch (playerState.kind) { + case 'lobby': { + presenceData.state = 'Waiting in lobby' + break + } + case 'postGame': { + presenceData.state = 'Viewing the results' + break + } + case 'eliminating': { + presenceData.state = 'Voting to eliminate a player' + break + } + case 'choosing': { + if (playerState.prompt?.text === '') + presenceData.state = 'Voting for a response' + else if (playerState.round === 'firestarter') + presenceData.state = 'Choosing a player to burn' + else if (playerState.round === 'finale') + presenceData.state = 'Deciding who should win' + break + } + case 'waiting': { + presenceData.state = 'Waiting' + break + } + case 'writing': { + if (playerState.isGoodbye) { + presenceData.state = 'Writing a goodbye message' + } + else { + switch (playerState.round) { + case 'intro': { + presenceData.state = 'Writing an introduction' + break + } + case 'connection': { + presenceData.state = 'Writing about a connection' + break + } + case 'quickie': { + presenceData.state = 'Writing an anonymous response' + break + } + case 'firestarter': { + presenceData.state = 'Writing a dramatic response' + break + } + case 'finale': { + presenceData.state = 'Writing a response for the finale' + break + } + case '': { + presenceData.state = 'Writing a victory speech' + break + } + default: { + presenceData.state = 'Writing a response' + } + } + } + break + } + } + return presenceData } diff --git a/websites/J/Jackbox/games/Party Pack 9/lineup.ts b/websites/J/Jackbox/games/Party Pack 9/lineup.ts index cc92237fe23f..fd21ff06f9d0 100644 --- a/websites/J/Jackbox/games/Party Pack 9/lineup.ts +++ b/websites/J/Jackbox/games/Party Pack 9/lineup.ts @@ -1,25 +1,24 @@ -export const name = "Quixort"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/41.png"; +export const name = 'Quixort' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/41.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "choices": { - return { state: "Selecting a topic to sort" }; - } - case "falling": { - return { state: "Sorting an item" }; - } - case "postGame": { - return { state: "Viewing the results" }; - } - default: { - return { state: "Waiting" }; - } - } + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'choices': { + return { state: 'Selecting a topic to sort' } + } + case 'falling': { + return { state: 'Sorting an item' } + } + case 'postGame': { + return { state: 'Viewing the results' } + } + default: { + return { state: 'Waiting' } + } + } } diff --git a/websites/J/Jackbox/games/Party Pack 9/range-game.ts b/websites/J/Jackbox/games/Party Pack 9/range-game.ts index 784a1ba6cbd2..cc1526b277cf 100644 --- a/websites/J/Jackbox/games/Party Pack 9/range-game.ts +++ b/websites/J/Jackbox/games/Party Pack 9/range-game.ts @@ -1,36 +1,35 @@ -export const name = "Nonsensory"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/42.png"; +export const name = 'Nonsensory' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/42.png' export function getPresenceData({ - playerState, + playerState, }: GameCallbackParams): PresenceData { - switch (playerState.kind) { - case "lobby": { - return { state: "Waiting in lobby" }; - } - case "postGame": { - return { state: "Viewing the results" }; - } - case "drawing": { - return { state: "Drawing a picture" }; - } - case "guess": { - return { state: "Guessing the value in the range" }; - } - case "postGuess": { - return { state: "Waiting for other players to guess" }; - } - case "singleTextEntry": { - return { state: "Answering a prompt" }; - } - case "choices": { - if (playerState.category === "walkthrough") - return { state: "Watching the tutorial" }; - else return { state: "Making a choice" }; - } - default: { - return { state: "Waiting" }; - } - } + switch (playerState.kind) { + case 'lobby': { + return { state: 'Waiting in lobby' } + } + case 'postGame': { + return { state: 'Viewing the results' } + } + case 'drawing': { + return { state: 'Drawing a picture' } + } + case 'guess': { + return { state: 'Guessing the value in the range' } + } + case 'postGuess': { + return { state: 'Waiting for other players to guess' } + } + case 'singleTextEntry': { + return { state: 'Answering a prompt' } + } + case 'choices': { + if (playerState.category === 'walkthrough') + return { state: 'Watching the tutorial' } + else return { state: 'Making a choice' } + } + default: { + return { state: 'Waiting' } + } + } } diff --git a/websites/J/Jackbox/games/index.ts b/websites/J/Jackbox/games/index.ts index 30b6bb9dfd4b..f3c45e56abaf 100644 --- a/websites/J/Jackbox/games/index.ts +++ b/websites/J/Jackbox/games/index.ts @@ -1,111 +1,111 @@ -import * as unknown from "./unknown"; -import * as ydkj2015 from "./Party Pack 1/ydkj2015"; -import * as lieswatter from "./Party Pack 1/lieswatter"; -import * as wordspud from "./Party Pack 1/wordspud"; -import * as drawful from "./Party Pack 1/drawful"; -import * as drawful2 from "./Party Pack 1/drawful2"; -import * as drawful2international from "./Party Pack 1/drawful2international"; -import * as auction from "./Party Pack 2/auction"; -import * as bombintern from "./Party Pack 2/bombintern"; -import * as earwax from "./Party Pack 2/earwax"; -import * as fibbage2 from "./Party Pack 2/fibbage2"; -import * as fibbage from "./Party Pack 2/fibbage"; -import * as quiplash from "./Party Pack 3/quiplash"; -import * as quiplash2 from "./Party Pack 3/quiplash2"; -import * as quiplash2international from "./Party Pack 3/quiplash2-international"; -import * as fakinit from "./Party Pack 3/fakinit"; -import * as awshirt from "./Party Pack 3/awshirt"; -import * as pollposition from "./Party Pack 3/pollposition"; -import * as triviadeath from "./Party Pack 3/triviadeath"; -import * as bracketeering from "./Party Pack 4/bracketeering"; -import * as overdrawn from "./Party Pack 4/overdrawn"; -import * as monstermingle from "./Party Pack 4/monstermingle"; -import * as survivetheinternet from "./Party Pack 4/survivetheinternet"; -import * as fibbage3 from "./Party Pack 4/fibbage3"; -import * as patentlystupid from "./Party Pack 5/patentlystupid"; -import * as rapbattle from "./Party Pack 5/rapbattle"; -import * as slingshoot from "./Party Pack 5/slingshoot"; -import * as splittheroom from "./Party Pack 5/splittheroom"; -import * as ydkj2018 from "./Party Pack 5/ydkj2018"; -import * as jokeboat from "./Party Pack 6/jokeboat"; -import * as pushthebutton from "./Party Pack 6/pushthebutton"; -import * as ridictionary from "./Party Pack 6/ridictionary"; -import * as rolemodels from "./Party Pack 6/rolemodels"; -import * as triviadeath2 from "./Party Pack 6/triviadeath2"; -import * as blankyblank from "./Party Pack 7/blanky-blank"; -import * as everyday from "./Party Pack 7/everyday"; -import * as jackboxtalks from "./Party Pack 7/jackbox-talks"; -import * as quiplash3 from "./Party Pack 7/quiplash3"; -import * as worldchamps from "./Party Pack 7/worldchamps"; -import * as applyyourself from "./Party Pack 8/apply-yourself"; -import * as drawfulanimate from "./Party Pack 8/drawful-animate"; -import * as surveybomb from "./Party Pack 8/survey-bomb"; -import * as thewheel from "./Party Pack 8/the-wheel"; -import * as murderdetectives from "./Party Pack 8/murder-detectives"; -import * as fourbage from "./Party Pack 9/fourbage"; -import * as htmf from "./Party Pack 9/htmf"; -import * as rangegame from "./Party Pack 9/range-game"; -import * as lineup from "./Party Pack 9/lineup"; -import * as antiquefreak from "./Party Pack 9/antique-freak"; -import * as awshirt2 from "./Party Pack 10/awshirt2"; -import * as nopusopus from "./Party Pack 10/nopus-opus"; -import * as riskytext from "./Party Pack 10/risky-text"; -import * as timetrivia from "./Party Pack 10/time-trivia"; -import * as usthem from "./Party Pack 10/us-them"; +import * as drawful from './Party Pack 1/drawful' +import * as drawful2 from './Party Pack 1/drawful2' +import * as drawful2international from './Party Pack 1/drawful2international' +import * as lieswatter from './Party Pack 1/lieswatter' +import * as wordspud from './Party Pack 1/wordspud' +import * as ydkj2015 from './Party Pack 1/ydkj2015' +import * as auction from './Party Pack 2/auction' +import * as bombintern from './Party Pack 2/bombintern' +import * as earwax from './Party Pack 2/earwax' +import * as fibbage from './Party Pack 2/fibbage' +import * as fibbage2 from './Party Pack 2/fibbage2' +import * as awshirt from './Party Pack 3/awshirt' +import * as fakinit from './Party Pack 3/fakinit' +import * as pollposition from './Party Pack 3/pollposition' +import * as quiplash from './Party Pack 3/quiplash' +import * as quiplash2 from './Party Pack 3/quiplash2' +import * as quiplash2international from './Party Pack 3/quiplash2-international' +import * as triviadeath from './Party Pack 3/triviadeath' +import * as bracketeering from './Party Pack 4/bracketeering' +import * as fibbage3 from './Party Pack 4/fibbage3' +import * as monstermingle from './Party Pack 4/monstermingle' +import * as overdrawn from './Party Pack 4/overdrawn' +import * as survivetheinternet from './Party Pack 4/survivetheinternet' +import * as patentlystupid from './Party Pack 5/patentlystupid' +import * as rapbattle from './Party Pack 5/rapbattle' +import * as slingshoot from './Party Pack 5/slingshoot' +import * as splittheroom from './Party Pack 5/splittheroom' +import * as ydkj2018 from './Party Pack 5/ydkj2018' +import * as jokeboat from './Party Pack 6/jokeboat' +import * as pushthebutton from './Party Pack 6/pushthebutton' +import * as ridictionary from './Party Pack 6/ridictionary' +import * as rolemodels from './Party Pack 6/rolemodels' +import * as triviadeath2 from './Party Pack 6/triviadeath2' +import * as blankyblank from './Party Pack 7/blanky-blank' +import * as everyday from './Party Pack 7/everyday' +import * as jackboxtalks from './Party Pack 7/jackbox-talks' +import * as quiplash3 from './Party Pack 7/quiplash3' +import * as worldchamps from './Party Pack 7/worldchamps' +import * as applyyourself from './Party Pack 8/apply-yourself' +import * as drawfulanimate from './Party Pack 8/drawful-animate' +import * as murderdetectives from './Party Pack 8/murder-detectives' +import * as surveybomb from './Party Pack 8/survey-bomb' +import * as thewheel from './Party Pack 8/the-wheel' +import * as antiquefreak from './Party Pack 9/antique-freak' +import * as fourbage from './Party Pack 9/fourbage' +import * as htmf from './Party Pack 9/htmf' +import * as lineup from './Party Pack 9/lineup' +import * as rangegame from './Party Pack 9/range-game' +import * as awshirt2 from './Party Pack 10/awshirt2' +import * as nopusopus from './Party Pack 10/nopus-opus' +import * as riskytext from './Party Pack 10/risky-text' +import * as timetrivia from './Party Pack 10/time-trivia' +import * as usthem from './Party Pack 10/us-them' +import * as unknown from './unknown' export default { - unknown, - ydkj2015, - lieswatter, - wordspud, - drawful, - drawful2, - drawful2international, - auction, - bombintern, - earwax, - fibbage2, - fibbage, - quiplash, - quiplash2, - "quiplash2-international": quiplash2international, - fakinit, - awshirt, - pollposition, - triviadeath, - bracketeering, - overdrawn, - monstermingle, - survivetheinternet, - fibbage3, - patentlystupid, - rapbattle, - slingshoot, - splittheroom, - ydkj2018, - jokeboat, - pushthebutton, - ridictionary, - rolemodels, - triviadeath2, - "blanky-blank": blankyblank, - everyday, - "jackbox-talks": jackboxtalks, - quiplash3, - worldchamps, - "apply-yourself": applyyourself, - "drawful-animate": drawfulanimate, - "survey-bomb": surveybomb, - "the-wheel": thewheel, - "murder-detectives": murderdetectives, - fourbage, - htmf, - "range-game": rangegame, - lineup, - "antique-freak": antiquefreak, - awshirt2, - "nopus-opus": nopusopus, - "risky-text": riskytext, - "time-trivia": timetrivia, - "us-them": usthem, -} as Record; + unknown, + ydkj2015, + lieswatter, + wordspud, + drawful, + drawful2, + drawful2international, + auction, + bombintern, + earwax, + fibbage2, + fibbage, + quiplash, + quiplash2, + 'quiplash2-international': quiplash2international, + fakinit, + awshirt, + pollposition, + triviadeath, + bracketeering, + overdrawn, + monstermingle, + survivetheinternet, + fibbage3, + patentlystupid, + rapbattle, + slingshoot, + splittheroom, + ydkj2018, + jokeboat, + pushthebutton, + ridictionary, + rolemodels, + triviadeath2, + 'blanky-blank': blankyblank, + everyday, + 'jackbox-talks': jackboxtalks, + quiplash3, + worldchamps, + 'apply-yourself': applyyourself, + 'drawful-animate': drawfulanimate, + 'survey-bomb': surveybomb, + 'the-wheel': thewheel, + 'murder-detectives': murderdetectives, + fourbage, + htmf, + 'range-game': rangegame, + lineup, + 'antique-freak': antiquefreak, + awshirt2, + 'nopus-opus': nopusopus, + 'risky-text': riskytext, + 'time-trivia': timetrivia, + 'us-them': usthem, +} as Record diff --git a/websites/J/Jackbox/games/unknown.ts b/websites/J/Jackbox/games/unknown.ts index 82f934c8310e..fc545203802d 100644 --- a/websites/J/Jackbox/games/unknown.ts +++ b/websites/J/Jackbox/games/unknown.ts @@ -1,10 +1,9 @@ -export const tag = "unknown"; -export const name = "Unknown Game"; -export const logo = - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/logo.png"; +export const tag = 'unknown' +export const name = 'Unknown Game' +export const logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/logo.png' export function getPresenceData(info: GameCallbackParams): PresenceData { - return { - state: `Playing an unsupported game (${info.tag})`, - }; + return { + state: `Playing an unsupported game (${info.tag})`, + } } diff --git a/websites/J/Jackbox/metadata.json b/websites/J/Jackbox/metadata.json index 2ab52abb2ed3..b2a6ddbc6d5a 100644 --- a/websites/J/Jackbox/metadata.json +++ b/websites/J/Jackbox/metadata.json @@ -1,54 +1,54 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Stringy", - "id": "577743466940071949" - }, - "contributors": [ - { - "name": "theusaf", - "id": "193714715631812608" - } - ], - "service": "Jackbox", - "description": { - "en": "It's easy to use this website to turn your phone, tablet or computer into a controller for one of Jackbox Games many party games. All you'll need is a room code", - "nl": "Het is gemakkelijk om deze website te gebruiken om van je telefoon, tablet of computer een controller te maken voor een van de vele partygames van Jackbox Games. Het enige dat u nodig heeft, is een kamercode" - }, - "url": [ - "jackbox.tv", - "games.jackbox.tv", - "www.jackboxgames.com", - "shop.jackboxgames.com" - ], - "version": "2.1.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/thumbnail.png", - "color": "#4254f4", - "category": "games", - "tags": [ - "games" - ], - "readLogs": true, - "settings": [ - { - "id": "useName", - "title": "Show selected username", - "icon": "fas fa-user", - "value": true - }, - { - "id": "useTime", - "title": "Show time elapsed", - "icon": "fas fa-stopwatch", - "value": true - }, - { - "id": "useDetails", - "title": "Show game details", - "icon": "fas fa-circle-info", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Stringy", + "id": "577743466940071949" + }, + "contributors": [ + { + "name": "theusaf", + "id": "193714715631812608" + } + ], + "service": "Jackbox", + "description": { + "en": "It's easy to use this website to turn your phone, tablet or computer into a controller for one of Jackbox Games many party games. All you'll need is a room code", + "nl": "Het is gemakkelijk om deze website te gebruiken om van je telefoon, tablet of computer een controller te maken voor een van de vele partygames van Jackbox Games. Het enige dat u nodig heeft, is een kamercode" + }, + "url": [ + "jackbox.tv", + "games.jackbox.tv", + "www.jackboxgames.com", + "shop.jackboxgames.com" + ], + "version": "2.1.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/thumbnail.png", + "color": "#4254f4", + "category": "games", + "tags": [ + "games" + ], + "readLogs": true, + "settings": [ + { + "id": "useName", + "title": "Show selected username", + "icon": "fas fa-user", + "value": true + }, + { + "id": "useTime", + "title": "Show time elapsed", + "icon": "fas fa-stopwatch", + "value": true + }, + { + "id": "useDetails", + "title": "Show game details", + "icon": "fas fa-circle-info", + "value": true + } + ] +} diff --git a/websites/J/Jackbox/presence.ts b/websites/J/Jackbox/presence.ts index 43d88950b1f3..e4d35316b795 100644 --- a/websites/J/Jackbox/presence.ts +++ b/websites/J/Jackbox/presence.ts @@ -1,260 +1,277 @@ -import games from "./games/index"; +import games from './games/index' const presence = new Presence({ - clientId: "638118757453004820", -}); + clientId: '638118757453004820', +}) // The game state (usually contains the current game phase / 'kind') let gamePlayerState: GamePlayerState = { - playerName: null, - state: null, - username: null, - }, - // The player's details, such as name. May be set only at the start. - gamePlayerInfoState: GameInfoState = { - name: null, - }, - game: Game, - browsingTimestamp = Math.round(Date.now() / 1000), - gametag: string; + playerName: null as unknown as string, + state: null as unknown as string, + username: null as unknown as string, +} +// The player's details, such as name. May be set only at the start. +let gamePlayerInfoState: GameInfoState = { + name: null as unknown as string, +} +let game: Game +let browsingTimestamp = Math.round(Date.now() / 1000) +let gametag: string -if (document.location.hostname === "jackbox.tv") { - setInterval(async () => { - const playerStateLogs = await presence.getLogs( - /recv <- .*?("key": "(bc:customer|player|info):[a-z0-9-]+",)/s - ); - if (playerStateLogs.length > 0) { - let updatedMainState = false, - updatedInfoState = false; - for ( - let i = playerStateLogs.length - 1; - !(updatedInfoState && updatedMainState) && - i >= playerStateLogs.length - 6 && - i >= 0; - i-- - ) { - const latestLog = playerStateLogs[i]; - if (typeof latestLog !== "string") continue; - let parsedLog; - try { - parsedLog = JSON.parse(latestLog.slice(8)); - } catch { - presence.error(`Failed to parse log: ${latestLog}`); - continue; - } - switch (true) { - case /recv <- .*?"entities": {\n/s.test(latestLog): { - if (!updatedMainState) { - gamePlayerState = - parsedLog.result.entities[ - latestLog.match( - /"key": "((?:bc:customer|player):(?:[a-z0-9-]+))",/s - )?.[1] - ]?.[1].val ?? parsedLog.result.val; - updatedMainState = true; - } - if (!updatedInfoState) { - gamePlayerInfoState = - parsedLog.result.entities[ - latestLog.match(/"key": "(info:\d+)",/s)?.[1] - ]?.[1].val ?? parsedLog.result; - updatedInfoState = true; - } - break; - } - case /recv <- .*?"key": "((?:bc:customer|player):(?:[a-z0-9-]+))",/s.test( - latestLog - ): { - if (!updatedMainState) { - gamePlayerState = parsedLog.result.val; - updatedMainState = true; - } - break; - } - case /recv <- .*?"key": "info:\d+",/s.test(latestLog): { - if (!updatedInfoState) { - gamePlayerInfoState = parsedLog.result.val; - updatedInfoState = true; - } - } - } - } - } - if (!game) { - type JackboxStorageLetiable = { - tag: string; - }; - const { tag } = await presence.getPageletiable( - 'tv"]["storage' - ); - gametag = tag; - if (tag && tag !== "@connect") { - game = games[tag]; - browsingTimestamp = Math.round(Date.now() / 1000); - if (!game) game = games.unknown; - } - } - }, 1000); +if (document.location.hostname === 'jackbox.tv') { + setInterval(async () => { + const playerStateLogs = await presence.getLogs( + /recv <- .*?("key": "(bc:customer|player|info):[a-z0-9-]+",)/s, + ) + if (playerStateLogs.length > 0) { + let updatedMainState = false + let updatedInfoState = false + for ( + let i = playerStateLogs.length - 1; + !(updatedInfoState && updatedMainState) + && i >= playerStateLogs.length - 6 + && i >= 0; + i-- + ) { + const latestLog = playerStateLogs[i] + if (typeof latestLog !== 'string') + continue + let parsedLog + try { + parsedLog = JSON.parse(latestLog.slice(8)) + } + catch { + presence.error(`Failed to parse log: ${latestLog}`) + continue + } + switch (true) { + case /recv <- .*?"entities": \{\n/s.test(latestLog): { + if (!updatedMainState) { + gamePlayerState = parsedLog.result.entities[ + latestLog.match( + /"key": "((?:bc:customer|player):[a-z0-9-]+)",/, + )?.[1] ?? '' + ]?.[1].val ?? parsedLog.result.val + updatedMainState = true + } + if (!updatedInfoState) { + gamePlayerInfoState = parsedLog.result.entities[ + latestLog.match(/"key": "(info:\d+)",/)?.[1] ?? '' + ]?.[1].val ?? parsedLog.result + updatedInfoState = true + } + break + } + case /recv <- .*?"key": "(?:bc:customer|player):[a-z0-9-]+",/s.test( + latestLog, + ): { + if (!updatedMainState) { + gamePlayerState = parsedLog.result.val + updatedMainState = true + } + break + } + case /recv <- .*?"key": "info:\d+",/s.test(latestLog): { + if (!updatedInfoState) { + gamePlayerInfoState = parsedLog.result.val + updatedInfoState = true + } + } + } + } + } + if (!game) { + interface JackboxStorageLetiable { + tag: string + } + const { tag } = await presence.getPageletiable( + 'tv"]["storage', + ) + gametag = tag + if (tag && tag !== '@connect') { + game = games[tag] + browsingTimestamp = Math.round(Date.now() / 1000) + if (!game) + game = games.unknown + } + } + }, 1000) } -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/logo.png", - }; - const [useName, useTime, useDetails] = await Promise.all([ - presence.getSetting("useName"), - presence.getSetting("useTime"), - presence.getSetting("useDetails"), - ]), - { href, hostname, pathname, search } = document.location, - pathSplit = pathname.split("/").slice(1); +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/Jackbox/assets/logo.png', + } + const [useName, useTime, useDetails] = await Promise.all([ + presence.getSetting('useName'), + presence.getSetting('useTime'), + presence.getSetting('useDetails'), + ]) + const { href, hostname, pathname, search } = document.location + const pathSplit = pathname.split('/').slice(1) - if (useTime) presenceData.startTimestamp = browsingTimestamp; + if (useTime) + presenceData.startTimestamp = browsingTimestamp - switch (hostname) { - case "jackbox.tv": { - if (game) { - const { name, logo } = game; - presenceData.largeImageKey = logo; - presenceData.details = `Playing ${name}`; - if (useName) { - const { playerName, username, playerInfo } = gamePlayerState, - realUsername = - playerName ?? - username ?? - playerInfo?.username ?? - gamePlayerInfoState.name; - if (realUsername) { - if (useDetails) presenceData.details += ` as ${realUsername}`; - else presenceData.state = `as ${realUsername}`; - } - } - if (useDetails) { - const gamePresenceData = await game.getPresenceData({ - tag: gametag, - playerState: gamePlayerState, - infoState: gamePlayerInfoState, - presence, - }); - presenceData = { ...presenceData, ...gamePresenceData }; - } - } else presenceData.details = "Idle"; - break; - } - case "games.jackbox.tv": { - presenceData.details = "Looking at a past game"; - presenceData.state = document.title; - presenceData.largeImageKey = document.querySelector( - "[class*=-artifact] .image" - ).src; - presenceData.buttons = [ - { - label: "View Game", - url: href, - }, - ]; - break; - } - case "www.jackboxgames.com": { - switch (pathSplit[0] ?? "") { - case "": { - presenceData.details = "Browsing home page"; - break; - } - case "author": { - presenceData.details = "Browsing blog posts by author"; - presenceData.state = document - .querySelector("h1") - .textContent.match(/Author: (.*)/i)[1]; - break; - } - case "blog": { - presenceData.details = "Browsing blog posts"; - break; - } - case "category": { - presenceData.details = "Browsing blog category"; - presenceData.state = document - .querySelector("h1") - .textContent.match(/Category: (.*)/i)[1]; - break; - } - case "games": { - presenceData.details = "Browsing games"; - break; - } - case "tag": { - presenceData.details = "Browsing blog posts by tag"; - presenceData.state = document - .querySelector("h1") - .textContent.match(/Tag: (.*)/i)[1]; - break; - } - default: { - if (/^\/\d{4}(\/\d{2})?(\/\d{2})?\/$/.test(pathname)) { - presenceData.details = "Browsing blog posts by date"; - presenceData.state = document.querySelector("h1").textContent; - } else if ( - document.body.getAttribute("itemtype") === "http://schema.org/Blog" - ) { - presenceData.details = "Reading an article"; - presenceData.state = document.querySelector("h1").textContent; - presenceData.buttons = [ - { - label: "Read Article", - url: href, - }, - ]; - } else { - presenceData.details = "Browsing"; - presenceData.state = document.title.match( - /^(.*?)( - Jackbox Games)?$/ - )[1]; - } - } - } - break; - } - case "shop.jackboxgames.com": { - switch (pathSplit[0] ?? "") { - case "": { - presenceData.details = "Browsing store"; - break; - } - case "cart": { - presenceData.details = "Viewing cart"; - break; - } - case "collections": { - if (pathSplit[1]) { - if (pathSplit.includes("products")) { - presenceData.details = "Viewing a product"; - presenceData.state = document.querySelector("h1").textContent; - } else { - presenceData.details = "Browsing collection"; - presenceData.state = document.querySelector("h1").textContent; - } - } else presenceData.details = "Browsing collections"; - break; - } - case "products": { - if (pathSplit[1]) { - presenceData.details = "Viewing a product"; - presenceData.state = document.querySelector("h1").textContent; - } else presenceData.details = "Browsing collections"; - break; - } - case "search": { - presenceData.details = "Searching store"; - presenceData.state = new URLSearchParams(search).get("q"); - break; - } - } - break; - } - } + switch (hostname) { + case 'jackbox.tv': { + if (game) { + const { name, logo } = game + presenceData.largeImageKey = logo + presenceData.details = `Playing ${name}` + if (useName) { + const { playerName, username, playerInfo } = gamePlayerState + const realUsername = playerName + ?? username + ?? playerInfo?.username + ?? gamePlayerInfoState.name + if (realUsername) { + if (useDetails) + presenceData.details += ` as ${realUsername}` + else presenceData.state = `as ${realUsername}` + } + } + if (useDetails) { + const gamePresenceData = await game.getPresenceData({ + tag: gametag, + playerState: gamePlayerState, + infoState: gamePlayerInfoState, + presence, + }) + presenceData = { ...presenceData, ...gamePresenceData } + } + } + else { + presenceData.details = 'Idle' + } + break + } + case 'games.jackbox.tv': { + presenceData.details = 'Looking at a past game' + presenceData.state = document.title + presenceData.largeImageKey = document.querySelector( + '[class*=-artifact] .image', + )?.src + presenceData.buttons = [ + { + label: 'View Game', + url: href, + }, + ] + break + } + case 'www.jackboxgames.com': { + switch (pathSplit[0] ?? '') { + case '': { + presenceData.details = 'Browsing home page' + break + } + case 'author': { + presenceData.details = 'Browsing blog posts by author' + presenceData.state = document + .querySelector('h1') + ?.textContent + ?.match(/Author: (.*)/i)?.[1] + break + } + case 'blog': { + presenceData.details = 'Browsing blog posts' + break + } + case 'category': { + presenceData.details = 'Browsing blog category' + presenceData.state = document + .querySelector('h1') + ?.textContent + ?.match(/Category: (.*)/i)?.[1] + break + } + case 'games': { + presenceData.details = 'Browsing games' + break + } + case 'tag': { + presenceData.details = 'Browsing blog posts by tag' + presenceData.state = document + .querySelector('h1') + ?.textContent + ?.match(/Tag: (.*)/i)?.[1] + break + } + default: { + if (/^\/\d{4}(?:\/\d{2})?(?:\/\d{2})?\/$/.test(pathname)) { + presenceData.details = 'Browsing blog posts by date' + presenceData.state = document.querySelector('h1')?.textContent + } + else if ( + document.body.getAttribute('itemtype') === 'http://schema.org/Blog' + ) { + presenceData.details = 'Reading an article' + presenceData.state = document.querySelector('h1')?.textContent + presenceData.buttons = [ + { + label: 'Read Article', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing' + presenceData.state = document.title.match( + /^(.*?)( - Jackbox Games)?$/, + )?.[1] + } + } + } + break + } + case 'shop.jackboxgames.com': { + switch (pathSplit[0] ?? '') { + case '': { + presenceData.details = 'Browsing store' + break + } + case 'cart': { + presenceData.details = 'Viewing cart' + break + } + case 'collections': { + if (pathSplit[1]) { + if (pathSplit.includes('products')) { + presenceData.details = 'Viewing a product' + presenceData.state = document.querySelector('h1')?.textContent + } + else { + presenceData.details = 'Browsing collection' + presenceData.state = document.querySelector('h1')?.textContent + } + } + else { + presenceData.details = 'Browsing collections' + } + break + } + case 'products': { + if (pathSplit[1]) { + presenceData.details = 'Viewing a product' + presenceData.state = document.querySelector('h1')?.textContent + } + else { + presenceData.details = 'Browsing collections' + } + break + } + case 'search': { + presenceData.details = 'Searching store' + presenceData.state = new URLSearchParams(search).get('q') + break + } + } + break + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/J/Jackbox/util.ts b/websites/J/Jackbox/util.ts index d0cd78ff1207..1139fadf2bd3 100644 --- a/websites/J/Jackbox/util.ts +++ b/websites/J/Jackbox/util.ts @@ -1,64 +1,66 @@ -const uploadedFiles: Record = {}; +const uploadedFiles: Record = {} export async function uploadFile( - url: string, - defaultImage: string, - presence: Presence + url: string, + defaultImage: string, + presence: Presence, ): Promise { - if (uploadedFiles[url]) return uploadedFiles[url]; - uploadedFiles[url] = defaultImage; + if (uploadedFiles[url]) + return uploadedFiles[url] + uploadedFiles[url] = defaultImage - try { - const imageData = await fetch(url).then(res => res.blob()), - formData = new FormData(); - formData.append("file", imageData, "file"); - const resultURL = await fetch("https://pd.premid.app/create/image", { - method: "POST", - body: formData, - }).then(res => res.text()); + try { + const imageData = await fetch(url).then(res => res.blob()) + const formData = new FormData() + formData.append('file', imageData, 'file') + const resultURL = await fetch('https://pd.premid.app/create/image', { + method: 'POST', + body: formData, + }).then(res => res.text()) - presence.info(resultURL); - uploadedFiles[url] = resultURL; - return resultURL; - } catch (err) { - presence.error(err); - return url; - } + presence.info(resultURL) + uploadedFiles[url] = resultURL + return resultURL + } + catch (err) { + presence.error(err as string) + return url + } } -const svgCache: Map = new Map(); +const svgCache: Map = new Map() export function getSVGImageData(initialSvg: SVGElement): Promise { - if (svgCache.has(initialSvg)) - return Promise.resolve(svgCache.get(initialSvg)); + if (svgCache.has(initialSvg)) + return Promise.resolve(svgCache.get(initialSvg)!) - const clone = initialSvg.cloneNode(true) as SVGElement, - initialPaths = initialSvg.querySelectorAll("path"), - clonePaths = clone.querySelectorAll("path"), - canvas = document.createElement("canvas"), - ctx = canvas.getContext("2d"), - image = document.createElement("img"); + const clone = initialSvg.cloneNode(true) as SVGElement + const initialPaths = initialSvg.querySelectorAll('path') + const clonePaths = clone.querySelectorAll('path') + const canvas = document.createElement('canvas') + const ctx = canvas.getContext('2d')! + const image = document.createElement('img') - canvas.width = 512; - canvas.height = 512; + canvas.width = 512 + canvas.height = 512 - // To fix issues on some browsers like Firefox - clone.setAttribute("width", "512"); - clone.setAttribute("height", "512"); + // To fix issues on some browsers like Firefox + clone.setAttribute('width', '512') + clone.setAttribute('height', '512') - for (const [i, initialPath] of initialPaths.entries()) { - const fillStyle = getComputedStyle(initialPath).fill; - clonePaths[i].setAttribute("fill", fillStyle); - } + for (const [i, initialPath] of initialPaths.entries()) { + const fillStyle = getComputedStyle(initialPath).fill + clonePaths[i].setAttribute('fill', fillStyle) + } - const xml = new XMLSerializer().serializeToString(clone), - svgURL = `data:image/svg+xml;base64,${btoa(xml)}`; + const xml = new XMLSerializer().serializeToString(clone) + const svgURL = `data:image/svg+xml;base64,${btoa(xml)}` - return new Promise(resolve => { - image.onload = () => { - ctx.drawImage(image, 0, 0, 512, 512); - const data = canvas.toDataURL("image/png"); - svgCache.set(initialSvg, data); - resolve(data); - }; - image.src = svgURL; - }); + return new Promise((resolve) => { + image.onload = () => { + ctx.drawImage(image, 0, 0, 512, 512) + const data = canvas.toDataURL('image/png') + svgCache.set(initialSvg, data) + resolve(data) + } + image.src = svgURL + }) } diff --git a/websites/J/Japanese Mahjong Wiki/metadata.json b/websites/J/Japanese Mahjong Wiki/metadata.json index 756ee825d63a..8b5fe5061123 100644 --- a/websites/J/Japanese Mahjong Wiki/metadata.json +++ b/websites/J/Japanese Mahjong Wiki/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "Japanese Mahjong Wiki", - "description": { - "en": "A wiki whose main purpose is to provide English speakers easy access and material pertaining to Japanese mahjong." - }, - "url": "riichi.wiki", - "version": "1.0.5", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Japanese%20Mahjong%20Wiki/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Japanese%20Mahjong%20Wiki/assets/thumbnail.jpg", - "color": "#F1ECE6", - "category": "games", - "tags": [ - "mahjong", - "japan", - "japanese", - "riichi", - "wiki", - "culture" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "Japanese Mahjong Wiki", + "description": { + "en": "A wiki whose main purpose is to provide English speakers easy access and material pertaining to Japanese mahjong." + }, + "url": "riichi.wiki", + "version": "1.0.5", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Japanese%20Mahjong%20Wiki/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Japanese%20Mahjong%20Wiki/assets/thumbnail.jpg", + "color": "#F1ECE6", + "category": "games", + "tags": [ + "mahjong", + "japan", + "japanese", + "riichi", + "wiki", + "culture" + ] +} diff --git a/websites/J/Japanese Mahjong Wiki/pages/special.ts b/websites/J/Japanese Mahjong Wiki/pages/special.ts index 565e0d550b2c..3b77685f903c 100644 --- a/websites/J/Japanese Mahjong Wiki/pages/special.ts +++ b/websites/J/Japanese Mahjong Wiki/pages/special.ts @@ -1,68 +1,68 @@ -import { findNearestAboveElement, squareImage } from "../util/util"; +import { findNearestAboveElement, squareImage } from '../util/util' // Wiki-specific groups of pages const strategies = new Set([ - "Sakigiri", - "Suji", - "Kabe", - "Betaori", - "Kawa", - "Sashikomi", - "Defense", - "Tile_efficiency", - "Atozuke", - "Yaku_compatibility", - "Damaten", - "Kan", - "Machi", - "Riichi_strategy", - "Shanten", - "Tenpai", - "Ukeire", - "What_would_you_discard", - "Dora", - ]), - yaku = new Set([ - "Menzenchin_tsumohou", - "Riichi", - "Ippatsu", - "Pinfu", - "Iipeikou", - "Haitei raoyue and houtei raoyui", - "Rinshan_kaihou", - "Chankan", - "Tanyao", - "Yakuhai", - "Daburu_riichi", - "Chanta", - "Sanshouku_doujun", - "Ikkitsuukan", - "Toitoihou", - "Sanankou", - "Sanshoku_doukou", - "Sankantsu", - "Chiitoitsu", - "Honroutou", - "Shousangen", - "Honiisou", - "Junchantaiyaochuu", - "Ryanpeikou", - "Chiniisou", - "Kazoe_yakuman", - "Kokushi_musou", - "Suuankou", - "Daisangen", - "Suushiihou", - "Tsuuiisou", - "Chinroutou", - "Ryuuiisou", - "Chuuren_poutou", - "Suukantsu", - "Tenhou_and_chiihou", - "Nagashi_mangan", - ]), - games = new Set(["Riichi_City", "Majsoul", "Sega_MJ", "Tenhou.net"]), - SLIDESHOW_TIMEOUT = 6000; + 'Sakigiri', + 'Suji', + 'Kabe', + 'Betaori', + 'Kawa', + 'Sashikomi', + 'Defense', + 'Tile_efficiency', + 'Atozuke', + 'Yaku_compatibility', + 'Damaten', + 'Kan', + 'Machi', + 'Riichi_strategy', + 'Shanten', + 'Tenpai', + 'Ukeire', + 'What_would_you_discard', + 'Dora', +]) +const yaku = new Set([ + 'Menzenchin_tsumohou', + 'Riichi', + 'Ippatsu', + 'Pinfu', + 'Iipeikou', + 'Haitei raoyue and houtei raoyui', + 'Rinshan_kaihou', + 'Chankan', + 'Tanyao', + 'Yakuhai', + 'Daburu_riichi', + 'Chanta', + 'Sanshouku_doujun', + 'Ikkitsuukan', + 'Toitoihou', + 'Sanankou', + 'Sanshoku_doukou', + 'Sankantsu', + 'Chiitoitsu', + 'Honroutou', + 'Shousangen', + 'Honiisou', + 'Junchantaiyaochuu', + 'Ryanpeikou', + 'Chiniisou', + 'Kazoe_yakuman', + 'Kokushi_musou', + 'Suuankou', + 'Daisangen', + 'Suushiihou', + 'Tsuuiisou', + 'Chinroutou', + 'Ryuuiisou', + 'Chuuren_poutou', + 'Suukantsu', + 'Tenhou_and_chiihou', + 'Nagashi_mangan', +]) +const games = new Set(['Riichi_City', 'Majsoul', 'Sega_MJ', 'Tenhou.net']) +const SLIDESHOW_TIMEOUT = 6000 /** * Applies page details based on the current location. @@ -71,236 +71,237 @@ const strategies = new Set([ * @returns Whether the page uses slideshows. */ export async function specialPageHandler( - presenceData: PresenceData, - slideshow: Slideshow + presenceData: PresenceData, + slideshow: Slideshow, ): Promise { - const { pathname, href, search } = document.location, - searchParams = new URLSearchParams(search), - pageTitle = document.querySelector(".mw-page-title-main"); - let firstPath = pathname.split("/").find(Boolean), - usesSlideshows = false; - if (firstPath === "index.php") firstPath = searchParams.get("title"); + const { pathname, href, search } = document.location + const searchParams = new URLSearchParams(search) + const pageTitle = document.querySelector('.mw-page-title-main') + let firstPath = pathname.split('/').find(Boolean) + let usesSlideshows = false + if (firstPath === 'index.php') + firstPath = searchParams.get('title') ?? '' - if (searchParams.has("search")) { - presenceData.details = "Searching for a page"; - presenceData.state = document.querySelector( - "#searchText > input" - )?.value; - } else if (searchParams.has("action") || searchParams.has("veaction")) { - const action = searchParams.get("action") ?? searchParams.get("veaction"); - switch (action) { - case "edit": { - presenceData.details = "Editing a page"; - presenceData.state = - document.querySelector("#firstHeadingTitle") ?? - pageTitle; - break; - } - case "history": { - presenceData.details = "Viewing the revision history of a page"; - presenceData.state = pageTitle; - break; - } - } - } else { - // Common WikiMedia pages - switch (true) { - case firstPath.startsWith("Talk:"): { - presenceData.details = `Viewing the talk page for '${pageTitle.textContent}'`; - break; - } - case firstPath.startsWith("User:"): { - presenceData.details = "Viewing a user page"; - presenceData.state = pageTitle; - presenceData.buttons = [{ label: "View User Page", url: href }]; - break; - } - case firstPath.startsWith("User_talk:"): { - presenceData.details = "Viewing a user's talk page"; - presenceData.state = pageTitle; - break; - } - case firstPath.startsWith("File:"): { - presenceData.details = "Viewing a file"; - presenceData.state = pageTitle; - presenceData.smallImageKey = await squareImage( - document.querySelector("#file img") - ); - break; - } - case firstPath.startsWith("Category:"): { - presenceData.details = "Viewing a category"; - presenceData.state = pageTitle; - presenceData.buttons = [{ label: "View Category", url: href }]; - break; - } - case firstPath === "Special:Upload": { - presenceData.details = "Uploading a file"; - break; - } - case firstPath === "Special:Contributions": { - presenceData.details = "Viewing a user's contributions"; - presenceData.state = document.querySelector( - ".mw-contributions-user-tools > a" - ); - break; - } - } - // Wiki-specific pages - switch (firstPath) { - case "Jikaze": { - presenceData.details = "Reading about seat winds"; - break; - } - case "List_of_Mahjong_Soul_characters": { - const characters = document.querySelectorAll( - "h2 + ul[style] > li" - ); - presenceData.details = "Viewing Mahjong Soul characters"; - usesSlideshows = true; - for (const character of characters) { - const tmpPresenceData: PresenceData = { ...presenceData }, - characterImage = character.querySelector("img"), - characterName = character.querySelector("p > b"); - tmpPresenceData.smallImageKey = await squareImage(characterImage); - tmpPresenceData.smallImageText = characterName.textContent; - tmpPresenceData.state = characterName.textContent; - slideshow.addSlide( - characterName.textContent, - tmpPresenceData, - SLIDESHOW_TIMEOUT - ); - } - break; - } - case "List_of_mahjong_video_games": { - presenceData.details = "Viewing the list of mahjong video games"; - break; - } - case "List_of_Riichi_City_characters": { - const characters = document.querySelectorAll( - ".riichi-city-characters > li" - ); - presenceData.details = "Viewing Riichi City characters"; - usesSlideshows = true; - for (const character of characters) { - const tmpPresenceData: PresenceData = { ...presenceData }, - characterImage = character.querySelector("img"), - characterName = character.querySelector("p > b"); - tmpPresenceData.smallImageKey = await squareImage(characterImage); - tmpPresenceData.smallImageText = characterName.textContent; - tmpPresenceData.state = characterName.textContent; - slideshow.addSlide( - characterName.textContent, - tmpPresenceData, - SLIDESHOW_TIMEOUT - ); - } - break; - } - case "List_of_yaku": { - const tables = document.querySelectorAll( - ".content-table-wrapper" - ); - presenceData.details = "Viewing list of yaku"; - usesSlideshows = true; - for (const table of tables) { - const tmpPresenceData: PresenceData = { ...presenceData }, - mainName = table.querySelector("a"), - englishName = table.querySelector("dd dl"), - closed = table.querySelector("dd + dd"), - description = - table.querySelector("td:last-child"), - sectionHeader = findNearestAboveElement(table, "h2").querySelector( - ".mw-headline" - ); - if (!table.querySelector(".wikitable")) continue; - tmpPresenceData.state = `${mainName.textContent} (${englishName.textContent}) - ${sectionHeader.textContent}`; - tmpPresenceData.smallImageKey = Assets.Question; - tmpPresenceData.smallImageText = `${closed.textContent} - ${description.textContent}`; - tmpPresenceData.buttons = [{ label: "View Yaku", url: mainName }]; - slideshow.addSlide( - mainName.textContent, - tmpPresenceData, - SLIDESHOW_TIMEOUT - ); - } - break; - } - case "Local_yaku": { - presenceData.details = "Viewing local yaku"; - break; - } - case "Mahjong_equipment": { - const tables = document.querySelectorAll( - ".content-table-wrapper" - ); - presenceData.details = "Reading about the mahjong equipment"; - usesSlideshows = true; - for (const table of tables) { - const sectionTitle = - table.previousElementSibling.querySelector( - ".mw-headline" - ), - images = table - .querySelector("tbody > tr") - .querySelectorAll("td img"), - descriptions = table - .querySelector("tbody > tr + tr") - .querySelectorAll("td"); - for (const [i, image] of images.entries()) { - const tmpPresenceData: PresenceData = { ...presenceData }; - tmpPresenceData.smallImageKey = await squareImage(image); - tmpPresenceData.smallImageText = descriptions[i]; - tmpPresenceData.state = sectionTitle; - slideshow.addSlide( - descriptions[i].textContent, - tmpPresenceData, - SLIDESHOW_TIMEOUT - ); - } - } - break; - } - case "Mentsu": { - presenceData.details = "Reading about tile groups"; - break; - } - case "Rules_overview": { - presenceData.details = "Reading the rules"; - break; - } - } - // Wiki-specific groups of pages - for (const strategy of strategies) { - if (firstPath === strategy) { - presenceData.details = "Reading about a strategy"; - presenceData.state = pageTitle; - presenceData.buttons = [{ label: "View Strategy", url: href }]; - break; - } - } - for (const yakuPage of yaku) { - if (firstPath === yakuPage) { - presenceData.details = "Reading about a yaku"; - presenceData.state = pageTitle; - presenceData.buttons = [{ label: "View Yaku", url: href }]; - break; - } - } - for (const game of games) { - if (firstPath === game) { - presenceData.details = "Reading about a mahjong game"; - presenceData.state = pageTitle; - presenceData.buttons = [{ label: "View Game", url: href }]; - break; - } - } + if (searchParams.has('search')) { + presenceData.details = 'Searching for a page' + presenceData.state = document.querySelector( + '#searchText > input', + )?.value + } + else if (searchParams.has('action') || searchParams.has('veaction')) { + const action = searchParams.get('action') ?? searchParams.get('veaction') + switch (action) { + case 'edit': { + presenceData.details = 'Editing a page' + presenceData.state = document.querySelector('#firstHeadingTitle') + ?? pageTitle + break + } + case 'history': { + presenceData.details = 'Viewing the revision history of a page' + presenceData.state = pageTitle + break + } + } + } + else { + // Common WikiMedia pages + switch (true) { + case firstPath?.startsWith('Talk:'): { + presenceData.details = `Viewing the talk page for '${pageTitle?.textContent}'` + break + } + case firstPath?.startsWith('User:'): { + presenceData.details = 'Viewing a user page' + presenceData.state = pageTitle + presenceData.buttons = [{ label: 'View User Page', url: href }] + break + } + case firstPath?.startsWith('User_talk:'): { + presenceData.details = 'Viewing a user\'s talk page' + presenceData.state = pageTitle + break + } + case firstPath?.startsWith('File:'): { + presenceData.details = 'Viewing a file' + presenceData.state = pageTitle + presenceData.smallImageKey = await squareImage( + document.querySelector('#file img')!, + ) + break + } + case firstPath?.startsWith('Category:'): { + presenceData.details = 'Viewing a category' + presenceData.state = pageTitle + presenceData.buttons = [{ label: 'View Category', url: href }] + break + } + case firstPath === 'Special:Upload': { + presenceData.details = 'Uploading a file' + break + } + case firstPath === 'Special:Contributions': { + presenceData.details = 'Viewing a user\'s contributions' + presenceData.state = document.querySelector( + '.mw-contributions-user-tools > a', + ) + break + } + } + // Wiki-specific pages + switch (firstPath) { + case 'Jikaze': { + presenceData.details = 'Reading about seat winds' + break + } + case 'List_of_Mahjong_Soul_characters': { + const characters = document.querySelectorAll( + 'h2 + ul[style] > li', + ) + presenceData.details = 'Viewing Mahjong Soul characters' + usesSlideshows = true + for (const character of characters) { + const tmpPresenceData: PresenceData = { ...presenceData } + const characterImage = character.querySelector('img') + const characterName = character.querySelector('p > b') + tmpPresenceData.smallImageKey = await squareImage(characterImage!) + tmpPresenceData.smallImageText = characterName?.textContent + tmpPresenceData.state = characterName?.textContent + slideshow.addSlide( + characterName?.textContent ?? '', + tmpPresenceData, + SLIDESHOW_TIMEOUT, + ) + } + break + } + case 'List_of_mahjong_video_games': { + presenceData.details = 'Viewing the list of mahjong video games' + break + } + case 'List_of_Riichi_City_characters': { + const characters = document.querySelectorAll( + '.riichi-city-characters > li', + ) + presenceData.details = 'Viewing Riichi City characters' + usesSlideshows = true + for (const character of characters) { + const tmpPresenceData: PresenceData = { ...presenceData } + const characterImage = character.querySelector('img') + const characterName = character.querySelector('p > b') + tmpPresenceData.smallImageKey = await squareImage(characterImage!) + tmpPresenceData.smallImageText = characterName?.textContent + tmpPresenceData.state = characterName?.textContent + slideshow.addSlide( + characterName?.textContent ?? '', + tmpPresenceData, + SLIDESHOW_TIMEOUT, + ) + } + break + } + case 'List_of_yaku': { + const tables = document.querySelectorAll( + '.content-table-wrapper', + ) + presenceData.details = 'Viewing list of yaku' + usesSlideshows = true + for (const table of tables) { + const tmpPresenceData: PresenceData = { ...presenceData } + const mainName = table.querySelector('a') + const englishName = table.querySelector('dd dl') + const closed = table.querySelector('dd + dd') + const description = table.querySelector('td:last-child') + const sectionHeader = findNearestAboveElement(table, 'h2')?.querySelector( + '.mw-headline', + ) + if (!table.querySelector('.wikitable')) + continue + tmpPresenceData.state = `${mainName?.textContent} (${englishName?.textContent}) - ${sectionHeader?.textContent}` + tmpPresenceData.smallImageKey = Assets.Question + tmpPresenceData.smallImageText = `${closed?.textContent} - ${description?.textContent}` + tmpPresenceData.buttons = [{ label: 'View Yaku', url: mainName }] + slideshow.addSlide( + mainName?.textContent ?? '', + tmpPresenceData, + SLIDESHOW_TIMEOUT, + ) + } + break + } + case 'Local_yaku': { + presenceData.details = 'Viewing local yaku' + break + } + case 'Mahjong_equipment': { + const tables = document.querySelectorAll( + '.content-table-wrapper', + ) + presenceData.details = 'Reading about the mahjong equipment' + usesSlideshows = true + for (const table of tables) { + const sectionTitle = table.previousElementSibling?.querySelector( + '.mw-headline', + ) + const images = table + .querySelector('tbody > tr') + ?.querySelectorAll('td img') + const descriptions = table + .querySelector('tbody > tr + tr') + ?.querySelectorAll('td') + for (const [i, image] of (images?.entries() ?? [])) { + const tmpPresenceData: PresenceData = { ...presenceData } + tmpPresenceData.smallImageKey = await squareImage(image!) + tmpPresenceData.smallImageText = descriptions?.[i]?.textContent + tmpPresenceData.state = sectionTitle?.textContent + slideshow.addSlide( + descriptions?.[i]?.textContent ?? '', + tmpPresenceData, + SLIDESHOW_TIMEOUT, + ) + } + } + break + } + case 'Mentsu': { + presenceData.details = 'Reading about tile groups' + break + } + case 'Rules_overview': { + presenceData.details = 'Reading the rules' + break + } + } + // Wiki-specific groups of pages + for (const strategy of strategies) { + if (firstPath === strategy) { + presenceData.details = 'Reading about a strategy' + presenceData.state = pageTitle + presenceData.buttons = [{ label: 'View Strategy', url: href }] + break + } + } + for (const yakuPage of yaku) { + if (firstPath === yakuPage) { + presenceData.details = 'Reading about a yaku' + presenceData.state = pageTitle + presenceData.buttons = [{ label: 'View Yaku', url: href }] + break + } + } + for (const game of games) { + if (firstPath === game) { + presenceData.details = 'Reading about a mahjong game' + presenceData.state = pageTitle + presenceData.buttons = [{ label: 'View Game', url: href }] + break + } + } - if (!presenceData.details) { - presenceData.details = "Viewing a page"; - presenceData.state = pageTitle; - } - } - return usesSlideshows; + if (!presenceData.details) { + presenceData.details = 'Viewing a page' + presenceData.state = pageTitle + } + } + return usesSlideshows } diff --git a/websites/J/Japanese Mahjong Wiki/pages/static.ts b/websites/J/Japanese Mahjong Wiki/pages/static.ts index cdb00dbb1379..9a4f055ed8f3 100644 --- a/websites/J/Japanese Mahjong Wiki/pages/static.ts +++ b/websites/J/Japanese Mahjong Wiki/pages/static.ts @@ -1,18 +1,18 @@ // MediaWiki static pages export const staticPages: Record = { - "/Main_Page": { - details: "Viewing the main page", - }, - "/Special:RecentChanges": { - details: "Viewing recent changes", - }, - "/Special:SpecialPages": { - details: "Viewing special pages", - }, - "/Special:Preferences": { - details: "Managing their preferences", - }, - "/Special:Watchlist": { - details: "Viewing their watchlist", - }, -}; + '/Main_Page': { + details: 'Viewing the main page', + }, + '/Special:RecentChanges': { + details: 'Viewing recent changes', + }, + '/Special:SpecialPages': { + details: 'Viewing special pages', + }, + '/Special:Preferences': { + details: 'Managing their preferences', + }, + '/Special:Watchlist': { + details: 'Viewing their watchlist', + }, +} diff --git a/websites/J/Japanese Mahjong Wiki/presence.ts b/websites/J/Japanese Mahjong Wiki/presence.ts index 10e6a19182c3..3c3c7da68061 100644 --- a/websites/J/Japanese Mahjong Wiki/presence.ts +++ b/websites/J/Japanese Mahjong Wiki/presence.ts @@ -1,44 +1,46 @@ -import { specialPageHandler } from "./pages/special"; -import { staticPages } from "./pages/static"; +import { specialPageHandler } from './pages/special' +import { staticPages } from './pages/static' const presence = new Presence({ - clientId: "1221269583567261786", - }), - slideshow = presence.createSlideshow(), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1221269583567261786', +}) +const slideshow = presence.createSlideshow() +const browsingTimestamp = Math.floor(Date.now() / 1000) -let oldPage: string; +let oldPage: string const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/J/Japanese%20Mahjong%20Wiki/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Japanese%20Mahjong%20Wiki/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - name: "Japanese Mahjong Wiki", - }, - { pathname } = document.location; - - if (oldPage !== pathname) { - oldPage = pathname; - slideshow.deleteAllSlides(); - } - - let isStatic = false, - usesSlideshows = false; - for (const [path, data] of Object.entries(staticPages)) { - if (path === pathname) { - isStatic = true; - Object.assign(presenceData, data); - break; - } - } - - if (!isStatic) - usesSlideshows = await specialPageHandler(presenceData, slideshow); - - if (usesSlideshows) presence.setActivity(slideshow); - else if (presenceData.details) presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + name: 'Japanese Mahjong Wiki', + } + const { pathname } = document.location + + if (oldPage !== pathname) { + oldPage = pathname + slideshow.deleteAllSlides() + } + + let isStatic = false + let usesSlideshows = false + for (const [path, data] of Object.entries(staticPages)) { + if (path === pathname) { + isStatic = true + Object.assign(presenceData, data) + break + } + } + + if (!isStatic) + usesSlideshows = await specialPageHandler(presenceData, slideshow) + + if (usesSlideshows) + presence.setActivity(slideshow) + else if (presenceData.details) + presence.setActivity(presenceData) +}) diff --git a/websites/J/Japanese Mahjong Wiki/util/util.ts b/websites/J/Japanese Mahjong Wiki/util/util.ts index 93949c1942cf..3cd51ffc28e6 100644 --- a/websites/J/Japanese Mahjong Wiki/util/util.ts +++ b/websites/J/Japanese Mahjong Wiki/util/util.ts @@ -1,42 +1,46 @@ export function findNearestAboveElement( - element: Element, - selector: string + element: Element, + selector: string, ): Element | null { - let currentElement: Element | null = element; - while (currentElement) { - if (currentElement.matches(selector)) return currentElement; - currentElement = currentElement.previousElementSibling; - } - return null; + let currentElement: Element | null = element + while (currentElement) { + if (currentElement.matches(selector)) + return currentElement + currentElement = currentElement.previousElementSibling + } + return null } -const imageCache: Record> = {}; +const imageCache: Record> = {} export async function squareImage( - image: HTMLImageElement + image: HTMLImageElement, ): Promise { - const { src, width, height } = image; - if (imageCache[src]) return imageCache[src]; - const canvas = document.createElement("canvas"), - ctx = canvas.getContext("2d"); - canvas.width = width; - canvas.height = height; - if (width > height) canvas.height = width; - if (height > width) canvas.width = height; - if (width === height) { - imageCache[src] = Promise.resolve(src); - return src; - } - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.drawImage( - image, - (canvas.width - width) / 2, - (canvas.height - height) / 2 - ); - const output = new Promise(resolve => { - canvas.toBlob(blob => { - resolve(blob); - }); - }); - imageCache[src] = output; - return output; + const { src, width, height } = image + if (src in imageCache) + return imageCache[src] + const canvas = document.createElement('canvas') + const ctx = canvas.getContext('2d')! + canvas.width = width + canvas.height = height + if (width > height) + canvas.height = width + if (height > width) + canvas.width = height + if (width === height) { + imageCache[src] = Promise.resolve(src) + return src + } + ctx.clearRect(0, 0, canvas.width, canvas.height) + ctx.drawImage( + image, + (canvas.width - width) / 2, + (canvas.height - height) / 2, + ) + const output = new Promise((resolve) => { + canvas.toBlob((blob) => { + resolve(blob!) + }) + }) + imageCache[src] = output + return output } diff --git a/websites/J/Japari Library/metadata.json b/websites/J/Japari Library/metadata.json index 3a6491ac5f2a..8a6b0f7af9c0 100644 --- a/websites/J/Japari Library/metadata.json +++ b/websites/J/Japari Library/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Flashlight", - "id": "158418656861093888" - }, - "service": "Japari Library", - "description": { - "en": "Japari Library is a wiki based around the Kemono Friends multimedia franchise.", - "nl": "Japari Library is een wiki die is gebaseerd op de multimediafranchise Kemono Friends." - }, - "url": "japari-library.com", - "version": "1.1.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Japari%20Library/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Japari%20Library/assets/thumbnail.png", - "color": "#4CC5FF", - "category": "anime", - "tags": [ - "anime", - "wiki" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Flashlight", + "id": "158418656861093888" + }, + "service": "Japari Library", + "description": { + "en": "Japari Library is a wiki based around the Kemono Friends multimedia franchise.", + "nl": "Japari Library is een wiki die is gebaseerd op de multimediafranchise Kemono Friends." + }, + "url": "japari-library.com", + "version": "1.1.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Japari%20Library/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Japari%20Library/assets/thumbnail.png", + "color": "#4CC5FF", + "category": "anime", + "tags": [ + "anime", + "wiki" + ] +} diff --git a/websites/J/Japari Library/presence.ts b/websites/J/Japari Library/presence.ts index 59086fc34874..69b1a89bc8e6 100644 --- a/websites/J/Japari Library/presence.ts +++ b/websites/J/Japari Library/presence.ts @@ -1,62 +1,64 @@ const presence = new Presence({ - clientId: "670669014363668481", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - actionURL = new URL(document.location.href), - title2URL = new URL(document.location.href); -let title: HTMLElement; - -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/Japari%20Library/assets/logo.png", - startTimestamp: browsingTimestamp, - }; - - title = document.querySelector("h1#firstHeading"); - - const actionResult = actionURL.searchParams.get("action"), - title2Result = title2URL.searchParams.get("title"); - - if (document.location.pathname === "/wiki/Main_Page") { - presenceData.state = "Main Page | Home"; - - delete presenceData.details; - } else if (title && document.location.pathname.includes("/wiki/")) { - presenceData.details = "Reading about:"; - - presenceData.state = title.textContent; - } else if ( - actionResult === "history" && - title2Result && - document.location.pathname.includes("/w/") - ) { - presenceData.details = "Viewing revision history of:"; - - if (title2Result.includes("_")) - presenceData.state = title2Result.replaceAll("_", " "); - else presenceData.state = title2Result; - } else if ( - actionResult === "edit" && - title2Result && - document.location.pathname.includes("/w/") - ) { - presenceData.details = "Editing a page:"; - - if (title2Result.includes("_")) - presenceData.state = title2Result.replaceAll("_", " "); - else presenceData.state = title2Result; - } else if ( - actionResult === "formedit" && - title2Result && - document.location.pathname.includes("/w/") - ) { - presenceData.details = "Form editing a page:"; - - if (title2Result.includes("_")) - presenceData.state = title2Result.replaceAll("_", " "); - else presenceData.state = title2Result; - } - - presence.setActivity(presenceData); -}); + clientId: '670669014363668481', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const actionURL = new URL(document.location.href) +const title2URL = new URL(document.location.href) + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/Japari%20Library/assets/logo.png', + startTimestamp: browsingTimestamp, + } + + const title = document.querySelector('h1#firstHeading') + + const actionResult = actionURL.searchParams.get('action') + const title2Result = title2URL.searchParams.get('title') + + if (document.location.pathname === '/wiki/Main_Page') { + presenceData.state = 'Main Page | Home' + + delete presenceData.details + } + else if (title && document.location.pathname.includes('/wiki/')) { + presenceData.details = 'Reading about:' + + presenceData.state = title.textContent + } + else if ( + actionResult === 'history' + && title2Result + && document.location.pathname.includes('/w/') + ) { + presenceData.details = 'Viewing revision history of:' + + if (title2Result.includes('_')) + presenceData.state = title2Result.replaceAll('_', ' ') + else presenceData.state = title2Result + } + else if ( + actionResult === 'edit' + && title2Result + && document.location.pathname.includes('/w/') + ) { + presenceData.details = 'Editing a page:' + + if (title2Result.includes('_')) + presenceData.state = title2Result.replaceAll('_', ' ') + else presenceData.state = title2Result + } + else if ( + actionResult === 'formedit' + && title2Result + && document.location.pathname.includes('/w/') + ) { + presenceData.details = 'Form editing a page:' + + if (title2Result.includes('_')) + presenceData.state = title2Result.replaceAll('_', ' ') + else presenceData.state = title2Result + } + + presence.setActivity(presenceData) +}) diff --git a/websites/J/Jellyfin/metadata.json b/websites/J/Jellyfin/metadata.json index 168681e7175a..0d4fb08dc0ab 100644 --- a/websites/J/Jellyfin/metadata.json +++ b/websites/J/Jellyfin/metadata.json @@ -1,52 +1,52 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "alexbcberio", - "id": "202915432175239169" - }, - "contributors": [ - { - "name": "Bas950", - "id": "241278257335500811" - } - ], - "service": "Jellyfin", - "description": { - "en": "The Free Software Media System", - "nl": "Het gratis software mediasysteem" - }, - "url": "jellyfin.org", - "regExp": "(jellyfin.org)|(.*[/]web[/](index[.]html#|#))", - "version": "1.9.1", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jellyfin/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jellyfin/assets/thumbnail.png", - "color": "#00698c", - "category": "videos", - "tags": [ - "video", - "movie", - "tv", - "media" - ], - "settings": [ - { - "id": "showMediaTimestamps", - "title": "Show media timestamps", - "icon": "fad fa-play", - "value": true - }, - { - "id": "showTimestamps", - "title": "Show timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "showThumbnails", - "title": "Show thumbnails", - "icon": "fad fa-image", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "alexbcberio", + "id": "202915432175239169" + }, + "contributors": [ + { + "name": "Bas950", + "id": "241278257335500811" + } + ], + "service": "Jellyfin", + "description": { + "en": "The Free Software Media System", + "nl": "Het gratis software mediasysteem" + }, + "url": "jellyfin.org", + "regExp": "(jellyfin.org)|(.*[/]web[/](index[.]html#|#))", + "version": "1.9.1", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jellyfin/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jellyfin/assets/thumbnail.png", + "color": "#00698c", + "category": "videos", + "tags": [ + "video", + "movie", + "tv", + "media" + ], + "settings": [ + { + "id": "showMediaTimestamps", + "title": "Show media timestamps", + "icon": "fad fa-play", + "value": true + }, + { + "id": "showTimestamps", + "title": "Show timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "showThumbnails", + "title": "Show thumbnails", + "icon": "fad fa-image", + "value": true + } + ] +} diff --git a/websites/J/Jellyfin/presence.ts b/websites/J/Jellyfin/presence.ts index 08686beff177..94b383259864 100644 --- a/websites/J/Jellyfin/presence.ts +++ b/websites/J/Jellyfin/presence.ts @@ -3,930 +3,944 @@ * I've tried to set as many properties as I could find. */ -//#region Interfaces +// #region Interfaces interface ApiClient { - enableAutomaticBitrateDetection: boolean; - enableAutomaticNetworking: boolean; - lastDetectedBitrate: number; - lastDetectedBitrateTime: number; // timestamp - lastFetch: number; // timestamp - lastPlaybackProgressReport: number; - lastPlaybackProgressReportTicks: number; - manualAddressOnly: boolean; - _appName: string; - _appVersion: string; - _currentUser: { - Configuration: { - AudioLanguagePreference: string; - DisplayCollectionsView: boolean; - DisplayMissingEpisodes: boolean; - EnableLocalPassword: boolean; - EnableNextEpisodeAutoPlay: boolean; - HidePlayedInLatest: boolean; - OrderedViews: string[]; - PlayDefaultAudioTrack: boolean; - RememberAudioSelections: boolean; - RememberSubtitleSelections: boolean; - SubtitleLanguagePreference: string; - SubtitleMode: string; - }; - HasConfiguredEasyPassword: boolean; - HasConfiguredPassword: boolean; - HasPassword: boolean; - Id: string; - LastActivityDate: string; // date, ex: "2020-05-30T21:51:23.9732162Z" - LastLoginDate: string; // date, ex: "2020-05-30T21:51:23.9732162Z" - Name: string; - Policy: { - AuthenticationProviderId: string; - EnableAllChannels: boolean; - EnableAllDevices: boolean; - EnableAllFolders: boolean; - EnableAudioPlaybackTranscoding: boolean; - EnableContentDeletion: boolean; - EnableContentDownloading: boolean; - EnableLiveTvAccess: boolean; - EnableLiveTvManagement: boolean; - EnableMediaConversion: boolean; - EnableMediaPlayback: boolean; - EnablePlaybackRemuxing: boolean; - EnablePublicSharing: boolean; - EnableRemoteAccess: boolean; - EnableRemoteControlOfOtherUsers: boolean; - EnableSharedDeviceControl: boolean; - EnableSyncTranscoding: boolean; - EnableUserPreferenceAccess: boolean; - EnableVideoPlaybackTranscoding: boolean; - ForceRemoteSourceTranscoding: boolean; - InvalidLoginAttemptCount: boolean; - IsAdministrator: boolean; - IsDisabled: boolean; - IsHidden: boolean; - LoginAttemptsBeforeLockout: number; - PasswordResetProviderId: string; - RemoteClientBitrateLimit: number; - }; - PrimaryImageAspectRatio: number; - PrimaryImageTag: string; - ServerId: string; - }; - _deviceId: string; - _deviceName: string; - _endPointInfo: { - IsInNetwork: boolean; - IsLocal: boolean; - }; - _serverAddress: string; - _serverInfo: Server; - _serverVersion: string; - _webSocket: { - binaryType: string; - bufferedAmount: number; - extensions: string; - protocol: string; - readyState: number; - url: string; - }; + enableAutomaticBitrateDetection: boolean + enableAutomaticNetworking: boolean + lastDetectedBitrate: number + lastDetectedBitrateTime: number // timestamp + lastFetch: number // timestamp + lastPlaybackProgressReport: number + lastPlaybackProgressReportTicks: number + manualAddressOnly: boolean + _appName: string + _appVersion: string + _currentUser: { + Configuration: { + AudioLanguagePreference: string + DisplayCollectionsView: boolean + DisplayMissingEpisodes: boolean + EnableLocalPassword: boolean + EnableNextEpisodeAutoPlay: boolean + HidePlayedInLatest: boolean + OrderedViews: string[] + PlayDefaultAudioTrack: boolean + RememberAudioSelections: boolean + RememberSubtitleSelections: boolean + SubtitleLanguagePreference: string + SubtitleMode: string + } + HasConfiguredEasyPassword: boolean + HasConfiguredPassword: boolean + HasPassword: boolean + Id: string + LastActivityDate: string // date, ex: "2020-05-30T21:51:23.9732162Z" + LastLoginDate: string // date, ex: "2020-05-30T21:51:23.9732162Z" + Name: string + Policy: { + AuthenticationProviderId: string + EnableAllChannels: boolean + EnableAllDevices: boolean + EnableAllFolders: boolean + EnableAudioPlaybackTranscoding: boolean + EnableContentDeletion: boolean + EnableContentDownloading: boolean + EnableLiveTvAccess: boolean + EnableLiveTvManagement: boolean + EnableMediaConversion: boolean + EnableMediaPlayback: boolean + EnablePlaybackRemuxing: boolean + EnablePublicSharing: boolean + EnableRemoteAccess: boolean + EnableRemoteControlOfOtherUsers: boolean + EnableSharedDeviceControl: boolean + EnableSyncTranscoding: boolean + EnableUserPreferenceAccess: boolean + EnableVideoPlaybackTranscoding: boolean + ForceRemoteSourceTranscoding: boolean + InvalidLoginAttemptCount: boolean + IsAdministrator: boolean + IsDisabled: boolean + IsHidden: boolean + LoginAttemptsBeforeLockout: number + PasswordResetProviderId: string + RemoteClientBitrateLimit: number + } + PrimaryImageAspectRatio: number + PrimaryImageTag: string + ServerId: string + } + _deviceId: string + _deviceName: string + _endPointInfo: { + IsInNetwork: boolean + IsLocal: boolean + } + _serverAddress: string + _serverInfo: Server + _serverVersion: string + _webSocket: { + binaryType: string + bufferedAmount: number + extensions: string + protocol: string + readyState: number + url: string + } } interface MediaStream { - Codec: string; - TimeBase: string; - CodecTimeBase: string; - VideoRange: string; - DisplayTitle: string; - IsInterlaced: boolean; - BitRate: number; - RefFrames: number; - IsDefault: boolean; - IsForced: boolean; - Height: number; - Width: number; - AverageFrameRate: number; - RealFrameRate: number; - Profile: string; - Type: string; - AspectRatio: string; - Index: number; - IsExternal: boolean; - IsTextSubtitleStream: boolean; - SupportsExternalStream: boolean; - PixelFormat: string; - Level: number; + Codec: string + TimeBase: string + CodecTimeBase: string + VideoRange: string + DisplayTitle: string + IsInterlaced: boolean + BitRate: number + RefFrames: number + IsDefault: boolean + IsForced: boolean + Height: number + Width: number + AverageFrameRate: number + RealFrameRate: number + Profile: string + Type: string + AspectRatio: string + Index: number + IsExternal: boolean + IsTextSubtitleStream: boolean + SupportsExternalStream: boolean + PixelFormat: string + Level: number } interface MediaSource { - Protocol: string; - Id: string; - Path: string; - Type: string; - Container: string; - Size: number; - Name: string; - IsRemote: boolean; - ETag: string; - RunTimeTicks: number; - ReadAtNativeFramerate: boolean; - IgnoreDts: boolean; - IgnoreIndex: boolean; - GenPtsInput: boolean; - SupportsTranscoding: true; - SupportsDirectStream: boolean; - SupportsDirectPlay: boolean; - IsInfiniteStream: boolean; - RequiresOpening: boolean; - RequiresClosing: boolean; - RequiresLooping: boolean; - SupportsProbing: true; - VideoType: string; - MediaStreams: MediaStream[]; - MediaAttachments: []; - Formats: []; - Bitrate: number; - RequiredHttpHeaders: unknown; - DefaultAudioStreamIndex: number; + Protocol: string + Id: string + Path: string + Type: string + Container: string + Size: number + Name: string + IsRemote: boolean + ETag: string + RunTimeTicks: number + ReadAtNativeFramerate: boolean + IgnoreDts: boolean + IgnoreIndex: boolean + GenPtsInput: boolean + SupportsTranscoding: true + SupportsDirectStream: boolean + SupportsDirectPlay: boolean + IsInfiniteStream: boolean + RequiresOpening: boolean + RequiresClosing: boolean + RequiresLooping: boolean + SupportsProbing: true + VideoType: string + MediaStreams: MediaStream[] + MediaAttachments: [] + Formats: [] + Bitrate: number + RequiredHttpHeaders: unknown + DefaultAudioStreamIndex: number } interface ExternalUrl { - Name: string; - Url: string; + Name: string + Url: string } interface Person { - Name: string; - Id: string; - Role: string; - Type: string; - PrimaryImageTag: string; + Name: string + Id: string + Role: string + Type: string + PrimaryImageTag: string } interface UserData { - PlaybackPositionTicks: number; - PlayCount: number; - IsFavorite: boolean; - LastPlayedDate: string; // date, ex: "2020-05-30T21:51:23.9732162Z" - Played: boolean; - Key: string; + PlaybackPositionTicks: number + PlayCount: number + IsFavorite: boolean + LastPlayedDate: string // date, ex: "2020-05-30T21:51:23.9732162Z" + Played: boolean + Key: string } interface Chapter { - StartPositionTicks: number; - Name: string; - ImageDateModified: string; // date, ex: "2020-05-30T21:51:23.9732162Z" + StartPositionTicks: number + Name: string + ImageDateModified: string // date, ex: "2020-05-30T21:51:23.9732162Z" } interface MediaInfo { - AlbumArtist: string; - AlbumArtists: { Name: string; Id: string }[]; - AlbumId: string; - AlbumPrimaryImageTag: string; - ArtistsItems: { Name: string; Id: string }[]; - Artists: string[]; - Name: string; - OriginalTitle: string; - ServerId: string; - Id: string; - Etag: string; - DateCreated: string; // date, ex: "2020-05-30T21:51:23.9732162Z" - CanDelete: boolean; - CanDownload: boolean; - HasSubtitles: boolean; - Container: string; - SortName: string; - PremiereDate: string; // date, ex: "2020-05-30T21:51:23.9732162Z" - ExternalUrls: ExternalUrl[]; - MediaSources: MediaSource[]; - Path: string; - EnableMediaSourceDisplay: boolean; - Overview: string; - // TagLines: Array; - // Genres: Array; - CommunityRating: number; - RunTimeTicks: number; - PlayAccess: string; - ProductionYear: number; - IndexNumber: number; - ParentIndexNumber: number; - // RemoteTrailers: Array; - ProviderIds: { - Tvdb?: number; - }; - IsHD: boolean; - IsFolder: boolean; - ParentId: string; - Type: - | "Audio" - | "MusicAlbum" - | "MusicArtist" - | "Movie" - | "Series" - | "Season" - | "Episode" - | "TvChannel" - | "Person"; - People: Person[]; - // Studios: Array; - // GenreItems: Array; - ParentBackdropItemId: string; - ParentBackdropImageTags: string[]; - LocalTrailerCount: number; - UserData: UserData; - RecursiveItemCount: number; - Status: string; - SeriesName: string; - SeriesId: string; - SeasonId: string; - SpecialFeatureCount: number; - DisplayPreferencesId: string; - // Tags: Array; - PrimaryImageAspectRatio: number; - SeriesPrimaryImageTag: string; - SeasonName: string; - MediaStreams: MediaStream[]; - VideoType: string; - ImageTags: { - Primary: string; - }; - // BackdropImageTags: Array; - // ScreenshotImageTags: Array; - SeriesStudio: string; - Chapters: Chapter[]; - LocationType: string; - MediaType: string; - // LockedFields: Array; - LockData: boolean; - Width: number; - Height: number; + AlbumArtist: string + AlbumArtists: { Name: string, Id: string }[] + AlbumId: string + AlbumPrimaryImageTag: string + ArtistsItems: { Name: string, Id: string }[] + Artists: string[] + Name: string + OriginalTitle: string + ServerId: string + Id: string + Etag: string + DateCreated: string // date, ex: "2020-05-30T21:51:23.9732162Z" + CanDelete: boolean + CanDownload: boolean + HasSubtitles: boolean + Container: string + SortName: string + PremiereDate: string // date, ex: "2020-05-30T21:51:23.9732162Z" + ExternalUrls: ExternalUrl[] + MediaSources: MediaSource[] + Path: string + EnableMediaSourceDisplay: boolean + Overview: string + // TagLines: Array; + // Genres: Array; + CommunityRating: number + RunTimeTicks: number + PlayAccess: string + ProductionYear: number + IndexNumber: number + ParentIndexNumber: number + // RemoteTrailers: Array; + ProviderIds: { + Tvdb?: number + } + IsHD: boolean + IsFolder: boolean + ParentId: string + Type: + | 'Audio' + | 'MusicAlbum' + | 'MusicArtist' + | 'Movie' + | 'Series' + | 'Season' + | 'Episode' + | 'TvChannel' + | 'Person' + People: Person[] + // Studios: Array; + // GenreItems: Array; + ParentBackdropItemId: string + ParentBackdropImageTags: string[] + LocalTrailerCount: number + UserData: UserData + RecursiveItemCount: number + Status: string + SeriesName: string + SeriesId: string + SeasonId: string + SpecialFeatureCount: number + DisplayPreferencesId: string + // Tags: Array; + PrimaryImageAspectRatio: number + SeriesPrimaryImageTag: string + SeasonName: string + MediaStreams: MediaStream[] + VideoType: string + ImageTags: { + Primary: string + } + // BackdropImageTags: Array; + // ScreenshotImageTags: Array; + SeriesStudio: string + Chapters: Chapter[] + LocationType: string + MediaType: string + // LockedFields: Array; + LockData: boolean + Width: number + Height: number } interface Server { - AccessToken: string; - DateLastAccessed: number; // timestamp - Id: string; - IsLocalServer: boolean; - LastConnectionMode: number; - LocalAddress: string; - ManualAddress: string; - Name: string; - RemoteAddress: string; - Type: "Server"; - UserId: string; - manualAddressOnly: boolean; + AccessToken: string + DateLastAccessed: number // timestamp + Id: string + IsLocalServer: boolean + LastConnectionMode: number + LocalAddress: string + ManualAddress: string + Name: string + RemoteAddress: string + Type: 'Server' + UserId: string + manualAddressOnly: boolean } // #endregion const enum Assets { - logo = "https://cdn.rcd.gg/PreMiD/websites/J/Jellyfin/assets/logo.png", + logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Jellyfin/assets/logo.png', +} +const JELLYFIN_URL = 'jellyfin.org' +// all the presence art assets uploaded to discord +const presenceData: PresenceData = { + largeImageKey: Assets.logo, + startTimestamp: Math.floor(Date.now() / 1000), } -const JELLYFIN_URL = "jellyfin.org", - // all the presence art assets uploaded to discord - presenceData: PresenceData = { - largeImageKey: Assets.logo, - startTimestamp: Math.floor(Date.now() / 1000), - }; -let ApiClient: ApiClient, - presence: Presence, - wasLogin = false; +let apiClient: ApiClient +let presence: Presence +let wasLogin = false /** * Obtain the base name Url of the server */ function jellyfinBasenameUrl(): string { - const { pathname } = location; + const { pathname } = location - return `${location.origin}${pathname.replace( - pathname.split("/").slice(-2).join("/"), - "" - )}`; + return `${location.origin}${pathname.replace( + pathname.split('/').slice(-2).join('/'), + '', + )}` } /** * Obtain the url of the primary image of a media given its id */ function mediaPrimaryImage(mediaInfo: MediaInfo): string { - let mediaId: string; - - switch (mediaInfo.Type) { - case "Episode": - mediaId = mediaInfo.SeriesId; - break; - case "Audio": - mediaId = mediaInfo.AlbumId; - break; - default: - mediaId = mediaInfo.Id; - } - - return `${jellyfinBasenameUrl()}Items/${mediaId}/Images/Primary?fillHeight=256&fillWidth=256`; + let mediaId: string + + switch (mediaInfo.Type) { + case 'Episode': + mediaId = mediaInfo.SeriesId + break + case 'Audio': + mediaId = mediaInfo.AlbumId + break + default: + mediaId = mediaInfo.Id + } + + return `${jellyfinBasenameUrl()}Items/${mediaId}/Images/Primary?fillHeight=256&fillWidth=256` } /** * Handle the presence when the audio player is active */ async function handleAudioPlayback(): Promise { - const regexResult = /\/Audio\/(\w+)\/universal/.exec( - document.querySelector("audio").src - ); + const regexResult = /\/Audio\/(\w+)\/universal/.exec( + document.querySelector('audio')?.src ?? '', + ) - if (!regexResult) { - presence.error("Could not obtain audio itemId"); - return; - } + if (!regexResult) { + presence.error('Could not obtain audio itemId') + return + } - await setPresenceByMediaId(regexResult[1]); + await setPresenceByMediaId(regexResult[1]) } /** * Handle the presence while the user is in the official website */ function handleOfficialWebsite(): void { - presenceData.details = "At jellyfin.org"; - - switch (location.pathname) { - case "/": - presenceData.state = "On landing page"; - break; - case "/posts/": - presenceData.state = "Reading the latest posts"; - presenceData.smallImageKey = Assets.Reading; - break; - case "/clients/": - presenceData.state = "Checking clients"; - presenceData.smallImageKey = Assets.Search; - break; - case "/downloads/": - presenceData.state = "On downloads"; - presenceData.smallImageKey = Assets.Downloading; - break; - case "/contribute/": - presenceData.state = "Learning how to contribute"; - break; - case "/contact/": - presenceData.state = "On contact page"; - break; - default: - // reading the docs - if (location.pathname.indexOf("/docs/") === 0) { - presenceData.state = `Reading the docs: ${document.title - .split("|")[0] - .trim()}`; - presenceData.smallImageKey = Assets.Reading; - } - } + presenceData.details = 'At jellyfin.org' + + switch (location.pathname) { + case '/': + presenceData.state = 'On landing page' + break + case '/posts/': + presenceData.state = 'Reading the latest posts' + presenceData.smallImageKey = Assets.Reading + break + case '/clients/': + presenceData.state = 'Checking clients' + presenceData.smallImageKey = Assets.Search + break + case '/downloads/': + presenceData.state = 'On downloads' + presenceData.smallImageKey = Assets.Downloading + break + case '/contribute/': + presenceData.state = 'Learning how to contribute' + break + case '/contact/': + presenceData.state = 'On contact page' + break + default: + // reading the docs + if (location.pathname.indexOf('/docs/') === 0) { + presenceData.state = `Reading the docs: ${document.title + .split('|')[0] + .trim()}` + presenceData.smallImageKey = Assets.Reading + } + } } /** * Obtain the authenticated user id */ function getUserId(): string { - try { - return ApiClient._currentUser.Id; - } catch (e) { - const servers: Server[] = JSON.parse( - localStorage.getItem("jellyfin_credentials") - ).Servers; - - return ( - servers.length === 1 - ? servers[0] - : servers.find( - (s: Server) => - s.Id === - new URLSearchParams(location.hash.split("?")[1]).get("serverId") - ) - ).UserId; - } + try { + return apiClient._currentUser.Id + } + catch { + const servers: Server[] = JSON.parse( + localStorage.getItem('jellyfin_credentials') ?? '{}', + ).Servers + + return ( + servers.length === 1 + ? servers[0] + : servers.find( + (s: Server) => + s.Id + === new URLSearchParams(location.hash.split('?')[1]).get('serverId'), + ) + )?.UserId ?? '' + } } /** * Cache performed mediaInfo */ -const mediaInfoCache = new Map(); +const mediaInfoCache = new Map() /** * Obtain media info given an itemId */ async function obtainMediaInfo(itemId: string): Promise { - if (mediaInfoCache.has(itemId)) return mediaInfoCache.get(itemId); - - const res = await fetch( - `${jellyfinBasenameUrl()}Users/${getUserId()}/Items/${itemId}`, - { - credentials: "include", - headers: { - "x-emby-authorization": - `MediaBrowser Client="${ApiClient._appName}",` + - `Device="${ApiClient._deviceName}",` + - `DeviceId="${ApiClient._deviceId}",` + - `Version="${ApiClient._appVersion}",` + - `Token="${ApiClient._serverInfo.AccessToken}"`, - }, - } - ), - mediaInfo: MediaInfo = await res.json(); - - mediaInfoCache.set(itemId, mediaInfo); - - return mediaInfoCache.get(itemId); + if (mediaInfoCache.has(itemId)) + return mediaInfoCache.get(itemId)! + + const res = await fetch( + `${jellyfinBasenameUrl()}Users/${getUserId()}/Items/${itemId}`, + { + credentials: 'include', + headers: { + 'x-emby-authorization': `MediaBrowser Client="${apiClient._appName}",` + + `Device="${apiClient._deviceName}",` + + `DeviceId="${apiClient._deviceId}",` + + `Version="${apiClient._appVersion}",` + + `Token="${apiClient._serverInfo.AccessToken}"`, + }, + }, + ) + const mediaInfo: MediaInfo = await res.json() + + mediaInfoCache.set(itemId, mediaInfo) + + return mediaInfoCache.get(itemId)! } /** * Cache performed media searches */ -const searchMediaCache = new Map(), - uploadedMediaCache = new Map(); +const searchMediaCache = new Map() +const uploadedMediaCache = new Map() /** * Search Movie and Series given a term */ async function searchMedia(searchTerm: string): Promise { - if (searchMediaCache.has(searchTerm)) return searchMediaCache.get(searchTerm); - - if (/-[ ]S[0-9]+:E[0-9]+[ ]-/.test(searchTerm)) - searchTerm = searchTerm.split(" - ").pop(); - - // The API does not like the year in the search term - searchTerm = searchTerm.replace(/\([0-9]{4}\)/, "").trim(); - - const res = await fetch( - `${jellyfinBasenameUrl()}Users/${getUserId()}/Items/?searchTerm=${searchTerm}` + - "&IncludePeople=false&IncludeMedia=true&IncludeGenres=false&IncludeStudios=false" + - "&IncludeArtists=false&IncludeItemTypes=Movie,Episode&Limit=3" + - "&Fields=PrimaryImageAspectRatio%2CCanDelete%2CBasicSyncInfo%2CMediaSourceCount" + - "&Recursive=true&EnableTotalRecordCount=false&ImageTypeLimit=1", - { - credentials: "include", - headers: { - "x-emby-authorization": - `MediaBrowser Client="${ApiClient._appName}",` + - `Device="${ApiClient._deviceName}",` + - `DeviceId="${ApiClient._deviceId}",` + - `Version="${ApiClient._appVersion}",` + - `Token="${ApiClient._serverInfo.AccessToken}"`, - }, - } - ), - resJson = await res.json(); - - searchMediaCache.set(searchTerm, resJson.Items); - - return searchMediaCache.get(searchTerm); + if (searchMediaCache.has(searchTerm)) + return searchMediaCache.get(searchTerm)! + + if (/- S\d+:E\d+ -/.test(searchTerm)) + searchTerm = searchTerm.split(' - ').pop() ?? '' + + // The API does not like the year in the search term + searchTerm = searchTerm.replace(/\(\d{4}\)/, '').trim() + + const res = await fetch( + `${jellyfinBasenameUrl()}Users/${getUserId()}/Items/?searchTerm=${searchTerm}` + + '&IncludePeople=false&IncludeMedia=true&IncludeGenres=false&IncludeStudios=false' + + '&IncludeArtists=false&IncludeItemTypes=Movie,Episode&Limit=3' + + '&Fields=PrimaryImageAspectRatio%2CCanDelete%2CBasicSyncInfo%2CMediaSourceCount' + + '&Recursive=true&EnableTotalRecordCount=false&ImageTypeLimit=1', + { + credentials: 'include', + headers: { + 'x-emby-authorization': `MediaBrowser Client="${apiClient._appName}",` + + `Device="${apiClient._deviceName}",` + + `DeviceId="${apiClient._deviceId}",` + + `Version="${apiClient._appVersion}",` + + `Token="${apiClient._serverInfo.AccessToken}"`, + }, + }, + ) + const resJson = await res.json() + + searchMediaCache.set(searchTerm, resJson.Items) + + return searchMediaCache.get(searchTerm)! } /** * Handles the presence when the user is using the video player */ async function handleVideoPlayback(): Promise { - if (!document.querySelector("#videoOsdPage")) { - // elements not loaded yet - return; - } - - // title on the header - const [mediaInfo] = await searchMedia( - document.querySelector("h3.pageTitle").textContent - ); - - if (mediaInfo) { - await setPresenceByMediaId(mediaInfo.Id); - return; - } - - // display generic info - presenceData.details = "Watching:"; - presenceData.state = "Unknown Content"; - - if (!presenceData.state) delete presenceData.state; + if (!document.querySelector('#videoOsdPage')) { + // elements not loaded yet + return + } + + // title on the header + const [mediaInfo] = await searchMedia( + document.querySelector('h3.pageTitle')?.textContent ?? '', + ) + + if (mediaInfo) { + await setPresenceByMediaId(mediaInfo.Id) + return + } + + // display generic info + presenceData.details = 'Watching:' + presenceData.state = 'Unknown Content' + + if (!presenceData.state) + delete presenceData.state } /** * Handle the presence when the user is playing back content remotely */ async function handleRemotePlayback(): Promise { - const [, mediaId] = /\/Items\/(\w+)\/Images/.exec( - document.querySelector(".nowPlayingImage").style - .backgroundImage - ); + const [, mediaId] = /\/Items\/(\w+)\/Images/.exec( + document.querySelector('.nowPlayingImage')?.style.backgroundImage ?? '', + ) ?? [] - await setPresenceByMediaId(mediaId); + await setPresenceByMediaId(mediaId) } /** * Handle the presence when the user is viewing the details of an item */ async function handleItemDetails(): Promise { - const data = await obtainMediaInfo( - new URLSearchParams(location.hash.split("?")[1]).get("id") - ); - - if (!data) { - presenceData.details = "Browsing details of an item"; - presenceData.state = "Could not get item details"; - } else if (typeof data === "string") return; - else { - presenceData.details = `Browsing details of: ${data.Name}`; - - switch (data.Type) { - case "Movie": - presenceData.state = `${data.Type} ─ ${data.OriginalTitle} (${data.ProductionYear})`; - break; - case "Series": - presenceData.state = `${data.Type} ─ (${data.Status})`; - break; - case "Season": - presenceData.state = `${data.Type} ─ ${data.SeriesName}`; - break; - case "Episode": - presenceData.state = `${data.Type} ─ ${data.SeriesName} - ${data.SeasonName}`; - break; - case "Person": { - let description = "Description not available"; - - if (data.Overview) { - description = - data.Overview.substring(0, 40) + - (data.Overview.length > 40 ? "..." : ""); - } - presenceData.state = `${data.Type} ─ ${description}`; - break; - } - case "MusicAlbum": - presenceData.state = `${data.Type} ─ ${data.RecursiveItemCount} songs`; - break; - case "MusicArtist": - case "TvChannel": - presenceData.state = `${data.Type} ─ No further information available`; - break; - default: - presenceData.state = "No further information available"; - } - - if (await presence.getSetting("showThumbnails")) - presenceData.largeImageKey = mediaPrimaryImage(data); - } + const data = await obtainMediaInfo( + new URLSearchParams(location.hash.split('?')[1]).get('id')!, + ) + + if (!data) { + presenceData.details = 'Browsing details of an item' + presenceData.state = 'Could not get item details' + } + else if (typeof data !== 'string') { + presenceData.details = `Browsing details of: ${data.Name}` + + switch (data.Type) { + case 'Movie': + presenceData.state = `${data.Type} ─ ${data.OriginalTitle} (${data.ProductionYear})` + break + case 'Series': + presenceData.state = `${data.Type} ─ (${data.Status})` + break + case 'Season': + presenceData.state = `${data.Type} ─ ${data.SeriesName}` + break + case 'Episode': + presenceData.state = `${data.Type} ─ ${data.SeriesName} - ${data.SeasonName}` + break + case 'Person': { + let description = 'Description not available' + + if (data.Overview) { + description = data.Overview.substring(0, 40) + + (data.Overview.length > 40 ? '...' : '') + } + presenceData.state = `${data.Type} ─ ${description}` + break + } + case 'MusicAlbum': + presenceData.state = `${data.Type} ─ ${data.RecursiveItemCount} songs` + break + case 'MusicArtist': + case 'TvChannel': + presenceData.state = `${data.Type} ─ No further information available` + break + default: + presenceData.state = 'No further information available' + } + + if (await presence.getSetting('showThumbnails')) + presenceData.largeImageKey = mediaPrimaryImage(data) + } } /** * Sets a presence based on the given multimedia mediaId */ async function setPresenceByMediaId(mediaId: string): Promise { - const mediaInfo = await obtainMediaInfo(mediaId); - - let title: string, subtitle: string; - - switch (mediaInfo.Type) { - case "Audio": - presenceData.type = ActivityType.Listening; - title = `Listening to ${mediaInfo.Name ?? "Unknown title"}`; - subtitle = `By ${mediaInfo.AlbumArtist ?? "Unknown artist"}`; - break; - case "Movie": - case "Series": - title = `Watching ${mediaInfo.Type}`; - subtitle = mediaInfo.Name; - break; - case "Episode": - title = `Watching: ${mediaInfo.SeriesName}`; - subtitle = `${/S[0-9]+:E[0-9]+/.exec( - document.querySelector(".pageTitle").textContent - )} - ${mediaInfo.Name}`; - break; - case "TvChannel": - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = "Live TV"; - break; - default: - title = `Watching ${mediaInfo.Type}`; - subtitle = mediaInfo.Name; - } - - if (presenceData.type !== ActivityType.Listening) - presenceData.type = ActivityType.Watching; - - if (await presence.getSetting("showThumbnails")) - presenceData.largeImageKey = mediaPrimaryImage(mediaInfo); - - if (mediaInfo.Type !== "TvChannel") { - const mediaElement = - document.querySelector("audio, video"), - paused = mediaElement - ? mediaElement.paused - : document - .querySelector( - ".nowPlayingBar .playPauseButton span" - ) - .classList.contains("play_arrow"); - - if (paused) { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = "Paused"; - - delete presenceData.endTimestamp; - } else { - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Playing"; - - // TODO: worth setting timestamps on remote playback? Requires WS connection - if (mediaElement && (await presence.getSetting("showMediaTimestamps"))) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(mediaElement); - } - } - } - - presenceData.details = title; - presenceData.state = subtitle; - - if (!presenceData.state) delete presenceData.state; + const mediaInfo = await obtainMediaInfo(mediaId) + + let title: string | undefined, subtitle: string | undefined + + switch (mediaInfo.Type) { + case 'Audio': + presenceData.type = ActivityType.Listening + title = `Listening to ${mediaInfo.Name ?? 'Unknown title'}` + subtitle = `By ${mediaInfo.AlbumArtist ?? 'Unknown artist'}` + break + case 'Movie': + case 'Series': + title = `Watching ${mediaInfo.Type}` + subtitle = mediaInfo.Name + break + case 'Episode': + title = `Watching: ${mediaInfo.SeriesName}` + subtitle = `${/S\d+:E\d+/.exec( + document.querySelector('.pageTitle')?.textContent ?? '', + )} - ${mediaInfo.Name}` + break + case 'TvChannel': + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = 'Live TV' + break + default: + title = `Watching ${mediaInfo.Type}` + subtitle = mediaInfo.Name + } + + if (presenceData.type !== ActivityType.Listening) + presenceData.type = ActivityType.Watching + + if (await presence.getSetting('showThumbnails')) + presenceData.largeImageKey = mediaPrimaryImage(mediaInfo) + + if (mediaInfo.Type !== 'TvChannel') { + const mediaElement = document.querySelector('audio, video') + const paused = mediaElement + ? mediaElement.paused + : document + .querySelector( + '.nowPlayingBar .playPauseButton span', + ) + ?.classList + .contains('play_arrow') + + if (paused) { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Paused' + + delete presenceData.endTimestamp + } + else { + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Playing' + + // TODO: worth setting timestamps on remote playback? Requires WS connection + if (mediaElement && (await presence.getSetting('showMediaTimestamps'))) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(mediaElement) + } + } + } + + presenceData.details = title + presenceData.state = subtitle + + if (!presenceData.state) + delete presenceData.state } /** * Suspend execution of code for an interval, see */ function sleep(ms: number): Promise { - return new Promise(res => { - setTimeout(res, ms); - }); + return new Promise((res) => { + setTimeout(res, ms) + }) } /** * Refreshes the ApiClient object */ async function loggedIn(): Promise { - let apiClient: ApiClient; + let newApiClient: ApiClient - do { - await sleep(125); - apiClient = await presence.getPageletiable("ApiClient"); - } while (!apiClient._serverInfo.AccessToken); + do { + await sleep(125) + newApiClient = await presence.getPageletiable('ApiClient') + } while (!apiClient._serverInfo.AccessToken) - ApiClient = apiClient; + apiClient = newApiClient } /** * Handle the presence while the user is in the web client */ async function handleWebClient(): Promise { - const audioElement = document.body.querySelector("audio"), - nowPlayingBar = document.querySelector(".nowPlayingBar"); - - // audio player active - if ( - audioElement && - audioElement.classList.contains("mediaPlayerAudio") && - audioElement.src - ) { - await handleAudioPlayback(); - return; - } else if ( - nowPlayingBar && - !nowPlayingBar.classList.contains("nowPlayingBar-hidden") - ) { - await handleRemotePlayback(); - return; - } - - presenceData.details = "At web client"; - - // obtain the path, on the example would return "login.html" - // https://media.domain.tld/web/index.html#!/login.html?serverid=randomserverid - - const path = location.hash.split("?")[0].substring(2); - - if (path === "login.html") { - wasLogin = true; - presenceData.state = "Logging in"; - } else if (wasLogin) { - loggedIn(); - wasLogin = false; - } - - switch (path) { - case "home.html": - presenceData.state = "At home"; - break; - case "search.html": - presenceData.state = "Searching"; - presenceData.smallImageKey = Assets.Search; - break; - - // user preferences - case "mypreferencesmenu.html": - case "myprofile.html": // profile - case "mypreferencesdisplay.html": // display - case "mypreferenceshome.html": // home - case "mypreferencesplayback.html": // playback - case "mypreferencessubtitles.html": // subtitles - presenceData.state = "On user preferences"; - break; - - // admin dashboard - case "dashboard.html": // server section - case "dashboardgeneral.html": // general - case "userprofiles.html": // user profiles - case "useredit.html": // editing user profile - case "userlibraryaccess.html": // editing user profile > library access - case "userparentalcontrol.html": // editing user profile > parental control - case "userpassword.html": // editing user profile > password - case "library.html": // managing library - case "librarydisplay.html": // library display settings - case "metadataimages.html": // library metadata settings - case "metadatanfo.html": // library NFO settings - case "encodingsettings.html": // encoding settings > transcoding - case "playbackconfiguration.html": // encoding settings > resume - case "streamingsettings.html": // encoding settings > streaming - case "devices.html": // devices - case "device.html": // editing device - case "serveractivity.html": // server activity - case "dlnasettings.html": // dlna settings > settings - case "dlnaprofiles.html": // dlna settings > profiles - case "dlnaprofile.html": // dlna settings > add profile - case "livetvstatus.html": // manage live tv - case "livetvtuner.html": // add/manage tv tuner - case "livetvguideprovider.html": // add/manage tv guide provider - case "livetvsettings.html": // live tv settings (dvr) // advanced section - case "networking.html": // networking - case "apikeys.html": // api keys - case "log.html": // logs - case "notificationsettings.html": // notification settings - case "installedplugins.html": // plugins - case "availableplugins.html": // plugins catalog - case "scheduledtasks.html": // scheduled tasks - case "configurationpage": // plugins configuration page - presenceData.state = "On admin dashboard"; - break; - - case "movies.html": - presenceData.state = "Browsing movies"; - break; - - case "tv.html": - presenceData.state = "Browsing tv series"; - break; - - case "music.html": - presenceData.state = "Browsing music"; - break; - - case "livetv.html": - presenceData.state = "Browsing Live TV"; - break; - - case "edititemmetadata.html": - presenceData.state = "Editing media metadata"; - break; - - case "details": - await handleItemDetails(); - break; - - case "video": - await handleVideoPlayback(); - break; - - case "nowplaying.html": - presenceData.state = "Viewing the audio playlist"; - break; - } + const audioElement = document.body.querySelector('audio') + const nowPlayingBar = document.querySelector('.nowPlayingBar') + + // audio player active + if ( + audioElement + && audioElement.classList.contains('mediaPlayerAudio') + && audioElement.src + ) { + await handleAudioPlayback() + return + } + else if ( + nowPlayingBar + && !nowPlayingBar.classList.contains('nowPlayingBar-hidden') + ) { + await handleRemotePlayback() + return + } + + presenceData.details = 'At web client' + + // obtain the path, on the example would return "login.html" + // https://media.domain.tld/web/index.html#!/login.html?serverid=randomserverid + + const path = location.hash.split('?')[0].substring(2) + + if (path === 'login.html') { + wasLogin = true + presenceData.state = 'Logging in' + } + else if (wasLogin) { + loggedIn() + wasLogin = false + } + + switch (path) { + case 'home.html': + presenceData.state = 'At home' + break + case 'search.html': + presenceData.state = 'Searching' + presenceData.smallImageKey = Assets.Search + break + + // user preferences + case 'mypreferencesmenu.html': + case 'myprofile.html': // profile + case 'mypreferencesdisplay.html': // display + case 'mypreferenceshome.html': // home + case 'mypreferencesplayback.html': // playback + case 'mypreferencessubtitles.html': // subtitles + presenceData.state = 'On user preferences' + break + + // admin dashboard + case 'dashboard.html': // server section + case 'dashboardgeneral.html': // general + case 'userprofiles.html': // user profiles + case 'useredit.html': // editing user profile + case 'userlibraryaccess.html': // editing user profile > library access + case 'userparentalcontrol.html': // editing user profile > parental control + case 'userpassword.html': // editing user profile > password + case 'library.html': // managing library + case 'librarydisplay.html': // library display settings + case 'metadataimages.html': // library metadata settings + case 'metadatanfo.html': // library NFO settings + case 'encodingsettings.html': // encoding settings > transcoding + case 'playbackconfiguration.html': // encoding settings > resume + case 'streamingsettings.html': // encoding settings > streaming + case 'devices.html': // devices + case 'device.html': // editing device + case 'serveractivity.html': // server activity + case 'dlnasettings.html': // dlna settings > settings + case 'dlnaprofiles.html': // dlna settings > profiles + case 'dlnaprofile.html': // dlna settings > add profile + case 'livetvstatus.html': // manage live tv + case 'livetvtuner.html': // add/manage tv tuner + case 'livetvguideprovider.html': // add/manage tv guide provider + case 'livetvsettings.html': // live tv settings (dvr) // advanced section + case 'networking.html': // networking + case 'apikeys.html': // api keys + case 'log.html': // logs + case 'notificationsettings.html': // notification settings + case 'installedplugins.html': // plugins + case 'availableplugins.html': // plugins catalog + case 'scheduledtasks.html': // scheduled tasks + case 'configurationpage': // plugins configuration page + presenceData.state = 'On admin dashboard' + break + + case 'movies.html': + presenceData.state = 'Browsing movies' + break + + case 'tv.html': + presenceData.state = 'Browsing tv series' + break + + case 'music.html': + presenceData.state = 'Browsing music' + break + + case 'livetv.html': + presenceData.state = 'Browsing Live TV' + break + + case 'edititemmetadata.html': + presenceData.state = 'Editing media metadata' + break + + case 'details': + await handleItemDetails() + break + + case 'video': + await handleVideoPlayback() + break + + case 'nowplaying.html': + presenceData.state = 'Viewing the audio playlist' + break + } } /** * Sets default values to the presenceData object */ async function setDefaultsToPresence(): Promise { - presenceData.largeImageKey = Assets.logo; + presenceData.largeImageKey = Assets.logo - if (presenceData.smallImageKey) delete presenceData.smallImageKey; + if (presenceData.smallImageKey) + delete presenceData.smallImageKey - if (presenceData.smallImageText) delete presenceData.smallImageText; + if (presenceData.smallImageText) + delete presenceData.smallImageText - if (presenceData.state) delete presenceData.state; + if (presenceData.state) + delete presenceData.state - if (presenceData.startTimestamp) delete presenceData.startTimestamp; + if (presenceData.startTimestamp) + delete presenceData.startTimestamp - if (isNaN(presenceData.endTimestamp as number)) - delete presenceData.endTimestamp; + if (Number.isNaN(presenceData.endTimestamp as number)) + delete presenceData.endTimestamp - if ((await presence.getSetting("showTimestamps")) === false) - delete presenceData.startTimestamp; + if ((await presence.getSetting('showTimestamps')) === false) + delete presenceData.startTimestamp } /** * Initializes the ApiClient object */ async function refreshApiClient(): Promise { - ApiClient ??= ( - await presence.getPageVariable>("ApiClient") - ).ApiClient; + apiClient ??= ( + await presence.getPageVariable>('ApiClient') + ).ApiClient } /** * Imports the ApiClient variable and verifies that we are in the jellyfin web client */ async function isJellyfinWebClient(): Promise { - if (!ApiClient) await refreshApiClient(); - - if ( - ApiClient && - typeof ApiClient === "object" && - ApiClient._appName && - ApiClient._appName === "Jellyfin Web" - ) - return true; - - return false; + if (!apiClient) + await refreshApiClient() + + if ( + apiClient + && typeof apiClient === 'object' + && apiClient._appName + && apiClient._appName === 'Jellyfin Web' + ) { + return true + } + + return false } /** * PreMiD tick function */ async function updateData(): Promise { - await setDefaultsToPresence(); - - let showPresence = false; - - // we are on the official jellyfin page - if (location.host.toLowerCase() === JELLYFIN_URL) { - showPresence = true; - handleOfficialWebsite(); - - // we are on the web client and has been verified - } else if (await isJellyfinWebClient()) { - showPresence = true; - await handleWebClient(); - } - - // if jellyfin is detected init/update the presence status - if (showPresence) { - const largeImageKey = presenceData.largeImageKey as string; - if (isPrivateIP(largeImageKey)) { - if (uploadedMediaCache.has(largeImageKey)) - presenceData.largeImageKey = uploadedMediaCache.get(largeImageKey); - else { - await fetch(largeImageKey) - .then(res => res.blob()) - .then(blob => { - const reader = new FileReader(); - reader.readAsDataURL(blob); - reader.onloadend = () => { - const result = reader.result as string; - uploadedMediaCache.set(largeImageKey, result); - presenceData.largeImageKey = result; - }; - }); - } - } - - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); - } + await setDefaultsToPresence() + + let showPresence = false + + // we are on the official jellyfin page + if (location.host.toLowerCase() === JELLYFIN_URL) { + showPresence = true + handleOfficialWebsite() + + // we are on the web client and has been verified + } + else if (await isJellyfinWebClient()) { + showPresence = true + await handleWebClient() + } + + // if jellyfin is detected init/update the presence status + if (showPresence) { + const largeImageKey = presenceData.largeImageKey as string + if (isPrivateIP(largeImageKey)) { + if (uploadedMediaCache.has(largeImageKey)) { + presenceData.largeImageKey = uploadedMediaCache.get(largeImageKey) + } + else { + await fetch(largeImageKey) + .then(res => res.blob()) + .then((blob) => { + const reader = new FileReader() + reader.readAsDataURL(blob) + reader.onloadend = () => { + const result = reader.result as string + uploadedMediaCache.set(largeImageKey, result) + presenceData.largeImageKey = result + } + }) + } + } + + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) + } } function isPrivateIP(ip: string): boolean { - return /^http:\/\/(192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[01])\.|127\.0\.0\.1|localhost)/.test( - ip - ); + return /^http:\/\/(?:192\.168\.|10\.|172\.(?:1[6-9]|2\d|3[01])\.|127\.0\.0\.1|localhost)/.test( + ip, + ) } /** * Check if the presence should be initialized, if so start doing the magic */ async function init(): Promise { - let validPage = false, - infoMessage; - - // jellyfin website - if (location.host === JELLYFIN_URL) { - validPage = true; - infoMessage = "Jellyfin website detected"; - - // web client - } else { - try { - for (const server of JSON.parse( - localStorage.getItem("jellyfin_credentials") - ).Servers) { - // user has accessed in the last 30 seconds, should be enough for slow connections - if ( - Date.now() - new Date(server.DateLastAccessed).getTime() < - 30 * 1000 - ) { - validPage = true; - infoMessage = "Jellyfin web client detected"; - } - } - } catch (e) { - validPage = false; - } - } - - if (validPage) { - presence = new Presence({ - clientId: "669359568391766018", - }); - - presence.info(infoMessage); - presence.on("UpdateData", updateData); - } + let validPage = false + let infoMessage + + // jellyfin website + if (location.host === JELLYFIN_URL) { + validPage = true + infoMessage = 'Jellyfin website detected' + + // web client + } + else { + try { + for (const server of JSON.parse( + localStorage.getItem('jellyfin_credentials') ?? '{}', + ).Servers) { + // user has accessed in the last 30 seconds, should be enough for slow connections + if ( + Date.now() - new Date(server.DateLastAccessed).getTime() + < 30 * 1000 + ) { + validPage = true + infoMessage = 'Jellyfin web client detected' + } + } + } + catch { + validPage = false + } + } + + if (validPage) { + presence = new Presence({ + clientId: '669359568391766018', + }) + + presence.info(infoMessage ?? '') + presence.on('UpdateData', updateData) + } } -init(); +init() diff --git a/websites/J/Jet Set Radio Live/metadata.json b/websites/J/Jet Set Radio Live/metadata.json index 860b78a5d828..815a0a548459 100644 --- a/websites/J/Jet Set Radio Live/metadata.json +++ b/websites/J/Jet Set Radio Live/metadata.json @@ -1,52 +1,52 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Snazzah", - "id": "158049329150427136" - }, - "contributors": [ - { - "name": "sks316", - "id": "226098403304538122" - } - ], - "service": "Jet Set Radio Live", - "description": { - "en": "Yo! You've heard about Jet Set Radio, right? It's only the hottest radio station straight outta Tokyo-to! Tune in. Turn on. Jet Set Radiooo!!!", - "nl": "Yo! Je hebt toch van Jet Set Radio gehoord? Het is alleen het populairste radiostation dat rechtstreeks uit Tokio komt! Stem af. Zet aan. Jetset Radiooo !!!" - }, - "url": [ - "jetsetradio.live", - "jetsetradiofuture.live" - ], - "version": "2.3.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jet%20Set%20Radio%20Live/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jet%20Set%20Radio%20Live/assets/thumbnail.jpg", - "color": "#FFE222", - "category": "music", - "tags": [ - "music", - "radio" - ], - "settings": [ - { - "id": "song", - "title": "Show Current Song", - "icon": "fas fa-music", - "value": true - }, - { - "id": "timestamp", - "title": "Show Timestamps", - "icon": "fas fa-clock", - "value": true - }, - { - "id": "buttons", - "title": "Show Presence Buttons", - "icon": "fas fa-th-large", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Snazzah", + "id": "158049329150427136" + }, + "contributors": [ + { + "name": "sks316", + "id": "226098403304538122" + } + ], + "service": "Jet Set Radio Live", + "description": { + "en": "Yo! You've heard about Jet Set Radio, right? It's only the hottest radio station straight outta Tokyo-to! Tune in. Turn on. Jet Set Radiooo!!!", + "nl": "Yo! Je hebt toch van Jet Set Radio gehoord? Het is alleen het populairste radiostation dat rechtstreeks uit Tokio komt! Stem af. Zet aan. Jetset Radiooo !!!" + }, + "url": [ + "jetsetradio.live", + "jetsetradiofuture.live" + ], + "version": "2.3.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jet%20Set%20Radio%20Live/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jet%20Set%20Radio%20Live/assets/thumbnail.jpg", + "color": "#FFE222", + "category": "music", + "tags": [ + "music", + "radio" + ], + "settings": [ + { + "id": "song", + "title": "Show Current Song", + "icon": "fas fa-music", + "value": true + }, + { + "id": "timestamp", + "title": "Show Timestamps", + "icon": "fas fa-clock", + "value": true + }, + { + "id": "buttons", + "title": "Show Presence Buttons", + "icon": "fas fa-th-large", + "value": true + } + ] +} diff --git a/websites/J/Jet Set Radio Live/presence.ts b/websites/J/Jet Set Radio Live/presence.ts index 0f4f6ad32d31..e2e5a298cc12 100644 --- a/websites/J/Jet Set Radio Live/presence.ts +++ b/websites/J/Jet Set Radio Live/presence.ts @@ -1,110 +1,111 @@ const presence = new Presence({ - clientId: "782853565550034954", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }), - stationIDMap: { [key: string]: string } = { - olliolliworld: "OlliOlli World", - spacechannel5: "Space Channel 5", - live: "Jet Set Radio Live", - outerspace: "Outer Space", - classic: "Classic", - future: "Future", - ultraremixes: "Ultra Remixes", - garage: "The Garage", - ggs: "GG's", - noisetanks: "Noise Tanks", - poisonjam: "Poison Jam", - rapid99: "Rapid 99", - loveshockers: "Love Shockers", - immortals: "The Immortals", - doomriders: "Doom Riders", - goldenrhinos: "Golden Rhinos", - ganjah: "Ganjah", - lofi: "Lo-Fi", - chiptunes: "Chiptunes", - retroremix: "Retro Remix", - classical: "Classical Remix", - revolution: "Revolution", - endofdays: "End of Days", - silvagunner: "SilvaGunner x JSR", - futuregeneration: "Future Generation", - jetmashradio: "Jet Mash Radio", - memoriesoftokyoto: "Memories of Tokyo-to", - tokyotofuture: "Sounds of Tokyo-to Future", - crazytaxi: "Crazy Taxi", - ollieking: "Ollie King", - toejamandearl: "Toe Jam & Earl", - hover: "Hover", - butterflies: "Butterflies", - lethalleagueblaze: "Lethal League Blaze", - bonafidebloom: "BonafideBloom", - djchidow: "DJ Chidow", - verafx: "VeraFX", - summer: "Summer", - halloween: "Halloween", - christmas: "Christmas", - snowfi: "Snow-Fi", - brc: "Bomb Rush Cyberfunk", - elaquent: "Elaquent", - turntablism: "Turntablism", - sonicrush: "Sonic Rush", - }; + clientId: '782853565550034954', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) +const stationIDMap: { [key: string]: string } = { + olliolliworld: 'OlliOlli World', + spacechannel5: 'Space Channel 5', + live: 'Jet Set Radio Live', + outerspace: 'Outer Space', + classic: 'Classic', + future: 'Future', + ultraremixes: 'Ultra Remixes', + garage: 'The Garage', + ggs: 'GG\'s', + noisetanks: 'Noise Tanks', + poisonjam: 'Poison Jam', + rapid99: 'Rapid 99', + loveshockers: 'Love Shockers', + immortals: 'The Immortals', + doomriders: 'Doom Riders', + goldenrhinos: 'Golden Rhinos', + ganjah: 'Ganjah', + lofi: 'Lo-Fi', + chiptunes: 'Chiptunes', + retroremix: 'Retro Remix', + classical: 'Classical Remix', + revolution: 'Revolution', + endofdays: 'End of Days', + silvagunner: 'SilvaGunner x JSR', + futuregeneration: 'Future Generation', + jetmashradio: 'Jet Mash Radio', + memoriesoftokyoto: 'Memories of Tokyo-to', + tokyotofuture: 'Sounds of Tokyo-to Future', + crazytaxi: 'Crazy Taxi', + ollieking: 'Ollie King', + toejamandearl: 'Toe Jam & Earl', + hover: 'Hover', + butterflies: 'Butterflies', + lethalleagueblaze: 'Lethal League Blaze', + bonafidebloom: 'BonafideBloom', + djchidow: 'DJ Chidow', + verafx: 'VeraFX', + summer: 'Summer', + halloween: 'Halloween', + christmas: 'Christmas', + snowfi: 'Snow-Fi', + brc: 'Bomb Rush Cyberfunk', + elaquent: 'Elaquent', + turntablism: 'Turntablism', + sonicrush: 'Sonic Rush', +} -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - type: ActivityType.Listening, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/Jet%20Set%20Radio%20Live/assets/logo.png", - }, - audio = document.querySelector("#audioPlayer"), - songName = document.querySelector( - "#programInformationText.objectSettings.touchableOff" - ), - buttons = await presence.getSetting("buttons"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + type: ActivityType.Listening, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/Jet%20Set%20Radio%20Live/assets/logo.png', + } + const audio = document.querySelector('#audioPlayer') + const songName = document.querySelector( + '#programInformationText.objectSettings.touchableOff', + ) + const buttons = await presence.getSetting('buttons') - if (songName.textContent.length < 1 || !audio) - presenceData.details = "Not tuned in."; - else { - const stationImage = - document.querySelector("#graffitiSoul").src, - stationName = stationIDMap[stationImage.split("/")[5]]; - presenceData.largeImageKey = stationImage; - if (stationName) presenceData.state = stationName; + if ((songName?.textContent && songName.textContent.length < 1) || !audio) { + presenceData.details = 'Not tuned in.' + } + else { + const stationImage = document.querySelector('#graffitiSoul')?.src + const stationName = stationIDMap[stationImage?.split('/')[5] ?? ''] + presenceData.largeImageKey = stationImage + if (stationName) + presenceData.state = stationName - if ( - !audio.paused && - !document.querySelector('#loadingTrackCircle:not([style*="hidden"])') - ) { - if (await presence.getSetting("song")) - presenceData.details = songName.textContent; - if ( - (await presence.getSetting("timestamp")) && - isFinite(audio.duration) - ) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(audio); - } - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = (await strings).play; - } else { - presenceData.details = "Paused"; - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = (await strings).pause; - } + if ( + !audio.paused + && !document.querySelector('#loadingTrackCircle:not([style*="hidden"])') + ) { + if (await presence.getSetting('song')) + presenceData.details = songName?.textContent + if ( + (await presence.getSetting('timestamp')) + && Number.isFinite(audio.duration) + ) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(audio) + } + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = (await strings).play + } + else { + presenceData.details = 'Paused' + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = (await strings).pause + } - if (buttons) { - presenceData.buttons = [ - { - label: "Tune In", - url: document.URL, - }, - ]; - } - } + if (buttons) { + presenceData.buttons = [ + { + label: 'Tune In', + url: document.URL, + }, + ] + } + } - if (!presenceData.details && presenceData.state) presence.setActivity(); - else presence.setActivity(presenceData); -}); + if (!presenceData.details && presenceData.state) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/J/JeuxVideo.com/metadata.json b/websites/J/JeuxVideo.com/metadata.json index 5d0b4a62599d..3c0cef39c4ce 100644 --- a/websites/J/JeuxVideo.com/metadata.json +++ b/websites/J/JeuxVideo.com/metadata.json @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "jordanamr", - "id": "621796333669449749" - }, - "service": "JeuxVideo.com", - "description": { - "en": "JVC (jeuxvideo.com) is a famous french board and news site about video games.", - "fr": "JVC (jeuxvideo.com) est un forum et site d'actualité populaire sur les jeux vidéos.", - "nl": "JVC (jeuxvideo.com) is een beroemde Franse bord- en nieuwssite over videogames." - }, - "url": "www.jeuxvideo.com", - "version": "1.2.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/JeuxVideo.com/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/JeuxVideo.com/assets/thumbnail.png", - "color": "#FF582E", - "category": "socials", - "tags": [ - "news", - "games", - "forum", - "board", - "jvc", - "jeuxvideocom", - "jeuxvideo-com", - "18-25", - "1825" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "jordanamr", + "id": "621796333669449749" + }, + "service": "JeuxVideo.com", + "description": { + "en": "JVC (jeuxvideo.com) is a famous french board and news site about video games.", + "fr": "JVC (jeuxvideo.com) est un forum et site d'actualité populaire sur les jeux vidéos.", + "nl": "JVC (jeuxvideo.com) is een beroemde Franse bord- en nieuwssite over videogames." + }, + "url": "www.jeuxvideo.com", + "version": "1.2.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/JeuxVideo.com/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/JeuxVideo.com/assets/thumbnail.png", + "color": "#FF582E", + "category": "socials", + "tags": [ + "news", + "games", + "forum", + "board", + "jvc", + "jeuxvideocom", + "jeuxvideo-com", + "18-25", + "1825" + ] +} diff --git a/websites/J/JeuxVideo.com/presence.ts b/websites/J/JeuxVideo.com/presence.ts index d63e80deb5e3..3bd6099e2765 100644 --- a/websites/J/JeuxVideo.com/presence.ts +++ b/websites/J/JeuxVideo.com/presence.ts @@ -1,72 +1,79 @@ const presence = new Presence({ - clientId: "651930315279040512", -}); + clientId: '651930315279040512', +}) /** * Truncate a string by "..." if needed - * @param {String} text The string to truncate - * @param {Number} length The desized length + * @param {string} text The string to truncate + * @param {number} length The desized length */ function truncateString(text: string, length: number): string { - if (text.length > length) return `${text.substring(0, length - 3)}...`; - else return text; + if (text.length > length) + return `${text.substring(0, length - 3)}...` + else return text } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/JeuxVideo.com/assets/logo.jpg", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/JeuxVideo.com/assets/logo.jpg', + } - if (document.location.pathname === "/") - presenceData.details = "Page d'accueil"; - else if (document.location.pathname.includes("/news/")) { - presenceData.details = "Lis une actualité"; - presenceData.state = truncateString( - document.querySelector("div.titre-wrapper").textContent, - 128 - ); - } else if (document.location.pathname.includes("/videos/")) { - presenceData.details = "Regarde une vidéo"; - presenceData.state = truncateString( - document.querySelector("div.titre-video").textContent, - 128 - ); - } else if (document.location.pathname.includes("/test/")) { - presenceData.details = "Lis un test"; - presenceData.state = `${truncateString( - document.querySelector(".gameHeaderBanner__title").textContent, - 128 - )} (${ - document.querySelector(".bloc-avis-testeur > .note > strong").textContent - }/20)`; - } else if (document.location.pathname.includes("/messages-prives/")) - presenceData.details = "Lis ses MP"; - else if (document.location.pathname.includes("/forums/0-")) { - presenceData.details = truncateString( - document.querySelector( - "#forum-main-col > .titre-head-bloc > .titre-bloc-forum" - ).textContent, - 64 - ); - presenceData.state = document.querySelector( - ".panel-heading > .nb-connect-fofo" - ).textContent; - } else if (document.location.pathname.includes("/forums/")) { - presenceData.details = truncateString( - document.querySelector( - ".bloc-fil-ariane-crumb-forum > .fil-ariane-crumb > span:last-of-type > a" - ).textContent, - 64 - ); - presenceData.state = truncateString( - document.querySelector( - "#forum-main-col > .titre-head-bloc > .titre-bloc-forum > #bloc-title-forum" - ).textContent, - 128 - ); - } + if (document.location.pathname === '/') { + presenceData.details = 'Page d\'accueil' + } + else if (document.location.pathname.includes('/news/')) { + presenceData.details = 'Lis une actualité' + presenceData.state = truncateString( + document.querySelector('div.titre-wrapper')?.textContent ?? '', + 128, + ) + } + else if (document.location.pathname.includes('/videos/')) { + presenceData.details = 'Regarde une vidéo' + presenceData.state = truncateString( + document.querySelector('div.titre-video')?.textContent ?? '', + 128, + ) + } + else if (document.location.pathname.includes('/test/')) { + presenceData.details = 'Lis un test' + presenceData.state = `${truncateString( + document.querySelector('.gameHeaderBanner__title')?.textContent ?? '', + 128, + )} (${ + document.querySelector('.bloc-avis-testeur > .note > strong')?.textContent ?? '' + }/20)` + } + else if (document.location.pathname.includes('/messages-prives/')) { + presenceData.details = 'Lis ses MP' + } + else if (document.location.pathname.includes('/forums/0-')) { + presenceData.details = truncateString( + document.querySelector( + '#forum-main-col > .titre-head-bloc > .titre-bloc-forum', + )?.textContent ?? '', + 64, + ) + presenceData.state = document.querySelector( + '.panel-heading > .nb-connect-fofo', + )?.textContent + } + else if (document.location.pathname.includes('/forums/')) { + presenceData.details = truncateString( + document.querySelector( + '.bloc-fil-ariane-crumb-forum > .fil-ariane-crumb > span:last-of-type > a', + )?.textContent ?? '', + 64, + ) + presenceData.state = truncateString( + document.querySelector( + '#forum-main-col > .titre-head-bloc > .titre-bloc-forum > #bloc-title-forum', + )?.textContent ?? '', + 128, + ) + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/J/JioCinema/metadata.json b/websites/J/JioCinema/metadata.json index 722a41250112..fd0f8be0e0e6 100644 --- a/websites/J/JioCinema/metadata.json +++ b/websites/J/JioCinema/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "manish", - "id": "332177981214818315" - }, - "service": "JioCinema", - "description": { - "en": "JioCinema is a video streaming service offered by Jio where in you can watch movies, TV shows, Jio exclusives, documentaries and trailers.", - "nl": "JioCinema is een videostreamingdienst aangeboden door Jio waar u films, tv-shows, exclusieve Jio, documentaires en trailers kunt bekijken." - }, - "url": "www.jiocinema.com", - "version": "1.2.26", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/JioCinema/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/JioCinema/assets/thumbnail.png", - "color": "#ec5a7f", - "category": "videos", - "tags": [ - "movies", - "shows", - "videos", - "tv" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "manish", + "id": "332177981214818315" + }, + "service": "JioCinema", + "description": { + "en": "JioCinema is a video streaming service offered by Jio where in you can watch movies, TV shows, Jio exclusives, documentaries and trailers.", + "nl": "JioCinema is een videostreamingdienst aangeboden door Jio waar u films, tv-shows, exclusieve Jio, documentaires en trailers kunt bekijken." + }, + "url": "www.jiocinema.com", + "version": "1.2.26", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/JioCinema/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/JioCinema/assets/thumbnail.png", + "color": "#ec5a7f", + "category": "videos", + "tags": [ + "movies", + "shows", + "videos", + "tv" + ] +} diff --git a/websites/J/JioCinema/presence.ts b/websites/J/JioCinema/presence.ts index 16da5273b893..3f40c181b70c 100644 --- a/websites/J/JioCinema/presence.ts +++ b/websites/J/JioCinema/presence.ts @@ -1,52 +1,60 @@ const presence: Presence = new Presence({ - clientId: "632479205707350037", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }), - startTimestamp = Math.floor(Date.now() / 1000); + clientId: '632479205707350037', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) +const startTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/JioCinema/assets/logo.png", - startTimestamp, - }, - url = window.location.href; - if (url.includes("/watch/")) { - const [video] = document.querySelectorAll("video"); - presenceData.details = - document.querySelectorAll(".meta-data-title")[0].textContent; - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/J/JioCinema/assets/logo.png"; - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? (await strings).pause - : (await strings).play; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ); - if (url.includes("/tv/")) { - presenceData.state = ( - document.querySelectorAll("div.now-playing") as NodeListOf - )[0].offsetParent - .querySelectorAll("span.jioTitle")[1] - .textContent.replace("| ", ""); - } else if (url.includes("/movies/")) presenceData.state = "Movie"; - else if (url.includes("/playlist/")) presenceData.state = "Music Video"; - else presenceData.state = "Video"; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/JioCinema/assets/logo.png', + startTimestamp, + } + const url = window.location.href + if (url.includes('/watch/')) { + const [video] = document.querySelectorAll('video') + presenceData.details = document.querySelectorAll('.meta-data-title')[0].textContent + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/J/JioCinema/assets/logo.png' + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? (await strings).pause + : (await strings).play; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) + if (url.includes('/tv/')) { + presenceData.state = ( + document.querySelectorAll('div.now-playing') as NodeListOf + )[0]?.offsetParent + ?.querySelectorAll('span.jioTitle')[1] + ?.textContent + ?.replace('| ', '') + } + else if (url.includes('/movies/')) { + presenceData.state = 'Movie' + } + else if (url.includes('/playlist/')) { + presenceData.state = 'Music Video' + } + else { + presenceData.state = 'Video' + } - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else if (url.includes("/search/")) { - presenceData.details = "Searching..."; - presenceData.smallImageKey = Assets.Search; - } else presenceData.details = "Browsing"; + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else if (url.includes('/search/')) { + presenceData.details = 'Searching...' + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = 'Browsing' + } - presence.setActivity(presenceData, true); -}); + presence.setActivity(presenceData, true) +}) diff --git a/websites/J/Jira Software/metadata.json b/websites/J/Jira Software/metadata.json index 65e5a1ab0851..1d0afe8dda4d 100644 --- a/websites/J/Jira Software/metadata.json +++ b/websites/J/Jira Software/metadata.json @@ -1,37 +1,37 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "isladot", - "id": "385895205406244865" - }, - "service": "Jira Software", - "description": { - "en": "Jira Software is built for every member of your software team to plan, track, and release great software. WARN: For now, only projects hosted on atlassian domains are supported.", - "it": "Jira Software è creato apposta per ogni membro del tuo team di sviluppo software, per pianificare, tenere traccia e rilasciare software fantastici. WARN: Per il momento, sono supportati solo i progetti hostati sui domini atlassian.", - "nl": "Jira Software is gebouwd zodat elk lid van uw softwareteam geweldige software kan plannen, volgen en vrijgeven. WAARSCHUWING: voorlopig worden alleen projecten ondersteund die worden gehost op atlassian-domeinen." - }, - "url": "www.atlassian.com", - "regExp": "[a-z0-9]+[.]atlassian[.]net", - "version": "1.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jira%20Software/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jira%20Software/assets/thumbnail.png", - "color": "#2684FF", - "category": "other", - "tags": [ - "projects", - "board", - "software", - "management", - "issues", - "tasks" - ], - "settings": [ - { - "id": "showSettingsSections", - "title": "Show Settings sub-sections.", - "icon": "fas fa-cogs", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "isladot", + "id": "385895205406244865" + }, + "service": "Jira Software", + "description": { + "en": "Jira Software is built for every member of your software team to plan, track, and release great software. WARN: For now, only projects hosted on atlassian domains are supported.", + "it": "Jira Software è creato apposta per ogni membro del tuo team di sviluppo software, per pianificare, tenere traccia e rilasciare software fantastici. WARN: Per il momento, sono supportati solo i progetti hostati sui domini atlassian.", + "nl": "Jira Software is gebouwd zodat elk lid van uw softwareteam geweldige software kan plannen, volgen en vrijgeven. WAARSCHUWING: voorlopig worden alleen projecten ondersteund die worden gehost op atlassian-domeinen." + }, + "url": "www.atlassian.com", + "regExp": "[a-z0-9]+[.]atlassian[.]net", + "version": "1.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jira%20Software/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jira%20Software/assets/thumbnail.png", + "color": "#2684FF", + "category": "other", + "tags": [ + "projects", + "board", + "software", + "management", + "issues", + "tasks" + ], + "settings": [ + { + "id": "showSettingsSections", + "title": "Show Settings sub-sections.", + "icon": "fas fa-cogs", + "value": true + } + ] +} diff --git a/websites/J/Jira Software/presence.ts b/websites/J/Jira Software/presence.ts index 2ea9dafcc59b..ee3f0946d676 100644 --- a/websites/J/Jira Software/presence.ts +++ b/websites/J/Jira Software/presence.ts @@ -1,213 +1,223 @@ const presence = new Presence({ - clientId: "782358522628145153", //Presence Application ID on Discord Developers. - }), - browsingTimestamp = Math.floor(Date.now() / 1000); - -let projectName: string; - -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/Jira%20Software/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - path = document.location.pathname; - - if (document.location.hostname.match(/[a-z0-9]+[.]atlassian[.]net/)) { - //If user is not creating a new issue. - if (document.title !== "Create issue - Jira") { - //Projects homepage section. - if (path === "/projects" || path === "/secure/BrowseProjects.jspa") - presenceData.details = "Browsing Projects."; - else if (path.includes("/jira/software/projects/")) { - //Project sections. - projectName = path - .replace("/jira/software/projects/", "") - .split("/") - .shift(); - - //Project Board section. - if (path.match(/\/[a-zA-Z0-9]+\/boards\/[0-9]$/)) { - presenceData.details = `Viewing ${ - document.querySelector( - '#jira-frontend > #helpPanelContainer > div:first-child > div > div[data-testid="Content"] > div:first-child > div:first-child > div:first-child > div > div:nth-child(2) > div:first-child > div:first-child > div > h1' - ).textContent - }.`; - presenceData.state = `Project: ${projectName}`; - } else if (path.includes("/reports")) { - //Project Report section. - enum reportType { - burnup = "Analyzing Burnup report.", - burndown = "Analyzing Burndown report.", - velocity = "Analyzing Velocity report.", - cumulative = "Analyzing Cumulative report.", - } - - presenceData.details = - reportType[path.split("/").pop() as keyof typeof reportType] || - "Analyzing Reports."; - presenceData.state = `Project: ${projectName}`; - } else if (path.includes("/issues/")) { - //Project Issues section. - const issueName = path.split("/").pop(); - - if (issueName === "") { - presenceData.details = "Tracking Issues."; - presenceData.state = `Project: ${projectName}`; - } else { - presenceData.details = `Viewing Issue ${issueName}.`; - presenceData.state = `Project: ${projectName}`; - } - } else if (path.includes("/settings/")) { - //Project Settings section. - //Getting user preference for showSettingsSections. - const showSettingsSections = await presence.getSetting( - "showSettingsSections" - ); - - //If user set showSettingsSection = True - if (showSettingsSections) { - //Settings sections with no sub-links. - if (!path.includes("/issuetypes") && !path.includes("/apps")) { - enum settingsSection { - details = "Editing Details settings.", - access = "Editing Access settings.", - notifications = "Editing Notifications settings.", - features = "Editing Features settings.", - } - - presenceData.details = - settingsSection[ - path.split("/").pop() as keyof typeof settingsSection - ]; - presenceData.state = `Project: ${projectName}`; - } else if (path.includes("/apps/")) { - if (path.includes("/app-fields")) { - presenceData.details = "Editing Apps settings: App fields."; - presenceData.state = `Project: ${projectName}`; - } else { - presenceData.details = - "Editing Apps settings: Project automation."; - presenceData.state = `Project: ${projectName}`; - } - } else { - presenceData.details = `Editing Issue type: ${ - document.querySelector( - '#jira-frontend > #helpPanelContainer > div > div > div[data-testid="Content"] > div:first-child > div:first-child > div > div:nth-child(2) > div > div > div:first-child > div:nth-child(3) > div > div > div:first-child > div > form > div > div > div > h1' - ).textContent - }.`; - presenceData.state = `Project: ${projectName}`; - } - } else { - //If user set showSettingsSection = False - presenceData.details = "Editing Settings."; - presenceData.state = `Project: ${projectName}`; - } - } else { - //Project sections with no sub-links. - enum projectSections { - roadmap = "Viewing Roadmap.", - backlog = "Viewing Backlog.", - code = "Reviewing Code.", - pages = "Viewing Pages.", - } - - presenceData.details = - projectSections[ - path.split("/").pop() as keyof typeof projectSections - ]; - presenceData.state = `Project: ${projectName}`; - } - } else if (path.includes("/projects/")) { - //Project Releases section, the only one with a different path. - projectName = path.replace("/projects/", "").split("/").pop(); - - presenceData.details = "Viewing Releases."; - presenceData.state = `Project: ${projectName}`; - } else if (path === "/jira/your-work") { - //Your work section. - presenceData.details = "Viewing personal Issues."; - } else if (path.includes("/browse/")) { - //Browsing Issue section. - presenceData.details = `Viewing Issue ${path.split("/").pop()}`; - } else { - switch (path) { - case "/issues/": { - //Advanced Issues section. - enum issuesSection { - "My open issues." = -1, - "Reported by me." = -2, - "Viewed recently." = -3, - "All issues." = -4, - "Open issues." = -5, - "Created recently." = -6, - "Resolved recently." = -7, - "Updated recently." = -8, - "Done issues." = -9, - } - - presenceData.details = "Tracking global Issues:"; - presenceData.state = - issuesSection[ - parseInt( - document.location.search.split("=", 2).pop().substr(0, 2) - ) - ] || "Searching for an issue."; - - break; - } - case "/secure/ManageFilters.jspa": { - //Filters section. - presenceData.details = "Managing Filters."; - - break; - } - case "/jira/dashboards": { - //Dashboards homepage section. - presenceData.details = "Browsing Dashboards."; - - break; - } - case "/secure/Dashboard.jspa": { - //Dashboard section. - presenceData.details = "Viewing a Dashboard:"; - presenceData.state = document.querySelector( - "#dashboard-content > div:first-child > div > div:first-child > h1" - ).textContent; - - break; - } - case "/jira/people/search": { - //People homepage section. (yeah, path is correct, don't ask me why there is a "search", ~isladot) - presenceData.details = "Browsing Users."; - - break; - } - default: - if (path.match(/\/jira\/people\/[a-z0-9]+$/)) { - //User profile page section. - presenceData.details = "Viewing a User:"; - presenceData.state = document.querySelector( - '#jira-frontend > #helpPanelContainer > div > div > div[data-testid="Content"] > div:first-child > div > div > div > div > div:nth-child(2) > aside > div:first-child > div > div:nth-child(2) > h2' - ).textContent; - } else if (path.match(/\/jira\/people\/team\/[a-z0-9-]+$/)) { - //Team profile page section. - presenceData.details = "Viewing a Team:"; - presenceData.state = document.querySelector( - '#helpPanelContainer > div > div > div[data-testid="Content"] > div:first-child > div > div > div > div:nth-child(2) > aside > div:first-child > div > div:first-child > form > div > div > div > div' - ).textContent; - } else if (path === "/secure/ViewPersonalSettings.jspa") { - //Personal settings section. - presenceData.details = "Editing Personal settings."; - } - } - } - } else { - //If user is creating a new issue. - presenceData.details = "Creating an Issue."; - } - } - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + clientId: '782358522628145153', // Presence Application ID on Discord Developers. +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/Jira%20Software/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const path = document.location.pathname + + if (document.location.hostname.match(/[a-z0-9]+\.atlassian\.net/)) { + // If user is not creating a new issue. + if (document.title !== 'Create issue - Jira') { + // Projects homepage section. + if (path === '/projects' || path === '/secure/BrowseProjects.jspa') { + presenceData.details = 'Browsing Projects.' + } + else if (path.includes('/jira/software/projects/')) { + // Project sections. + const projectName = path + .replace('/jira/software/projects/', '') + .split('/') + .shift() + + // Project Board section. + if (path.match(/\/[a-zA-Z0-9]+\/boards\/\d$/)) { + presenceData.details = `Viewing ${ + document.querySelector( + '#jira-frontend > #helpPanelContainer > div:first-child > div > div[data-testid="Content"] > div:first-child > div:first-child > div:first-child > div > div:nth-child(2) > div:first-child > div:first-child > div > h1', + )?.textContent + }.` + presenceData.state = `Project: ${projectName}` + } + else if (path.includes('/reports')) { + // Project Report section. + enum reportType { + burnup = 'Analyzing Burnup report.', + burndown = 'Analyzing Burndown report.', + velocity = 'Analyzing Velocity report.', + cumulative = 'Analyzing Cumulative report.', + } + + presenceData.details = reportType[path.split('/').pop() as keyof typeof reportType] + || 'Analyzing Reports.' + presenceData.state = `Project: ${projectName}` + } + else if (path.includes('/issues/')) { + // Project Issues section. + const issueName = path.split('/').pop() + + if (issueName === '') { + presenceData.details = 'Tracking Issues.' + presenceData.state = `Project: ${projectName}` + } + else { + presenceData.details = `Viewing Issue ${issueName}.` + presenceData.state = `Project: ${projectName}` + } + } + else if (path.includes('/settings/')) { + // Project Settings section. + // Getting user preference for showSettingsSections. + const showSettingsSections = await presence.getSetting( + 'showSettingsSections', + ) + + // If user set showSettingsSection = True + if (showSettingsSections) { + // Settings sections with no sub-links. + if (!path.includes('/issuetypes') && !path.includes('/apps')) { + enum settingsSection { + details = 'Editing Details settings.', + access = 'Editing Access settings.', + notifications = 'Editing Notifications settings.', + features = 'Editing Features settings.', + } + + presenceData.details = settingsSection[ + path.split('/').pop() as keyof typeof settingsSection + ] + presenceData.state = `Project: ${projectName}` + } + else if (path.includes('/apps/')) { + if (path.includes('/app-fields')) { + presenceData.details = 'Editing Apps settings: App fields.' + presenceData.state = `Project: ${projectName}` + } + else { + presenceData.details = 'Editing Apps settings: Project automation.' + presenceData.state = `Project: ${projectName}` + } + } + else { + presenceData.details = `Editing Issue type: ${ + document.querySelector( + '#jira-frontend > #helpPanelContainer > div > div > div[data-testid="Content"] > div:first-child > div:first-child > div > div:nth-child(2) > div > div > div:first-child > div:nth-child(3) > div > div > div:first-child > div > form > div > div > div > h1', + )?.textContent + }.` + presenceData.state = `Project: ${projectName}` + } + } + else { + // If user set showSettingsSection = False + presenceData.details = 'Editing Settings.' + presenceData.state = `Project: ${projectName}` + } + } + else { + // Project sections with no sub-links. + enum projectSections { + roadmap = 'Viewing Roadmap.', + backlog = 'Viewing Backlog.', + code = 'Reviewing Code.', + pages = 'Viewing Pages.', + } + + presenceData.details = projectSections[ + path.split('/').pop() as keyof typeof projectSections + ] + presenceData.state = `Project: ${projectName}` + } + } + else if (path.includes('/projects/')) { + // Project Releases section, the only one with a different path. + const projectName = path.replace('/projects/', '').split('/').pop() + + presenceData.details = 'Viewing Releases.' + presenceData.state = `Project: ${projectName}` + } + else if (path === '/jira/your-work') { + // Your work section. + presenceData.details = 'Viewing personal Issues.' + } + else if (path.includes('/browse/')) { + // Browsing Issue section. + presenceData.details = `Viewing Issue ${path.split('/').pop()}` + } + else { + switch (path) { + case '/issues/': { + // Advanced Issues section. + enum issuesSection { + 'My open issues.' = -1, + 'Reported by me.' = -2, + 'Viewed recently.' = -3, + 'All issues.' = -4, + 'Open issues.' = -5, + 'Created recently.' = -6, + 'Resolved recently.' = -7, + 'Updated recently.' = -8, + 'Done issues.' = -9, + } + + presenceData.details = 'Tracking global Issues:' + presenceData.state = issuesSection[ + Number.parseInt( + document.location.search.split('=', 2).pop()?.substr(0, 2) ?? '', + ) + ] || 'Searching for an issue.' + + break + } + case '/secure/ManageFilters.jspa': { + // Filters section. + presenceData.details = 'Managing Filters.' + + break + } + case '/jira/dashboards': { + // Dashboards homepage section. + presenceData.details = 'Browsing Dashboards.' + + break + } + case '/secure/Dashboard.jspa': { + // Dashboard section. + presenceData.details = 'Viewing a Dashboard:' + presenceData.state = document.querySelector( + '#dashboard-content > div:first-child > div > div:first-child > h1', + )?.textContent + + break + } + case '/jira/people/search': { + // People homepage section. (yeah, path is correct, don't ask me why there is a "search", ~isladot) + presenceData.details = 'Browsing Users.' + + break + } + default: + if (path.match(/\/jira\/people\/[a-z0-9]+$/)) { + // User profile page section. + presenceData.details = 'Viewing a User:' + presenceData.state = document.querySelector( + '#jira-frontend > #helpPanelContainer > div > div > div[data-testid="Content"] > div:first-child > div > div > div > div > div:nth-child(2) > aside > div:first-child > div > div:nth-child(2) > h2', + )?.textContent + } + else if (path.match(/\/jira\/people\/team\/[a-z0-9-]+$/)) { + // Team profile page section. + presenceData.details = 'Viewing a Team:' + presenceData.state = document.querySelector( + '#helpPanelContainer > div > div > div[data-testid="Content"] > div:first-child > div > div > div > div:nth-child(2) > aside > div:first-child > div > div:first-child > form > div > div > div > div', + )?.textContent + } + else if (path === '/secure/ViewPersonalSettings.jspa') { + // Personal settings section. + presenceData.details = 'Editing Personal settings.' + } + } + } + } + else { + // If user is creating a new issue. + presenceData.details = 'Creating an Issue.' + } + } + + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/J/Jisho/metadata.json b/websites/J/Jisho/metadata.json index 2f68e35c63e9..bade45d00a7d 100644 --- a/websites/J/Jisho/metadata.json +++ b/websites/J/Jisho/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "SagaFreya", - "id": "316314134990028810" - }, - "service": "Jisho", - "description": { - "en": "Jisho is a powerful Japanese-English dictionary. It lets you find words, kanji, example sentences and more quickly and easily.", - "nl": "Jisho is een krachtig Japans-Engels woordenboek. Hiermee kunt u woorden, kanji, voorbeeldzinnen en sneller en gemakkelijker vinden." - }, - "url": "jisho.org", - "version": "1.0.20", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jisho/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jisho/assets/thumbnail.png", - "color": "#0bba17", - "category": "other", - "tags": [ - "japanese", - "english", - "dictionary", - "translator", - "language" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "SagaFreya", + "id": "316314134990028810" + }, + "service": "Jisho", + "description": { + "en": "Jisho is a powerful Japanese-English dictionary. It lets you find words, kanji, example sentences and more quickly and easily.", + "nl": "Jisho is een krachtig Japans-Engels woordenboek. Hiermee kunt u woorden, kanji, voorbeeldzinnen en sneller en gemakkelijker vinden." + }, + "url": "jisho.org", + "version": "1.0.20", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jisho/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jisho/assets/thumbnail.png", + "color": "#0bba17", + "category": "other", + "tags": [ + "japanese", + "english", + "dictionary", + "translator", + "language" + ] +} diff --git a/websites/J/Jisho/presence.ts b/websites/J/Jisho/presence.ts index 06b6ca13afa7..04df7711cc4b 100644 --- a/websites/J/Jisho/presence.ts +++ b/websites/J/Jisho/presence.ts @@ -1,74 +1,87 @@ const presence = new Presence({ - clientId: "715912352561627246", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '715912352561627246', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/J/Jisho/assets/logo.png", - smallImageText: "Jisho Japanese Dictionary", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/Jisho/assets/logo.png', + smallImageText: 'Jisho Japanese Dictionary', + startTimestamp: browsingTimestamp, + } - if (document.location.hostname === "jisho.org") { - if (document.location.pathname === "/") { - presenceData.details = "Viewing a page:"; - presenceData.state = "Home"; - } else if (document.location.pathname.startsWith("/search")) { - if (document.querySelector("#result_area > div.kanji > div") === null) { - presenceData.details = "Searching:"; - presenceData.state = decodeURIComponent( - document.location.pathname.substr(8) - ); - presence.info("searching"); - } else { - presenceData.details = "Viewing a kanji:"; - const kanji = document.querySelector( - "#result_area > div.kanji > div > div > div > div > h1.character" - ).textContent, - meaning = document - .querySelector( - "#result_area > div.kanji > div > div > div > div > div.kanji-details__main-meanings" - ) - .textContent.trim(); - presenceData.state = `${kanji} - ${meaning}`; - presence.info(`${kanji} - ${meaning}`); - } - } else if (document.location.pathname.startsWith("/word")) { - presenceData.details = "Viewing a word:"; - presenceData.state = decodeURIComponent( - document.location.pathname.substr(6) - ); - } else if (document.location.pathname.startsWith("/forum")) { - if (document.location.pathname.length < 8) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Forum"; - } else { - presenceData.details = "Reading a forum post:"; - presenceData.state = document.querySelector( - "#page_container > div > article.discussion_thread > div.first_comment > div.comment_body > div.discussion_title > h2" - ).textContent; - } - } else if (document.location.pathname.startsWith("/users")) { - presenceData.details = "Viewing a user:"; - presenceData.state = document.querySelector( - "#page_container > div > div.page > article > h2" - ).textContent; - } else if (document.location.pathname.startsWith("/sentences")) { - presenceData.details = "Reading a sentence:"; - presenceData.state = document.querySelector( - "#page_container > div > div.page > article.sentences > li.sentence > div.sentence_content > div.english_sentence > span.english" - ).textContent; - } else if (document.location.pathname.startsWith("/docs")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Search Options"; - } else if (document.location.pathname.startsWith("/about")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "About"; - } - } else if (document.location.hostname === "classic.jisho.org") - presenceData.details = "Jisho Classic"; + if (document.location.hostname === 'jisho.org') { + if (document.location.pathname === '/') { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Home' + } + else if (document.location.pathname.startsWith('/search')) { + if (document.querySelector('#result_area > div.kanji > div') === null) { + presenceData.details = 'Searching:' + presenceData.state = decodeURIComponent( + document.location.pathname.substr(8), + ) + presence.info('searching') + } + else { + presenceData.details = 'Viewing a kanji:' + const kanji = document.querySelector( + '#result_area > div.kanji > div > div > div > div > h1.character', + )?.textContent + const meaning = document + .querySelector( + '#result_area > div.kanji > div > div > div > div > div.kanji-details__main-meanings', + ) + ?.textContent + ?.trim() + presenceData.state = `${kanji} - ${meaning}` + presence.info(`${kanji} - ${meaning}`) + } + } + else if (document.location.pathname.startsWith('/word')) { + presenceData.details = 'Viewing a word:' + presenceData.state = decodeURIComponent( + document.location.pathname.substr(6), + ) + } + else if (document.location.pathname.startsWith('/forum')) { + if (document.location.pathname.length < 8) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Forum' + } + else { + presenceData.details = 'Reading a forum post:' + presenceData.state = document.querySelector( + '#page_container > div > article.discussion_thread > div.first_comment > div.comment_body > div.discussion_title > h2', + )?.textContent + } + } + else if (document.location.pathname.startsWith('/users')) { + presenceData.details = 'Viewing a user:' + presenceData.state = document.querySelector( + '#page_container > div > div.page > article > h2', + )?.textContent + } + else if (document.location.pathname.startsWith('/sentences')) { + presenceData.details = 'Reading a sentence:' + presenceData.state = document.querySelector( + '#page_container > div > div.page > article.sentences > li.sentence > div.sentence_content > div.english_sentence > span.english', + )?.textContent + } + else if (document.location.pathname.startsWith('/docs')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Search Options' + } + else if (document.location.pathname.startsWith('/about')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'About' + } + } + else if (document.location.hostname === 'classic.jisho.org') { + presenceData.details = 'Jisho Classic' + } - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/J/JoJo's Bizarre Encyclopedia/metadata.json b/websites/J/JoJo's Bizarre Encyclopedia/metadata.json index 6709b2d032a1..33925ae5ccab 100644 --- a/websites/J/JoJo's Bizarre Encyclopedia/metadata.json +++ b/websites/J/JoJo's Bizarre Encyclopedia/metadata.json @@ -1,34 +1,34 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Wavpro", - "id": "499951033951191040" - }, - "service": "JoJo's Bizarre Encyclopedia", - "description": { - "en": "JoJo's Bizarre Encyclopedia is a wiki dedicated to JoJo's Bizarre Adventure written and illustrated by Hirohiko Araki." - }, - "url": [ - "jojowiki.com", - "jojo-news.com" - ], - "regExp": "(jojowiki|jojo-news)[.]com[/]", - "version": "1.1.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/JoJo's%20Bizarre%20Encyclopedia/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/JoJo's%20Bizarre%20Encyclopedia/assets/thumbnail.png", - "color": "#ea0fa3", - "category": "other", - "tags": [ - "wiki", - "jojo", - "jjba" - ], - "settings": [ - { - "id": "showButtons", - "title": "Show Buttons", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Wavpro", + "id": "499951033951191040" + }, + "service": "JoJo's Bizarre Encyclopedia", + "description": { + "en": "JoJo's Bizarre Encyclopedia is a wiki dedicated to JoJo's Bizarre Adventure written and illustrated by Hirohiko Araki." + }, + "url": [ + "jojowiki.com", + "jojo-news.com" + ], + "regExp": "(jojowiki|jojo-news)[.]com[/]", + "version": "1.1.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/JoJo's%20Bizarre%20Encyclopedia/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/JoJo's%20Bizarre%20Encyclopedia/assets/thumbnail.png", + "color": "#ea0fa3", + "category": "other", + "tags": [ + "wiki", + "jojo", + "jjba" + ], + "settings": [ + { + "id": "showButtons", + "title": "Show Buttons", + "value": true + } + ] +} diff --git a/websites/J/JoJo's Bizarre Encyclopedia/presence.ts b/websites/J/JoJo's Bizarre Encyclopedia/presence.ts index 0e5b169689f0..944924633d08 100644 --- a/websites/J/JoJo's Bizarre Encyclopedia/presence.ts +++ b/websites/J/JoJo's Bizarre Encyclopedia/presence.ts @@ -1,217 +1,235 @@ const presence = new Presence({ - clientId: "1007688410875564062", -}); + clientId: '1007688410875564062', +}) -presence.on("UpdateData", async () => { - let presenceData: PresenceData = {}; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = {} - const showButtons = await presence.getSetting("showButtons"), - { hostname, pathname, origin, href, search } = document.location, - searchParams = new URLSearchParams(search); + const showButtons = await presence.getSetting('showButtons') + const { hostname, pathname, origin, href, search } = document.location + const searchParams = new URLSearchParams(search) - if (hostname === "jojowiki.com") { - presenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/JoJo's%20Bizarre%20Encyclopedia/assets/0.png", - smallImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/JoJo's%20Bizarre%20Encyclopedia/assets/1.png", - smallImageText: "jojowiki.com", - }; - presenceData.details = "Browsing JoJoWiki"; + if (hostname === 'jojowiki.com') { + presenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/JoJo\'s%20Bizarre%20Encyclopedia/assets/0.png', + smallImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/JoJo\'s%20Bizarre%20Encyclopedia/assets/1.png', + smallImageText: 'jojowiki.com', + } + presenceData.details = 'Browsing JoJoWiki' - if ( - pathname === "" || - pathname === "/" || - pathname === "/JoJo_Wiki" || - (pathname === "/index.php" && !searchParams.get("action")) - ) - presenceData.state = "Viewing homepage"; - else if (pathname.toLowerCase().includes("/index.php")) { - const search = searchParams.get("search"), - action = searchParams.get("action"); + if ( + pathname === '' + || pathname === '/' + || pathname === '/JoJo_Wiki' + || (pathname === '/index.php' && !searchParams.get('action')) + ) { + presenceData.state = 'Viewing homepage' + } + else if (pathname.toLowerCase().includes('/index.php')) { + const search = searchParams.get('search') + const action = searchParams.get('action') - let title; - if (searchParams.get("title")) - title = urlToTitle(searchParams.get("title")); - else title = "Homepage"; + let title + if (searchParams.get('title')) + title = urlToTitle(searchParams.get('title')!) + else title = 'Homepage' - if (search?.length > 0) presenceData.state = `Searching "${search}"`; - else if (action === "history") { - presenceData.state = `Viewing history: ${title}`; - presenceData.buttons = [ - { - label: "View Page", - url: `${origin}/${titleToUrl(title)}`, - }, - ]; - } else if (action === "purge") { - presenceData.state = `Purging: ${title}`; - presenceData.buttons = [ - { - label: "View Page", - url: `${origin}/${titleToUrl(title)}`, - }, - ]; - } - } else if (pathname.toLowerCase().startsWith("/user:")) { - presenceData.state = `Viewing User: ${pathname.match(/\/user:(.*)/i)[1]}`; - presenceData.buttons = [ - { - label: "View User", - url: href, - }, - ]; - } else if (pathname.toLowerCase().startsWith("/category:")) { - presenceData.state = `Viewing Category: ${urlToTitle( - pathname.match(/\/category:(.*)/i)[1] - )}`; - presenceData.buttons = [ - { - label: "View Category", - url: href, - }, - ]; - } else if (pathname.toLowerCase().startsWith("/file:")) { - presenceData.state = `Viewing File: ${pathname.match(/\/file:(.*)/i)[1]}`; - presenceData.buttons = [ - { - label: "View File", - url: href, - }, - ]; - } else if (pathname.toLowerCase().startsWith("/special:")) { - if (pathname.toLowerCase().startsWith("/special:movepage/")) { - const title = urlToTitle(pathname.substring(18)); - presenceData.state = `Moving: ${title}`; - presenceData.buttons = [ - { - label: "View Page", - url: `${origin}/${titleToUrl(title)}`, - }, - ]; - } else if (pathname.toLowerCase().startsWith("/special:notifications")) - presenceData.state = "Checking Notifications"; - else if (pathname.toLowerCase().startsWith("/special:preferences")) - presenceData.state = "Viewing Settings"; - } else if ( - pathname.toLowerCase().startsWith("/user_talk:") || - pathname.toLowerCase().startsWith("/userwiki:") || - pathname.toLowerCase().startsWith("/jojo_wiki:") - ) { - // nothing here, just used to ignore these as long as no functionality is applied to them. - } else if ( - pathname.toLowerCase().startsWith("/list_of_references_to_jojo") - ) { - presenceData.state = "Browsing JoJo References 👀"; - presenceData.buttons = [ - { - label: "Join The Fun!", - url: href, - }, - ]; - } else if (pathname.toLowerCase().startsWith("/talk:")) { - presenceData.state = `Discussing: ${document - .querySelector("#firstHeading") - .innerHTML.replace(/^Talk:/, "")}`; - presenceData.buttons = [ - { - label: "Join The Discussion!", - url: href, - }, - ]; - } else { - const title = urlToTitle(location.pathname.substring(1)); + if (search && search.length > 0) { + presenceData.state = `Searching "${search}"` + } + else if (action === 'history') { + presenceData.state = `Viewing history: ${title}` + presenceData.buttons = [ + { + label: 'View Page', + url: `${origin}/${titleToUrl(title)}`, + }, + ] + } + else if (action === 'purge') { + presenceData.state = `Purging: ${title}` + presenceData.buttons = [ + { + label: 'View Page', + url: `${origin}/${titleToUrl(title)}`, + }, + ] + } + } + else if (pathname.toLowerCase().startsWith('/user:')) { + presenceData.state = `Viewing User: ${pathname.match(/\/user:(.*)/i)?.[1]}` + presenceData.buttons = [ + { + label: 'View User', + url: href, + }, + ] + } + else if (pathname.toLowerCase().startsWith('/category:')) { + presenceData.state = `Viewing Category: ${urlToTitle( + pathname.match(/\/category:(.*)/i)?.[1] ?? '', + )}` + presenceData.buttons = [ + { + label: 'View Category', + url: href, + }, + ] + } + else if (pathname.toLowerCase().startsWith('/file:')) { + presenceData.state = `Viewing File: ${pathname.match(/\/file:(.*)/i)?.[1]}` + presenceData.buttons = [ + { + label: 'View File', + url: href, + }, + ] + } + else if (pathname.toLowerCase().startsWith('/special:')) { + if (pathname.toLowerCase().startsWith('/special:movepage/')) { + const title = urlToTitle(pathname.substring(18)) + presenceData.state = `Moving: ${title}` + presenceData.buttons = [ + { + label: 'View Page', + url: `${origin}/${titleToUrl(title)}`, + }, + ] + } + else if (pathname.toLowerCase().startsWith('/special:notifications')) { + presenceData.state = 'Checking Notifications' + } + else if (pathname.toLowerCase().startsWith('/special:preferences')) { + presenceData.state = 'Viewing Settings' + } + } + else if ( + pathname.toLowerCase().startsWith('/user_talk:') + || pathname.toLowerCase().startsWith('/userwiki:') + || pathname.toLowerCase().startsWith('/jojo_wiki:') + ) { + // nothing here, just used to ignore these as long as no functionality is applied to them. + } + else if ( + pathname.toLowerCase().startsWith('/list_of_references_to_jojo') + ) { + presenceData.state = 'Browsing JoJo References 👀' + presenceData.buttons = [ + { + label: 'Join The Fun!', + url: href, + }, + ] + } + else if (pathname.toLowerCase().startsWith('/talk:')) { + presenceData.state = `Discussing: ${document + .querySelector('#firstHeading') + ?.innerHTML + .replace(/^Talk:/, '')}` + presenceData.buttons = [ + { + label: 'Join The Discussion!', + url: href, + }, + ] + } + else { + const title = urlToTitle(location.pathname.substring(1)) - if ( - searchParams.get("veswitched")?.length || - searchParams.get("veaction") === "edit" - ) { - presenceData.state = `Editing: ${title}`; - presenceData.buttons = [ - { - label: "View Page", - url: `${origin}/${titleToUrl(title)}`, - }, - ]; - } else { - presenceData.state = `Reading: ${title}`; - presenceData.buttons = [ - { - label: "View Page", - url: href, - }, - ]; - } - } - } - if (hostname === "jojo-news.com") { - presenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/JoJo's%20Bizarre%20Encyclopedia/assets/0.png", - smallImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/JoJo's%20Bizarre%20Encyclopedia/assets/2.png", - smallImageText: "jojo-news.com", - }; - presenceData.details = "Browsing News"; + if ( + searchParams.get('veswitched')?.length + || searchParams.get('veaction') === 'edit' + ) { + presenceData.state = `Editing: ${title}` + presenceData.buttons = [ + { + label: 'View Page', + url: `${origin}/${titleToUrl(title)}`, + }, + ] + } + else { + presenceData.state = `Reading: ${title}` + presenceData.buttons = [ + { + label: 'View Page', + url: href, + }, + ] + } + } + } + if (hostname === 'jojo-news.com') { + presenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/JoJo\'s%20Bizarre%20Encyclopedia/assets/0.png', + smallImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/JoJo\'s%20Bizarre%20Encyclopedia/assets/2.png', + smallImageText: 'jojo-news.com', + } + presenceData.details = 'Browsing News' - if (pathname === "" || pathname === "/" || pathname === "/JoJo_Wiki") - presenceData.state = "Viewing: Homepage"; - else if (pathname.match(/^\/\d+\/\d+\/\d+\//)) { - presenceData.state = `Reading ${ - document.querySelectorAll(".entry-title.entry--item.h2")[0].innerHTML - }`; - presenceData.buttons = [ - { - label: "Read Article", - url: href, - }, - ]; - } else if (pathname.toLowerCase() === "/fun/jojodle/") { - presenceData.state = "Playing JoJodle!"; - presenceData.buttons = [ - { - label: "Play Along!", - url: href, - }, - ]; - } else if (pathname.toLowerCase().includes("/category")) { - let category = pathname.toLowerCase().match(/^\/category\/(.+)/)[1]; + if (pathname === '' || pathname === '/' || pathname === '/JoJo_Wiki') { + presenceData.state = 'Viewing: Homepage' + } + else if (pathname.match(/^\/\d+\/\d+\/\d+\//)) { + presenceData.state = `Reading ${ + document.querySelectorAll('.entry-title.entry--item.h2')[0].innerHTML + }` + presenceData.buttons = [ + { + label: 'Read Article', + url: href, + }, + ] + } + else if (pathname.toLowerCase() === '/fun/jojodle/') { + presenceData.state = 'Playing JoJodle!' + presenceData.buttons = [ + { + label: 'Play Along!', + url: href, + }, + ] + } + else if (pathname.toLowerCase().includes('/category')) { + let category = pathname.toLowerCase().match(/^\/category\/(.+)/)?.[1] - category = newsUrlToCategory(category); + category = newsUrlToCategory(category ?? '') - presenceData.state = `Browsing category: ${category}`; - } - } - if (!showButtons) delete presenceData.buttons; - presence.setActivity(presenceData); -}); + presenceData.state = `Browsing category: ${category}` + } + } + if (!showButtons) + delete presenceData.buttons + presence.setActivity(presenceData) +}) function titleToUrl(title: string) { - return encodeURI(title.replace(/\s/g, "_")); + return encodeURI(title.replace(/\s/g, '_')) } function urlToTitle(url: string) { - return decodeURI(url.replaceAll("_", " ")); + return decodeURI(url.replaceAll('_', ' ')) } function toTitleCase(phrase: string) { - return phrase - .toLowerCase() - .split(" ") - .map(word => word.charAt(0).toUpperCase() + word.slice(1)) - .join(" "); + return phrase + .toLowerCase() + .split(' ') + .map(word => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' ') } function newsUrlToCategory(url: string) { - url = url.replace(/(^\/|\/$)/g, ""); - const urlSplit = url.split("/"); - // Get last sub category in category list - if (urlSplit.length > 1) url = urlSplit[urlSplit.length - 1]; + url = url.replace(/(^\/|\/$)/g, '') + const urlSplit = url.split('/') + // Get last sub category in category list + if (urlSplit.length > 1) + url = urlSplit[urlSplit.length - 1] - url = url.replaceAll("-", " "); - url = toTitleCase(url); + url = url.replaceAll('-', ' ') + url = toTitleCase(url) - url = url.replace(/\bjojos\b/i, "JoJo's"); - url = url.replace(/^interview$/i, "Interviews"); - url = url.replace(/^exclusive$/i, "Exclusives"); - url = url.replace(/^analysis$/i, "Analyses"); + url = url.replace(/\bjojos\b/i, 'JoJo\'s') + url = url.replace(/^interview$/i, 'Interviews') + url = url.replace(/^exclusive$/i, 'Exclusives') + url = url.replace(/^analysis$/i, 'Analyses') - return url; + return url } diff --git a/websites/J/Joox/metadata.json b/websites/J/Joox/metadata.json index bd6cfa82e93d..efa3c23a2ad0 100644 --- a/websites/J/Joox/metadata.json +++ b/websites/J/Joox/metadata.json @@ -1,36 +1,36 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Yusaki", - "id": "439582316873121793" - }, - "service": "Joox", - "description": { - "en": "JOOX - music streaming platform that gives you an access to millions of songs. Download JOOX FREE, free music, free radio, top charts, playlists, new releases", - "th": "JOOX - music แพล็ตฟอร์มบริการฟังเพลง สตรีมเพลง ที่ให้คุณเข้าถึงเพลงนับล้าน ดาวน์โหลด JOOX ฟรี ฟังเพลงฟรี ฟังวิทยุออนไลน์ ชาร์ตเพลงล่าสุด เพลย์ลิสต์ เพลงออกใหม่", - "nl": "JOOX - muziekstreamingplatform dat u toegang geeft tot miljoenen nummers. Download JOOX GRATIS, gratis muziek, gratis radio, toplijsten, afspeellijsten, nieuwe releases" - }, - "url": "www.joox.com", - "regExp": "([a-z0-9-]+[.])*joox[.]com[/]", - "version": "1.2.15", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Joox/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Joox/assets/thumbnail.jpg", - "color": "#5abf77", - "category": "music", - "tags": [ - "joox", - "music", - "streamming", - "free", - "song" - ], - "settings": [ - { - "id": "cover", - "title": "Show Cover", - "icon": "fad fa-images", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Yusaki", + "id": "439582316873121793" + }, + "service": "Joox", + "description": { + "en": "JOOX - music streaming platform that gives you an access to millions of songs. Download JOOX FREE, free music, free radio, top charts, playlists, new releases", + "th": "JOOX - music แพล็ตฟอร์มบริการฟังเพลง สตรีมเพลง ที่ให้คุณเข้าถึงเพลงนับล้าน ดาวน์โหลด JOOX ฟรี ฟังเพลงฟรี ฟังวิทยุออนไลน์ ชาร์ตเพลงล่าสุด เพลย์ลิสต์ เพลงออกใหม่", + "nl": "JOOX - muziekstreamingplatform dat u toegang geeft tot miljoenen nummers. Download JOOX GRATIS, gratis muziek, gratis radio, toplijsten, afspeellijsten, nieuwe releases" + }, + "url": "www.joox.com", + "regExp": "([a-z0-9-]+[.])*joox[.]com[/]", + "version": "1.2.15", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Joox/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Joox/assets/thumbnail.jpg", + "color": "#5abf77", + "category": "music", + "tags": [ + "joox", + "music", + "streamming", + "free", + "song" + ], + "settings": [ + { + "id": "cover", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true + } + ] +} diff --git a/websites/J/Joox/presence.ts b/websites/J/Joox/presence.ts index 8e4ee581b6bf..77d74a508f58 100644 --- a/websites/J/Joox/presence.ts +++ b/websites/J/Joox/presence.ts @@ -1,54 +1,58 @@ const presence = new Presence({ - clientId: "715116675346989096", -}); + clientId: '715116675346989096', +}) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/J/Joox/assets/0.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Joox/assets/0.png', } -presence.on("UpdateData", async () => { - const player = Array.from(document.querySelectorAll("i")).find(x => - ["playerIcon playerIcon--play", "playerIcon playerIcon--pause"].includes( - x.className - ) - ), - cover = await presence.getSetting("cover"); +presence.on('UpdateData', async () => { + const player = Array.from(document.querySelectorAll('i')).find(x => + ['playerIcon playerIcon--play', 'playerIcon playerIcon--pause'].includes( + x.className, + ), + ) + const cover = await presence.getSetting('cover') - if (player) { - const paused = player.className.includes("pause") === false, - currentSong = Array.from(document.querySelectorAll("div")).find( - x => - x.children.length === 2 && - x.children[0].tagName === "B" && - x.children[1].tagName === "SPAN" - ), - title = currentSong.children[0].textContent, - author = currentSong.children[1].textContent, - timestamps = presence.getTimestamps( - presence.timestampFromFormat( - document.querySelector("#currentTime").textContent - ), - presence.timestampFromFormat( - document.querySelector("#currentTime").nextSibling.textContent - ) - ), - presenceData: PresenceData = { - details: title, - state: author, - largeImageKey: cover - ? document.querySelector(`img[alt="${title}"]`).src - : Assets.Logo, - smallImageKey: paused ? Assets.Pause : Assets.Play, - smallImageText: paused ? "Paused" : "Playing", - startTimestamp: timestamps[0], - endTimestamp: timestamps[1], - }; + if (player) { + const paused = player.className.includes('pause') === false + const currentSong = Array.from(document.querySelectorAll('div')).find( + x => + x.children.length === 2 + && x.children[0].tagName === 'B' + && x.children[1].tagName === 'SPAN', + )! + const title = currentSong.children[0].textContent + const author = currentSong.children[1].textContent + const timestamps = presence.getTimestamps( + presence.timestampFromFormat( + document.querySelector('#currentTime')?.textContent ?? '', + ), + presence.timestampFromFormat( + document.querySelector('#currentTime')?.nextSibling?.textContent ?? '', + ), + ) + const presenceData: PresenceData = { + details: title, + state: author, + largeImageKey: cover + ? document.querySelector(`img[alt="${title}"]`)?.src + : Assets.Logo, + smallImageKey: paused ? Assets.Pause : Assets.Play, + smallImageText: paused ? 'Paused' : 'Playing', + startTimestamp: timestamps[0], + endTimestamp: timestamps[1], + } - if (paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } + if (paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } - if (title && author) presence.setActivity(presenceData, !paused); - } else presence.clearActivity(); -}); + if (title && author) + presence.setActivity(presenceData, !paused) + } + else { + presence.clearActivity() + } +}) diff --git a/websites/J/Joyn/metadata.json b/websites/J/Joyn/metadata.json index ff071e02140b..bb222fdd0ec8 100644 --- a/websites/J/Joyn/metadata.json +++ b/websites/J/Joyn/metadata.json @@ -1,45 +1,45 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "N0chteil ^^", - "id": "495901098926669825" - }, - "service": "Joyn", - "description": { - "en": "Joyn GmbH is a German joint venture of the media groups ProSiebenSat.1 Media and Discovery, which deals with streaming media products.", - "de": "Die Joyn GmbH ist ein deutsches Gemeinschaftsunternehmen der Medienkonzerne ProSiebenSat.1 Media und Discovery, das sich mit Streaming-Media-Produkten beschäftigt.", - "nl": "Joyn GmbH is een Duitse joint venture van de mediagroepen ProSiebenSat.1 Media en Discovery, die zich bezighoudt met streaming mediaproducten." - }, - "url": [ - "www.joyn.de", - "joyn.de" - ], - "version": "1.2.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Joyn/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Joyn/assets/thumbnail.png", - "color": "#000", - "category": "videos", - "tags": [ - "streaming", - "joyn" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "timeRemaining", - "title": "Show remaining time", - "icon": "fad fa-hourglass-half", - "value": true - }, - { - "id": "showButtons", - "title": "Show Buttons", - "icon": "fad fa-mouse-pointer", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "N0chteil ^^", + "id": "495901098926669825" + }, + "service": "Joyn", + "description": { + "en": "Joyn GmbH is a German joint venture of the media groups ProSiebenSat.1 Media and Discovery, which deals with streaming media products.", + "de": "Die Joyn GmbH ist ein deutsches Gemeinschaftsunternehmen der Medienkonzerne ProSiebenSat.1 Media und Discovery, das sich mit Streaming-Media-Produkten beschäftigt.", + "nl": "Joyn GmbH is een Duitse joint venture van de mediagroepen ProSiebenSat.1 Media en Discovery, die zich bezighoudt met streaming mediaproducten." + }, + "url": [ + "www.joyn.de", + "joyn.de" + ], + "version": "1.2.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Joyn/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Joyn/assets/thumbnail.png", + "color": "#000", + "category": "videos", + "tags": [ + "streaming", + "joyn" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "timeRemaining", + "title": "Show remaining time", + "icon": "fad fa-hourglass-half", + "value": true + }, + { + "id": "showButtons", + "title": "Show Buttons", + "icon": "fad fa-mouse-pointer", + "value": true + } + ] +} diff --git a/websites/J/Joyn/presence.ts b/websites/J/Joyn/presence.ts index b51bcbf4b286..717a9dfe2d7f 100644 --- a/websites/J/Joyn/presence.ts +++ b/websites/J/Joyn/presence.ts @@ -1,312 +1,327 @@ const presence = new Presence({ - clientId: "799629862620758046", -}); + 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("lang").catch(() => "en") - ); + 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('lang').catch(() => 'en'), + ) } -let strings: Awaited>, - oldLang: string = null; +let strings: Awaited> +let oldLang: string | null = 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("lang").catch(() => "en"), - setting = { - timeRemaining: await presence.getSetting("timeRemaining"), - showButtons: await presence.getSetting("showButtons"), - }, - urlpath = window.location.pathname.split("/"), - video: HTMLVideoElement = document.querySelector("div video"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/Joyn/assets/logo.jpg', + } + const newLang = await presence.getSetting('lang').catch(() => 'en') + const setting = { + timeRemaining: await presence.getSetting('timeRemaining'), + showButtons: await presence.getSetting('showButtons'), + } + const urlpath = window.location.pathname.split('/') + const video = document.querySelector('div video') - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + 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(".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 ( + 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('.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]}`, - }, - ]; - } + 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; + 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]}`, - }, - ]; - } + 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; + 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]}`, - }, - ]; - } + 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; - } + 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 && !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 && !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: 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 && !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 show', + url: window.location.href, + }, + ] + } + } + else if (urlpath[1] === 'play' && urlpath[2] === 'compilation') { + presenceData.details = document.title.replace('| Joyn', '') + presenceData.state = 'Compilation' + if (video && !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 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 && !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"; + 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 '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 '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(); -}); + 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' + break + } + } + } + } + } + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/J/Jstris/metadata.json b/websites/J/Jstris/metadata.json index 1e7e80404e64..2cf60803aa0b 100644 --- a/websites/J/Jstris/metadata.json +++ b/websites/J/Jstris/metadata.json @@ -1,22 +1,22 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "ayanamy.jy126", - "id": "243279723487035393" - }, - "service": "Jstris", - "description": { - "en": "Jstris is just standard competitive multiplayer Tetris, but made with JS. NOTICE: To activate the 'Join' button to allow others to join your game through Discord, type in `/link` into the Jstris lobby's chat.", - "nl": "Jstris is gewoon een standaard competitieve multiplayer Tetris, maar dan gemaakt met JS. LET OP: Om de 'Join'-knop te activeren zodat anderen via Discord aan je spel kunnen deelnemen, typ je' / link 'in de chat van de Jstris-lobby." - }, - "url": "jstris.jezevec10.com", - "version": "1.1.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jstris/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jstris/assets/thumbnail.png", - "color": "#375a7f", - "category": "games", - "tags": [ - "puzzle" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "ayanamy.jy126", + "id": "243279723487035393" + }, + "service": "Jstris", + "description": { + "en": "Jstris is just standard competitive multiplayer Tetris, but made with JS. NOTICE: To activate the 'Join' button to allow others to join your game through Discord, type in `/link` into the Jstris lobby's chat.", + "nl": "Jstris is gewoon een standaard competitieve multiplayer Tetris, maar dan gemaakt met JS. LET OP: Om de 'Join'-knop te activeren zodat anderen via Discord aan je spel kunnen deelnemen, typ je' / link 'in de chat van de Jstris-lobby." + }, + "url": "jstris.jezevec10.com", + "version": "1.1.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jstris/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jstris/assets/thumbnail.png", + "color": "#375a7f", + "category": "games", + "tags": [ + "puzzle" + ] +} diff --git a/websites/J/Jstris/presence.ts b/websites/J/Jstris/presence.ts index 1339dd76b975..794968710f62 100644 --- a/websites/J/Jstris/presence.ts +++ b/websites/J/Jstris/presence.ts @@ -1,173 +1,178 @@ const presence = new Presence({ - clientId: "754149249335296010", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '754149249335296010', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/Jstris/assets/logo.png", - }, - pathname = document.location.pathname.split("/").splice(1), - queryString = document.location.search.substring(1); - presenceData.startTimestamp = browsingTimestamp; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/Jstris/assets/logo.png', + } + const pathname = document.location.pathname.split('/').splice(1) + const queryString = document.location.search.substring(1) + presenceData.startTimestamp = browsingTimestamp - //Sets BaseUrl - const BaseUrl = "https://jstris.jezevec10.com", - //Inits temporary button array that is to be applied to presenceData later. - tempButtons = new Array(0), - //Sets button for joining. - joinLinkArr = document.querySelectorAll(".joinLink"), - //Sets username - username = getUsername(); + // Sets BaseUrl + const BaseUrl = 'https://jstris.jezevec10.com' + // Inits temporary button array that is to be applied to presenceData later. + const tempButtons = Array.from({ length: 0 }) + // Sets button for joining. + const joinLinkArr = document.querySelectorAll('.joinLink') + // Sets username + const username = getUsername() - if (joinLinkArr.length !== 0) { - tempButtons.push({ - label: "Join", - url: joinLinkArr[joinLinkArr.length - 1].textContent, - }); - } - //Sets button for viewing profile. + if (joinLinkArr.length !== 0) { + tempButtons.push({ + label: 'Join', + url: joinLinkArr[joinLinkArr.length - 1].textContent, + }) + } + // Sets button for viewing profile. - if (typeof username !== "undefined") { - tempButtons.push({ - label: "View Profile", - url: `${BaseUrl}/u/${username}`, - }); - } + if (typeof username !== 'undefined') { + tempButtons.push({ + label: 'View Profile', + url: `${BaseUrl}/u/${username}`, + }) + } - switch (pathname[0]) { - //Play Modes - case "": - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Ingame..."; - if (queryString) { - const queryObj = parseQuery(queryString); - switch (queryObj.play) { - case "1": - presenceData.details = "Sprint"; - if (queryObj.rule) presenceData.state = "Special Ruleset"; - else presenceData.state = sprintLineMode(queryObj.mode); + switch (pathname[0]) { + // Play Modes + case '': + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Ingame...' + if (queryString) { + const queryObj = parseQuery(queryString) + switch (queryObj.play) { + case '1': + presenceData.details = 'Sprint' + if (queryObj.rule) + presenceData.state = 'Special Ruleset' + else presenceData.state = sprintLineMode(queryObj.mode) - break; - case "2": - presenceData.details = "Practice"; - break; - case "3": - presenceData.details = "Cheese Race"; - break; - case "4": - presenceData.details = "Survival"; - break; - case "5": - presenceData.details = "Ultra"; - break; - case "6": - presenceData.details = "Playing Custom Map"; - presenceData.state = `Map ID: ${queryObj.map}`; - if (tempButtons.length !== 2) { - tempButtons.unshift({ - label: "Play Map", - url: `${BaseUrl}/?play=6&map=${queryObj.map}`, - }); - } - break; - case "7": - presenceData.details = "20TSD"; - break; - case "8": - presenceData.details = "PC Mode"; - break; - } - } else presenceData.details = "Live"; + break + case '2': + presenceData.details = 'Practice' + break + case '3': + presenceData.details = 'Cheese Race' + break + case '4': + presenceData.details = 'Survival' + break + case '5': + presenceData.details = 'Ultra' + break + case '6': + presenceData.details = 'Playing Custom Map' + presenceData.state = `Map ID: ${queryObj.map}` + if (tempButtons.length !== 2) { + tempButtons.unshift({ + label: 'Play Map', + url: `${BaseUrl}/?play=6&map=${queryObj.map}`, + }) + } + break + case '7': + presenceData.details = '20TSD' + break + case '8': + presenceData.details = 'PC Mode' + break + } + } + else { + presenceData.details = 'Live' + } - break; - //Leaderboards - case "sprint": - presenceData.details = leaderboardText("Sprint"); - break; - case "cheese": - presenceData.details = leaderboardText("Cheese Race"); - break; - case "survival": - presenceData.details = leaderboardText("Survival"); - break; - case "ultra": - presenceData.details = leaderboardText("Ultra"); - break; - case "20TSD": - presenceData.details = leaderboardText("20TSD"); - break; - case "PC-mode": - presenceData.details = leaderboardText("PC Mode"); - break; - //Maps - case "maps": - presenceData.details = "Browsing Maps"; - break; - case "map": - presenceData.details = `Viewing Map: ${ - document.querySelector("h1").textContent - }`; - presenceData.state = `Map ID: ${pathname[1]}`; - break; - //User - case "u": - presenceData.details = `Viewing User: ${pathname[1]}`; - presenceData.state = - document.querySelector(".col-md-8").textContent; - break; - default: - //Idle - presenceData.details = "Idling"; - break; - } + break + // Leaderboards + case 'sprint': + presenceData.details = leaderboardText('Sprint') + break + case 'cheese': + presenceData.details = leaderboardText('Cheese Race') + break + case 'survival': + presenceData.details = leaderboardText('Survival') + break + case 'ultra': + presenceData.details = leaderboardText('Ultra') + break + case '20TSD': + presenceData.details = leaderboardText('20TSD') + break + case 'PC-mode': + presenceData.details = leaderboardText('PC Mode') + break + // Maps + case 'maps': + presenceData.details = 'Browsing Maps' + break + case 'map': + presenceData.details = `Viewing Map: ${ + document.querySelector('h1')?.textContent + }` + presenceData.state = `Map ID: ${pathname[1]}` + break + // User + case 'u': + presenceData.details = `Viewing User: ${pathname[1]}` + presenceData.state = document.querySelector('.col-md-8')?.textContent + break + default: + // Idle + presenceData.details = 'Idling' + break + } - //Sets the buttons: - if (tempButtons.length !== 0 && tempButtons.length <= 2) - presenceData.buttons = tempButtons as [ButtonData, ButtonData?]; + // Sets the buttons: + if (tempButtons.length !== 0 && tempButtons.length <= 2) + presenceData.buttons = tempButtons as [ButtonData, ButtonData?] - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) function getUsername() { - try { - return document - .querySelectorAll(".navbar-right")[0] - .querySelectorAll(".dropdown-toggle")[1] - .textContent.replace(/\n/g, ""); - } catch (err) { - return; - } + try { + return document + .querySelectorAll('.navbar-right')[0] + ?.querySelectorAll('.dropdown-toggle')[1] + ?.textContent + ?.replace(/\n/g, '') + } + catch { + + } } function parseQuery(search: string) { - return JSON.parse( - `{"${search.replaceAll("&", '","').replaceAll("=", '":"')}"}`, - function (key, value) { - return key === "" ? value : decodeURIComponent(value); - } - ); + return JSON.parse( + `{"${search.replaceAll('&', '","').replaceAll('=', '":"')}"}`, + (key, value) => { + return key === '' ? value : decodeURIComponent(value) + }, + ) } function leaderboardText(innerText: string) { - return `Browsing ${innerText} Leaderboards`; + return `Browsing ${innerText} Leaderboards` } function sprintLineMode(mode: string) { - switch (mode) { - case "1": - return "40 Lines"; - break; - case "2": - return "20 Lines"; - break; - case "3": - return "100 Lines"; - break; - case "4": - return "1000 Lines"; - break; - } + switch (mode) { + case '1': + return '40 Lines' + break + case '2': + return '20 Lines' + break + case '3': + return '100 Lines' + break + case '4': + return '1000 Lines' + break + } } diff --git a/websites/J/Jummbox/metadata.json b/websites/J/Jummbox/metadata.json index 997a05bdba7e..9bc80e74df9d 100644 --- a/websites/J/Jummbox/metadata.json +++ b/websites/J/Jummbox/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "HiddenRealm", - "id": "444628005646499851" - }, - "service": "Jummbox", - "description": { - "en": "Allows users to see music creation info and time used", - "nl": "Hiermee kunnen gebruikers informatie over het maken van muziek en de gebruikte tijd zien" - }, - "url": "jummb.us", - "version": "1.1.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jummbox/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jummbox/assets/thumbnail.png", - "color": "#7744FF", - "category": "music", - "tags": [ - "music", - "music-creation", - "beepbox", - "jummbox", - "chiptune" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "HiddenRealm", + "id": "444628005646499851" + }, + "service": "Jummbox", + "description": { + "en": "Allows users to see music creation info and time used", + "nl": "Hiermee kunnen gebruikers informatie over het maken van muziek en de gebruikte tijd zien" + }, + "url": "jummb.us", + "version": "1.1.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Jummbox/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Jummbox/assets/thumbnail.png", + "color": "#7744FF", + "category": "music", + "tags": [ + "music", + "music-creation", + "beepbox", + "jummbox", + "chiptune" + ] +} diff --git a/websites/J/Jummbox/presence.ts b/websites/J/Jummbox/presence.ts index 19421f063b49..cafe50edb469 100644 --- a/websites/J/Jummbox/presence.ts +++ b/websites/J/Jummbox/presence.ts @@ -1,15 +1,15 @@ const presence = new Presence({ - clientId: "637737627151368202", -}); + clientId: '637737627151368202', +}) -presence.on("UpdateData", async () => { - const presenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/Jummbox/assets/logo.png", - details: "Using Jummbox", - state: "Making a Beep", - }; +presence.on('UpdateData', async () => { + const presenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/Jummbox/assets/logo.png', + details: 'Using Jummbox', + state: 'Making a Beep', + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/J/Juniperbot/metadata.json b/websites/J/Juniperbot/metadata.json index e6d4f16673c2..f311a09e2119 100644 --- a/websites/J/Juniperbot/metadata.json +++ b/websites/J/Juniperbot/metadata.json @@ -1,36 +1,36 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "MrLivixx", - "id": "502948927809781763" - }, - "service": "Juniperbot", - "description": { - "ru": "Многофункциональный, полностью настраиваемый бот для платформы Discord, с панелью управления.", - "en": "Fluffy Discord Bot (Music, Ranking, Reminder, Vk Community bridge, WikiFur)", - "nl": "Fluffy Discord Bot (Muziek, Ranking, Herinnering, Vk Community-brug, WikiFur)" - }, - "url": [ - "docs.juniper.bot", - "feedback.juniper.bot", - "juniper.bot" - ], - "version": "2.0.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/thumbnail.png", - "color": "#C27C0E", - "category": "other", - "tags": [ - "bot", - "discord", - "juniper", - "juniperbot" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "MrLivixx", + "id": "502948927809781763" + }, + "service": "Juniperbot", + "description": { + "ru": "Многофункциональный, полностью настраиваемый бот для платформы Discord, с панелью управления.", + "en": "Fluffy Discord Bot (Music, Ranking, Reminder, Vk Community bridge, WikiFur)", + "nl": "Fluffy Discord Bot (Muziek, Ranking, Herinnering, Vk Community-brug, WikiFur)" + }, + "url": [ + "docs.juniper.bot", + "feedback.juniper.bot", + "juniper.bot" + ], + "version": "2.0.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/thumbnail.png", + "color": "#C27C0E", + "category": "other", + "tags": [ + "bot", + "discord", + "juniper", + "juniperbot" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + } + ] +} diff --git a/websites/J/Juniperbot/presence.ts b/websites/J/Juniperbot/presence.ts index ebd619ee33a8..8c6cb5c95319 100644 --- a/websites/J/Juniperbot/presence.ts +++ b/websites/J/Juniperbot/presence.ts @@ -1,135 +1,136 @@ -const presence = new Presence({ clientId: "739908991274057870" }), - browsingTimestamp = Math.floor(Date.now() / 1000); +const presence = new Presence({ clientId: '739908991274057870' }) +const browsingTimestamp = Math.floor(Date.now() / 1000) function pathIncludes(string: string): boolean { - return document.location.pathname.toLowerCase().includes(string); + return document.location.pathname.toLowerCase().includes(string) } -const host = document.location.hostname; +const host = document.location.hostname async function getStrings() { - return presence.getStrings( - { - reading: "general.readingAbout", - leaderboard: "juniperbot.leaderboard", - viewMainPage: "juniperbot.mainpage", - serverdash: "juniperbot.serverdash", - serverdashname: "juniperbot.serverdashname", - donate: "juniperbot.donate", - servers: "juniperbot.servers", - commands: "juniperbot.commands", - stats: "juniperbot.stats", - usercard: "juniperbot.usercard", - terms: "general.terms", - privacy: "general.privacy", - cookies: "juniperbot.cookies", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + reading: 'general.readingAbout', + leaderboard: 'juniperbot.leaderboard', + viewMainPage: 'juniperbot.mainpage', + serverdash: 'juniperbot.serverdash', + serverdashname: 'juniperbot.serverdashname', + donate: 'juniperbot.donate', + servers: 'juniperbot.servers', + commands: 'juniperbot.commands', + stats: 'juniperbot.stats', + usercard: 'juniperbot.usercard', + terms: 'general.terms', + privacy: 'general.privacy', + cookies: 'juniperbot.cookies', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } -let strings: Awaited>, - oldLang: string = null; +let strings: Awaited> +let oldLang: string | null = null const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/logo.png", - Stats = "https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/0.png", - Donate = "https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/1.png", - List = "https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/2.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/logo.png', + Stats = 'https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/0.png', + Donate = 'https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/1.png', + List = 'https://cdn.rcd.gg/PreMiD/websites/J/Juniperbot/assets/2.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { largeImageKey: Assets.Logo }, - newLang = await presence.getSetting("lang").catch(() => "en"); - - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } - - if (host === "juniper.bot") { - presenceData.startTimestamp = browsingTimestamp; - - switch (true) { - case pathIncludes("/ranking/"): - presenceData.details = strings.leaderboard; - presenceData.state = document.querySelector( - ".guild--info h1.font-weight-thin.display-2" - ).textContent; - presenceData.smallImageKey = Assets.List; - break; - case pathIncludes("/dashboard/"): - presenceData.details = strings.serverdash; - presenceData.state = strings.serverdashname.replace( - "{0}", - document.querySelector(".guild--info h1.font-weight-thin.display-2") - .textContent - ); - break; - - case pathIncludes("/donate"): - presenceData.details = strings.donate; - presenceData.smallImageKey = Assets.Donate; - break; - - case pathIncludes("/servers"): - presenceData.details = strings.servers; - presenceData.smallImageKey = Assets.List; - break; - - case pathIncludes("/commands"): - presenceData.details = strings.commands; - presenceData.smallImageKey = Assets.List; - break; - - case pathIncludes("/status"): - presenceData.details = strings.stats; - presenceData.smallImageKey = Assets.Stats; - break; - - case pathIncludes("/user/card"): - presenceData.details = strings.usercard; - break; - - case pathIncludes("/terms"): - presenceData.details = `${strings.reading} ${strings.terms}`; - presenceData.smallImageKey = Assets.List; - break; - - case pathIncludes("/cookie"): - presenceData.details = `${strings.reading} ${strings.cookies}`; - presenceData.smallImageKey = Assets.List; - break; - - case pathIncludes("/privacy"): - presenceData.details = `${strings.reading} ${strings.privacy}`; - presenceData.smallImageKey = Assets.List; - break; - - default: - presenceData.details = "Main page"; - break; - } - } - if (host === "docs.juniper.bot") { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = document.title; - presenceData.state = "docs.juniper.bot"; - presenceData.smallImageKey = Assets.List; - } - if (host === "feedback.juniper.bot") { - presenceData.startTimestamp = browsingTimestamp; - presenceData.state = "feedback.juniper.bot"; - switch (true) { - case pathIncludes("/posts/"): - presenceData.details = `${strings.reading} ${ - document.querySelector(".post-header h1").textContent - }`; - break; - default: - presenceData.details = strings.viewMainPage; - break; - } - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { largeImageKey: Assets.Logo } + const newLang = await presence.getSetting('lang').catch(() => 'en') + + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } + + if (host === 'juniper.bot') { + presenceData.startTimestamp = browsingTimestamp + + switch (true) { + case pathIncludes('/ranking/'): + presenceData.details = strings.leaderboard + presenceData.state = document.querySelector( + '.guild--info h1.font-weight-thin.display-2', + )?.textContent + presenceData.smallImageKey = Assets.List + break + case pathIncludes('/dashboard/'): + presenceData.details = strings.serverdash + presenceData.state = strings.serverdashname.replace( + '{0}', + document.querySelector('.guild--info h1.font-weight-thin.display-2') + ?.textContent ?? '', + ) + break + + case pathIncludes('/donate'): + presenceData.details = strings.donate + presenceData.smallImageKey = Assets.Donate + break + + case pathIncludes('/servers'): + presenceData.details = strings.servers + presenceData.smallImageKey = Assets.List + break + + case pathIncludes('/commands'): + presenceData.details = strings.commands + presenceData.smallImageKey = Assets.List + break + + case pathIncludes('/status'): + presenceData.details = strings.stats + presenceData.smallImageKey = Assets.Stats + break + + case pathIncludes('/user/card'): + presenceData.details = strings.usercard + break + + case pathIncludes('/terms'): + presenceData.details = `${strings.reading} ${strings.terms}` + presenceData.smallImageKey = Assets.List + break + + case pathIncludes('/cookie'): + presenceData.details = `${strings.reading} ${strings.cookies}` + presenceData.smallImageKey = Assets.List + break + + case pathIncludes('/privacy'): + presenceData.details = `${strings.reading} ${strings.privacy}` + presenceData.smallImageKey = Assets.List + break + + default: + presenceData.details = 'Main page' + break + } + } + if (host === 'docs.juniper.bot') { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = document.title + presenceData.state = 'docs.juniper.bot' + presenceData.smallImageKey = Assets.List + } + if (host === 'feedback.juniper.bot') { + presenceData.startTimestamp = browsingTimestamp + presenceData.state = 'feedback.juniper.bot' + switch (true) { + case pathIncludes('/posts/'): + presenceData.details = `${strings.reading} ${ + document.querySelector('.post-header h1')?.textContent + }` + break + default: + presenceData.details = strings.viewMainPage + break + } + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/J/Just Dance Now/metadata.json b/websites/J/Just Dance Now/metadata.json index a64edfeae1b2..2c1b1dde47e6 100644 --- a/websites/J/Just Dance Now/metadata.json +++ b/websites/J/Just Dance Now/metadata.json @@ -1,46 +1,46 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "joerkig", - "id": "205984221859151873" - }, - "service": "Just Dance Now", - "description": { - "en": "UNLEASH YOUR INNER DANCER! · Experience Just Dance's greatest dance routines without a console." - }, - "url": "justdancenow.com", - "version": "1.1.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Just%20Dance%20Now/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Just%20Dance%20Now/assets/thumbnail.png", - "color": "#558e9c", - "category": "games", - "tags": [ - "justdance", - "dance", - "gaming", - "dancing", - "music", - "multiplayer" - ], - "settings": [ - { - "id": "time", - "title": "Show Elapsed", - "icon": "fas fa-stopwatch", - "value": true - }, - { - "id": "cover", - "title": "Show Cover", - "icon": "fad fa-images", - "value": true - }, - { - "id": "roomCode", - "title": "Show Room Code", - "icon": "fas fa-comment-smile", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "joerkig", + "id": "205984221859151873" + }, + "service": "Just Dance Now", + "description": { + "en": "UNLEASH YOUR INNER DANCER! · Experience Just Dance's greatest dance routines without a console." + }, + "url": "justdancenow.com", + "version": "1.1.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Just%20Dance%20Now/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Just%20Dance%20Now/assets/thumbnail.png", + "color": "#558e9c", + "category": "games", + "tags": [ + "justdance", + "dance", + "gaming", + "dancing", + "music", + "multiplayer" + ], + "settings": [ + { + "id": "time", + "title": "Show Elapsed", + "icon": "fas fa-stopwatch", + "value": true + }, + { + "id": "cover", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true + }, + { + "id": "roomCode", + "title": "Show Room Code", + "icon": "fas fa-comment-smile", + "value": false + } + ] +} diff --git a/websites/J/Just Dance Now/presence.ts b/websites/J/Just Dance Now/presence.ts index 86344b800d66..5d2f3ae8a5dd 100644 --- a/websites/J/Just Dance Now/presence.ts +++ b/websites/J/Just Dance Now/presence.ts @@ -1,146 +1,157 @@ const presence = new Presence({ - clientId: "928372793438011433", - }), - browsingStamp = Math.floor(Date.now() / 1000); + clientId: '928372793438011433', +}) +const browsingStamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/J/Just%20Dance%20Now/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/J/Just%20Dance%20Now/assets/logo.png', } -presence.on("UpdateData", async () => { - const [time, cover, roomCode] = await Promise.all([ - presence.getSetting("time"), - presence.getSetting("cover"), - presence.getSetting("roomCode"), - ]), - presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingStamp, - }, - coverURL = document.querySelector( - `#section-${document - .querySelector(".selected") - ?.getAttribute("section-id")} .item-selected .song__cover` - )?.src, - songTitle = document.querySelector( - `#section-${document - .querySelector(".selected") - ?.getAttribute("section-id")} .item-selected .title` - )?.textContent, - roomCodeString = document.querySelector(".danceroom__number")?.textContent; +presence.on('UpdateData', async () => { + const [time, cover, roomCode] = await Promise.all([ + presence.getSetting('time'), + presence.getSetting('cover'), + presence.getSetting('roomCode'), + ]) + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingStamp, + } + const coverURL = document.querySelector( + `#section-${document + .querySelector('.selected') + ?.getAttribute('section-id')} .item-selected .song__cover`, + )?.src + const songTitle = document.querySelector( + `#section-${document + .querySelector('.selected') + ?.getAttribute('section-id')} .item-selected .title`, + )?.textContent + const roomCodeString = document.querySelector('.danceroom__number')?.textContent - if (document.querySelector("html").className.includes("vip")) { - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/J/Just%20Dance%20Now/assets/0.png"; - presenceData.smallImageText = "VIP"; - } - if (!document.querySelector("html").className.includes("state-")) - presenceData.details = "Viewing Homepage"; - else { - switch ( - document.querySelector("html")?.className?.match(/state-([a-z]{0,15})/)[1] - ) { - case "afterdance": { - presenceData.details = "Scores"; - presenceData.state = songTitle; - if (cover) presenceData.largeImageKey = coverURL; + if (document.querySelector('html')?.className.includes('vip')) { + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/J/Just%20Dance%20Now/assets/0.png' + presenceData.smallImageText = 'VIP' + } + if (!document.querySelector('html')?.className.includes('state-')) { + presenceData.details = 'Viewing Homepage' + } + else { + switch ( + document.querySelector('html')?.className?.match(/state-([a-z]{0,15})/)?.[1] + ) { + case 'afterdance': { + presenceData.details = 'Scores' + presenceData.state = songTitle + if (cover) + presenceData.largeImageKey = coverURL - if (roomCode) presenceData.details = `Scores (${roomCodeString})`; - break; - } - case "tutorial": { - presenceData.details = "Tutorial"; - presenceData.state = songTitle; - if (cover) presenceData.largeImageKey = coverURL; + if (roomCode) + presenceData.details = `Scores (${roomCodeString})` + break + } + case 'tutorial': { + presenceData.details = 'Tutorial' + presenceData.state = songTitle + if (cover) + presenceData.largeImageKey = coverURL - if (roomCode) presenceData.details = `Tutorial (${roomCodeString})`; - break; - } - case "dance": { - presenceData.details = "Playing"; - presenceData.state = songTitle; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia( - document.querySelector("#in-game_video") - ); - if (cover) presenceData.largeImageKey = coverURL; + if (roomCode) + presenceData.details = `Tutorial (${roomCodeString})` + break + } + case 'dance': { + presenceData.details = 'Playing' + presenceData.state = songTitle; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia( + document.querySelector('#in-game_video')!, + ) + if (cover) + presenceData.largeImageKey = coverURL - if (roomCode) presenceData.details = `Playing (${roomCodeString})`; - break; - } - case "coachselection": { - presenceData.details = "Coach Selection"; - presenceData.state = `${ - document.querySelector(".coach-selection__details-song").textContent - }`; - if (roomCode) - presenceData.details = `Coach Selection (${roomCodeString})`; + if (roomCode) + presenceData.details = `Playing (${roomCodeString})` + break + } + case 'coachselection': { + presenceData.details = 'Coach Selection' + presenceData.state = `${ + document.querySelector('.coach-selection__details-song')?.textContent + }` + if (roomCode) + presenceData.details = `Coach Selection (${roomCodeString})` - if (cover) presenceData.largeImageKey = coverURL; - break; - } - case "songselection": { - if ( - document - .querySelector(".selected") - .getAttribute("section-id") === "playlist" - ) { - presenceData.details = `Browsing ${ - document.querySelector(".selected > .tabs--text").textContent - }`; - presenceData.state = songTitle; - if (cover) { - presenceData.largeImageKey = - document.querySelector( - ".playlist--banner__selected > img" - )?.src ?? Assets.Logo; - } - if (roomCode) { - presenceData.details = `Browsing ${ - document.querySelector(".selected > .tabs--text").textContent - } (${roomCodeString})`; - } - if (document.querySelector("#section-playlist .item-selected")) { - presenceData.state = document.querySelector( - "#section-playlist .item-selected .title" - ).textContent; - if (cover) presenceData.largeImageKey = coverURL; - } - } else if ( - document - .querySelector(".selected") - .getAttribute("section-id") === "songlist" - ) { - presenceData.details = `Browsing ${ - document.querySelector(".selected > .tabs--text").textContent - }`; - if (document.querySelector("#section-songlist .item-selected")) { - presenceData.state = document.querySelector( - "#section-songlist .item-selected .title" - ).textContent; - if (cover) presenceData.largeImageKey = coverURL; - } - if (roomCode) { - presenceData.details = `Browsing ${ - document.querySelector(".selected > .tabs--text").textContent - } (${roomCodeString})`; - } - } else if ( - document - .querySelector(".selected") - .getAttribute("section-id") === "leaderboard" - ) { - presenceData.details = "Viewing leaderboard"; - presenceData.state = document.querySelector( - "#leaderboard-tabs .selected" - ).textContent; - } - break; - } - } - } + if (cover) + presenceData.largeImageKey = coverURL + break + } + case 'songselection': { + if ( + document + .querySelector('.selected') + ?.getAttribute('section-id') === 'playlist' + ) { + presenceData.details = `Browsing ${ + document.querySelector('.selected > .tabs--text')?.textContent + }` + presenceData.state = songTitle + if (cover) { + presenceData.largeImageKey = document.querySelector( + '.playlist--banner__selected > img', + )?.src ?? Assets.Logo + } + if (roomCode) { + presenceData.details = `Browsing ${ + document.querySelector('.selected > .tabs--text')?.textContent + } (${roomCodeString})` + } + if (document.querySelector('#section-playlist .item-selected')) { + presenceData.state = document.querySelector( + '#section-playlist .item-selected .title', + )?.textContent + if (cover) + presenceData.largeImageKey = coverURL + } + } + else if ( + document + .querySelector('.selected') + ?.getAttribute('section-id') === 'songlist' + ) { + presenceData.details = `Browsing ${ + document.querySelector('.selected > .tabs--text')?.textContent + }` + if (document.querySelector('#section-songlist .item-selected')) { + presenceData.state = document.querySelector( + '#section-songlist .item-selected .title', + )?.textContent + if (cover) + presenceData.largeImageKey = coverURL + } + if (roomCode) { + presenceData.details = `Browsing ${ + document.querySelector('.selected > .tabs--text')?.textContent + } (${roomCodeString})` + } + } + else if ( + document + .querySelector('.selected') + ?.getAttribute('section-id') === 'leaderboard' + ) { + presenceData.details = 'Viewing leaderboard' + presenceData.state = document.querySelector( + '#leaderboard-tabs .selected', + )?.textContent + } + break + } + } + } - if (!time) delete presenceData.startTimestamp; + if (!time) + delete presenceData.startTimestamp - if (presenceData.details) presence.setActivity(presenceData); -}); + if (presenceData.details) + presence.setActivity(presenceData) +}) diff --git a/websites/J/Just Light Novels/metadata.json b/websites/J/Just Light Novels/metadata.json index 060f79ab6767..022302268f26 100644 --- a/websites/J/Just Light Novels/metadata.json +++ b/websites/J/Just Light Novels/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Nekolen", - "id": "270125856679002113" - }, - "contributors": [ - { - "name": "Bas950", - "id": "241278257335500811" - } - ], - "service": "Just Light Novels", - "description": { - "en": "Just Light Novels! Home of All Light Novels", - "nl": "Gewoon lichte romans! Huis van alle lichte romans" - }, - "url": "justlightnovels.com", - "version": "1.2.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Just%20Light%20Novels/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Just%20Light%20Novels/assets/thumbnail.png", - "color": "#0000ff", - "category": "other", - "tags": [ - "light-novels", - "reading", - "free" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Nekolen", + "id": "270125856679002113" + }, + "contributors": [ + { + "name": "Bas950", + "id": "241278257335500811" + } + ], + "service": "Just Light Novels", + "description": { + "en": "Just Light Novels! Home of All Light Novels", + "nl": "Gewoon lichte romans! Huis van alle lichte romans" + }, + "url": "justlightnovels.com", + "version": "1.2.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/Just%20Light%20Novels/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/Just%20Light%20Novels/assets/thumbnail.png", + "color": "#0000ff", + "category": "other", + "tags": [ + "light-novels", + "reading", + "free" + ] +} diff --git a/websites/J/Just Light Novels/presence.ts b/websites/J/Just Light Novels/presence.ts index 57decda26d48..f53a506037ac 100644 --- a/websites/J/Just Light Novels/presence.ts +++ b/websites/J/Just Light Novels/presence.ts @@ -1,58 +1,62 @@ const presence = new Presence({ - clientId: "631595418085490689", -}); + clientId: '631595418085490689', +}) function capitalize(string: string): string { - return string.charAt(0).toUpperCase() + string.slice(1); + return string.charAt(0).toUpperCase() + string.slice(1) } -const elapsed = Math.floor(Date.now() / 1000); -let stext; +const elapsed = Math.floor(Date.now() / 1000) +let stext -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/Just%20Light%20Novels/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/Just%20Light%20Novels/assets/logo.png', + } - presenceData.startTimestamp = elapsed; + presenceData.startTimestamp = elapsed - if (document.location.pathname === "/") { - presenceData.details = "Browsing novels"; - presenceData.state = "at Homepage"; - } else if (document.location.pathname === "//") { - stext = document.location.search.split("="); - presenceData.details = "Searching novels"; - presenceData.state = `Keyword: ${capitalize( - stext[1].split("+").join(" ") - )}`; - } else if (document.location.pathname.startsWith("/category/")) { - stext = document.location.pathname.split("/"); - presenceData.details = "Searching novels "; - presenceData.state = `${capitalize(stext[1])}: ${capitalize( - stext[2].split("-").join(" ") - )}`; - } else if ( - ["/reviews/", "/ln-fest-series/"].includes(document.location.pathname) - ) { - presenceData.details = "Browsing site"; - presenceData.state = `looking at ${capitalize( - document.location.pathname.split("/").join("").split("-").join(" ") - )}`; - } else { - const d = document.location.pathname.split("/"); - if (d.length === 5) { - presenceData.details = `Reading ${capitalize( - d[3].split("-").join(" ") - )}(${d[1]})`; - presenceData.state = `Looking at ${ - document.location.hash.length === 0 - ? "Novel" - : capitalize(document.location.hash.replace("#", "")) - }`; - } - } + if (document.location.pathname === '/') { + presenceData.details = 'Browsing novels' + presenceData.state = 'at Homepage' + } + else if (document.location.pathname === '//') { + stext = document.location.search.split('=') + presenceData.details = 'Searching novels' + presenceData.state = `Keyword: ${capitalize( + stext[1].split('+').join(' '), + )}` + } + else if (document.location.pathname.startsWith('/category/')) { + stext = document.location.pathname.split('/') + presenceData.details = 'Searching novels ' + presenceData.state = `${capitalize(stext[1])}: ${capitalize( + stext[2].split('-').join(' '), + )}` + } + else if ( + ['/reviews/', '/ln-fest-series/'].includes(document.location.pathname) + ) { + presenceData.details = 'Browsing site' + presenceData.state = `looking at ${capitalize( + document.location.pathname.split('/').join('').split('-').join(' '), + )}` + } + else { + const d = document.location.pathname.split('/') + if (d.length === 5) { + presenceData.details = `Reading ${capitalize( + d[3].split('-').join(' '), + )}(${d[1]})` + presenceData.state = `Looking at ${ + document.location.hash.length === 0 + ? 'Novel' + : capitalize(document.location.hash.replace('#', '')) + }` + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/J/jpdb/metadata.json b/websites/J/jpdb/metadata.json index 38ec5290c593..42c207413ab7 100644 --- a/websites/J/jpdb/metadata.json +++ b/websites/J/jpdb/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "nut1414", - "id": "179876009615556609" - }, - "service": "jpdb", - "description": { - "en": "Powerful Japanese dictionary and an all-in-one learning system for kanji and vocabulary." - }, - "url": "jpdb.io", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/jpdb/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/jpdb/assets/thumbnail.png", - "color": "#fe0000", - "category": "other", - "tags": [ - "japanese", - "english", - "dictionary", - "translator", - "language" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "nut1414", + "id": "179876009615556609" + }, + "service": "jpdb", + "description": { + "en": "Powerful Japanese dictionary and an all-in-one learning system for kanji and vocabulary." + }, + "url": "jpdb.io", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/jpdb/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/jpdb/assets/thumbnail.png", + "color": "#fe0000", + "category": "other", + "tags": [ + "japanese", + "english", + "dictionary", + "translator", + "language" + ] +} diff --git a/websites/J/jpdb/presence.ts b/websites/J/jpdb/presence.ts index 65a4132ea595..a167d72ce3f1 100644 --- a/websites/J/jpdb/presence.ts +++ b/websites/J/jpdb/presence.ts @@ -1,172 +1,221 @@ const presence = new Presence({ - clientId: "988699263775154176", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - deckList = [ - "/novel/", - "/vocabulary-list/", - "/textbook/", - "/anime/", - "/youtube-video/", - "/live-action/", - "/video-game/", - "/web-novel/", - "/visual-novel/", - "/audio/", - ]; + clientId: '988699263775154176', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const deckList = [ + '/novel/', + '/vocabulary-list/', + '/textbook/', + '/anime/', + '/youtube-video/', + '/live-action/', + '/video-game/', + '/web-novel/', + '/visual-novel/', + '/audio/', +] -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/J/jpdb/assets/logo.png", - startTimestamp: browsingTimestamp, - }; - if (document.location.pathname.includes("/learn")) { - presenceData.details = "Viewing learn page"; - const dueCountElem = - document.querySelector('a[href="/learn"]').firstElementChild; - if (dueCountElem.getAttribute("style") === "color: green;") - presenceData.state = `New: ${dueCountElem.textContent} items`; - else presenceData.state = `Due: ${dueCountElem.textContent} items`; - } else if (document.location.pathname.includes("/review")) { - presenceData.details = "Reviewing cards"; - const dueCountElem = - document.querySelector('a[href="/learn"]').firstElementChild; - if (dueCountElem.getAttribute("style") === "color: green;") - presenceData.state = `New: ${dueCountElem.textContent} items`; - else presenceData.state = `Due : ${dueCountElem.textContent} items`; - } else if (document.location.pathname.includes("/search")) { - if (document.querySelector("div.results.search")) { - presenceData.details = "Searching:"; - presenceData.state = encodeURI( - new URLSearchParams(document.location.search).get("q") - ); - } else if (document.querySelector("div.result.kanji")) { - presenceData.details = "Viewing a kanji:"; - presenceData.state = `${new URLSearchParams(document.location.search).get( - "q" - )} - ${decodeURI( - document.querySelector( - "div.result.kanji > div.vbox.gap > div.hbox > div.vbox.gap > div > div" - ).textContent - )}`; - } else if (document.querySelector("div.result.vocabulary")) { - presenceData.details = "Viewing a word:"; - presenceData.state = decodeURI( - new URLSearchParams(document.location.search).get("q") - ); - } - } else if (document.location.pathname.includes("/prebuilt_decks")) { - presenceData.details = "Finding pre-built deck"; - presenceData.state = - new URLSearchParams(document.location.search).get("q") || ""; - } else if (document.location.pathname.includes("/vocabulary/")) { - presenceData.details = "Viewing a word:"; - presenceData.state = decodeURI(document.location.pathname.split("/")[3]); - } else if (document.location.pathname.includes("/kanji/")) { - presenceData.details = "Viewing a kanji:"; - presenceData.state = decodeURI(document.location.pathname.split("/")[2]); - } else if (document.location.pathname.includes("/conjugate")) { - presenceData.details = "Viewing conjugations:"; - presenceData.state = decodeURI(document.location.pathname.split("/")[3]); - } else if (document.location.pathname.includes("/conjugation")) { - presenceData.details = "Reading about conjugation:"; - presenceData.state = decodeURI(document.location.pathname.split("/")[3]); - } else if (deckList.some(deck => document.location.pathname.includes(deck))) { - presenceData.details = "Viewing pre-built deck:"; - if (document.location.pathname.includes("/vocabulary-list")) { - presenceData.state = document - .querySelector("h4") - .textContent.substring(17); - } else presenceData.state = document.querySelector("h3").textContent; - } else if (document.location.pathname.includes("/anki-import/deck")) { - presenceData.details = "Viewing an imported deck:"; - presenceData.state = document - .querySelector("div.container.bugfix") - .firstElementChild.textContent.substring(15); - } else if (document.location.pathname.includes("/deck")) { - presenceData.details = "Viewing a deck:"; - presenceData.state = document.querySelector( - "div.container.bugfix > div:nth-child(2)" - ).textContent; - } else if (document.location.pathname.includes("/stats")) { - presenceData.details = "Viewing stats"; - presenceData.state = document.querySelector( - "div.container.bugfix > p" - ).textContent; - } else if (document.location.pathname.includes("/anki-import/overview")) { - presenceData.details = "Importing from Anki"; - presenceData.state = `Total: ${ - document - .querySelector("div.container.bugfix > table > tbody > tr:nth-child(2)") - .textContent.substring(5) - .split("/")[0] - } items`; - } else if ( - document.location.pathname.includes("/add_to_deck_from_text_confirm") - ) { - presenceData.details = "Adding vocabulary from text"; - presenceData.state = `Total: ${document - .querySelector("div.container.bugfix > p") - .textContent.substring(76, 78)} items`; - } else if (document.location.pathname.includes("/add_to_deck_from_text")) - presenceData.details = "Adding vocabulary from text"; - else if ( - document.location.pathname.includes("/add-to-deck-from-satori-reader") - ) - presenceData.details = "Importing from Satori Reader"; - else if ( - document.location.pathname.includes("/add-to-deck-from-shirabe-jisho") - ) - presenceData.details = "Importing from Shirabe Jisho"; - else if (document.location.pathname.includes("/anki-import")) - presenceData.details = "Importing from Anki"; - else if (document.location.pathname.includes("/add-empty-deck")) - presenceData.details = "Creating a deck"; - else if (document.location.pathname.includes("/new_deck_from_text")) - presenceData.details = "Creating a deck from text"; - else if (document.location.pathname.includes("/new-deck-from-top-vocabulary")) - presenceData.details = "Creating a deck from top vocabulary"; - else if (document.location.pathname === "/") - presenceData.details = "Viewing home page"; - else if (document.location.pathname.includes("/quiz")) - presenceData.details = "Taking quizzes"; - else if (document.location.pathname.includes("/leaderboard")) - presenceData.details = "Viewing leaderboard"; - else if (document.location.pathname.includes("/settings")) - presenceData.details = "Viewing settings page"; - else if (document.location.pathname.includes("/contact-us")) - presenceData.details = "Viewing contact page"; - else if (document.location.pathname.includes("/labs")) - presenceData.details = "Viewing labs page"; - else if (document.location.pathname.includes("/anime-difficulty-list")) - presenceData.details = "Viewing anime difficulty list"; - else if (document.location.pathname.includes("/live-action-difficulty-list")) - presenceData.details = "Viewing live action difficulty list"; - else if (document.location.pathname.includes("/visual-novel-difficulty-list")) - presenceData.details = "Viewing visual novel difficulty list"; - else if (document.location.pathname.includes("/novel-difficulty-list")) - presenceData.details = "Viewing novel difficulty list"; - else if (document.location.pathname.includes("/web-novel-difficulty-list")) - presenceData.details = "Viewing web novel difficulty list"; - else if (document.location.pathname.includes("/kanji-by-frequency")) - presenceData.details = "Viewing kanji by frequency list"; - else if (document.location.pathname.includes("/kanken-kanji")) - presenceData.details = "Viewing Kanken kanji list"; - else if (document.location.pathname.includes("/analyze-text")) - presenceData.details = "Analyzing Japanese text"; - else if (document.location.pathname.includes("/about")) - presenceData.details = "Reading the about page"; - else if (document.location.pathname.includes("/faq")) - presenceData.details = "Reading FAQ"; - else if (document.location.pathname.includes("/privacy-policy")) - presenceData.details = "Reading privacy policy"; - else if (document.location.pathname.includes("/terms-of-use")) - presenceData.details = "Reading terms of use"; - else if (document.location.pathname.includes("/changelog")) - presenceData.details = "Reading changelog"; - else if (document.location.pathname.includes("/login")) - presenceData.details = "Logging in"; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/jpdb/assets/logo.png', + startTimestamp: browsingTimestamp, + } + if (document.location.pathname.includes('/learn')) { + presenceData.details = 'Viewing learn page' + const dueCountElem = document.querySelector('a[href="/learn"]')?.firstElementChild + if (dueCountElem?.getAttribute('style') === 'color: green;') + presenceData.state = `New: ${dueCountElem.textContent} items` + else presenceData.state = `Due: ${dueCountElem?.textContent} items` + } + else if (document.location.pathname.includes('/review')) { + presenceData.details = 'Reviewing cards' + const dueCountElem = document.querySelector('a[href="/learn"]')?.firstElementChild + if (dueCountElem?.getAttribute('style') === 'color: green;') + presenceData.state = `New: ${dueCountElem?.textContent} items` + else presenceData.state = `Due : ${dueCountElem?.textContent} items` + } + else if (document.location.pathname.includes('/search')) { + if (document.querySelector('div.results.search')) { + presenceData.details = 'Searching:' + presenceData.state = encodeURI( + new URLSearchParams(document.location.search).get('q')!, + ) + } + else if (document.querySelector('div.result.kanji')) { + presenceData.details = 'Viewing a kanji:' + presenceData.state = `${new URLSearchParams(document.location.search).get( + 'q', + )} - ${decodeURI( + document.querySelector( + 'div.result.kanji > div.vbox.gap > div.hbox > div.vbox.gap > div > div', + )?.textContent ?? '', + )}` + } + else if (document.querySelector('div.result.vocabulary')) { + presenceData.details = 'Viewing a word:' + presenceData.state = decodeURI( + new URLSearchParams(document.location.search).get('q')!, + ) + } + } + else if (document.location.pathname.includes('/prebuilt_decks')) { + presenceData.details = 'Finding pre-built deck' + presenceData.state = new URLSearchParams(document.location.search).get('q') || '' + } + else if (document.location.pathname.includes('/vocabulary/')) { + presenceData.details = 'Viewing a word:' + presenceData.state = decodeURI(document.location.pathname.split('/')[3]) + } + else if (document.location.pathname.includes('/kanji/')) { + presenceData.details = 'Viewing a kanji:' + presenceData.state = decodeURI(document.location.pathname.split('/')[2]) + } + else if (document.location.pathname.includes('/conjugate')) { + presenceData.details = 'Viewing conjugations:' + presenceData.state = decodeURI(document.location.pathname.split('/')[3]) + } + else if (document.location.pathname.includes('/conjugation')) { + presenceData.details = 'Reading about conjugation:' + presenceData.state = decodeURI(document.location.pathname.split('/')[3]) + } + else if (deckList.some(deck => document.location.pathname.includes(deck))) { + presenceData.details = 'Viewing pre-built deck:' + if (document.location.pathname.includes('/vocabulary-list')) { + presenceData.state = document + .querySelector('h4') + ?.textContent + ?.substring(17) + } + else { + presenceData.state = document.querySelector('h3')?.textContent + } + } + else if (document.location.pathname.includes('/anki-import/deck')) { + presenceData.details = 'Viewing an imported deck:' + presenceData.state = document + .querySelector('div.container.bugfix') + ?.firstElementChild + ?.textContent + ?.substring(15) + } + else if (document.location.pathname.includes('/deck')) { + presenceData.details = 'Viewing a deck:' + presenceData.state = document.querySelector( + 'div.container.bugfix > div:nth-child(2)', + )?.textContent + } + else if (document.location.pathname.includes('/stats')) { + presenceData.details = 'Viewing stats' + presenceData.state = document.querySelector( + 'div.container.bugfix > p', + )?.textContent + } + else if (document.location.pathname.includes('/anki-import/overview')) { + presenceData.details = 'Importing from Anki' + presenceData.state = `Total: ${ + document + .querySelector('div.container.bugfix > table > tbody > tr:nth-child(2)') + ?.textContent + ?.substring(5) + .split('/')[0] + } items` + } + else if ( + document.location.pathname.includes('/add_to_deck_from_text_confirm') + ) { + presenceData.details = 'Adding vocabulary from text' + presenceData.state = `Total: ${document + .querySelector('div.container.bugfix > p') + ?.textContent + ?.substring(76, 78)} items` + } + else if (document.location.pathname.includes('/add_to_deck_from_text')) { + presenceData.details = 'Adding vocabulary from text' + } + else if ( + document.location.pathname.includes('/add-to-deck-from-satori-reader') + ) { + presenceData.details = 'Importing from Satori Reader' + } + else if ( + document.location.pathname.includes('/add-to-deck-from-shirabe-jisho') + ) { + presenceData.details = 'Importing from Shirabe Jisho' + } + else if (document.location.pathname.includes('/anki-import')) { + presenceData.details = 'Importing from Anki' + } + else if (document.location.pathname.includes('/add-empty-deck')) { + presenceData.details = 'Creating a deck' + } + else if (document.location.pathname.includes('/new_deck_from_text')) { + presenceData.details = 'Creating a deck from text' + } + else if (document.location.pathname.includes('/new-deck-from-top-vocabulary')) { + presenceData.details = 'Creating a deck from top vocabulary' + } + else if (document.location.pathname === '/') { + presenceData.details = 'Viewing home page' + } + else if (document.location.pathname.includes('/quiz')) { + presenceData.details = 'Taking quizzes' + } + else if (document.location.pathname.includes('/leaderboard')) { + presenceData.details = 'Viewing leaderboard' + } + else if (document.location.pathname.includes('/settings')) { + presenceData.details = 'Viewing settings page' + } + else if (document.location.pathname.includes('/contact-us')) { + presenceData.details = 'Viewing contact page' + } + else if (document.location.pathname.includes('/labs')) { + presenceData.details = 'Viewing labs page' + } + else if (document.location.pathname.includes('/anime-difficulty-list')) { + presenceData.details = 'Viewing anime difficulty list' + } + else if (document.location.pathname.includes('/live-action-difficulty-list')) { + presenceData.details = 'Viewing live action difficulty list' + } + else if (document.location.pathname.includes('/visual-novel-difficulty-list')) { + presenceData.details = 'Viewing visual novel difficulty list' + } + else if (document.location.pathname.includes('/novel-difficulty-list')) { + presenceData.details = 'Viewing novel difficulty list' + } + else if (document.location.pathname.includes('/web-novel-difficulty-list')) { + presenceData.details = 'Viewing web novel difficulty list' + } + else if (document.location.pathname.includes('/kanji-by-frequency')) { + presenceData.details = 'Viewing kanji by frequency list' + } + else if (document.location.pathname.includes('/kanken-kanji')) { + presenceData.details = 'Viewing Kanken kanji list' + } + else if (document.location.pathname.includes('/analyze-text')) { + presenceData.details = 'Analyzing Japanese text' + } + else if (document.location.pathname.includes('/about')) { + presenceData.details = 'Reading the about page' + } + else if (document.location.pathname.includes('/faq')) { + presenceData.details = 'Reading FAQ' + } + else if (document.location.pathname.includes('/privacy-policy')) { + presenceData.details = 'Reading privacy policy' + } + else if (document.location.pathname.includes('/terms-of-use')) { + presenceData.details = 'Reading terms of use' + } + else if (document.location.pathname.includes('/changelog')) { + presenceData.details = 'Reading changelog' + } + else if (document.location.pathname.includes('/login')) { + presenceData.details = 'Logging in' + } - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/J/jut.su/metadata.json b/websites/J/jut.su/metadata.json index 82170a3b47d4..895f0f36bbcf 100644 --- a/websites/J/jut.su/metadata.json +++ b/websites/J/jut.su/metadata.json @@ -1,34 +1,34 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "stavzdev", - "id": "291568379423096832" - }, - "contributors": [ - { - "id": "226622016986415104", - "name": "cramatsu" - }, - { - "id": "638080361179512853", - "name": "Dark_Ville" - } - ], - "service": "jut.su", - "description": { - "en": "Jut.su is Russian anime website", - "ru": "Jut.su — это русский сайт с аниме", - "nl": "Jut.su is een Russische anime-website" - }, - "url": "jut.su", - "version": "3.0.11", - "logo": "https://cdn.rcd.gg/PreMiD/websites/J/jut.su/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/jut.su/assets/thumbnail.png", - "color": "#c9e58b", - "category": "anime", - "tags": [ - "jutsu", - "anime" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "stavzdev", + "id": "291568379423096832" + }, + "contributors": [ + { + "id": "226622016986415104", + "name": "cramatsu" + }, + { + "id": "638080361179512853", + "name": "Dark_Ville" + } + ], + "service": "jut.su", + "description": { + "en": "Jut.su is Russian anime website", + "ru": "Jut.su — это русский сайт с аниме", + "nl": "Jut.su is een Russische anime-website" + }, + "url": "jut.su", + "version": "3.0.11", + "logo": "https://cdn.rcd.gg/PreMiD/websites/J/jut.su/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/J/jut.su/assets/thumbnail.png", + "color": "#c9e58b", + "category": "anime", + "tags": [ + "jutsu", + "anime" + ] +} diff --git a/websites/J/jut.su/presence.ts b/websites/J/jut.su/presence.ts index d97c9c161c4f..1c8043446383 100644 --- a/websites/J/jut.su/presence.ts +++ b/websites/J/jut.su/presence.ts @@ -1,105 +1,105 @@ const presence = new Presence({ - clientId: "1066684228726698014", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1066684228726698014', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/J/jut.su/assets/logo.png", - startTimestamp: browsingTimestamp, - type: ActivityType.Watching, - }, - { pathname } = document.location, - title = - document.querySelector('[class="b-b-title center"]') ?? - document.querySelector('[itemprop="name"]'), - search = document.querySelector('[name="ystext"]'), - mangaTitle = document - .querySelector("#the_manga_title") - ?.textContent.split(":"), - video = document.querySelector( - '[id="my-player_html5_api"]' - ), - name = document.querySelector("#dle-content > div > h1 > span"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/J/jut.su/assets/logo.png', + startTimestamp: browsingTimestamp, + type: ActivityType.Watching, + } + const { pathname } = document.location + const title = document.querySelector('[class="b-b-title center"]') + ?? document.querySelector('[itemprop="name"]') + const search = document.querySelector('[name="ystext"]') + const mangaTitle = document + .querySelector('#the_manga_title') + ?.textContent + ?.split(':') + const video = document.querySelector( + '[id="my-player_html5_api"]', + ) + const name = document.querySelector('#dle-content > div > h1 > span') - switch (true) { - case !!search?.value: - presenceData.details = "Ищет по запросу"; - presenceData.state = `«${search.value}»`; - break; - case pathname === "/": - presenceData.details = "На домашней странице"; - break; - case pathname === "/pm/": - presenceData.details = "Просматривает сообщения"; - break; - case !!pathname.match(/read-[0-9]*/gm): - presenceData.details = "Учавствует в переписке"; - break; - case !!pathname.match(/\/user\//): - presenceData.details = "Смотрит профиль"; - presenceData.state = pathname.split("/")[2].replace(/\+/g, " "); - break; - case !!pathname.match(/\/rewards\//): - presenceData.details = "Смотрит награды пользователя"; - presenceData.state = pathname.split("/")[2].replace(/\+/g, " "); - break; - case !!pathname.match(/\/tests\//): - presenceData.details = "Проходит тест"; - break; - case pathname === "/anime/": - presenceData.details = "Смотрит список аниме"; - break; - case pathname === "/manga/": - presenceData.details = "Смотрит список манги Наруто"; - break; - case pathname === "/novels/": - presenceData.details = "Смотрит список новелл"; - break; - case !!mangaTitle: - presenceData.details = `Читает мангу «${mangaTitle[0]}»`; - presenceData.state = mangaTitle[1]; - break; - case !!video: { - delete presenceData.startTimestamp; + switch (true) { + case !!search?.value: + presenceData.details = 'Ищет по запросу' + presenceData.state = `«${search.value}»` + break + case pathname === '/': + presenceData.details = 'На домашней странице' + break + case pathname === '/pm/': + presenceData.details = 'Просматривает сообщения' + break + case !!pathname.match(/read-\d*/g): + presenceData.details = 'Учавствует в переписке' + break + case !!pathname.match(/\/user\//): + presenceData.details = 'Смотрит профиль' + presenceData.state = pathname.split('/')[2].replace(/\+/g, ' ') + break + case !!pathname.match(/\/rewards\//): + presenceData.details = 'Смотрит награды пользователя' + presenceData.state = pathname.split('/')[2].replace(/\+/g, ' ') + break + case !!pathname.match(/\/tests\//): + presenceData.details = 'Проходит тест' + break + case pathname === '/anime/': + presenceData.details = 'Смотрит список аниме' + break + case pathname === '/manga/': + presenceData.details = 'Смотрит список манги Наруто' + break + case pathname === '/novels/': + presenceData.details = 'Смотрит список новелл' + break + case !!mangaTitle: + presenceData.details = `Читает мангу «${mangaTitle[0]}»` + presenceData.state = mangaTitle[1] + break + case !!video: { + delete presenceData.startTimestamp - if (!video.paused && !isNaN(Number(video.duration))) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Воспроизводится"; - } else { - delete presenceData.endTimestamp; - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = "Приостановлено"; - } - const titles = name.textContent - .replace(/смотреть\s/i, "") - .replace(/([0-9]* сезон)?\s?[0-9]* серия|[0-9] фильм/g, "") - .trim(); - presenceData.details = titles; - presenceData.state = name.textContent - .replace(/смотреть\s/i, "") - .replace(titles, ""); + if (!video.paused && !Number.isNaN(Number(video.duration))) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Воспроизводится' + } + else { + delete presenceData.endTimestamp + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Приостановлено' + } + const titles = name?.textContent + ?.replace(/смотреть\s/i, '') + .replace(/(\d* сезон)?\s?\d* серия|\d фильм/g, '') + .trim() + presenceData.details = titles + presenceData.state = name?.textContent + ?.replace(/смотреть\s/i, '') + .replace(titles ?? '', '') - const coverArtElement = document.querySelector( - ".all_anime_title.aat_ep" - ); - if (coverArtElement) { - const coverArt = coverArtElement.style.backgroundImage; - if (coverArt) { - presenceData.largeImageKey = coverArt - .replace('url("', "") - .replace('")', ""); - } - } - break; - } - case !!title: - presenceData.details = "Смотрит страницу аниме"; - presenceData.state = title.attributes.getNamedItem("content").value; - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + const coverArtElement = document.querySelector( + '.all_anime_title.aat_ep', + ) + if (coverArtElement) { + const coverArt = coverArtElement.style.backgroundImage + if (coverArt) { + presenceData.largeImageKey = coverArt + .replace('url("', '') + .replace('")', '') + } + } + break + } + case !!title: + presenceData.details = 'Смотрит страницу аниме' + presenceData.state = title.attributes.getNamedItem('content')?.value + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +})