diff --git a/websites/T/TCRF/metadata.json b/websites/T/TCRF/metadata.json index 99d1f350f24f..f395f8a1d26b 100644 --- a/websites/T/TCRF/metadata.json +++ b/websites/T/TCRF/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Nekolen", - "id": "270125856679002113" - }, - "service": "TCRF", - "description": { - "en": "The Cutting Room Floor is a site dedicated to unearthing and researching unused and cut content from video games.", - "nl": "The Cutting Room Floor is een site gewijd aan het opgraven en onderzoeken van ongebruikte en geknipte inhoud uit videogames." - }, - "url": "tcrf.net", - "version": "1.4.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TCRF/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TCRF/assets/thumbnail.png", - "color": "#D3D3D3", - "category": "games", - "tags": [ - "games", - "retro", - "wiki", - "research", - "cut-contents" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Nekolen", + "id": "270125856679002113" + }, + "service": "TCRF", + "description": { + "en": "The Cutting Room Floor is a site dedicated to unearthing and researching unused and cut content from video games.", + "nl": "The Cutting Room Floor is een site gewijd aan het opgraven en onderzoeken van ongebruikte en geknipte inhoud uit videogames." + }, + "url": "tcrf.net", + "version": "1.4.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TCRF/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TCRF/assets/thumbnail.png", + "color": "#D3D3D3", + "category": "games", + "tags": [ + "games", + "retro", + "wiki", + "research", + "cut-contents" + ] +} diff --git a/websites/T/TCRF/presence.ts b/websites/T/TCRF/presence.ts index bbcbbb7c02da..3ea31409aa13 100644 --- a/websites/T/TCRF/presence.ts +++ b/websites/T/TCRF/presence.ts @@ -1,51 +1,58 @@ -// eslint-disable-next-line no-one-time-vars/no-one-time-vars const presence = new Presence({ - clientId: "631259475038175232", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '631259475038175232', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let x: string; +let x: string -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/T/TCRF/assets/logo.png", - startTimestamp: browsingTimestamp, - }; - if (document.location.pathname === "/The_Cutting_Room_Floor") { - presenceData.details = "browsing TCRF"; - presenceData.state = "at Homepage"; - } else if ( - ["/Help:Contents", "/Category:To_do", "/Special:RecentChanges"].includes( - document.location.pathname - ) - ) { - const [d, d1] = document.location.pathname.replace("/", "").split(":"); - presenceData.details = `browsing ${d}`; - presenceData.state = `at ${d1}`; - } else if (document.location.pathname.startsWith("/Help:Contents/")) { - const help = document.location.pathname.split("/"), - d = help[1].split(":"); - presenceData.details = `getting ${d[0]}`; - presenceData.state = `${d[1]}: ${help[2] - .replace("%26", "&") - .split("_") - .join(" ")}`; - } else { - const name = document - .querySelector("#firstHeading") - .textContent.replace(")", "") - .split("("); - if (name[0].startsWith("Prerelease:")) { - const d = name[0].split(":"); - x = `Game: ${d[1]}(${d[0]})`; - } else x = `Game: ${name[0]}`; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TCRF/assets/logo.png', + startTimestamp: browsingTimestamp, + } + if (document.location.pathname === '/The_Cutting_Room_Floor') { + presenceData.details = 'browsing TCRF' + presenceData.state = 'at Homepage' + } + else if ( + ['/Help:Contents', '/Category:To_do', '/Special:RecentChanges'].includes( + document.location.pathname, + ) + ) { + const [d, d1] = document.location.pathname.replace('/', '').split(':') + presenceData.details = `browsing ${d}` + presenceData.state = `at ${d1}` + } + else if (document.location.pathname.startsWith('/Help:Contents/')) { + const help = document.location.pathname.split('/') + const d = help[1].split(':') + presenceData.details = `getting ${d[0]}` + presenceData.state = `${d[1]}: ${help[2] + .replace('%26', '&') + .split('_') + .join(' ')}` + } + else { + const name = document + .querySelector('#firstHeading') + ?.textContent + ?.replace(')', '') + .split('(') + if (name?.[0].startsWith('Prerelease:')) { + const d = name[0].split(':') + x = `Game: ${d[1]}(${d[0]})` + } + else { + x = `Game: ${name?.[0]}` + } - let stated; - if (!name[1]) stated = "Platform: Multiple"; - else stated = `Platform: ${name[1]} `; + let stated + if (!name?.[1]) + stated = 'Platform: Multiple' + else stated = `Platform: ${name[1]} ` - //var year = document.getElementsByClassName("mw-headline")[1].textContent - presenceData.details = x; - presenceData.state = stated; - } -}); + // var year = document.getElementsByClassName("mw-headline")[1].textContent + presenceData.details = x + presenceData.state = stated + } +}) diff --git a/websites/T/TETR.IO/metadata.json b/websites/T/TETR.IO/metadata.json index 73fd0573e9ba..583d37e152a3 100644 --- a/websites/T/TETR.IO/metadata.json +++ b/websites/T/TETR.IO/metadata.json @@ -1,39 +1,39 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Rare Akuma ☆", - "id": "250044591686811669" - }, - "service": "TETR.IO", - "description": { - "en": "TETR.IO is a free-to-play online multiplayer and single player fan game", - "nl": "TETR.IO is een gratis te spelen online multiplayer- en singleplayer-fanspel", - "vi_VN": "TETR.IO là trò chơi nhiều người chơi/một người chơi miễn phí trực tuyến" - }, - "url": "tetr.io", - "version": "1.1.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/thumbnail.jpg", - "color": "#142472", - "category": "games", - "tags": [ - "puzzle", - "multiplayer", - "online" - ], - "settings": [ - { - "id": "privateRoom", - "title": "Show Private Room button", - "icon": "fas fa-user-secret", - "value": true - }, - { - "id": "showButtons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Rare Akuma ☆", + "id": "250044591686811669" + }, + "service": "TETR.IO", + "description": { + "en": "TETR.IO is a free-to-play online multiplayer and single player fan game", + "nl": "TETR.IO is een gratis te spelen online multiplayer- en singleplayer-fanspel", + "vi_VN": "TETR.IO là trò chơi nhiều người chơi/một người chơi miễn phí trực tuyến" + }, + "url": "tetr.io", + "version": "1.1.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/thumbnail.jpg", + "color": "#142472", + "category": "games", + "tags": [ + "puzzle", + "multiplayer", + "online" + ], + "settings": [ + { + "id": "privateRoom", + "title": "Show Private Room button", + "icon": "fas fa-user-secret", + "value": true + }, + { + "id": "showButtons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/T/TETR.IO/presence.ts b/websites/T/TETR.IO/presence.ts index bb631a460b97..4f50228bb4c6 100644 --- a/websites/T/TETR.IO/presence.ts +++ b/websites/T/TETR.IO/presence.ts @@ -1,151 +1,170 @@ const presence = new Presence({ - clientId: "815006153066151998", - }), - SelectorMap = { - header: "div#header_text.ns", - username: "h1#me_username", - status: "div#social_status", - game: "div#social_status > b", - roomid: "div#roomid", - replay: "div#data_replay", - }, - menuPrincipal = ["SOLO", "MULTIPLAYER"], - soloModes: { [key: string]: string } = { - zen: "ZEN", - bl: "BLITZ", - lines40: "40 LINES", - ct: "CUSTOM", - ctgame: "custom game", - }; -let browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '815006153066151998', +}) +const SelectorMap = { + header: 'div#header_text.ns', + username: 'h1#me_username', + status: 'div#social_status', + game: 'div#social_status > b', + roomid: 'div#roomid', + replay: 'div#data_replay', +} +const menuPrincipal = ['SOLO', 'MULTIPLAYER'] +const soloModes: { [key: string]: string } = { + zen: 'ZEN', + bl: 'BLITZ', + lines40: '40 LINES', + ct: 'CUSTOM', + ctgame: 'custom game', +} +let browsingTimestamp = Math.floor(Date.now() / 1000) -function getText(selector: string): string { - if ( - document.querySelector(selector) !== null && - document.querySelector(selector) - ) - return document.querySelector(selector).textContent; - else return null; +function getText(selector: string): string | null { + if ( + document.querySelector(selector) !== null + && document.querySelector(selector) + ) { + return document.querySelector(selector)?.textContent ?? null + } + else { + return null + } } const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/logo.jpg", - Qp = "https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/0.png", - Ct = "https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/1.png", - Tl = "https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/2.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/logo.jpg', + Qp = 'https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/0.png', + Ct = 'https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/1.png', + Tl = 'https://cdn.rcd.gg/PreMiD/websites/T/TETR.IO/assets/2.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }, - showPrivButton = await presence.getSetting("privateRoom"), - showButtons = await presence.getSetting("showButtons"), - header = getText(SelectorMap.header), - status = getText(SelectorMap.status), - game = getText(SelectorMap.game), - roomID = getText(SelectorMap.roomid); - if ( - status.includes("Idle") || - status.includes("Busy") || - status.includes("Offline") - ) - presenceData.details = status; - else if (menuPrincipal.includes(header)) { - browsingTimestamp = Math.floor(Date.now() / 1000); - presenceData.details = header; - presenceData.state = "In Menus"; - } else if (Object.values(soloModes).includes(header)) { - browsingTimestamp = Math.floor(Date.now() / 1000); - presenceData.details = header; - presenceData.state = "Setting up game"; - presenceData.smallImageKey = Object.keys(soloModes).find( - key => soloModes[key] === header - ); - presenceData.smallImageText = header; - } else if (header.includes("LISTING")) { - browsingTimestamp = Math.floor(Date.now() / 1000); - presenceData.details = "ROOM LISTING"; - presenceData.state = "Browsing public rooms"; - presenceData.smallImageKey = Assets.Ct; - presenceData.smallImageText = "ROOM LISTING"; - } else if (status.includes("custom room")) { - if (status.includes("game")) - presenceData.startTimestamp = browsingTimestamp; - else browsingTimestamp = Math.floor(Date.now() / 1000); - presenceData.details = "CUSTOM GAME"; - presenceData.state = status.replace(/([a-z]+) .* ([a-z]+)/i, "$1 $2"); - presenceData.smallImageKey = Assets.Ct; - presenceData.smallImageText = game; - if (status.includes("public")) { - presenceData.buttons = [ - { - label: "Enter Public Room", - url: `https://tetr.io/${roomID}`, - }, - ]; - } else if (showPrivButton) { - presenceData.buttons = [ - { - label: "Enter Private Room", - url: `https://tetr.io/${roomID}`, - }, - ]; - } - } else if (status.includes("QUICK")) { - if (status.includes("game")) - presenceData.startTimestamp = browsingTimestamp; - else browsingTimestamp = Math.floor(Date.now() / 1000); - presenceData.details = game; - presenceData.state = status.replace(/([a-z]+) .* ([a-z]+)/i, "$1 $2"); - presenceData.smallImageKey = Assets.Qp; - presenceData.smallImageText = game; - } else if (status.includes("LEAGUE")) { - if (status.includes("game")) - presenceData.startTimestamp = browsingTimestamp; - else browsingTimestamp = Math.floor(Date.now() / 1000); - presenceData.details = game; - presenceData.state = status.replace(/([a-z]+) .* ([a-z]+)/i, "$1 $2"); - presenceData.smallImageKey = Assets.Tl; - presenceData.smallImageText = game; - } else if (header.includes("LEAGUE")) { - browsingTimestamp = Math.floor(Date.now() / 1000); - presenceData.details = header; - presenceData.smallImageKey = Assets.Tl; - presenceData.smallImageText = header; - } else if (Object.values(soloModes).includes(game)) { - if (!header.includes("RESULTS")) - presenceData.startTimestamp = browsingTimestamp; - else { - browsingTimestamp = Math.floor(Date.now() / 1000); - presenceData.state = "Checking Results"; - } - presenceData.details = game; - presenceData.smallImageKey = Object.keys(soloModes).find( - key => soloModes[key] === game - ); - presenceData.smallImageText = game; - } else if (!document.querySelector("#replay").classList.contains("hidden")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "REPLAY"; - presenceData.state = getText(SelectorMap.replay); - } else { - browsingTimestamp = Math.floor(Date.now() / 1000); - presenceData.details = status; - } - if ( - getText(SelectorMap.username) !== "" && - !getText(SelectorMap.username).includes("guest-") && - showButtons - ) { - presenceData.buttons = [ - { - label: "View Profile", - url: `https://ch.tetr.io/u/${getText(SelectorMap.username)}`, - }, - ]; - } else delete presenceData.buttons; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } + const showPrivButton = await presence.getSetting('privateRoom') + const showButtons = await presence.getSetting('showButtons') + const header = getText(SelectorMap.header) + const status = getText(SelectorMap.status) + const game = getText(SelectorMap.game) + const roomID = getText(SelectorMap.roomid) + if ( + status?.includes('Idle') + || status?.includes('Busy') + || status?.includes('Offline') + ) { + presenceData.details = status + } + else if (menuPrincipal.includes(header ?? '')) { + browsingTimestamp = Math.floor(Date.now() / 1000) + presenceData.details = header + presenceData.state = 'In Menus' + } + else if (Object.values(soloModes).includes(header ?? '')) { + browsingTimestamp = Math.floor(Date.now() / 1000) + presenceData.details = header + presenceData.state = 'Setting up game' + presenceData.smallImageKey = Object.keys(soloModes).find( + key => soloModes[key] === header, + ) + presenceData.smallImageText = header + } + else if (header?.includes('LISTING')) { + browsingTimestamp = Math.floor(Date.now() / 1000) + presenceData.details = 'ROOM LISTING' + presenceData.state = 'Browsing public rooms' + presenceData.smallImageKey = Assets.Ct + presenceData.smallImageText = 'ROOM LISTING' + } + else if (status?.includes('custom room')) { + if (status.includes('game')) + presenceData.startTimestamp = browsingTimestamp + else browsingTimestamp = Math.floor(Date.now() / 1000) + presenceData.details = 'CUSTOM GAME' + presenceData.state = status.replace(/([a-z]+) .* ([a-z]+)/i, '$1 $2') + presenceData.smallImageKey = Assets.Ct + presenceData.smallImageText = game + if (status.includes('public')) { + presenceData.buttons = [ + { + label: 'Enter Public Room', + url: `https://tetr.io/${roomID}`, + }, + ] + } + else if (showPrivButton) { + presenceData.buttons = [ + { + label: 'Enter Private Room', + url: `https://tetr.io/${roomID}`, + }, + ] + } + } + else if (status?.includes('QUICK')) { + if (status.includes('game')) + presenceData.startTimestamp = browsingTimestamp + else browsingTimestamp = Math.floor(Date.now() / 1000) + presenceData.details = game + presenceData.state = status.replace(/([a-z]+) .* ([a-z]+)/i, '$1 $2') + presenceData.smallImageKey = Assets.Qp + presenceData.smallImageText = game + } + else if (status?.includes('LEAGUE')) { + if (status.includes('game')) + presenceData.startTimestamp = browsingTimestamp + else browsingTimestamp = Math.floor(Date.now() / 1000) + presenceData.details = game + presenceData.state = status.replace(/([a-z]+) .* ([a-z]+)/i, '$1 $2') + presenceData.smallImageKey = Assets.Tl + presenceData.smallImageText = game + } + else if (header?.includes('LEAGUE')) { + browsingTimestamp = Math.floor(Date.now() / 1000) + presenceData.details = header + presenceData.smallImageKey = Assets.Tl + presenceData.smallImageText = header + } + else if (Object.values(soloModes).includes(game ?? '')) { + if (!header?.includes('RESULTS')) { + presenceData.startTimestamp = browsingTimestamp + } + else { + browsingTimestamp = Math.floor(Date.now() / 1000) + presenceData.state = 'Checking Results' + } + presenceData.details = game + presenceData.smallImageKey = Object.keys(soloModes).find( + key => soloModes[key] === game, + ) + presenceData.smallImageText = game + } + else if (!document.querySelector('#replay')?.classList.contains('hidden')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'REPLAY' + presenceData.state = getText(SelectorMap.replay) + } + else { + browsingTimestamp = Math.floor(Date.now() / 1000) + presenceData.details = status + } + if ( + getText(SelectorMap.username) !== '' + && !getText(SelectorMap.username)?.includes('guest-') + && showButtons + ) { + presenceData.buttons = [ + { + label: 'View Profile', + url: `https://ch.tetr.io/u/${getText(SelectorMap.username)}`, + }, + ] + } + else { + delete presenceData.buttons + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TMDB/metadata.json b/websites/T/TMDB/metadata.json index ed63fd817ef7..8fce73f0f0f8 100644 --- a/websites/T/TMDB/metadata.json +++ b/websites/T/TMDB/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Keksi♡", - "id": "527147599942385674" - }, - "service": "TMDB", - "description": { - "en": "The Movie Database (TMDB) is a popular, user editable database for movies and TV shows." - }, - "url": "www.themoviedb.org", - "version": "1.0.11", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TMDB/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TMDB/assets/thumbnail.png", - "color": "#032541", - "category": "socials", - "tags": [ - "movies", - "shows", - "videos", - "tv" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Keksi♡", + "id": "527147599942385674" + }, + "service": "TMDB", + "description": { + "en": "The Movie Database (TMDB) is a popular, user editable database for movies and TV shows." + }, + "url": "www.themoviedb.org", + "version": "1.0.11", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TMDB/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TMDB/assets/thumbnail.png", + "color": "#032541", + "category": "socials", + "tags": [ + "movies", + "shows", + "videos", + "tv" + ] +} diff --git a/websites/T/TMDB/presence.ts b/websites/T/TMDB/presence.ts index ffebe805b9b9..ea80f1ec2258 100644 --- a/websites/T/TMDB/presence.ts +++ b/websites/T/TMDB/presence.ts @@ -1,101 +1,139 @@ const presence: Presence = new Presence({ - clientId: "966643093308837938", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '966643093308837938', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TMDB/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname } = window.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TMDB/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname } = window.location - if (pathname.startsWith("/u")) { - const user = pathname.split("/")[2]; + if (pathname.startsWith('/u')) { + const user = pathname.split('/')[2] - if (pathname.includes("watchlist")) - presenceData.details = `Viewing ${user}'s watchlist`; - else if (pathname.includes("favorites")) - presenceData.details = `Viewing ${user}'s favorites`; - else if (pathname.includes("lists")) - presenceData.details = `Viewing ${user}'s lists`; - else if (pathname.includes("activity")) - presenceData.details = `Viewing ${user}'s activity`; - else if (pathname.includes("discussions")) - presenceData.details = `Reading ${user}'s discussions`; - else if (pathname.includes("ratings")) - presenceData.details = `Viewing ${user}'s ratings`; - else if (pathname.includes("recommendations")) - presenceData.details = `Viewing ${user}'s recommendations`; - else if (pathname.includes("events")) - presenceData.details = `Viewing ${user}'s events`; - else presenceData.details = `Viewing ${user}'s profile`; - } else if (pathname.startsWith("/movie")) { - if (pathname.startsWith("/movie/now-playing")) - presenceData.details = "Viewing now playing movies"; - else if (pathname.startsWith("/movie/upcoming")) - presenceData.details = "Viewing upcoming movies"; - else if (pathname.startsWith("/movie/top-rated")) - presenceData.details = "Viewing top rated movies"; - else if (pathname.startsWith("/movie/new")) - presenceData.details = "Adding a new movie"; - else if (pathname.split("/").length === 3) { - presenceData.details = `Viewing ${document - .querySelector(`h2 > [href="${pathname}"]`) - .textContent.trim()}`; - } else if (pathname.includes("/reviews")) { - presenceData.details = `Reading ${document - .querySelector( - `h2 > [href="${pathname.split("/").slice(0, 3).join("/")}"]` - ) - .textContent.trim()}'s reviews`; - } else if (pathname.includes("/discuss")) { - presenceData.details = `Reading ${document - .querySelector("h2") - .textContent.trim()}`; - } else presenceData.details = "Viewing movies"; - } else if (pathname.startsWith("/tv")) { - if (pathname.startsWith("/tv/airing-today")) - presenceData.details = "Viewing airing today TV shows"; - else if (pathname.startsWith("/tv/on-the-air")) - presenceData.details = "Viewing airing TV shows"; - else if (pathname.startsWith("/tv/top-rated")) - presenceData.details = "Viewing top rated TV shows"; - else if (pathname.startsWith("/tv/new")) - presenceData.details = "Adding a new TV show"; - else if (pathname.split("/").length === 3) { - presenceData.details = `Viewing ${document - .querySelector(`h2 > [href="${pathname}"]`) - .textContent.trim()}`; - } else if (pathname.includes("/reviews")) { - presenceData.state = `Reading ${document - .querySelector( - `h2 > [href="${pathname.split("/").slice(0, 3).join("/")}"]` - ) - .textContent.trim()}'s reviews`; - } else if (pathname.includes("/discuss")) { - presenceData.details = `Reading ${document - .querySelector("h2") - .textContent.trim()}`; - } else presenceData.details = "Viewing TV shows"; - } else if (pathname.startsWith("/person")) { - if (pathname.split("/").length === 3) { - presenceData.details = `Viewing ${document - .querySelector(`h2 > [href="${pathname}"]`) - .textContent.trim()}`; - } else presenceData.details = "Viewing Popular People list"; - } else if (pathname.startsWith("/discuss")) - presenceData.details = "Viewing discussions"; - else if (pathname.startsWith("/leaderboard")) - presenceData.details = "Viewing leaderboard"; - else if (pathname.startsWith("/talk")) - presenceData.details = "Viewing TMDB support"; - else if (pathname.startsWith("/search")) { - const query = document.querySelector("input").value; - if (query.length > 0) presenceData.details = `Searching for ${query}`; - else presenceData.details = "Searching"; - } else if (pathname.startsWith("/")) presenceData.details = "Browsing TMDB"; + if (pathname.includes('watchlist')) + presenceData.details = `Viewing ${user}'s watchlist` + else if (pathname.includes('favorites')) + presenceData.details = `Viewing ${user}'s favorites` + else if (pathname.includes('lists')) + presenceData.details = `Viewing ${user}'s lists` + else if (pathname.includes('activity')) + presenceData.details = `Viewing ${user}'s activity` + else if (pathname.includes('discussions')) + presenceData.details = `Reading ${user}'s discussions` + else if (pathname.includes('ratings')) + presenceData.details = `Viewing ${user}'s ratings` + else if (pathname.includes('recommendations')) + presenceData.details = `Viewing ${user}'s recommendations` + else if (pathname.includes('events')) + presenceData.details = `Viewing ${user}'s events` + else presenceData.details = `Viewing ${user}'s profile` + } + else if (pathname.startsWith('/movie')) { + if (pathname.startsWith('/movie/now-playing')) { + presenceData.details = 'Viewing now playing movies' + } + else if (pathname.startsWith('/movie/upcoming')) { + presenceData.details = 'Viewing upcoming movies' + } + else if (pathname.startsWith('/movie/top-rated')) { + presenceData.details = 'Viewing top rated movies' + } + else if (pathname.startsWith('/movie/new')) { + presenceData.details = 'Adding a new movie' + } + else if (pathname.split('/').length === 3) { + presenceData.details = `Viewing ${document + .querySelector(`h2 > [href="${pathname}"]`) + ?.textContent + ?.trim()}` + } + else if (pathname.includes('/reviews')) { + presenceData.details = `Reading ${document + .querySelector( + `h2 > [href="${pathname.split('/').slice(0, 3).join('/')}"]`, + ) + ?.textContent + ?.trim()}'s reviews` + } + else if (pathname.includes('/discuss')) { + presenceData.details = `Reading ${document + .querySelector('h2') + ?.textContent + ?.trim()}` + } + else { + presenceData.details = 'Viewing movies' + } + } + else if (pathname.startsWith('/tv')) { + if (pathname.startsWith('/tv/airing-today')) { + presenceData.details = 'Viewing airing today TV shows' + } + else if (pathname.startsWith('/tv/on-the-air')) { + presenceData.details = 'Viewing airing TV shows' + } + else if (pathname.startsWith('/tv/top-rated')) { + presenceData.details = 'Viewing top rated TV shows' + } + else if (pathname.startsWith('/tv/new')) { + presenceData.details = 'Adding a new TV show' + } + else if (pathname.split('/').length === 3) { + presenceData.details = `Viewing ${document + .querySelector(`h2 > [href="${pathname}"]`) + ?.textContent + ?.trim()}` + } + else if (pathname.includes('/reviews')) { + presenceData.state = `Reading ${document + .querySelector( + `h2 > [href="${pathname.split('/').slice(0, 3).join('/')}"]`, + ) + ?.textContent + ?.trim()}'s reviews` + } + else if (pathname.includes('/discuss')) { + presenceData.details = `Reading ${document + .querySelector('h2') + ?.textContent + ?.trim()}` + } + else { + presenceData.details = 'Viewing TV shows' + } + } + else if (pathname.startsWith('/person')) { + if (pathname.split('/').length === 3) { + presenceData.details = `Viewing ${document + .querySelector(`h2 > [href="${pathname}"]`) + ?.textContent + ?.trim()}` + } + else { + presenceData.details = 'Viewing Popular People list' + } + } + else if (pathname.startsWith('/discuss')) { + presenceData.details = 'Viewing discussions' + } + else if (pathname.startsWith('/leaderboard')) { + presenceData.details = 'Viewing leaderboard' + } + else if (pathname.startsWith('/talk')) { + presenceData.details = 'Viewing TMDB support' + } + else if (pathname.startsWith('/search')) { + const query = document.querySelector('input')?.value + if (query && query.length > 0) + presenceData.details = `Searching for ${query}` + else presenceData.details = 'Searching' + } + else if (pathname.startsWith('/')) { + presenceData.details = 'Browsing TMDB' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/TOD/metadata.json b/websites/T/TOD/metadata.json index 5b7ed217a67b..af783aae05cb 100644 --- a/websites/T/TOD/metadata.json +++ b/websites/T/TOD/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "640526616350425100", - "name": "itswise" - }, - "service": "TOD", - "description": { - "en": "TOD is a video-streaming platform which includes a lot of movies, TV shows and matches provided by BeIN." - }, - "url": [ - "tod.tv", - "www.tod.tv" - ], - "version": "1.0.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TOD/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TOD/assets/thumbnail.jpeg", - "color": "#FEBC11", - "category": "videos", - "tags": [ - "tod", - "video", - "media", - "sports", - "matches" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "640526616350425100", + "name": "itswise" + }, + "service": "TOD", + "description": { + "en": "TOD is a video-streaming platform which includes a lot of movies, TV shows and matches provided by BeIN." + }, + "url": [ + "tod.tv", + "www.tod.tv" + ], + "version": "1.0.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TOD/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TOD/assets/thumbnail.jpeg", + "color": "#FEBC11", + "category": "videos", + "tags": [ + "tod", + "video", + "media", + "sports", + "matches" + ] +} diff --git a/websites/T/TOD/presence.ts b/websites/T/TOD/presence.ts index 994a4bcd85c0..043ecb0e2506 100644 --- a/websites/T/TOD/presence.ts +++ b/websites/T/TOD/presence.ts @@ -1,284 +1,289 @@ -const { href } = document.location; +const { href } = document.location class TOD extends Presence { - constructor(presenceOptions: PresenceOptions) { - super(presenceOptions); - } - - getVideo() { - return document.querySelector("video"); - } - - getVideoType() { - if ( - this.getVideoTitle().match(/S\d+\s*\|\s*E\d+/i) || - this.getVideoTitle().match(/EP\s*\d+/i) - ) - return "show"; - else return "movie"; - } - - getTitle(eyebrow = false) { - if (this.isWatching() && eyebrow) return this.getVideoTitle(); - - const title = document.querySelector( - "div.bein-dh1-hero__head-container > h1.bein-dh1-hero__title.heading-shadow" - )?.textContent; - - return ( - title ?? this.getVideoTitle()?.replace(/\d+\s*-\s*\d+/, "vs") ?? "Unknown" - ); - } - - getVideoTitle() { - return document.querySelector("div.diva-standard-title")?.textContent; - } - - isWatching() { - return !!this.getVideoTitle(); - } - - isLive() { - return !!document.querySelector("span.diva-live-now"); - } - - isTrailer() { - return this.getVideoTitle().includes("Trailer"); - } + constructor(presenceOptions: PresenceOptions) { + super(presenceOptions) + } + + getVideo() { + return document.querySelector('video') + } + + getVideoType() { + if ( + this.getVideoTitle()?.match(/S\d+\s*\|\s*E\d+/i) + || this.getVideoTitle()?.match(/EP\s*\d+/i) + ) { + return 'show' + } + else { + return 'movie' + } + } + + getTitle(eyebrow = false) { + if (this.isWatching() && eyebrow) + return this.getVideoTitle() + + const title = document.querySelector( + 'div.bein-dh1-hero__head-container > h1.bein-dh1-hero__title.heading-shadow', + )?.textContent + + return ( + title ?? this.getVideoTitle()?.replace(/\d+\s*-\s*\d+/, 'vs') ?? 'Unknown' + ) + } + + getVideoTitle() { + return document.querySelector('div.diva-standard-title')?.textContent + } + + isWatching() { + return !!this.getVideoTitle() + } + + isLive() { + return !!document.querySelector('span.diva-live-now') + } + + isTrailer() { + return this.getVideoTitle()?.includes('Trailer') + } } const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/TOD/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/TOD/assets/logo.png', } const presence = new TOD({ - clientId: "1229087342787039334", - }), - data: { - startedSince: number; - settings?: { - id: string; - delete?: boolean; - data: string[]; - }[]; - presence: { - [key: string]: { - setPresenceData?: () => void; - }; - }; - } = { - presence: {}, - startedSince: Math.floor(Date.now() / 1000), - }; - -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - type: ActivityType.Watching, - smallImageKey: Assets.Search, - smallImageText: "Browsing", - largeImageKey: Assets.Logo, - details: "Browsing...", - startTimestamp: data.startedSince, - }; - - data.presence = { - "/movie/([a-zA-Z0-9-]+)": { - setPresenceData() { - if (presence.isWatching()) { - const video = presence.getVideo(); - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - - if (presence.isTrailer()) { - presenceData.details = "Watching a trailer"; - presenceData.state = presence.getVideoTitle().replace(/- (.+)/, ""); - - presenceData.smallImageText = video.paused ? "Paused" : "Playing"; - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Play; - - presenceData.buttons = [ - { - label: "Watch Trailer", - url: href, - }, - ]; - } else { - presenceData.details = `Watching ${presence.getVideoType()}`; - presenceData.state = presence.getVideoTitle(); - - presenceData.smallImageText = video.paused ? "Paused" : "Playing"; - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Play; - - presenceData.buttons = [ - { - label: `Watch ${ - presence.getVideoType() === "show" ? "Show" : "Movie" - }`, - url: href, - }, - ]; - } - - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else { - (presenceData.details = `Viewing ${ - presence.getVideoType() === "show" ? "Show" : "Movie" - }:`), - (presenceData.state = presence.getVideoTitle().replace(/(.+)/, "")); - - presenceData.buttons = [ - { - label: `View ${ - presence.getVideoType() === "show" ? "Show" : "Movie" - }:`, - url: href, - }, - ]; - } - }, - }, - "/watch/(soccer|multisports)-([a-zA-Z0-9-]+)": { - setPresenceData() { - if (presence.isWatching()) { - const video = presence.getVideo(); - if (presence.isLive()) { - presenceData.smallImageText = video.paused ? "Paused" : "Live"; - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Live; - } else { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - - presenceData.smallImageText = video.paused ? "Paused" : "Playing"; - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Play; - } - - presenceData.details = presence.getTitle(); - presenceData.state = "Match"; - - presenceData.buttons = [ - { - label: "Watch Match", - url: href, - }, - ]; - - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else { - presenceData.details = "Watching match:"; - presenceData.state = presence.getTitle(); - - presenceData.buttons = [ - { - label: "Watch Match", - url: href, - }, - ]; - } - }, - }, - "/sports/event/soccer-([a-zA-Z0-9-]+)": { - setPresenceData() { - if (presence.isWatching()) { - const video = presence.getVideo(); - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - - presenceData.details = presence.getTitle(); - presenceData.state = "Match"; - - presenceData.smallImageText = video.paused ? "Paused" : "Playing"; - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Play; - - presenceData.buttons = [ - { - label: "Preview Match", - url: href, - }, - ]; - - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else { - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = "Viewing"; - presenceData.details = "Previewing match:"; - presenceData.state = presence.getTitle(); - - presenceData.buttons = [ - { - label: "Preview Match", - url: href, - }, - ]; - } - }, - }, - "/account": { - setPresenceData() { - presenceData.details = "Viewing their settings"; - }, - }, - }; - - data.settings = [ - { - id: "timestamp", - data: ["startTimestamp", "endTimestamp"], - }, - { - id: "buttons", - data: ["buttons"], - }, - { - id: "smallImage", - data: ["smallImageKey"], - }, - ]; - - let presenceSelect; - - for (const [pathname, PData] of Object.entries(data.presence)) { - if (new RegExp(pathname).test(document.location.pathname)) { - presenceSelect = pathname; - PData.setPresenceData(); - } - } - - if (!presenceSelect && presence.isWatching()) { - const presenceKey = - presence.getVideoType() === "movie" || presence.getVideoType() === "show" - ? "/movie/([a-zA-Z0-9-]+)" - : "Unknown"; - data.presence[presenceKey].setPresenceData(); - } - - for (const setting of data.settings) { - const settingValue = await presence.getSetting(setting.id); - - if (!settingValue) { - for (const PData of setting.data) - delete presenceData[PData as keyof PresenceData]; - } - } - - presence.setActivity(presenceData); -}); + clientId: '1229087342787039334', +}) +const data: { + startedSince: number + settings?: { + id: string + delete?: boolean + data: string[] + }[] + presence: { + [key: string]: { + setPresenceData?: () => void + } + } +} = { + presence: {}, + startedSince: Math.floor(Date.now() / 1000), +} + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + type: ActivityType.Watching, + smallImageKey: Assets.Search, + smallImageText: 'Browsing', + largeImageKey: Assets.Logo, + details: 'Browsing...', + startTimestamp: data.startedSince, + } + + data.presence = { + '/movie/([a-zA-Z0-9-]+)': { + setPresenceData() { + if (presence.isWatching()) { + const video = presence.getVideo()!; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + + if (presence.isTrailer()) { + presenceData.details = 'Watching a trailer' + presenceData.state = presence.getVideoTitle()?.replace(/- (.+)/, '') + + presenceData.smallImageText = video.paused ? 'Paused' : 'Playing' + presenceData.smallImageKey = video.paused + ? Assets.Pause + : Assets.Play + + presenceData.buttons = [ + { + label: 'Watch Trailer', + url: href, + }, + ] + } + else { + presenceData.details = `Watching ${presence.getVideoType()}` + presenceData.state = presence.getVideoTitle() + + presenceData.smallImageText = video.paused ? 'Paused' : 'Playing' + presenceData.smallImageKey = video.paused + ? Assets.Pause + : Assets.Play + + presenceData.buttons = [ + { + label: `Watch ${ + presence.getVideoType() === 'show' ? 'Show' : 'Movie' + }`, + url: href, + }, + ] + } + + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else { + presenceData.details = `Viewing ${ + presence.getVideoType() === 'show' ? 'Show' : 'Movie' + }:` + presenceData.state = presence.getVideoTitle()?.replace(/(.+)/, '') + + presenceData.buttons = [ + { + label: `View ${ + presence.getVideoType() === 'show' ? 'Show' : 'Movie' + }:`, + url: href, + }, + ] + } + }, + }, + '/watch/(soccer|multisports)-([a-zA-Z0-9-]+)': { + setPresenceData() { + if (presence.isWatching()) { + const video = presence.getVideo()! + if (presence.isLive()) { + presenceData.smallImageText = video.paused ? 'Paused' : 'Live' + presenceData.smallImageKey = video.paused + ? Assets.Pause + : Assets.Live + } + else { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + + presenceData.smallImageText = video.paused ? 'Paused' : 'Playing' + presenceData.smallImageKey = video.paused + ? Assets.Pause + : Assets.Play + } + + presenceData.details = presence.getTitle() + presenceData.state = 'Match' + + presenceData.buttons = [ + { + label: 'Watch Match', + url: href, + }, + ] + + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else { + presenceData.details = 'Watching match:' + presenceData.state = presence.getTitle() + + presenceData.buttons = [ + { + label: 'Watch Match', + url: href, + }, + ] + } + }, + }, + '/sports/event/soccer-([a-zA-Z0-9-]+)': { + setPresenceData() { + if (presence.isWatching()) { + const video = presence.getVideo()!; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + + presenceData.details = presence.getTitle() + presenceData.state = 'Match' + + presenceData.smallImageText = video.paused ? 'Paused' : 'Playing' + presenceData.smallImageKey = video.paused + ? Assets.Pause + : Assets.Play + + presenceData.buttons = [ + { + label: 'Preview Match', + url: href, + }, + ] + + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else { + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = 'Viewing' + presenceData.details = 'Previewing match:' + presenceData.state = presence.getTitle() + + presenceData.buttons = [ + { + label: 'Preview Match', + url: href, + }, + ] + } + }, + }, + '/account': { + setPresenceData() { + presenceData.details = 'Viewing their settings' + }, + }, + } + + data.settings = [ + { + id: 'timestamp', + data: ['startTimestamp', 'endTimestamp'], + }, + { + id: 'buttons', + data: ['buttons'], + }, + { + id: 'smallImage', + data: ['smallImageKey'], + }, + ] + + let presenceSelect + + for (const [pathname, PData] of Object.entries(data.presence)) { + if (new RegExp(pathname).test(document.location.pathname)) { + presenceSelect = pathname + PData?.setPresenceData?.() + } + } + + if (!presenceSelect && presence.isWatching()) { + const presenceKey = presence.getVideoType() === 'movie' || presence.getVideoType() === 'show' + ? '/movie/([a-zA-Z0-9-]+)' + : 'Unknown' + data.presence[presenceKey]?.setPresenceData?.() + } + + for (const setting of data.settings) { + const settingValue = await presence.getSetting(setting.id) + + if (!settingValue) { + for (const PData of setting.data) + delete presenceData[PData as keyof PresenceData] + } + } + + presence.setActivity(presenceData) +}) diff --git a/websites/T/TRanimeizle/iframe.ts b/websites/T/TRanimeizle/iframe.ts index f7b6932a2905..27e62d55e0b6 100644 --- a/websites/T/TRanimeizle/iframe.ts +++ b/websites/T/TRanimeizle/iframe.ts @@ -1,13 +1,13 @@ -const TRanimeizleIframe = new iFrame(); +const TRanimeizleIframe = new iFrame() -TRanimeizleIframe.on("UpdateData", () => { - const video: HTMLVideoElement = document.querySelector("video"); +TRanimeizleIframe.on('UpdateData', () => { + const video = document.querySelector('video') - if (video && !isNaN(video.duration)) { - TRanimeizleIframe.send({ - duration: video.duration, - currentTime: video.currentTime, - paused: video.paused, - }); - } -}); + if (video && !Number.isNaN(video.duration)) { + TRanimeizleIframe.send({ + duration: video.duration, + currentTime: video.currentTime, + paused: video.paused, + }) + } +}) diff --git a/websites/T/TRanimeizle/presence.ts b/websites/T/TRanimeizle/presence.ts index a5fab1b6c870..7966955e5be9 100644 --- a/websites/T/TRanimeizle/presence.ts +++ b/websites/T/TRanimeizle/presence.ts @@ -1,110 +1,117 @@ const presence = new Presence({ - clientId: "819994268801957899", - }), - pages: { [k: string]: string } = { - "/": "Ana Sayfa", - "/haberler": "Haberler", - "/ekipAlimi/translator": "Çevirmen Alımı", - "/ekipAlimi/uploader": "Yükleyici Alımı", - "/ekipAlimi/encoder": "Encoder Alımı", - "/ekipAlimi/editor": "Editör Alımı", - "/iletisim": "İletişim", - "/Account/Login": "Giriş Yap", - "/Account/Register": "Kayıt Ol", - }, - strings = presence.getStrings( - { - play: "general.playing", - pause: "general.paused", - }, - "tr" - ); + clientId: '819994268801957899', +}) +const pages: { [k: string]: string } = { + '/': 'Ana Sayfa', + '/haberler': 'Haberler', + '/ekipAlimi/translator': 'Çevirmen Alımı', + '/ekipAlimi/uploader': 'Yükleyici Alımı', + '/ekipAlimi/encoder': 'Encoder Alımı', + '/ekipAlimi/editor': 'Editör Alımı', + '/iletisim': 'İletişim', + '/Account/Login': 'Giriş Yap', + '/Account/Register': 'Kayıt Ol', +} +const strings = presence.getStrings( + { + play: 'general.playing', + pause: 'general.paused', + }, + 'tr', +) interface iframeData { - duration: number; - currentTime: number; - paused: boolean; + duration: number + currentTime: number + paused: boolean } -let video: iframeData; -presence.on("iFrameData", (data: iframeData) => { - if (data) video = data; -}); +let video: iframeData +presence.on('iFrameData', (data: unknown) => { + if (data) + video = data as iframeData +}) -const startTimestamp = Math.floor(Date.now() / 1000); -presence.on("UpdateData", async () => { - const page: string = location.pathname, - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TRanimeizle/assets/logo.png", - startTimestamp, - }; +const startTimestamp = Math.floor(Date.now() / 1000) +presence.on('UpdateData', async () => { + const page: string = location.pathname + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TRanimeizle/assets/logo.png', + startTimestamp, + } - if (page.includes("/arama/")) { - presenceData.details = "Bir şey arıyor:"; - presenceData.state = document - .querySelector(".post-head .title strong") - ?.textContent.replaceAll('"', ""); - presenceData.smallImageKey = Assets.Search; - } else if (page.includes("/harfler/")) { - const letter = document.querySelector( - ".post-head .title strong" - )?.textContent; + if (page.includes('/arama/')) { + presenceData.details = 'Bir şey arıyor:' + presenceData.state = document + .querySelector('.post-head .title strong') + ?.textContent + ?.replaceAll('"', '') + presenceData.smallImageKey = Assets.Search + } + else if (page.includes('/harfler/')) { + const letter = document.querySelector( + '.post-head .title strong', + )?.textContent - presenceData.details = "Bir harfe göz atıyor:"; - presenceData.state = letter ? `Harf: ${letter}` : "Bilinmeyen Harf"; - } else if (page.includes("/tur/")) { - presenceData.details = "Bir kategoriye göz atıyor:"; - presenceData.state = - document.querySelector(".post-head .title strong")?.textContent ?? - "Bilinmeyen Kategori"; - } else if (page.includes("/anime/")) { - presenceData.details = "Bir animeye göz atıyor:"; - presenceData.state = document - .querySelector(".container .playlist-title h1") - ?.textContent?.replace("İzle", ""); - } else if (page.includes("/haberler/")) { - presenceData.details = - document.querySelector(".post-header h1")?.textContent ?? - "Bilinmeyen Gönderi"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Bir gönderi okuyor"; - } else if (page.includes("/BanaOzel/")) { - presenceData.details = "Bir listeye göz atıyor:"; - presenceData.state = - document.querySelector(".post-head .title")?.textContent ?? - "Bilinmeyen Liste"; - } else if (Object.keys(video || {}).length > 0) { - // Set timestamps - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(video.currentTime, video.duration); + presenceData.details = 'Bir harfe göz atıyor:' + presenceData.state = letter ? `Harf: ${letter}` : 'Bilinmeyen Harf' + } + else if (page.includes('/tur/')) { + presenceData.details = 'Bir kategoriye göz atıyor:' + presenceData.state = document.querySelector('.post-head .title strong')?.textContent + ?? 'Bilinmeyen Kategori' + } + else if (page.includes('/anime/')) { + presenceData.details = 'Bir animeye göz atıyor:' + presenceData.state = document + .querySelector('.container .playlist-title h1') + ?.textContent + ?.replace('İzle', '') + } + else if (page.includes('/haberler/')) { + presenceData.details = document.querySelector('.post-header h1')?.textContent + ?? 'Bilinmeyen Gönderi' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Bir gönderi okuyor' + } + else if (page.includes('/BanaOzel/')) { + presenceData.details = 'Bir listeye göz atıyor:' + presenceData.state = document.querySelector('.post-head .title')?.textContent + ?? 'Bilinmeyen Liste' + } + else if (Object.keys(video || {}).length > 0) { + // Set timestamps + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(video.currentTime, video.duration) - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } - presenceData.buttons = [ - { - label: "Bölümü İzle", - url: location.href, - }, - ]; + presenceData.buttons = [ + { + label: 'Bölümü İzle', + url: location.href, + }, + ] - // Set playing/paused text - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? (await strings).pause - : (await strings).play; + // Set playing/paused text + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? (await strings).pause + : (await strings).play - presenceData.state = document - .querySelector(".container .playlist-title h1") - ?.textContent?.replace("İzle", ""); - } else if (pages[page] || pages[page.slice(0, -1)]) { - presenceData.details = "Bir sayfaya göz atıyor:"; - presenceData.state = pages[page] || pages[page.slice(0, -1)]; - } + presenceData.state = document + .querySelector('.container .playlist-title h1') + ?.textContent + ?.replace('İzle', '') + } + else if (pages[page] || pages[page.slice(0, -1)]) { + presenceData.details = 'Bir sayfaya göz atıyor:' + presenceData.state = pages[page] || pages[page.slice(0, -1)] + } - if (Object.keys(presenceData).length > 2) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (Object.keys(presenceData).length > 2) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TV Time/metadata.json b/websites/T/TV Time/metadata.json index 744a5e1df6c2..addd6a61abc6 100644 --- a/websites/T/TV Time/metadata.json +++ b/websites/T/TV Time/metadata.json @@ -1,56 +1,56 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dark_Ville", - "id": "638080361179512853" - }, - "contributors": [ - { - "name": "Alexx", - "id": "604182077088202784" - } - ], - "service": "TV Time", - "description": { - "en": "TV Time is an online service centered exclusively on television series. It enables users to get information and comment on the shows they follow, featuring various segments of information related to them, such as new episodes release dates, and various options based on user reaction.", - "nl": "TV Time is een online dienst die uitsluitend gericht is op televisieseries. Het stelt gebruikers in staat om informatie te krijgen en commentaar te geven op de shows die ze volgen, met verschillende informatie-segmenten die aan hen gerelateerd zijn, zoals releasedatums van nieuwe afleveringen en verschillende opties op basis van de reactie van de gebruiker." - }, - "url": "www.tvtime.com", - "version": "1.3.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TV%20Time/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TV%20Time/assets/thumbnail.png", - "color": "#FDDF39", - "category": "other", - "tags": [ - "tvtime", - "movies", - "shows" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fas fa-user-secret", - "value": false - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true, - "if": { - "privacy": false - } - }, - { - "id": "covers", - "title": "Show Cover", - "icon": "fad fa-images", - "value": true, - "if": { - "privacy": false - } - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dark_Ville", + "id": "638080361179512853" + }, + "contributors": [ + { + "name": "Alexx", + "id": "604182077088202784" + } + ], + "service": "TV Time", + "description": { + "en": "TV Time is an online service centered exclusively on television series. It enables users to get information and comment on the shows they follow, featuring various segments of information related to them, such as new episodes release dates, and various options based on user reaction.", + "nl": "TV Time is een online dienst die uitsluitend gericht is op televisieseries. Het stelt gebruikers in staat om informatie te krijgen en commentaar te geven op de shows die ze volgen, met verschillende informatie-segmenten die aan hen gerelateerd zijn, zoals releasedatums van nieuwe afleveringen en verschillende opties op basis van de reactie van de gebruiker." + }, + "url": "www.tvtime.com", + "version": "1.3.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TV%20Time/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TV%20Time/assets/thumbnail.png", + "color": "#FDDF39", + "category": "other", + "tags": [ + "tvtime", + "movies", + "shows" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fas fa-user-secret", + "value": false + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true, + "if": { + "privacy": false + } + }, + { + "id": "covers", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true, + "if": { + "privacy": false + } + } + ] +} diff --git a/websites/T/TV Time/presence.ts b/websites/T/TV Time/presence.ts index 9dc840484388..566d6fa07ba5 100644 --- a/websites/T/TV Time/presence.ts +++ b/websites/T/TV Time/presence.ts @@ -1,192 +1,206 @@ const presence = new Presence({ - clientId: "844109006679179265", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '844109006679179265', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/TV%20Time/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/TV%20Time/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { href, pathname } = document.location, - [privacy, buttons, covers] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("buttons"), - presence.getSetting("covers"), - ]), - title = document.querySelector( - '[property="og:title"]' - )?.content, - search = document.querySelector( - '[id="global-search-input"]' - ), - splitPathname = pathname.split("/"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { href, pathname } = document.location + const [privacy, buttons, covers] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('buttons'), + presence.getSetting('covers'), + ]) + const title = document.querySelector( + '[property="og:title"]', + )?.content + const search = document.querySelector( + '[id="global-search-input"]', + ) + const splitPathname = pathname.split('/') - if (privacy) presenceData.details = "Browsing"; - else if (search?.value) { - presenceData.details = "Searching for"; - presenceData.state = search?.value; - presenceData.smallImageKey = Assets.Search; - } else if ( - pathname === `/${document.querySelector("html").getAttribute("lang")}` - ) - presenceData.details = "Viewing watchlist"; - else { - switch (splitPathname[2]) { - case "show": { - switch (splitPathname[3]) { - case "explore": { - if (!document.querySelector('[id="shows-results"]')) { - presenceData.details = "Exploring Shows"; - presenceData.buttons = [ - { - label: "Explore Shows", - url: href, - }, - ]; - } else { - presenceData.details = "Viewing search results for"; - presenceData.state = document - .querySelector('[id="shows-results"]') - .textContent.split('"')[1]; - } - break; - } - case "browse": { - const hrefSplit = href - .split("?")[1] - .replace("filter=", "") - .replace(/_/gm, " "); - presenceData.details = "Viewing shows filtered by"; - presenceData.state = `${hrefSplit - .at(0) - .toUpperCase()}${hrefSplit.slice(1)}`; - break; - } - default: { - presenceData.details = "Viewing"; - presenceData.state = title; - presenceData.largeImageKey = - document - .querySelector('img[src*="/poster/"]') - ?.getAttribute("src") ?? - document - .querySelector('[property="og:image"]') - ?.getAttribute("content") ?? - Assets.Logo; - if (title.match(/S[0-9]*E[0-9]/gm)) { - presenceData.buttons = [ - { - label: "View Episode", - url: href, - }, - ]; - } else { - presenceData.buttons = [ - { - label: "View Show", - url: href, - }, - ]; - } - break; - } - } - break; - } - case "actor": { - presenceData.details = "Viewing"; - presenceData.state = title; - presenceData.largeImageKey = - document - .querySelector('[property="og:image"]') - ?.getAttribute("content") ?? Assets.Logo; - presenceData.buttons = [ - { - label: "View Actor", - url: href, - }, - ]; - break; - } - case "upcoming": { - presenceData.details = "Viewing upcoming shows"; - presenceData.buttons = [ - { - label: "View Upcoming Shows", - url: href, - }, - ]; - break; - } - case "explore": { - if (!document.querySelector('[id="shows-results"]')) { - presenceData.details = "Exploring Shows"; - presenceData.buttons = [ - { - label: "Explore Shows", - url: href, - }, - ]; - } else { - presenceData.details = "Viewing search results for"; - presenceData.state = document - .querySelector('[id="shows-results"]') - .textContent.split('"')[1]; - } - break; - } - case "user": { - switch (splitPathname[4]) { - case "profile": { - presenceData.details = `Viewing ${title}'s ${ - document - .querySelector('[class="profile-nav"]') - .querySelector('[class*="active"]')?.textContent ?? "Profile" - }`; - presenceData.largeImageKey = - document - .querySelector('[class="avatar"]') - ?.firstElementChild?.firstElementChild?.getAttribute("src") ?? - document - .querySelector('[class="avatar"]') - ?.firstElementChild?.getAttribute("src"); - break; - } - case "calendar": { - presenceData.details = "Viewing Calendar for"; - presenceData.state = `${ - document.querySelector('[class="month-label"]').textContent - } ${ - document.querySelector('[class="day-number"]').textContent - } (${document - .querySelector('[class="relative-date"]') - .textContent.trim()})`; - presenceData.buttons = [ - { - label: "View Calendar", - url: href, - }, - ]; - break; - } - case "account": { - presenceData.details = `Managing ${ - document.querySelector('[class*="active"]').textContent - } account settings`; - break; - } - } - break; - } - } - } - if (!covers) presenceData.largeImageKey = Assets.Logo; - if (!buttons) delete presenceData.buttons; - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (privacy) { + presenceData.details = 'Browsing' + } + else if (search?.value) { + presenceData.details = 'Searching for' + presenceData.state = search?.value + presenceData.smallImageKey = Assets.Search + } + else if ( + pathname === `/${document.querySelector('html')?.getAttribute('lang')}` + ) { + presenceData.details = 'Viewing watchlist' + } + else { + switch (splitPathname[2]) { + case 'show': { + switch (splitPathname[3]) { + case 'explore': { + if (!document.querySelector('[id="shows-results"]')) { + presenceData.details = 'Exploring Shows' + presenceData.buttons = [ + { + label: 'Explore Shows', + url: href, + }, + ] + } + else { + presenceData.details = 'Viewing search results for' + presenceData.state = document + .querySelector('[id="shows-results"]') + ?.textContent + ?.split('"')[1] + } + break + } + case 'browse': { + const hrefSplit = href + .split('?')[1] + .replace('filter=', '') + .replace(/_/g, ' ') + presenceData.details = 'Viewing shows filtered by' + presenceData.state = `${hrefSplit + ?.at(0) + ?.toUpperCase()}${hrefSplit?.slice(1)}` + break + } + default: { + presenceData.details = 'Viewing' + presenceData.state = title + presenceData.largeImageKey = document + .querySelector('img[src*="/poster/"]') + ?.getAttribute('src') + ?? document + .querySelector('[property="og:image"]') + ?.getAttribute('content') + ?? Assets.Logo + if (title?.match(/S\d*E\d/g)) { + presenceData.buttons = [ + { + label: 'View Episode', + url: href, + }, + ] + } + else { + presenceData.buttons = [ + { + label: 'View Show', + url: href, + }, + ] + } + break + } + } + break + } + case 'actor': { + presenceData.details = 'Viewing' + presenceData.state = title + presenceData.largeImageKey = document + .querySelector('[property="og:image"]') + ?.getAttribute('content') ?? Assets.Logo + presenceData.buttons = [ + { + label: 'View Actor', + url: href, + }, + ] + break + } + case 'upcoming': { + presenceData.details = 'Viewing upcoming shows' + presenceData.buttons = [ + { + label: 'View Upcoming Shows', + url: href, + }, + ] + break + } + case 'explore': { + if (!document.querySelector('[id="shows-results"]')) { + presenceData.details = 'Exploring Shows' + presenceData.buttons = [ + { + label: 'Explore Shows', + url: href, + }, + ] + } + else { + presenceData.details = 'Viewing search results for' + presenceData.state = document + .querySelector('[id="shows-results"]') + ?.textContent + ?.split('"')[1] + } + break + } + case 'user': { + switch (splitPathname[4]) { + case 'profile': { + presenceData.details = `Viewing ${title}'s ${ + document + .querySelector('[class="profile-nav"]') + ?.querySelector('[class*="active"]') + ?.textContent ?? 'Profile' + }` + presenceData.largeImageKey = document + .querySelector('[class="avatar"]') + ?.firstElementChild + ?.firstElementChild + ?.getAttribute('src') + ?? document + .querySelector('[class="avatar"]') + ?.firstElementChild + ?.getAttribute('src') + break + } + case 'calendar': { + presenceData.details = 'Viewing Calendar for' + presenceData.state = `${ + document.querySelector('[class="month-label"]')?.textContent + } ${ + document.querySelector('[class="day-number"]')?.textContent + } (${document + .querySelector('[class="relative-date"]') + ?.textContent + ?.trim()})` + presenceData.buttons = [ + { + label: 'View Calendar', + url: href, + }, + ] + break + } + case 'account': { + presenceData.details = `Managing ${ + document.querySelector('[class*="active"]')?.textContent + } account settings` + break + } + } + break + } + } + } + if (!covers) + presenceData.largeImageKey = Assets.Logo + if (!buttons) + delete presenceData.buttons + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TV Tropes/metadata.json b/websites/T/TV Tropes/metadata.json index 4687e2fd1f85..aac149193a9c 100644 --- a/websites/T/TV Tropes/metadata.json +++ b/websites/T/TV Tropes/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "theusaf", - "id": "193714715631812608" - }, - "service": "TV Tropes", - "description": { - "en": "TV Tropes, the all-devouring pop-culture wiki, catalogs and cross-references recurrent plot devices, archetypes, and tropes in all forms of media." - }, - "url": "tvtropes.org", - "version": "1.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TV%20Tropes/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TV%20Tropes/assets/thumbnail.png", - "color": "#28323C", - "category": "other", - "tags": [ - "wiki", - "pop-culture", - "catalog" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "theusaf", + "id": "193714715631812608" + }, + "service": "TV Tropes", + "description": { + "en": "TV Tropes, the all-devouring pop-culture wiki, catalogs and cross-references recurrent plot devices, archetypes, and tropes in all forms of media." + }, + "url": "tvtropes.org", + "version": "1.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TV%20Tropes/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TV%20Tropes/assets/thumbnail.png", + "color": "#28323C", + "category": "other", + "tags": [ + "wiki", + "pop-culture", + "catalog" + ] +} diff --git a/websites/T/TV Tropes/presence.ts b/websites/T/TV Tropes/presence.ts index b70f2c513ac5..ac7fbacae442 100644 --- a/websites/T/TV Tropes/presence.ts +++ b/websites/T/TV Tropes/presence.ts @@ -1,85 +1,95 @@ const presence = new Presence({ - clientId: "864573021762224129", - }), - startTimestamp = Math.floor(Date.now() / 1e3), - whitespaceRegex = /^\s*|\n/gm; + clientId: '864573021762224129', +}) +const startTimestamp = Math.floor(Date.now() / 1e3) +const whitespaceRegex = /^\s*|\n/gm -presence.on("UpdateData", () => { - const [, pathCheck, mainPath, namespace] = - window.location.pathname.split("/"), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TV%20Tropes/assets/logo.png", - startTimestamp, - }; +presence.on('UpdateData', () => { + const [, pathCheck, mainPath, namespace] = window.location.pathname.split('/') + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TV%20Tropes/assets/logo.png', + startTimestamp, + } - function mainWikiPathDetails(namespace: string) { - if (namespace === "Main") { - presenceData.details = "Viewing a TV Trope"; - presenceData.state = document - .querySelector(".entry-title") - .textContent.replace(whitespaceRegex, ""); - } else { - const titleElement = document.querySelector(".entry-title"); - presenceData.details = "Viewing a page"; - presenceData.state = `${titleElement - .querySelector("strong") - .textContent.replace( - / \/ $/, - "" - )} / ${titleElement.childNodes[2].textContent.replace( - whitespaceRegex, - "" - )}`; - } - } + function mainWikiPathDetails(namespace: string) { + if (namespace === 'Main') { + presenceData.details = 'Viewing a TV Trope' + presenceData.state = document + .querySelector('.entry-title') + ?.textContent + ?.replace(whitespaceRegex, '') + } + else { + const titleElement = document.querySelector('.entry-title') + presenceData.details = 'Viewing a page' + presenceData.state = `${titleElement + ?.querySelector('strong') + ?.textContent + ?.replace( + / \/ $/, + '', + )} / ${titleElement?.childNodes[2]?.textContent?.replace( + whitespaceRegex, + '', + )}` + } + } - if (pathCheck === "pmwiki") { - switch (mainPath) { - case "pmwiki.php": { - mainWikiPathDetails(namespace); - break; - } - case "profile.php": { - presenceData.details = "Viewing User Profile"; - break; - } - case "topics.php": { - presenceData.details = "Browsing the Forum Homepage"; - break; - } - case "conversations.php": { - presenceData.details = "Browsing Forum Category"; - presenceData.state = document - .querySelector(".entry-title") - .childNodes[2].textContent.replace(whitespaceRegex, ""); - break; - } - case "posts.php": { - presenceData.details = "Browsing Forum Post"; - presenceData.state = document - .querySelector(".entry-title") - .textContent.replace(whitespaceRegex, ""); - break; - } - case "wysiwyg_source_editor.php": { - const searchParams = new URLSearchParams(window.location.search); - presenceData.details = "Editing TV Trope Page"; - presenceData.state = `${searchParams.get( - "groupname" - )} / ${searchParams.get("title")}`; - break; - } - case "createconversation.php": { - presenceData.details = "Creating a Forum Post"; - break; - } - default: { - presenceData.details = "Browsing TV Tropes"; - presenceData.state = document.title; - } - } - } else if (pathCheck) mainWikiPathDetails(pathCheck); - else presenceData.details = "Browsing TV Tropes Homepage"; - if (presenceData.details) presence.setActivity(presenceData); -}); + if (pathCheck === 'pmwiki') { + switch (mainPath) { + case 'pmwiki.php': { + mainWikiPathDetails(namespace) + break + } + case 'profile.php': { + presenceData.details = 'Viewing User Profile' + break + } + case 'topics.php': { + presenceData.details = 'Browsing the Forum Homepage' + break + } + case 'conversations.php': { + presenceData.details = 'Browsing Forum Category' + presenceData.state = document + .querySelector('.entry-title') + ?.childNodes[2] + ?.textContent + ?.replace(whitespaceRegex, '') + break + } + case 'posts.php': { + presenceData.details = 'Browsing Forum Post' + presenceData.state = document + .querySelector('.entry-title') + ?.textContent + ?.replace(whitespaceRegex, '') + break + } + case 'wysiwyg_source_editor.php': { + const searchParams = new URLSearchParams(window.location.search) + presenceData.details = 'Editing TV Trope Page' + presenceData.state = `${searchParams.get( + 'groupname', + )} / ${searchParams.get('title')}` + break + } + case 'createconversation.php': { + presenceData.details = 'Creating a Forum Post' + break + } + default: { + presenceData.details = 'Browsing TV Tropes' + presenceData.state = document.title + } + } + } + else if (pathCheck) { + mainWikiPathDetails(pathCheck) + } + else { + presenceData.details = 'Browsing TV Tropes Homepage' + } + if (presenceData.details) + presence.setActivity(presenceData) +}) diff --git a/websites/T/TVING/metadata.json b/websites/T/TVING/metadata.json index 6cd858ca4da4..ab21583b9deb 100644 --- a/websites/T/TVING/metadata.json +++ b/websites/T/TVING/metadata.json @@ -1,40 +1,40 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Slowlfie", - "id": "374905512661221377" - }, - "service": "TVING", - "altnames": [ - "티빙" - ], - "description": { - "en": "Stream now from the tibbing originals to the latest popular dramas, entertainment and exclusive movies from tvN, JTBC, Mnet, OCN and more.", - "ko_KR": "티빙 오리지널부터 tvN, JTBC, Mnet, OCN 등 최신 인기 드라마와 예능, 독점 영화까지 지금 스트리밍하세요." - }, - "url": "www.tving.com", - "version": "1.0.16", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TVING/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TVING/assets/thumbnail.png", - "color": "#FF143C", - "category": "videos", - "tags": [ - "시리즈", - "영화" - ], - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - }, - { - "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": "Slowlfie", + "id": "374905512661221377" + }, + "service": "TVING", + "altnames": [ + "티빙" + ], + "description": { + "en": "Stream now from the tibbing originals to the latest popular dramas, entertainment and exclusive movies from tvN, JTBC, Mnet, OCN and more.", + "ko_KR": "티빙 오리지널부터 tvN, JTBC, Mnet, OCN 등 최신 인기 드라마와 예능, 독점 영화까지 지금 스트리밍하세요." + }, + "url": "www.tving.com", + "version": "1.0.16", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TVING/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TVING/assets/thumbnail.png", + "color": "#FF143C", + "category": "videos", + "tags": [ + "시리즈", + "영화" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + }, + { + "id": "cover", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true + } + ] +} diff --git a/websites/T/TVING/presence.ts b/websites/T/TVING/presence.ts index 40231a26d35a..248a729652d0 100644 --- a/websites/T/TVING/presence.ts +++ b/websites/T/TVING/presence.ts @@ -1,128 +1,134 @@ const presence = new Presence({ - clientId: "831432191120375829", - }), - browsingTimestamp = Date.now() / 1000, - shortenedURLs: Record = {}; + clientId: '831432191120375829', +}) +const browsingTimestamp = Date.now() / 1000 +const shortenedURLs: Record = {} async function getShortURL(url: string) { - if (!url || url.length < 256) return url; - if (shortenedURLs[url]) return shortenedURLs[url]; - try { - const pdURL = await ( - await fetch(`https://pd.premid.app/create/${url}`) - ).text(); - shortenedURLs[url] = pdURL; - return pdURL; - } catch (err) { - presence.error(err); - return url; - } + if (!url || url.length < 256) + return url + if (shortenedURLs[url]) + return shortenedURLs[url] + try { + const pdURL = await ( + await fetch(`https://pd.premid.app/create/${url}`) + ).text() + shortenedURLs[url] = pdURL + return pdURL + } + catch (err) { + presence.error(err as string) + return url + } } -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/T/TVING/assets/logo.png", - smallImageKey: Assets.Search, - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TVING/assets/logo.png', + smallImageKey: Assets.Search, + startTimestamp: browsingTimestamp, + } - const [buttons, cover] = await Promise.all([ - presence.getSetting("buttons"), - presence.getSetting("cover"), - ]), - pages: Record< - string, - | PresenceData - | ((video?: HTMLVideoElement) => PresenceData | Promise) - > = { - "/(vod|movie)/player/": async video => { - const data: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TVING/assets/logo.png", - }; + const [buttons, cover] = await Promise.all([ + presence.getSetting('buttons'), + presence.getSetting('cover'), + ]) + const pages: Record< + string, + | PresenceData + | ((video?: HTMLVideoElement) => PresenceData | undefined | Promise) + > = { + '/(vod|movie)/player/': async (video) => { + const data: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TVING/assets/logo.png', + } - if (video) { - const title = [ - document.querySelector(".program-detail > h3").textContent.trim(), - document.querySelector(".title").textContent.trim(), - ], - coverUrl = ( - document.querySelector(".tags") - .nextElementSibling as HTMLImageElement - ).src; + if (video) { + const title = [ + document.querySelector('.program-detail > h3')?.textContent?.trim(), + document.querySelector('.title')?.textContent?.trim(), + ] + const coverUrl = ( + document.querySelector('.tags') + ?.nextElementSibling as HTMLImageElement + )?.src - data.details = title[1]; - data.state = !location.pathname.includes("/movie/") - ? title[0].replace(title[1], "").trim() - : "영화"; + data.details = title[1] + data.state = !location.pathname.includes('/movie/') + ? title[0]?.replace(title[1] ?? '', '').trim() + : '영화' - data.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - data.smallImageText = video.paused ? "Paused" : "Playing"; + data.smallImageKey = video.paused ? Assets.Pause : Assets.Play + data.smallImageText = video.paused ? 'Paused' : 'Playing' - if (cover && coverUrl) { - data.largeImageKey = await getShortURL(coverUrl); - data.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - } + if (cover && coverUrl) { + data.largeImageKey = await getShortURL(coverUrl) + data.smallImageKey = video.paused ? Assets.Pause : Assets.Play + } - if (!video.paused) { - [data.startTimestamp, data.endTimestamp] = - presence.getTimestampsfromMedia(video); - } + if (!video.paused) { + [data.startTimestamp, data.endTimestamp] = presence.getTimestampsfromMedia(video) + } - data.buttons = [ - { - label: !location.pathname.includes("/movie/") - ? "시리즈 보기" - : "영화 보기", - url: document.URL, - }, - ]; + data.buttons = [ + { + label: !location.pathname.includes('/movie/') + ? '시리즈 보기' + : '영화 보기', + url: document.URL, + }, + ] - return data; - } - }, - "/live/player/": video => ({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TVING/assets/logo.png", - details: document.querySelector(".live-title__channel").textContent, - state: "라이브", - smallImageKey: video.paused ? Assets.Pause : Assets.Play, - smallImageText: video.paused ? "일시 정지" : "재생 중", - endTimestamp: (() => { - if (!video.paused) - return presence.getTimestampsfromMedia(video).pop(); - })(), - buttons: [ - { - label: "라이브 보기", - url: document.URL, - }, - ], - }), - "/schedule/": { - details: "일정을 보는 중", - }, - "/event/": { - details: "이벤트 보는 중", - }, - "/faq/": { - details: "FAQ 보는 중", - }, - }; + return data + } + }, + '/live/player/': video => ({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TVING/assets/logo.png', + details: document.querySelector('.live-title__channel')?.textContent, + state: '라이브', + smallImageKey: video?.paused ? Assets.Pause : Assets.Play, + smallImageText: video?.paused ? '일시 정지' : '재생 중', + endTimestamp: (() => { + if (video && !video.paused) + return presence.getTimestampsfromMedia(video).pop() + })(), + buttons: [ + { + label: '라이브 보기', + url: document.URL, + }, + ], + }), + '/schedule/': { + details: '일정을 보는 중', + }, + '/event/': { + details: '이벤트 보는 중', + }, + '/faq/': { + details: 'FAQ 보는 중', + }, + } - for (const [path, data] of Object.entries(pages)) { - if (location.pathname.match(path)) { - if (typeof data === "function") { - const output = await data(document.querySelector("video")); + for (const [path, data] of Object.entries(pages)) { + if (location.pathname.match(path)) { + if (typeof data === 'function') { + const output = await data(document.querySelector('video')!) - if (output.largeImageKey) presenceData = output; - else presenceData = { ...presenceData, ...output }; - } else presenceData = { ...presenceData, ...data }; - } - } + if (output?.largeImageKey) + presenceData = output + else presenceData = { ...presenceData, ...output } as PresenceData + } + else { + presenceData = { ...presenceData, ...data } as PresenceData + } + } + } - if (!buttons) delete presenceData.buttons; + if (!buttons) + delete presenceData.buttons - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TVNZ OnDemand/iframe.ts b/websites/T/TVNZ OnDemand/iframe.ts index 437fdb7479ab..db3b60826c1f 100644 --- a/websites/T/TVNZ OnDemand/iframe.ts +++ b/websites/T/TVNZ OnDemand/iframe.ts @@ -1,15 +1,15 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", () => { - const video = document.querySelector( - "#vjs_video_1_html5_api" - ); - if (video && !isNaN(video.duration)) { - iframe.send({ - iFrameVideo: true, - currentTime: video.currentTime, - duration: video.duration, - paused: video.paused, - }); - } -}); +iframe.on('UpdateData', () => { + const video = document.querySelector( + '#vjs_video_1_html5_api', + ) + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iFrameVideo: true, + currentTime: video.currentTime, + duration: video.duration, + paused: video.paused, + }) + } +}) diff --git a/websites/T/TVNZ OnDemand/metadata.json b/websites/T/TVNZ OnDemand/metadata.json index 1b85ac577ff0..f0be75e92362 100644 --- a/websites/T/TVNZ OnDemand/metadata.json +++ b/websites/T/TVNZ OnDemand/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Cairo", - "id": "208105877838888960" - }, - "service": "TVNZ OnDemand", - "description": { - "en": "TVNZ OnDemand. We've rounded up the best of the best for you. Finding your favourite TVNZ shows and discovering new ones has never been easier.", - "nl": "TVNZ OnDemand. We hebben het beste van het beste voor je op een rijtje gezet. Het vinden van uw favoriete TVNZ-programma's en het ontdekken van nieuwe is nog nooit zo eenvoudig geweest." - }, - "url": [ - "www.tvnz.co.nz", - "login.tech.tvnz.co.nz" - ], - "version": "1.3.29", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TVNZ%20OnDemand/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TVNZ%20OnDemand/assets/thumbnail.png", - "color": "#167EF5", - "category": "videos", - "tags": [ - "streaming", - "video", - "media" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Cairo", + "id": "208105877838888960" + }, + "service": "TVNZ OnDemand", + "description": { + "en": "TVNZ OnDemand. We've rounded up the best of the best for you. Finding your favourite TVNZ shows and discovering new ones has never been easier.", + "nl": "TVNZ OnDemand. We hebben het beste van het beste voor je op een rijtje gezet. Het vinden van uw favoriete TVNZ-programma's en het ontdekken van nieuwe is nog nooit zo eenvoudig geweest." + }, + "url": [ + "www.tvnz.co.nz", + "login.tech.tvnz.co.nz" + ], + "version": "1.3.29", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TVNZ%20OnDemand/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TVNZ%20OnDemand/assets/thumbnail.png", + "color": "#167EF5", + "category": "videos", + "tags": [ + "streaming", + "video", + "media" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git a/websites/T/TVNZ OnDemand/presence.ts b/websites/T/TVNZ OnDemand/presence.ts index 454977b29f8d..e5249071022c 100644 --- a/websites/T/TVNZ OnDemand/presence.ts +++ b/websites/T/TVNZ OnDemand/presence.ts @@ -1,126 +1,133 @@ const presence = new Presence({ - clientId: "687426695417823238", -}); + clientId: '687426695417823238', +}) -let currentTime: number, duration: number, paused: boolean, playback; +let currentTime: number, duration: number, paused: boolean, playback presence.on( - "iFrameData", - (data: { duration: number; currentTime?: number; paused?: boolean }) => { - playback = data.duration ? true : false; - if (playback) ({ currentTime, duration, paused } = data); - } -); + 'iFrameData', + (inc: unknown) => { + const data = inc as { duration: number, currentTime: number, paused: boolean } + playback = !!data.duration + if (playback) + ({ currentTime, duration, paused } = data) + }, +) -presence.on("UpdateData", () => { - const [startTimestamp, endTimestamp] = presence.getTimestamps( - Math.floor(currentTime), - Math.floor(duration) - ), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TVNZ%20OnDemand/assets/logo.png", - }; +presence.on('UpdateData', () => { + const [startTimestamp, endTimestamp] = presence.getTimestamps( + Math.floor(currentTime), + Math.floor(duration), + ) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TVNZ%20OnDemand/assets/logo.png', + } - if (document.location.href.includes("login.tech.tvnz.co.nz")) - presenceData.details = "Logging in..."; - else if (document.location.pathname.includes("/1-news-special")) { - presenceData.details = "Watching a live 1 NEWS Special"; - presenceData.state = - document.querySelectorAll(".Hero-title")[1].textContent; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } else if ( - document.location.pathname.includes("/choose-profile") || - document.location.pathname.includes("/profiles-welcome") - ) - presenceData.details = "Choosing a profile"; - else if ( - document.URL === "https://www.tvnz.co.nz/" || - document.URL === "https://www.tvnz.co.nz" || - document.URL === "https://www.tvnz.co.nz/shows" - ) { - presenceData.details = "Browsing the main page"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } else if (document.location.pathname.includes("/episodes/")) { - if (!isNaN(endTimestamp)) { - [presenceData.startTimestamp, presenceData.endTimestamp] = [ - startTimestamp, - endTimestamp, - ]; - } + if (document.location.href.includes('login.tech.tvnz.co.nz')) { + presenceData.details = 'Logging in...' + } + else if (document.location.pathname.includes('/1-news-special')) { + presenceData.details = 'Watching a live 1 NEWS Special' + presenceData.state = document.querySelectorAll('.Hero-title')[1].textContent + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } + else if ( + document.location.pathname.includes('/choose-profile') + || document.location.pathname.includes('/profiles-welcome') + ) { + presenceData.details = 'Choosing a profile' + } + else if ( + document.URL === 'https://www.tvnz.co.nz/' + || document.URL === 'https://www.tvnz.co.nz' + || document.URL === 'https://www.tvnz.co.nz/shows' + ) { + presenceData.details = 'Browsing the main page' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } + else if (document.location.pathname.includes('/episodes/')) { + if (!Number.isNaN(endTimestamp)) { + [presenceData.startTimestamp, presenceData.endTimestamp] = [ + startTimestamp, + endTimestamp, + ] + } - presenceData.state = - document.querySelectorAll(".Player-title")[0].textContent; + presenceData.state = document.querySelectorAll('.Player-title')[0].textContent - if (paused) { - presenceData.details = "Watching a show"; - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - presenceData.smallImageKey = Assets.Pause; - } else { - presenceData.details = "Watching a show"; - presenceData.smallImageKey = Assets.Play; - } - } else if (document.location.pathname.includes("/shows/")) { - presenceData.details = "Viewing a show"; - presenceData.state = - document.querySelectorAll(".Hero-title")[1].textContent; - } else if ( - document.URL === "https://www.tvnz.co.nz/categories/my-favourites" - ) { - presenceData.details = "Browsing favourite shows"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } else if (document.location.pathname.includes("/categories/")) { - presenceData.details = "Browsing a category"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - presenceData.state = - document.querySelectorAll(".PageHeader-title")[0].textContent; - } else if ( - document.location.pathname.includes("/manage-profiles") || - document.location.pathname.includes("/add-profile") - ) - presenceData.details = "Managing profiles"; - else if (document.location.pathname.includes("/settings")) - presenceData.details = "Managing account details"; - else if (document.location.pathname.includes("/search")) { - presenceData.details = "Searching shows"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } else { - switch (document.URL) { - case "https://www.tvnz.co.nz/livetv": { - presenceData.details = "Viewing the Live TV guide"; - break; - } - case "https://www.tvnz.co.nz/livetv/tvnz-1": { - presenceData.details = "Watching TVNZ 1 Live"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - presenceData.state = - document.querySelectorAll(".Player-title")[0].textContent; + if (paused) { + presenceData.details = 'Watching a show' + delete presenceData.startTimestamp + delete presenceData.endTimestamp + presenceData.smallImageKey = Assets.Pause + } + else { + presenceData.details = 'Watching a show' + presenceData.smallImageKey = Assets.Play + } + } + else if (document.location.pathname.includes('/shows/')) { + presenceData.details = 'Viewing a show' + presenceData.state = document.querySelectorAll('.Hero-title')[1].textContent + } + else if ( + document.URL === 'https://www.tvnz.co.nz/categories/my-favourites' + ) { + presenceData.details = 'Browsing favourite shows' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } + else if (document.location.pathname.includes('/categories/')) { + presenceData.details = 'Browsing a category' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + presenceData.state = document.querySelectorAll('.PageHeader-title')[0].textContent + } + else if ( + document.location.pathname.includes('/manage-profiles') + || document.location.pathname.includes('/add-profile') + ) { + presenceData.details = 'Managing profiles' + } + else if (document.location.pathname.includes('/settings')) { + presenceData.details = 'Managing account details' + } + else if (document.location.pathname.includes('/search')) { + presenceData.details = 'Searching shows' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } + else { + switch (document.URL) { + case 'https://www.tvnz.co.nz/livetv': { + presenceData.details = 'Viewing the Live TV guide' + break + } + case 'https://www.tvnz.co.nz/livetv/tvnz-1': { + presenceData.details = 'Watching TVNZ 1 Live' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + presenceData.state = document.querySelectorAll('.Player-title')[0].textContent - break; - } - case "https://www.tvnz.co.nz/livetv/tvnz-2": { - presenceData.details = "Watching TVNZ 2 Live"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - presenceData.state = - document.querySelectorAll(".Player-title")[0].textContent; + break + } + case 'https://www.tvnz.co.nz/livetv/tvnz-2': { + presenceData.details = 'Watching TVNZ 2 Live' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + presenceData.state = document.querySelectorAll('.Player-title')[0].textContent - break; - } - case "https://www.tvnz.co.nz/livetv/tvnz-duke": { - presenceData.details = "Watching TVNZ Duke Live"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - presenceData.state = - document.querySelectorAll(".Player-title")[0].textContent; + break + } + case 'https://www.tvnz.co.nz/livetv/tvnz-duke': { + presenceData.details = 'Watching TVNZ Duke Live' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + presenceData.state = document.querySelectorAll('.Player-title')[0].textContent - break; - } - default: - if (document.location.pathname.includes("/one-news")) - presenceData.details = "Browsing 1 NEWS"; - } - } + break + } + default: + if (document.location.pathname.includes('/one-news')) + presenceData.details = 'Browsing 1 NEWS' + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TVer/metadata.json b/websites/T/TVer/metadata.json index caec7f6a3532..311d759f6e28 100644 --- a/websites/T/TVer/metadata.json +++ b/websites/T/TVer/metadata.json @@ -1,99 +1,99 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "223277933521928203", - "name": "ryunt" - }, - "service": "TVer", - "description": { - "en": "TVer is a Japanese ad-supported video on demand (AVOD) service. It allows viewers to watch TV programs they missed during their initial broadcast for free for one week.", - "ja_JP": "TVer(ティーバー)は国内最大級の見逃し無料配信動画サービスです。ドラマ、バラエティ、アニメ、報道・ドキュメンタリー、スポーツなど人気番組を毎週750番組以上見放題!" - }, - "url": "tver.jp", - "version": "1.0.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TVer/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TVer/assets/thumbnail.png", - "color": "#21ABE6", - "category": "videos", - "tags": [ - "shows", - "stream", - "streaming", - "tv", - "video" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "liveDetail", - "if": { - "privacy": false - }, - "title": "Stream Details row1", - "icon": "fas fa-comment-alt-edit", - "value": "%tvStation%", - "placeholder": "Use %tvStation% or %seriesTitle% or %title%" - }, - { - "id": "liveState", - "if": { - "privacy": false - }, - "title": "Stream Details row2", - "icon": "fas fa-comment-alt-edit", - "value": "%seriesTitle%", - "placeholder": "Use %tvStation% or %seriesTitle% or %title%" - }, - { - "id": "vidDetail", - "if": { - "privacy": false - }, - "title": "Video Details row1", - "icon": "fas fa-comment-alt-edit", - "value": "%seriesTitle%", - "placeholder": "Use %tvStation% or %seriesTitle% or %title%" - }, - { - "id": "vidState", - "if": { - "privacy": false - }, - "title": "Video Details row2", - "icon": "fas fa-comment-alt-edit", - "value": "%title%", - "placeholder": "Use %tvStation% or %seriesTitle% or %title%" - }, - { - "id": "timestamp", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "videoPic", - "title": "Show Video Picture", - "icon": "fad fa-images", - "value": false - }, - { - "id": "buttons", - "if": { - "privacy": false - }, - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "223277933521928203", + "name": "ryunt" + }, + "service": "TVer", + "description": { + "en": "TVer is a Japanese ad-supported video on demand (AVOD) service. It allows viewers to watch TV programs they missed during their initial broadcast for free for one week.", + "ja_JP": "TVer(ティーバー)は国内最大級の見逃し無料配信動画サービスです。ドラマ、バラエティ、アニメ、報道・ドキュメンタリー、スポーツなど人気番組を毎週750番組以上見放題!" + }, + "url": "tver.jp", + "version": "1.0.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TVer/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TVer/assets/thumbnail.png", + "color": "#21ABE6", + "category": "videos", + "tags": [ + "shows", + "stream", + "streaming", + "tv", + "video" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "liveDetail", + "if": { + "privacy": false + }, + "title": "Stream Details row1", + "icon": "fas fa-comment-alt-edit", + "value": "%tvStation%", + "placeholder": "Use %tvStation% or %seriesTitle% or %title%" + }, + { + "id": "liveState", + "if": { + "privacy": false + }, + "title": "Stream Details row2", + "icon": "fas fa-comment-alt-edit", + "value": "%seriesTitle%", + "placeholder": "Use %tvStation% or %seriesTitle% or %title%" + }, + { + "id": "vidDetail", + "if": { + "privacy": false + }, + "title": "Video Details row1", + "icon": "fas fa-comment-alt-edit", + "value": "%seriesTitle%", + "placeholder": "Use %tvStation% or %seriesTitle% or %title%" + }, + { + "id": "vidState", + "if": { + "privacy": false + }, + "title": "Video Details row2", + "icon": "fas fa-comment-alt-edit", + "value": "%title%", + "placeholder": "Use %tvStation% or %seriesTitle% or %title%" + }, + { + "id": "timestamp", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "videoPic", + "title": "Show Video Picture", + "icon": "fad fa-images", + "value": false + }, + { + "id": "buttons", + "if": { + "privacy": false + }, + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/T/TVer/presence.ts b/websites/T/TVer/presence.ts index 6c6879662fa4..1d073e33d25d 100644 --- a/websites/T/TVer/presence.ts +++ b/websites/T/TVer/presence.ts @@ -1,199 +1,213 @@ const presence = new Presence({ - clientId: "1206601150607134780", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - getStrings = async () => { - return presence.getStrings( - { - buttonWatchStream: "general.buttonWatchStream", - buttonWatchVideo: "general.buttonWatchVideo", - live: "general.live", - pause: "general.paused", - paused: "general.paused", - play: "general.playing", - playing: "general.playing", - readingArticle: "general.readingArticle", - search: "general.search", - searchFor: "general.searchFor", - searchSomething: "general.searchSomething", - upload: "youtube.upload", - viewHome: "general.viewHome", - viewList: "general.viewList", - viewSeries: "general.viewSeries", - waitingLive: "general.waitingLive", - waitingLiveThe: "general.waitingLiveThe", - watchingLive: "general.watchingLive", - watchingVid: "general.watchingVid", - }, - await presence.getSetting("lang").catch(() => "en") - ); - }; + clientId: '1206601150607134780', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +async function getStrings() { + return presence.getStrings( + { + buttonWatchStream: 'general.buttonWatchStream', + buttonWatchVideo: 'general.buttonWatchVideo', + live: 'general.live', + pause: 'general.paused', + paused: 'general.paused', + play: 'general.playing', + playing: 'general.playing', + readingArticle: 'general.readingArticle', + search: 'general.search', + searchFor: 'general.searchFor', + searchSomething: 'general.searchSomething', + upload: 'youtube.upload', + viewHome: 'general.viewHome', + viewList: 'general.viewList', + viewSeries: 'general.viewSeries', + waitingLive: 'general.waitingLive', + waitingLiveThe: 'general.waitingLiveThe', + watchingLive: 'general.watchingLive', + watchingVid: 'general.watchingVid', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) +} -let strings: Awaited>, - oldLang: string = null; +let strings: Awaited> +let oldLang: string | null = null -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - name: "Tver", - type: ActivityType.Watching, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TVer/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - [ - buttons, - liveDetail, - liveState, - newLang, - privacy, - showTimestamps, - vidDetail, - vidState, - videoPic, - ] = await Promise.all([ - presence.getSetting("buttons"), - presence.getSetting("liveDetail"), - presence.getSetting("liveState"), - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("privacy"), - presence.getSetting("timestamp"), - presence.getSetting("vidDetail"), - presence.getSetting("vidState"), - presence.getSetting("videoPic"), - ]), - { pathname, href } = document.location, - title = document.querySelector( - "[class^='titles_container'] h1" - )?.textContent, - seriesTitle = document.querySelector( - "[class^='titles_container'] h2" - )?.textContent; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + name: 'Tver', + type: ActivityType.Watching, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TVer/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const [ + buttons, + liveDetail, + liveState, + newLang, + privacy, + showTimestamps, + vidDetail, + vidState, + videoPic, + ] = await Promise.all([ + presence.getSetting('buttons'), + presence.getSetting('liveDetail'), + presence.getSetting('liveState'), + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('privacy'), + presence.getSetting('timestamp'), + presence.getSetting('vidDetail'), + presence.getSetting('vidState'), + presence.getSetting('videoPic'), + ]) + const { pathname, href } = document.location + const title = document.querySelector( + '[class^=\'titles_container\'] h1', + )?.textContent + const seriesTitle = document.querySelector( + '[class^=\'titles_container\'] h2', + )?.textContent - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - switch (pathname) { - case "/": { - presenceData.details = strings.viewHome; - break; - } - case "/mypage/fav": - case "/mypage/later": - case "/mypage/resume": { - presenceData.details = document.querySelector( - "[class*='mypage-page-main_selectedTab']" - )?.textContent; - break; - } - default: - if (pathname.includes("/live")) { - const isScheduled = document.querySelector( - "[class^='live-scheduled_host']" - ), - tvStation = document.querySelector( - "[class^='description_metaDetail'] > span" - )?.textContent; - if (privacy) { - if (isScheduled) presenceData.details = strings.waitingLive; - else presenceData.details = strings.watchingLive; - } else { - if (videoPic) { - presenceData.largeImageKey = document - .querySelector( - "[class*='live_active'] > div > img" - ) - ?.src.replace(/(thumbnail\/live\/)[^/]+/, "$1small") - .replace(/\.jpg.*$/, ".jpg"); - } - if (isScheduled) presenceData.details = strings.waitingLiveThe; - else { - presenceData.details = liveDetail - .replace("%tvStation%", tvStation ?? "") - .replace("%seriesTitle%", seriesTitle ?? "") - .replace("%title%", title ?? ""); - } - presenceData.state = liveState - .replace("%tvStation%", tvStation) - .replace("%seriesTitle%", seriesTitle ?? "") - .replace("%title%", title ?? ""); - presenceData.buttons = [ - { label: strings.buttonWatchStream, url: href }, - ]; - if ( - !document.querySelector("[class^='live-finished_host']") && - !isScheduled - ) { - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = strings.live; - } - } - } else if (pathname.includes("/episodes")) { - if (privacy) presenceData.details = strings.watchingVid; - else { - if (videoPic) { - presenceData.largeImageKey = `https://statics.tver.jp/images/content/thumbnail/episode/small/${ - pathname.split("/")[2] - }.jpg`; - } - const tvStation = document.querySelector( - "[class^='description_meta'] > div:nth-child(1)" - )?.textContent; - presenceData.details = vidDetail - .replace("%tvStation%", tvStation ?? "") - .replace("%seriesTitle%", seriesTitle ?? "") - .replace("%title%", title ?? ""); - presenceData.state = vidState - .replace("%tvStation%", tvStation) - .replace("%seriesTitle%", seriesTitle ?? "") - .replace("%title%", title ?? ""); - const { paused } = document.querySelector("video"); - if (!paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia( - document.querySelector("video") - ); - } - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = paused - ? strings.paused - : strings.playing; - presenceData.buttons = [ - { label: strings.buttonWatchVideo, url: href }, - ]; - } - } else if (pathname.includes("/series")) { - presenceData.details = strings.viewSeries; - if (!privacy) { - presenceData.state = document.querySelector( - "[class^='series-main_title']" - )?.textContent; - } - } else if (pathname.includes("/specials")) { - presenceData.details = strings.readingArticle; - if (!privacy) { - presenceData.state = document.querySelector( - "[class^='special-feature-page-main_title']" - )?.textContent; - } - } else if (pathname.includes("/rankings/episode")) { - presenceData.details = strings.viewList; - if (!privacy) { - presenceData.state = document.querySelector( - "[class^='select-tabs-switch-list_container']" - )?.textContent; - } - } else if (pathname.includes("/search")) - presenceData.details = strings.searchSomething; - else presenceData.details = strings.viewHome; - } + switch (pathname) { + case '/': { + presenceData.details = strings.viewHome + break + } + case '/mypage/fav': + case '/mypage/later': + case '/mypage/resume': { + presenceData.details = document.querySelector( + '[class*=\'mypage-page-main_selectedTab\']', + )?.textContent + break + } + default: + if (pathname.includes('/live')) { + const isScheduled = document.querySelector( + '[class^=\'live-scheduled_host\']', + ) + const tvStation = document.querySelector( + '[class^=\'description_metaDetail\'] > span', + )?.textContent + if (privacy) { + if (isScheduled) + presenceData.details = strings.waitingLive + else presenceData.details = strings.watchingLive + } + else { + if (videoPic) { + presenceData.largeImageKey = document + .querySelector( + '[class*=\'live_active\'] > div > img', + ) + ?.src + .replace(/(thumbnail\/live\/)[^/]+/, '$1small') + .replace(/\.jpg.*$/, '.jpg') + } + if (isScheduled) { + presenceData.details = strings.waitingLiveThe + } + else { + presenceData.details = liveDetail + .replace('%tvStation%', tvStation ?? '') + .replace('%seriesTitle%', seriesTitle ?? '') + .replace('%title%', title ?? '') + } + presenceData.state = liveState + .replace('%tvStation%', tvStation ?? '') + .replace('%seriesTitle%', seriesTitle ?? '') + .replace('%title%', title ?? '') + presenceData.buttons = [ + { label: strings.buttonWatchStream, url: href }, + ] + if ( + !document.querySelector('[class^=\'live-finished_host\']') + && !isScheduled + ) { + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = strings.live + } + } + } + else if (pathname.includes('/episodes')) { + if (privacy) { + presenceData.details = strings.watchingVid + } + else { + if (videoPic) { + presenceData.largeImageKey = `https://statics.tver.jp/images/content/thumbnail/episode/small/${ + pathname.split('/')[2] + }.jpg` + } + const tvStation = document.querySelector( + '[class^=\'description_meta\'] > div:nth-child(1)', + )?.textContent + presenceData.details = vidDetail + .replace('%tvStation%', tvStation ?? '') + .replace('%seriesTitle%', seriesTitle ?? '') + .replace('%title%', title ?? '') + presenceData.state = vidState + .replace('%tvStation%', tvStation ?? '') + .replace('%seriesTitle%', seriesTitle ?? '') + .replace('%title%', title ?? '') + const { paused } = document.querySelector('video')! + if (!paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia( + document.querySelector('video')!, + ) + } + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = paused + ? strings.paused + : strings.playing + presenceData.buttons = [ + { label: strings.buttonWatchVideo, url: href }, + ] + } + } + else if (pathname.includes('/series')) { + presenceData.details = strings.viewSeries + if (!privacy) { + presenceData.state = document.querySelector( + '[class^=\'series-main_title\']', + )?.textContent + } + } + else if (pathname.includes('/specials')) { + presenceData.details = strings.readingArticle + if (!privacy) { + presenceData.state = document.querySelector( + '[class^=\'special-feature-page-main_title\']', + )?.textContent + } + } + else if (pathname.includes('/rankings/episode')) { + presenceData.details = strings.viewList + if (!privacy) { + presenceData.state = document.querySelector( + '[class^=\'select-tabs-switch-list_container\']', + )?.textContent + } + } + else if (pathname.includes('/search')) { + presenceData.details = strings.searchSomething + } + else { + presenceData.details = strings.viewHome + } + } - if (!showTimestamps) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - if (!buttons) delete presenceData.buttons; + if (!showTimestamps) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + if (!buttons) + delete presenceData.buttons - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/TabNews/metadata.json b/websites/T/TabNews/metadata.json index f7e16b3c56b3..05a9c7cd1ae1 100644 --- a/websites/T/TabNews/metadata.json +++ b/websites/T/TabNews/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "354233941550694400", - "name": "Kuriel" - }, - "service": "TabNews", - "description": { - "en": "TabNews is a website with content for those who work with Programming and Technology.", - "pt_BR": "TabNews é um site com conteúdo para quem trabalha com Programação e Tecnologia." - }, - "url": "www.tabnews.com.br", - "version": "1.0.8", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TabNews/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TabNews/assets/thumbnail.png", - "color": "#ffffff", - "category": "socials", - "tags": [ - "programmming" - ], - "settings": [ - { - "id": "privacy", - "title": "Modo de privacidade", - "icon": "fa-solid fa-eye", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "354233941550694400", + "name": "Kuriel" + }, + "service": "TabNews", + "description": { + "en": "TabNews is a website with content for those who work with Programming and Technology.", + "pt_BR": "TabNews é um site com conteúdo para quem trabalha com Programação e Tecnologia." + }, + "url": "www.tabnews.com.br", + "version": "1.0.8", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TabNews/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TabNews/assets/thumbnail.png", + "color": "#ffffff", + "category": "socials", + "tags": [ + "programmming" + ], + "settings": [ + { + "id": "privacy", + "title": "Modo de privacidade", + "icon": "fa-solid fa-eye", + "value": false + } + ] +} diff --git a/websites/T/TabNews/presence.ts b/websites/T/TabNews/presence.ts index b5c54b9e69cd..0b954b41a1cb 100644 --- a/websites/T/TabNews/presence.ts +++ b/websites/T/TabNews/presence.ts @@ -1,114 +1,116 @@ const presence = new Presence({ - clientId: "1083051669996187748", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1083051669996187748', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - details: "Outros", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TabNews/assets/0.png", - startTimestamp: browsingTimestamp, - }, - [topLevelPath, secondLevelPath, thirdLevelPath, fourLevelPath] = - document.location.pathname.split("/"), - privacyMode = await presence.getSetting("privacy"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + details: 'Outros', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TabNews/assets/0.png', + startTimestamp: browsingTimestamp, + } + const [topLevelPath, secondLevelPath, thirdLevelPath, fourLevelPath] = document.location.pathname.split('/') + const privacyMode = await presence.getSetting('privacy') - switch (true) { - case !topLevelPath || secondLevelPath === "pagina": - presenceData.details = "Vendo conteúdos relevantes"; - if (secondLevelPath === "pagina") - presenceData.state = `Página ${thirdLevelPath}`; - break; - case secondLevelPath.startsWith("recentes"): - presenceData.details = "Vendo conteúdos recentes"; - if (fourLevelPath) presenceData.state = `Página ${fourLevelPath}`; - break; - default: - if (secondLevelPath && !thirdLevelPath) { - switch (secondLevelPath) { - case "publicar": - presenceData.details = "Publicando novo conteúdo"; - break; - case "perfil": - presenceData.details = "Editando perfil"; - break; - case "contato": - presenceData.details = "Vendo os contatos"; - break; - case "termos-de-uso": - presenceData.details = "Lendo os termos de uso"; - break; - case "status": - presenceData.details = "Vendo estatísticas do site"; - break; - case "museu": - presenceData.details = "Admirando o museu"; - break; - case "cadastro": - presenceData.details = "Fazendo o cadastro"; - break; - case "login": - presenceData.details = "Fazendo o login"; - break; - default: - if (document.querySelector("h1")) { - presenceData.details = "Vendo perfil de:"; - presenceData.state = !privacyMode - ? document.querySelector("h1")?.textContent - : "Anônimo"; - if (!privacyMode) { - presenceData.buttons = [ - { - label: "Ver perfil", - url: document.location.href, - }, - ]; - } - } else presenceData.details = "Vendo outros conteúdos"; - break; - } - } - if (thirdLevelPath) { - switch (thirdLevelPath) { - case "pagina": { - presenceData.details = `Vendo perfil de ${ - !privacyMode ? secondLevelPath : "Anônimo" - }`; - presenceData.state = `Página ${fourLevelPath}`; - break; - } - case "rss": - presenceData.details = "Vendo o Feed RSS"; - break; - default: - if (!document.querySelector("h1")) { - presenceData.details = "Lendo resposta a:"; - presenceData.state = - document.querySelector("strong")?.textContent; - presenceData.buttons = [ - { - label: "Ver resposta", - url: document.location.href, - }, - ]; - } else { - presenceData.details = "Lendo o conteúdo:"; - presenceData.state = - document.querySelector("h1")?.textContent; - presenceData.buttons = [ - { - label: "Ver conteúdo", - url: document.location.href, - }, - ]; - } - break; - } - break; - } - } + switch (true) { + case !topLevelPath || secondLevelPath === 'pagina': + presenceData.details = 'Vendo conteúdos relevantes' + if (secondLevelPath === 'pagina') + presenceData.state = `Página ${thirdLevelPath}` + break + case secondLevelPath.startsWith('recentes'): + presenceData.details = 'Vendo conteúdos recentes' + if (fourLevelPath) + presenceData.state = `Página ${fourLevelPath}` + break + default: + if (secondLevelPath && !thirdLevelPath) { + switch (secondLevelPath) { + case 'publicar': + presenceData.details = 'Publicando novo conteúdo' + break + case 'perfil': + presenceData.details = 'Editando perfil' + break + case 'contato': + presenceData.details = 'Vendo os contatos' + break + case 'termos-de-uso': + presenceData.details = 'Lendo os termos de uso' + break + case 'status': + presenceData.details = 'Vendo estatísticas do site' + break + case 'museu': + presenceData.details = 'Admirando o museu' + break + case 'cadastro': + presenceData.details = 'Fazendo o cadastro' + break + case 'login': + presenceData.details = 'Fazendo o login' + break + default: + if (document.querySelector('h1')) { + presenceData.details = 'Vendo perfil de:' + presenceData.state = !privacyMode + ? document.querySelector('h1')?.textContent + : 'Anônimo' + if (!privacyMode) { + presenceData.buttons = [ + { + label: 'Ver perfil', + url: document.location.href, + }, + ] + } + } + else { + presenceData.details = 'Vendo outros conteúdos' + } + break + } + } + if (thirdLevelPath) { + switch (thirdLevelPath) { + case 'pagina': { + presenceData.details = `Vendo perfil de ${ + !privacyMode ? secondLevelPath : 'Anônimo' + }` + presenceData.state = `Página ${fourLevelPath}` + break + } + case 'rss': + presenceData.details = 'Vendo o Feed RSS' + break + default: + if (!document.querySelector('h1')) { + presenceData.details = 'Lendo resposta a:' + presenceData.state = document.querySelector('strong')?.textContent + presenceData.buttons = [ + { + label: 'Ver resposta', + url: document.location.href, + }, + ] + } + else { + presenceData.details = 'Lendo o conteúdo:' + presenceData.state = document.querySelector('h1')?.textContent + presenceData.buttons = [ + { + label: 'Ver conteúdo', + url: document.location.href, + }, + ] + } + break + } + break + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Tabii/metadata.json b/websites/T/Tabii/metadata.json index e8d5068b323c..fff1055d2e1d 100644 --- a/websites/T/Tabii/metadata.json +++ b/websites/T/Tabii/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "180731688844787712", - "name": "tuleyman" - }, - "service": "Tabii", - "description": { - "en": "tabii - Watch TV Shows Movies and Series", - "tr": "tabii - TV Programları Filmleri ve Dizileri İzle" - }, - "url": [ - "www.tabii.com", - "tabii.com" - ], - "version": "1.0.8", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tabii/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tabii/assets/thumbnail.png", - "color": "#00ff99", - "category": "videos", - "tags": [ - "tabii", - "tb", - "tuleyman", - "tabiicom", - "wwwtabiicom" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "180731688844787712", + "name": "tuleyman" + }, + "service": "Tabii", + "description": { + "en": "tabii - Watch TV Shows Movies and Series", + "tr": "tabii - TV Programları Filmleri ve Dizileri İzle" + }, + "url": [ + "www.tabii.com", + "tabii.com" + ], + "version": "1.0.8", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tabii/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tabii/assets/thumbnail.png", + "color": "#00ff99", + "category": "videos", + "tags": [ + "tabii", + "tb", + "tuleyman", + "tabiicom", + "wwwtabiicom" + ] +} diff --git a/websites/T/Tabii/presence.ts b/websites/T/Tabii/presence.ts index 7e4df35ad062..83d5c3c2ba0d 100644 --- a/websites/T/Tabii/presence.ts +++ b/websites/T/Tabii/presence.ts @@ -1,77 +1,87 @@ const presence = new Presence({ - clientId: "1212022540080382013", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - view: "general.watching", - }); + clientId: '1212022540080382013', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', + view: 'general.watching', +}) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Tabii/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Tabii/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }, - { pathname, href } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } + const { pathname, href } = document.location - if (pathname === "/" || pathname.includes("/browse/")) { - const pageIds = [ - { id: "154830_134666", name: "Anasayfa" }, - { id: "149106_149112", name: "Dizi" }, - { id: "149265_149266", name: "Film" }, - { id: "149301_149418", name: "Belgesel" }, - { id: "149332_149333", name: "Çocuk" }, - { id: "233080_242470", name: "Tekrar İzle" }, - ]; + if (pathname === '/' || pathname.includes('/browse/')) { + const pageIds = [ + { id: '154830_134666', name: 'Anasayfa' }, + { id: '149106_149112', name: 'Dizi' }, + { id: '149265_149266', name: 'Film' }, + { id: '149301_149418', name: 'Belgesel' }, + { id: '149332_149333', name: 'Çocuk' }, + { id: '233080_242470', name: 'Tekrar İzle' }, + ] - presenceData.details = `${ - pageIds.find(x => pathname.includes(x.id))?.name - } Sayfasına Göz Atıyor`; - } else if (pathname.includes("/settings/account")) - presenceData.details = "Hesap Ayarlarına Göz Atıyor."; - else if (pathname.includes("/settings/profile")) - presenceData.details = "Profil Ayarlarına Göz Atıyor."; - else if (pathname.includes("/search")) { - if (document.querySelector("input").value) - presenceData.details = "Arama Yapıyor."; - else presenceData.details = "Arama Sayfasına Göz Atıyor."; - } else if (pathname.includes("/watch")) { - const video = document.querySelector("video"); + presenceData.details = `${ + pageIds.find(x => pathname.includes(x.id))?.name + } Sayfasına Göz Atıyor` + } + else if (pathname.includes('/settings/account')) { + presenceData.details = 'Hesap Ayarlarına Göz Atıyor.' + } + else if (pathname.includes('/settings/profile')) { + presenceData.details = 'Profil Ayarlarına Göz Atıyor.' + } + else if (pathname.includes('/search')) { + if (document.querySelector('input')?.value) + presenceData.details = 'Arama Yapıyor.' + else presenceData.details = 'Arama Sayfasına Göz Atıyor.' + } + else if (pathname.includes('/watch')) { + const video = document.querySelector('video') - if (video) { - presenceData.state = document.querySelector("h1")?.textContent; - const stringsData = await strings; - presenceData.buttons = [ - { - label: `${stringsData.view} ${presenceData.state}`, - url: href, - }, - ]; + if (video) { + presenceData.state = document.querySelector('h1')?.textContent + const stringsData = await strings + presenceData.buttons = [ + { + label: `${stringsData.view} ${presenceData.state}`, + url: href, + }, + ] - if (video.currentTime && video.duration) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); + if (video.currentTime && video.duration) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? stringsData.pause - : stringsData.play; - } - } - } else if (pathname.includes("/genre")) { - const catName = document.querySelector( - "#Main > div > div:nth-child(1) > main > div > div.flex.pt-8 > div > div > span:nth-child(2)" - ).textContent; - if (catName) presenceData.details = `${catName} Kategorisine Göz Atıyor.`; - else presenceData.details = "Kategori Sayfasına Göz Atıyor."; - } else if (pathname.includes("/my-stuff")) - presenceData.details = "Kütüphanesine Göz Atıyor."; - else if (pathname.includes("/faq")) - presenceData.details = "SSS'ye Göz Atıyor."; - else presenceData.details = "Bilinmeyen Sayfada."; + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? stringsData.pause + : stringsData.play + } + } + } + else if (pathname.includes('/genre')) { + const catName = document.querySelector( + '#Main > div > div:nth-child(1) > main > div > div.flex.pt-8 > div > div > span:nth-child(2)', + )?.textContent + if (catName) + presenceData.details = `${catName} Kategorisine Göz Atıyor.` + else presenceData.details = 'Kategori Sayfasına Göz Atıyor.' + } + else if (pathname.includes('/my-stuff')) { + presenceData.details = 'Kütüphanesine Göz Atıyor.' + } + else if (pathname.includes('/faq')) { + presenceData.details = 'SSS\'ye Göz Atıyor.' + } + else { + presenceData.details = 'Bilinmeyen Sayfada.' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/Taco/metadata.json b/websites/T/Taco/metadata.json index 63ebf69683cf..b653a1de1d13 100644 --- a/websites/T/Taco/metadata.json +++ b/websites/T/Taco/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Snazzah", - "id": "158049329150427136" - }, - "service": "Taco", - "description": { - "en": "Manage Trello boards and get notified of board updates straight from Discord!", - "nl": "Beheer Trello-borden en ontvang rechtstreeks vanuit Discord op de hoogte van bordupdates!" - }, - "url": "tacobot.app", - "version": "1.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Taco/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Taco/assets/thumbnail.png", - "color": "#93A01E", - "category": "other", - "tags": [ - "discord", - "bot", - "trello" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Snazzah", + "id": "158049329150427136" + }, + "service": "Taco", + "description": { + "en": "Manage Trello boards and get notified of board updates straight from Discord!", + "nl": "Beheer Trello-borden en ontvang rechtstreeks vanuit Discord op de hoogte van bordupdates!" + }, + "url": "tacobot.app", + "version": "1.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Taco/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Taco/assets/thumbnail.png", + "color": "#93A01E", + "category": "other", + "tags": [ + "discord", + "bot", + "trello" + ] +} diff --git a/websites/T/Taco/presence.ts b/websites/T/Taco/presence.ts index 5cabba7c0f5f..db37afdb4c6d 100644 --- a/websites/T/Taco/presence.ts +++ b/websites/T/Taco/presence.ts @@ -1,28 +1,24 @@ const presence = new Presence({ - clientId: "722549030244057161", -}); + clientId: '722549030244057161', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/T/Taco/assets/logo.png", - }; - switch (location.pathname.split("/")[1]) { - case "guide": - presenceData.details = "Reading the guide"; - presenceData.state = [ - document.querySelector(".sidebar-links > li > a.active") - ? document.querySelector(".sidebar-links > li > a.active").textContent - : null, - document.querySelector(".sidebar-sub-header > a.active") - ? document.querySelector(".sidebar-sub-header > a.active").textContent - : null, - ] - .filter(a => !!a) - .join(" ― "); - break; - default: - presenceData.details = "Homepage"; - break; - } - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Taco/assets/logo.png', + } + switch (location.pathname.split('/')[1]) { + case 'guide': + presenceData.details = 'Reading the guide' + presenceData.state = [ + document.querySelector('.sidebar-links > li > a.active')?.textContent, + document.querySelector('.sidebar-sub-header > a.active')?.textContent, + ] + .filter(a => !!a) + .join(' ― ') + break + default: + presenceData.details = 'Homepage' + break + } + presence.setActivity(presenceData) +}) diff --git a/websites/T/Tailwind CSS/metadata.json b/websites/T/Tailwind CSS/metadata.json index edd398167be9..4d8a5a3f745e 100644 --- a/websites/T/Tailwind CSS/metadata.json +++ b/websites/T/Tailwind CSS/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "tarikcoskun", - "id": "474537652943847444" - }, - "service": "Tailwind CSS", - "description": { - "en": "A utility-first CSS framework that can be composed to build any design, directly in your markup.", - "nl": "Een utility-first CSS-framework dat kan worden samengesteld om elk ontwerp te bouwen, rechtstreeks in uw opmaak." - }, - "url": [ - "tailwindcss.com", - "tailwindui.com", - "play.tailwindcss.com", - "blog.tailwindcss.com" - ], - "version": "1.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tailwind%20CSS/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tailwind%20CSS/assets/thumbnail.png", - "color": "#06b6d4", - "category": "other", - "tags": [ - "tailwind", - "framework", - "turkish" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "tarikcoskun", + "id": "474537652943847444" + }, + "service": "Tailwind CSS", + "description": { + "en": "A utility-first CSS framework that can be composed to build any design, directly in your markup.", + "nl": "Een utility-first CSS-framework dat kan worden samengesteld om elk ontwerp te bouwen, rechtstreeks in uw opmaak." + }, + "url": [ + "tailwindcss.com", + "tailwindui.com", + "play.tailwindcss.com", + "blog.tailwindcss.com" + ], + "version": "1.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tailwind%20CSS/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tailwind%20CSS/assets/thumbnail.png", + "color": "#06b6d4", + "category": "other", + "tags": [ + "tailwind", + "framework", + "turkish" + ] +} diff --git a/websites/T/Tailwind CSS/presence.ts b/websites/T/Tailwind CSS/presence.ts index 7cda6ffdc7a1..a2b17aab4f4a 100644 --- a/websites/T/Tailwind CSS/presence.ts +++ b/websites/T/Tailwind CSS/presence.ts @@ -1,70 +1,78 @@ -const presence = new Presence({ clientId: "818756651279450144" }); +const presence = new Presence({ clientId: '818756651279450144' }) -presence.on("UpdateData", async () => { - const path = location.pathname, - [subdomain] = location.host.split("."), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Tailwind%20CSS/assets/logo.png", - startTimestamp: Math.round(Date.now() / 1000), - }; +presence.on('UpdateData', async () => { + const path = location.pathname + const [subdomain] = location.host.split('.') + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Tailwind%20CSS/assets/logo.png', + startTimestamp: Math.round(Date.now() / 1000), + } - if (location.host === "tailwindui.com") { - presenceData.details = "Viewing page:"; - if (path.includes("/components")) { - if (path.includes("/components/")) { - const pathnames = location.pathname.split("/"); - presenceData.details = "Viewing component:"; - presenceData.state = `${pathnames[pathnames.length - 2] - .replaceAll("-", " ") - .replace(/(^\w|\s\w)/g, m => m.toUpperCase())} - ${ - document.querySelector("main .max-w-8xl h2")?.textContent || - "Unknown component" - }`; - } else { - presenceData.details = "Browsing components"; - presenceData.smallImageKey = Assets.Search; - } - } else { - switch (path) { - case "/pricing": { - presenceData.state = "Tailwind UI - Pricing"; - break; - } - case "/login": { - presenceData.state = "Tailwind UI - Login"; - break; - } - case "/": - { - presenceData.state = "Tailwind UI - Home"; - // No default - } - break; - } - } - } else if (subdomain === "blog") { - if (path !== "/") { - presenceData.details = "Reading an article:"; - presenceData.state = - document.querySelector("article header div div h1")?.textContent || - "Unknown article"; - presenceData.smallImageKey = Assets.Reading; - } else { - presenceData.details = "Browsing articles"; - presenceData.smallImageKey = Assets.Search; - } - } else if (subdomain === "play") presenceData.details = "In Tailwind Play"; - else if (path.includes("/docs")) { - presenceData.details = "Viewing documentation"; - presenceData.state = - document.querySelector("#content-wrapper div h1")?.textContent || - "Unknown page"; - } else if (path === "/") presenceData.details = "Viewing homepage"; - else if (path === "/resources") { - presenceData.details = "Viewing a page:"; - presenceData.state = "Resources"; - } else presenceData.details = "Viewing an unknown page"; + if (location.host === 'tailwindui.com') { + presenceData.details = 'Viewing page:' + if (path.includes('/components')) { + if (path.includes('/components/')) { + const pathnames = location.pathname.split('/') + presenceData.details = 'Viewing component:' + presenceData.state = `${pathnames[pathnames.length - 2] + .replaceAll('-', ' ') + .replace(/(^\w|\s\w)/g, m => m.toUpperCase())} - ${ + document.querySelector('main .max-w-8xl h2')?.textContent + || 'Unknown component' + }` + } + else { + presenceData.details = 'Browsing components' + presenceData.smallImageKey = Assets.Search + } + } + else { + switch (path) { + case '/pricing': { + presenceData.state = 'Tailwind UI - Pricing' + break + } + case '/login': { + presenceData.state = 'Tailwind UI - Login' + break + } + case '/': { + presenceData.state = 'Tailwind UI - Home' + break + } + } + } + } + else if (subdomain === 'blog') { + if (path !== '/') { + presenceData.details = 'Reading an article:' + presenceData.state = document.querySelector('article header div div h1')?.textContent + || 'Unknown article' + presenceData.smallImageKey = Assets.Reading + } + else { + presenceData.details = 'Browsing articles' + presenceData.smallImageKey = Assets.Search + } + } + else if (subdomain === 'play') { + presenceData.details = 'In Tailwind Play' + } + else if (path.includes('/docs')) { + presenceData.details = 'Viewing documentation' + presenceData.state = document.querySelector('#content-wrapper div h1')?.textContent + || 'Unknown page' + } + else if (path === '/') { + presenceData.details = 'Viewing homepage' + } + else if (path === '/resources') { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Resources' + } + else { + presenceData.details = 'Viewing an unknown page' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git "a/websites/T/Taiy\305\215/metadata.json" "b/websites/T/Taiy\305\215/metadata.json" index 81af6db6ad86..68180761d5d0 100644 --- "a/websites/T/Taiy\305\215/metadata.json" +++ "b/websites/T/Taiy\305\215/metadata.json" @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Luscarvalho", - "id": "458776046184169473" - }, - "service": "Taiyō", - "altnames": [ - "Taiyō.moe", - "Taiyo.moe", - "Taiyo" - ], - "description": { - "en": "Read manga online for free at Taiyō, without ads, with high-quality images, and reader support.", - "pt_BR": "Leia mangás online e gratuitamente na Taiyō, sem anúncios, com alta qualidade de imagens e suporte aos leitores." - }, - "url": [ - "taiyo.moe", - "www.taiyo.moe" - ], - "version": "1.0.5", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Taiy%C5%8D/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Taiy%C5%8D/assets/thumbnail.png", - "color": "#FF4F4F", - "category": "anime", - "tags": [ - "manga", - "reading" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Luscarvalho", + "id": "458776046184169473" + }, + "service": "Taiyō", + "altnames": [ + "Taiyō.moe", + "Taiyo.moe", + "Taiyo" + ], + "description": { + "en": "Read manga online for free at Taiyō, without ads, with high-quality images, and reader support.", + "pt_BR": "Leia mangás online e gratuitamente na Taiyō, sem anúncios, com alta qualidade de imagens e suporte aos leitores." + }, + "url": [ + "taiyo.moe", + "www.taiyo.moe" + ], + "version": "1.0.5", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Taiy%C5%8D/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Taiy%C5%8D/assets/thumbnail.png", + "color": "#FF4F4F", + "category": "anime", + "tags": [ + "manga", + "reading" + ] +} diff --git "a/websites/T/Taiy\305\215/presence.ts" "b/websites/T/Taiy\305\215/presence.ts" index be11ac7770f2..78b6da616a7f 100644 --- "a/websites/T/Taiy\305\215/presence.ts" +++ "b/websites/T/Taiy\305\215/presence.ts" @@ -1,96 +1,102 @@ const presence = new Presence({ - clientId: "1187606265829019689", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1187606265829019689', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Taiy%C5%8D/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { href, pathname } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Taiy%C5%8D/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { href, pathname } = document.location - switch (pathname.split("/")[1]) { - case "auth": - presenceData.details = "Fazendo login"; - break; + switch (pathname.split('/')[1]) { + case 'auth': + presenceData.details = 'Fazendo login' + break - case "dashboard": { - if (pathname.includes("/medias/import")) - presenceData.details = "Importando mangá"; - else if (pathname.includes("/medias/edit")) - presenceData.details = "Editando mangá"; - else if ( - pathname.includes("/chapters/upload") || - pathname.includes("/chapters/bulk-upload") - ) { - const chapterNumber = document.querySelector( - '.chapter-number input[type="number"]' - )?.value, - chapterVolume = document.querySelector( - '.chapter-volume input[type="number"]' - )?.value, - chapterTitle = document.querySelectorAll( - 'input[data-slot="input"]' - )[1]?.value; - if (chapterTitle) { - presenceData.details = `Upando: ${chapterTitle}`; - if (chapterNumber && chapterVolume) - presenceData.state = `Cap. ${chapterNumber} - Vol. ${chapterVolume}`; - } else presenceData.details = "Upando mangá..."; - } else if (pathname.includes("/scans/add")) - presenceData.details = "Adicionando scan"; - else presenceData.details = "No dashboard..."; - break; - } + case 'dashboard': { + if (pathname.includes('/medias/import')) { + presenceData.details = 'Importando mangá' + } + else if (pathname.includes('/medias/edit')) { + presenceData.details = 'Editando mangá' + } + else if ( + pathname.includes('/chapters/upload') + || pathname.includes('/chapters/bulk-upload') + ) { + const chapterNumber = document.querySelector( + '.chapter-number input[type="number"]', + )?.value + const chapterVolume = document.querySelector( + '.chapter-volume input[type="number"]', + )?.value + const chapterTitle = document.querySelectorAll( + 'input[data-slot="input"]', + )[1]?.value + if (chapterTitle) { + presenceData.details = `Upando: ${chapterTitle}` + if (chapterNumber && chapterVolume) + presenceData.state = `Cap. ${chapterNumber} - Vol. ${chapterVolume}` + } + else { + presenceData.details = 'Upando mangá...' + } + } + else if (pathname.includes('/scans/add')) { + presenceData.details = 'Adicionando scan' + } + else { + presenceData.details = 'No dashboard...' + } + break + } - case "chapter": { - const mediaLink = - document.querySelector(".media-title").href, - links = getCover(mediaLink.split("/")[4]); - if (links.length > 0) - presenceData.largeImageKey = `https://www.taiyo.moe${links[1]}`; - presenceData.details = - document.querySelector(".media-title")?.textContent; - presenceData.state = `${ - document.querySelector(".chapter-number")?.textContent - } - Página ${ - document.querySelector(".chapter-currentPage")?.textContent - }`; - presenceData.buttons = [ - { label: "Ler capítulo", url: href.replace(/\/[^/]*$/, "") }, - { label: "Ler mangá", url: mediaLink }, - ]; - break; - } + case 'chapter': { + const mediaLink = document.querySelector('.media-title')!.href + const links = getCover(mediaLink.split('/')[4]) + if (links.length > 0) + presenceData.largeImageKey = `https://www.taiyo.moe${links[1]}` + presenceData.details = document.querySelector('.media-title')?.textContent + presenceData.state = `${ + document.querySelector('.chapter-number')?.textContent + } - Página ${ + document.querySelector('.chapter-currentPage')?.textContent + }` + presenceData.buttons = [ + { label: 'Ler capítulo', url: href.replace(/\/[^/]*$/, '') }, + { label: 'Ler mangá', url: mediaLink }, + ] + break + } - case "media": { - presenceData.largeImageKey = - document.querySelector(".cover-url")?.src; - presenceData.details = - document.querySelector(".media-title")?.textContent; - presenceData.buttons = [{ label: "Ler mangá", url: href }]; - break; - } + case 'media': { + presenceData.largeImageKey = document.querySelector('.cover-url')?.src + presenceData.details = document.querySelector('.media-title')?.textContent + presenceData.buttons = [{ label: 'Ler mangá', url: href }] + break + } - default: - presenceData.details = "Na página inicial..."; - break; - } + default: + presenceData.details = 'Na página inicial...' + break + } - function getCover(uuid: string) { - const elements = document.querySelectorAll( - 'link[rel="preload"][as="image"]' - ), - links: string[] = []; - for (const element of elements) { - const imageSrcSet = element.getAttribute("imagesrcset"); - if (imageSrcSet) links.push(imageSrcSet.split(", ")[0].split(" ")[0]); - } - return links.filter(link => link.includes(uuid)); - } + function getCover(uuid: string) { + const elements = document.querySelectorAll( + 'link[rel="preload"][as="image"]', + ) + const links: string[] = [] + for (const element of elements) { + const imageSrcSet = element.getAttribute('imagesrcset') + if (imageSrcSet) + links.push(imageSrcSet.split(', ')[0].split(' ')[0]) + } + return links.filter(link => link.includes(uuid)) + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Take B1nzy To Space/metadata.json b/websites/T/Take B1nzy To Space/metadata.json index d51c0a2b30cf..7ce3158a693e 100644 --- a/websites/T/Take B1nzy To Space/metadata.json +++ b/websites/T/Take B1nzy To Space/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Coding", - "id": "276544649148235776" - }, - "service": "Take B1nzy To Space", - "description": { - "en": "Travel through space while listening to amazing music on a website developed by former Discord staff and Senior Ratelimiter B1nzy!", - "nl": "Reis door de ruimte terwijl je naar geweldige muziek luistert op een website die is ontwikkeld door voormalige Discord-medewerkers en Senior Ratelimiter B1nzy!" - }, - "url": "takeb1nzyto.space", - "version": "1.0.20", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Take%20B1nzy%20To%20Space/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Take%20B1nzy%20To%20Space/assets/thumbnail.png", - "color": "#060A22", - "category": "music", - "tags": [ - "music", - "media", - "space", - "b1nzy" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Coding", + "id": "276544649148235776" + }, + "service": "Take B1nzy To Space", + "description": { + "en": "Travel through space while listening to amazing music on a website developed by former Discord staff and Senior Ratelimiter B1nzy!", + "nl": "Reis door de ruimte terwijl je naar geweldige muziek luistert op een website die is ontwikkeld door voormalige Discord-medewerkers en Senior Ratelimiter B1nzy!" + }, + "url": "takeb1nzyto.space", + "version": "1.0.20", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Take%20B1nzy%20To%20Space/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Take%20B1nzy%20To%20Space/assets/thumbnail.png", + "color": "#060A22", + "category": "music", + "tags": [ + "music", + "media", + "space", + "b1nzy" + ] +} diff --git a/websites/T/Take B1nzy To Space/presence.ts b/websites/T/Take B1nzy To Space/presence.ts index ee12b2b83843..25318e5cb460 100644 --- a/websites/T/Take B1nzy To Space/presence.ts +++ b/websites/T/Take B1nzy To Space/presence.ts @@ -1,20 +1,19 @@ const presence = new Presence({ - clientId: "735314055861895288", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '735314055861895288', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Take%20B1nzy%20To%20Space/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Take%20B1nzy%20To%20Space/assets/logo.png', + startTimestamp: browsingTimestamp, + } - presenceData.details = `Playing ${ - document.querySelector("#song").textContent - }`; - presenceData.state = `Ratelimited for ${ - document.querySelector("#ratelimited-time").textContent - }s`; - presence.setActivity(presenceData); -}); + presenceData.details = `Playing ${ + document.querySelector('#song')?.textContent + }` + presenceData.state = `Ratelimited for ${ + document.querySelector('#ratelimited-time')?.textContent + }s` + presence.setActivity(presenceData) +}) diff --git a/websites/T/Tanks.gg/metadata.json b/websites/T/Tanks.gg/metadata.json index ef92aa2f8c53..2797c631c6ff 100644 --- a/websites/T/Tanks.gg/metadata.json +++ b/websites/T/Tanks.gg/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "unicornbetrayal", - "id": "377284540420587541" - }, - "service": "Tanks.gg", - "description": { - "en": "World of Tanks tank info and models." - }, - "url": "tanks.gg", - "version": "1.0.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tanks.gg/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tanks.gg/assets/thumbnail.png", - "color": "#481109", - "category": "games", - "tags": [ - "world-of-tanks", - "tanks", - "gaming", - "stats", - "compare" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "unicornbetrayal", + "id": "377284540420587541" + }, + "service": "Tanks.gg", + "description": { + "en": "World of Tanks tank info and models." + }, + "url": "tanks.gg", + "version": "1.0.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tanks.gg/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tanks.gg/assets/thumbnail.png", + "color": "#481109", + "category": "games", + "tags": [ + "world-of-tanks", + "tanks", + "gaming", + "stats", + "compare" + ] +} diff --git a/websites/T/Tanks.gg/presence.ts b/websites/T/Tanks.gg/presence.ts index 72fcbac83d4b..85810e2da280 100644 --- a/websites/T/Tanks.gg/presence.ts +++ b/websites/T/Tanks.gg/presence.ts @@ -1,92 +1,98 @@ const presence = new Presence({ - clientId: "1003195428642238464", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1003195428642238464', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Tanks.gg/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, href } = window.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Tanks.gg/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, href } = window.location - if (pathname === "/") presenceData.details = "Browsing the home page"; - else if (document.location.pathname.startsWith("/tank/")) { - presenceData.details = "Viewing a tank"; - presenceData.state = `${ - document.querySelector(".header-tank > h1").firstChild.textContent - }`; - presenceData.buttons = [ - { - label: "View Tank", - url: href, - }, - ]; - } else if (document.location.pathname.startsWith("/list/stats")) { - presenceData.details = "Browsing tanks by stats"; - presenceData.state = `Sorting by: ${ - document.querySelector( - "#content > div > div.container-fluid.main-container > div > div.filter > div.dropdown.stat > button" - ).textContent - }`; - presenceData.buttons = [ - { - label: "View Page", - url: href, - }, - ]; - } else if (document.location.pathname.startsWith("/techtree/")) { - presenceData.details = "Viewing the tech tree"; - presenceData.state = document.querySelector(".current").textContent; - presenceData.buttons = [ - { - label: "View Tech Tree", - url: href, - }, - ]; - } else if (document.location.pathname.startsWith("/compare/")) { - presenceData.details = "Comparing tanks"; - presenceData.buttons = [ - { - label: "View Comparison", - url: href, - }, - ]; - } else if (document.querySelector('[class="player-stats"]')) { - presenceData.details = `Viewing profile (${ - document.querySelector('[class="dropdown-item active"]').textContent - })`; - presenceData.state = `${ - document.querySelector( - "#content > div > div.container-fluid.main-container > div > div.top-container > div.main-col > h2" - ).firstChild.textContent - }`; - presenceData.buttons = [ - { - label: "View Profile", - url: href, - }, - ]; - } else { - switch (pathname) { - case "/list": { - presenceData.details = "Browsing tanks"; - break; - } - case "/compare": { - presenceData.details = "Comparing tanks"; - break; - } - case "/about": { - presenceData.details = "Viewing the about page"; - break; - } - case "/privacy": { - presenceData.details = "Viewing the privacy policy"; - break; - } - } - } - presence.setActivity(presenceData); -}); + if (pathname === '/') { + presenceData.details = 'Browsing the home page' + } + else if (document.location.pathname.startsWith('/tank/')) { + presenceData.details = 'Viewing a tank' + presenceData.state = `${ + document.querySelector('.header-tank > h1')?.firstChild?.textContent + }` + presenceData.buttons = [ + { + label: 'View Tank', + url: href, + }, + ] + } + else if (document.location.pathname.startsWith('/list/stats')) { + presenceData.details = 'Browsing tanks by stats' + presenceData.state = `Sorting by: ${ + document.querySelector( + '#content > div > div.container-fluid.main-container > div > div.filter > div.dropdown.stat > button', + )?.textContent + }` + presenceData.buttons = [ + { + label: 'View Page', + url: href, + }, + ] + } + else if (document.location.pathname.startsWith('/techtree/')) { + presenceData.details = 'Viewing the tech tree' + presenceData.state = document.querySelector('.current')?.textContent + presenceData.buttons = [ + { + label: 'View Tech Tree', + url: href, + }, + ] + } + else if (document.location.pathname.startsWith('/compare/')) { + presenceData.details = 'Comparing tanks' + presenceData.buttons = [ + { + label: 'View Comparison', + url: href, + }, + ] + } + else if (document.querySelector('[class="player-stats"]')) { + presenceData.details = `Viewing profile (${ + document.querySelector('[class="dropdown-item active"]')?.textContent + })` + presenceData.state = `${ + document.querySelector( + '#content > div > div.container-fluid.main-container > div > div.top-container > div.main-col > h2', + )?.firstChild?.textContent + }` + presenceData.buttons = [ + { + label: 'View Profile', + url: href, + }, + ] + } + else { + switch (pathname) { + case '/list': { + presenceData.details = 'Browsing tanks' + break + } + case '/compare': { + presenceData.details = 'Comparing tanks' + break + } + case '/about': { + presenceData.details = 'Viewing the about page' + break + } + case '/privacy': { + presenceData.details = 'Viewing the privacy policy' + break + } + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/T/Tatsumaki/metadata.json b/websites/T/Tatsumaki/metadata.json index 22e6b6ba9649..8a5aab885d4c 100644 --- a/websites/T/Tatsumaki/metadata.json +++ b/websites/T/Tatsumaki/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Eren", - "id": "478937019758673931" - }, - "service": "Tatsumaki", - "description": { - "tr": "Tatsumaki, en büyük botlardan biri olmakla birlikte içinde kullanıcı profilleri, seviyeler ve basit moderasyon sistemi bulunmakta.", - "en": "Tatsumaki is providing social aspects including member profiles, levels, fun stuff & simple moderation.", - "nl": "Tatsumaki biedt sociale aspecten, waaronder ledenprofielen, niveaus, leuke dingen en eenvoudige moderatie." - }, - "url": "tatsu.gg", - "version": "1.2.27", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tatsumaki/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tatsumaki/assets/thumbnail.png", - "color": "#3FA549", - "category": "other", - "tags": [ - "bot", - "tatsumaki" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Eren", + "id": "478937019758673931" + }, + "service": "Tatsumaki", + "description": { + "tr": "Tatsumaki, en büyük botlardan biri olmakla birlikte içinde kullanıcı profilleri, seviyeler ve basit moderasyon sistemi bulunmakta.", + "en": "Tatsumaki is providing social aspects including member profiles, levels, fun stuff & simple moderation.", + "nl": "Tatsumaki biedt sociale aspecten, waaronder ledenprofielen, niveaus, leuke dingen en eenvoudige moderatie." + }, + "url": "tatsu.gg", + "version": "1.2.27", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tatsumaki/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tatsumaki/assets/thumbnail.png", + "color": "#3FA549", + "category": "other", + "tags": [ + "bot", + "tatsumaki" + ] +} diff --git a/websites/T/Tatsumaki/presence.ts b/websites/T/Tatsumaki/presence.ts index 7802fd22468f..cc7cb86d3be3 100644 --- a/websites/T/Tatsumaki/presence.ts +++ b/websites/T/Tatsumaki/presence.ts @@ -1,36 +1,48 @@ const presence = new Presence({ - clientId: "652773935829614592", -}); + clientId: '652773935829614592', +}) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Tatsumaki/assets/logo.png", - }, - page = window.location.pathname, - browsingTimestamp = Math.floor(Date.now() / 1000); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Tatsumaki/assets/logo.png', + } + const page = window.location.pathname + const browsingTimestamp = Math.floor(Date.now() / 1000) - presenceData.startTimestamp = browsingTimestamp; + presenceData.startTimestamp = browsingTimestamp - if (page.endsWith("/editcard")) - presenceData.details = "Editing their profile card"; - else if (page.endsWith("/inventory")) - presenceData.details = "Viewing their inventory"; - else if (page.endsWith("/settings")) - presenceData.details = "Editing their settings"; - else if (page.startsWith("/blog")) presenceData.details = "Viewing all blogs"; - else if (page.startsWith("/article")) { - presenceData.details = "Reading an article:"; - presenceData.state = document.querySelector( - "#__next > main > div.css-vxgrp0 > main > div > div.css-17cwizr > div > h1" - ).textContent; - } else if (page.endsWith("/servers")) presenceData.details = "On dashboard"; - else if (page.startsWith("/server")) - presenceData.details = "Managing/Viewing a server"; - else if (page.startsWith("/shops")) presenceData.details = "On shop menu"; - else if (page.startsWith("/profile")) - presenceData.details = "Viewing their profile"; + if (page.endsWith('/editcard')) { + presenceData.details = 'Editing their profile card' + } + else if (page.endsWith('/inventory')) { + presenceData.details = 'Viewing their inventory' + } + else if (page.endsWith('/settings')) { + presenceData.details = 'Editing their settings' + } + else if (page.startsWith('/blog')) { + presenceData.details = 'Viewing all blogs' + } + else if (page.startsWith('/article')) { + presenceData.details = 'Reading an article:' + presenceData.state = document.querySelector( + '#__next > main > div.css-vxgrp0 > main > div > div.css-17cwizr > div > h1', + )?.textContent + } + else if (page.endsWith('/servers')) { + presenceData.details = 'On dashboard' + } + else if (page.startsWith('/server')) { + presenceData.details = 'Managing/Viewing a server' + } + else if (page.startsWith('/shops')) { + presenceData.details = 'On shop menu' + } + else if (page.startsWith('/profile')) { + presenceData.details = 'Viewing their profile' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TeamSeas/metadata.json b/websites/T/TeamSeas/metadata.json index 7249dd8bd6ce..bde84c70476f 100644 --- a/websites/T/TeamSeas/metadata.json +++ b/websites/T/TeamSeas/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "The Gamerzs", - "id": "730142125181894657" - }, - "service": "TeamSeas", - "description": { - "en": "Help us remove 30 million pounds of trash by January 1st, 2022." - }, - "url": "teamseas.org", - "version": "1.0.16", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TeamSeas/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TeamSeas/assets/thumbnail.png", - "color": "#0095c3", - "category": "other", - "tags": [ - "seas", - "mrbeast" - ], - "settings": [ - { - "id": "count", - "title": "Show donated amount", - "icon": "fas fa-dollar-sign", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "The Gamerzs", + "id": "730142125181894657" + }, + "service": "TeamSeas", + "description": { + "en": "Help us remove 30 million pounds of trash by January 1st, 2022." + }, + "url": "teamseas.org", + "version": "1.0.16", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TeamSeas/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TeamSeas/assets/thumbnail.png", + "color": "#0095c3", + "category": "other", + "tags": [ + "seas", + "mrbeast" + ], + "settings": [ + { + "id": "count", + "title": "Show donated amount", + "icon": "fas fa-dollar-sign", + "value": true + } + ] +} diff --git a/websites/T/TeamSeas/presence.ts b/websites/T/TeamSeas/presence.ts index 48fac2a679ad..bea95b4081c3 100644 --- a/websites/T/TeamSeas/presence.ts +++ b/websites/T/TeamSeas/presence.ts @@ -1,28 +1,28 @@ const presence = new Presence({ - clientId: "904072771900948570", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '904072771900948570', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TeamSeas/assets/logo.png", - }, - currentCount = await presence.getSetting("count"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TeamSeas/assets/logo.png', + } + const currentCount = await presence.getSetting('count') - if (currentCount) { - presenceData.details = `$${ - document.querySelector("#liveCounter")?.textContent - }`; - presenceData.state = "Currently Donated"; - } else { - presenceData.details = "Helping #TeamSeas clean"; - presenceData.state = "30million pounds by 2022"; - } - presenceData.startTimestamp = browsingTimestamp; - presenceData.buttons = [ - { label: "Visit #TeamTrees", url: "https://teamtrees.org" }, - ]; + if (currentCount) { + presenceData.details = `$${ + document.querySelector('#liveCounter')?.textContent + }` + presenceData.state = 'Currently Donated' + } + else { + presenceData.details = 'Helping #TeamSeas clean' + presenceData.state = '30million pounds by 2022' + } + presenceData.startTimestamp = browsingTimestamp + presenceData.buttons = [ + { label: 'Visit #TeamTrees', url: 'https://teamtrees.org' }, + ] - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/TeamTrees/metadata.json b/websites/T/TeamTrees/metadata.json index c54442f6c801..f5169cb8242c 100644 --- a/websites/T/TeamTrees/metadata.json +++ b/websites/T/TeamTrees/metadata.json @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "TeamTrees", - "description": { - "en": "Help us plant 20 million trees around the globe by January 1st, 2020.", - "nl": "Help ons om tegen 1 januari 2020 wereldwijd 20 miljoen bomen over de hele wereld te planten." - }, - "url": "teamtrees.org", - "version": "1.2.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TeamTrees/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TeamTrees/assets/thumbnail.jpg", - "color": "#8ab740", - "category": "other", - "tags": [ - "trees", - "mrbeast" - ], - "settings": [ - { - "id": "count", - "title": "Show donated amount", - "icon": "fas fa-dollar-sign", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "TeamTrees", + "description": { + "en": "Help us plant 20 million trees around the globe by January 1st, 2020.", + "nl": "Help ons om tegen 1 januari 2020 wereldwijd 20 miljoen bomen over de hele wereld te planten." + }, + "url": "teamtrees.org", + "version": "1.2.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TeamTrees/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TeamTrees/assets/thumbnail.jpg", + "color": "#8ab740", + "category": "other", + "tags": [ + "trees", + "mrbeast" + ], + "settings": [ + { + "id": "count", + "title": "Show donated amount", + "icon": "fas fa-dollar-sign", + "value": true + } + ] +} diff --git a/websites/T/TeamTrees/presence.ts b/websites/T/TeamTrees/presence.ts index f49261f8fa33..d6c5eb56c1c9 100644 --- a/websites/T/TeamTrees/presence.ts +++ b/websites/T/TeamTrees/presence.ts @@ -1,29 +1,29 @@ const presence = new Presence({ - clientId: "638344004085350400", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '638344004085350400', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TeamTrees/assets/logo.png", - }, - currentCount = await presence.getSetting("count"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TeamTrees/assets/logo.png', + } + const currentCount = await presence.getSetting('count') - if (currentCount) { - presenceData.details = `$${ - document.querySelector("#totalTrees")?.textContent - }`; - presenceData.state = "Currently Donated"; - } else { - presenceData.details = "Helping #TeamTrees plant"; - presenceData.state = "20million trees by 2020"; - } + if (currentCount) { + presenceData.details = `$${ + document.querySelector('#totalTrees')?.textContent + }` + presenceData.state = 'Currently Donated' + } + else { + presenceData.details = 'Helping #TeamTrees plant' + presenceData.state = '20million trees by 2020' + } - presenceData.startTimestamp = browsingTimestamp; - presenceData.buttons = [ - { label: "Visit #TeamSeas", url: "https://teamSeas.org" }, - ]; + presenceData.startTimestamp = browsingTimestamp + presenceData.buttons = [ + { label: 'Visit #TeamSeas', url: 'https://teamSeas.org' }, + ] - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/Tebex/metadata.json b/websites/T/Tebex/metadata.json index 8be06dfb6d90..9692d7ada0f4 100644 --- a/websites/T/Tebex/metadata.json +++ b/websites/T/Tebex/metadata.json @@ -1,38 +1,38 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dark_Ville", - "id": "638080361179512853" - }, - "service": "Tebex", - "description": { - "en": "Fund your game server costs with Tebex. The leading payment plugin for Minecraft, Rust, ARK, GTA V and more.", - "nl": "Financier jouw game server kosten met Tebex. De vooraanstaande betalingsplugin voor Minecraft, Rust, ARK, GTA V en meer." - }, - "url": [ - "tebex.io", - "docs.tebex.io" - ], - "regExp": "(.*[.]buycraft[.]net)|(.*[.]tebex[.]io)", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tebex/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tebex/assets/thumbnail.jpg", - "color": "#215AA9", - "category": "other", - "tags": [ - "buycraft", - "tebex" - ], - "settings": [ - { - "id": "buttons", - "if": { - "privacy": false - }, - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dark_Ville", + "id": "638080361179512853" + }, + "service": "Tebex", + "description": { + "en": "Fund your game server costs with Tebex. The leading payment plugin for Minecraft, Rust, ARK, GTA V and more.", + "nl": "Financier jouw game server kosten met Tebex. De vooraanstaande betalingsplugin voor Minecraft, Rust, ARK, GTA V en meer." + }, + "url": [ + "tebex.io", + "docs.tebex.io" + ], + "regExp": "(.*[.]buycraft[.]net)|(.*[.]tebex[.]io)", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tebex/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tebex/assets/thumbnail.jpg", + "color": "#215AA9", + "category": "other", + "tags": [ + "buycraft", + "tebex" + ], + "settings": [ + { + "id": "buttons", + "if": { + "privacy": false + }, + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/T/Tebex/presence.ts b/websites/T/Tebex/presence.ts index e34ce340ed52..b5e642d99265 100644 --- a/websites/T/Tebex/presence.ts +++ b/websites/T/Tebex/presence.ts @@ -1,150 +1,159 @@ const presence = new Presence({ - clientId: "974646056161804398", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '974646056161804398', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Tebex/assets/logo.jpg", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Tebex/assets/logo.jpg', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { hostname, href, pathname } = document.location, - pathnameSplit = pathname.split("/"), - buttons = await presence.getSetting("buttons"), - search = document.querySelector( - '[autocapitalize="sentences"]' - ); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { hostname, href, pathname } = document.location + const pathnameSplit = pathname.split('/') + const buttons = await presence.getSetting('buttons') + const search = document.querySelector( + '[autocapitalize="sentences"]', + ) - switch (hostname) { - case "www.tebex.io": - case "tebex.io": { - switch (pathnameSplit[1]) { - case "store": { - presenceData.details = `Viewing store function ${document - .querySelector( - '[class="text-white opacity-5 hover-opacity-10 opacity-10 "]' - ) - ?.textContent.toLowerCase()}`; - presenceData.buttons = [ - { - label: "View The Store", - url: href, - }, - ]; - break; - } - case "games": { - presenceData.details = "Viewing all games"; - break; - } - case "game-studios": { - presenceData.details = "Viewing info for game studios"; - presenceData.buttons = [ - { - label: "View Info", - url: href, - }, - ]; - break; - } - case "partners": { - presenceData.details = "Viewing partners"; - break; - } - case "contact": { - presenceData.details = "Viewing contact info"; - break; - } - case "": { - presenceData.details = "Viewing the home page"; - break; - } - default: { - presenceData.details = `Viewing ${document - .querySelector( - '[class="btn btn-outline-white dropdown-toggle btn-lg mx-3"]' - ) - .textContent.trim()}'s monetisation options`; - } - } - break; - } - case "docs.tebex.io": { - if (search?.value) { - presenceData.details = "Searching the docs for"; - presenceData.state = search?.value; - presenceData.smallImageKey = Assets.Search; - } else { - presenceData.details = `Reading the ${ - document.querySelector('[data-testid="page.title"]')?.textContent - } page`; - presenceData.smallImageKey = Assets.Reading; - presenceData.buttons = [ - { - label: "Read Docs", - url: href, - }, - ]; - } - break; - } - default: { - const viewing = `Viewing ${ - document.querySelector("[class*=store-name]")?.textContent ?? - document.querySelector("head > title")?.textContent.split("|")[0].trim() - }'s`; - switch (pathnameSplit[1]) { - case "": { - presenceData.details = `${viewing} homepage`; - break; - } - case "category": { - switch (pathnameSplit[2]) { - case "": { - presenceData.details = `${viewing} categories`; - break; - } - default: { - presenceData.details = `${viewing} ${ - document - .querySelector('[class="page-title"]') - ?.textContent.toLowerCase() ?? - document - .querySelectorAll('li[class="active"]')[1] - ?.textContent.toLowerCase() - }`; - break; - } - } - break; - } - case "about": { - presenceData.details = `${viewing} about page`; - presenceData.buttons = [ - { - label: "View The About Page", - url: href, - }, - ]; - break; - } - } - break; - } - } - if (!search && buttons && !presenceData.buttons) { - presenceData.buttons = [ - { - label: "View Page", - url: href, - }, - ]; - } else if (!buttons) delete presenceData.buttons; + switch (hostname) { + case 'www.tebex.io': + case 'tebex.io': { + switch (pathnameSplit[1]) { + case 'store': { + presenceData.details = `Viewing store function ${document + .querySelector( + '[class="text-white opacity-5 hover-opacity-10 opacity-10 "]', + ) + ?.textContent + ?.toLowerCase()}` + presenceData.buttons = [ + { + label: 'View The Store', + url: href, + }, + ] + break + } + case 'games': { + presenceData.details = 'Viewing all games' + break + } + case 'game-studios': { + presenceData.details = 'Viewing info for game studios' + presenceData.buttons = [ + { + label: 'View Info', + url: href, + }, + ] + break + } + case 'partners': { + presenceData.details = 'Viewing partners' + break + } + case 'contact': { + presenceData.details = 'Viewing contact info' + break + } + case '': { + presenceData.details = 'Viewing the home page' + break + } + default: { + presenceData.details = `Viewing ${document + .querySelector( + '[class="btn btn-outline-white dropdown-toggle btn-lg mx-3"]', + ) + ?.textContent + ?.trim()}'s monetisation options` + } + } + break + } + case 'docs.tebex.io': { + if (search?.value) { + presenceData.details = 'Searching the docs for' + presenceData.state = search?.value + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = `Reading the ${ + document.querySelector('[data-testid="page.title"]')?.textContent + } page` + presenceData.smallImageKey = Assets.Reading + presenceData.buttons = [ + { + label: 'Read Docs', + url: href, + }, + ] + } + break + } + default: { + const viewing = `Viewing ${ + document.querySelector('[class*=store-name]')?.textContent + ?? document.querySelector('head > title')?.textContent?.split('|')[0].trim() + }'s` + switch (pathnameSplit[1]) { + case '': { + presenceData.details = `${viewing} homepage` + break + } + case 'category': { + switch (pathnameSplit[2]) { + case '': { + presenceData.details = `${viewing} categories` + break + } + default: { + presenceData.details = `${viewing} ${ + document + .querySelector('[class="page-title"]') + ?.textContent + ?.toLowerCase() + ?? document + .querySelectorAll('li[class="active"]')[1] + ?.textContent + ?.toLowerCase() + }` + break + } + } + break + } + case 'about': { + presenceData.details = `${viewing} about page` + presenceData.buttons = [ + { + label: 'View The About Page', + url: href, + }, + ] + break + } + } + break + } + } + if (!search && buttons && !presenceData.buttons) { + presenceData.buttons = [ + { + label: 'View Page', + url: href, + }, + ] + } + else if (!buttons) { + delete presenceData.buttons + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Teknobuk/metadata.json b/websites/T/Teknobuk/metadata.json index 0273504e654c..253fb7be7b25 100644 --- a/websites/T/Teknobuk/metadata.json +++ b/websites/T/Teknobuk/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Arda", - "id": "403225819222245377" - }, - "service": "Teknobuk", - "description": { - "tr": "Teknobuk, tıpkı Webtekno ve ShiftDelete.Net gibi bir teknolojik haber sitesi.", - "en": "Teknobuk is a technology blog, just like Webtekno ve ShiftDelete.Net.", - "nl": "Teknobuk is een technologieblog, net als Webtekno ve ShiftDelete.Net." - }, - "url": [ - "www.teknobuk.com", - "teknobuk.com" - ], - "version": "1.2.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Teknobuk/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Teknobuk/assets/thumbnail.png", - "color": "#FABD1B", - "category": "other", - "tags": [ - "log", - "blog", - "technology", - "turkish" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Arda", + "id": "403225819222245377" + }, + "service": "Teknobuk", + "description": { + "tr": "Teknobuk, tıpkı Webtekno ve ShiftDelete.Net gibi bir teknolojik haber sitesi.", + "en": "Teknobuk is a technology blog, just like Webtekno ve ShiftDelete.Net.", + "nl": "Teknobuk is een technologieblog, net als Webtekno ve ShiftDelete.Net." + }, + "url": [ + "www.teknobuk.com", + "teknobuk.com" + ], + "version": "1.2.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Teknobuk/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Teknobuk/assets/thumbnail.png", + "color": "#FABD1B", + "category": "other", + "tags": [ + "log", + "blog", + "technology", + "turkish" + ] +} diff --git a/websites/T/Teknobuk/presence.ts b/websites/T/Teknobuk/presence.ts index adfe7c32395e..dc9f24c185f7 100644 --- a/websites/T/Teknobuk/presence.ts +++ b/websites/T/Teknobuk/presence.ts @@ -1,110 +1,111 @@ -const presence = new Presence({ clientId: "658192386899312651" }), - browsingTimestamp = Math.floor(Date.now() / 1000), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Teknobuk/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +const presence = new Presence({ clientId: '658192386899312651' }) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Teknobuk/assets/logo.png', + startTimestamp: browsingTimestamp, +} function makeRPC(title: string, category: string): void { - switch (category) { - case "kategori": { - presenceData.details = "Bir kategoriye göz atıyor:"; - presenceData.state = title; + switch (category) { + case 'kategori': { + presenceData.details = 'Bir kategoriye göz atıyor:' + presenceData.state = title - break; - } - case "etiket": { - presenceData.details = "Bir etikete göz atıyor:"; - presenceData.state = title; + break + } + case 'etiket': { + presenceData.details = 'Bir etikete göz atıyor:' + presenceData.state = title - break; - } - case "author": { - presenceData.details = "Bir yazara göz atıyor:"; - presenceData.state = title; + break + } + case 'author': { + presenceData.details = 'Bir yazara göz atıyor:' + presenceData.state = title - break; - } - // No default - } + break + } + } } -presence.on("UpdateData", () => { - const page = document.location.pathname; +presence.on('UpdateData', () => { + const page = document.location.pathname - // Homepage - if (page.length <= 1 || page.startsWith("/page")) { - presenceData.details = "Ana Sayfa"; - presenceData.state = "Haberlere göz atıyor..."; - } + // Homepage + if (page.length <= 1 || page.startsWith('/page')) { + presenceData.details = 'Ana Sayfa' + presenceData.state = 'Haberlere göz atıyor...' + } - // Reading an article - if ( - document.querySelector("#content > div:nth-child(2) > article > div > h1") - ?.textContent - ) { - presenceData.details = "Bir haber okuyor..."; - presenceData.state = document.querySelector( - "#content > div:nth-child(2) > article > div > h1" - ).textContent; - } + // Reading an article + if ( + document.querySelector('#content > div:nth-child(2) > article > div > h1') + ?.textContent + ) { + presenceData.details = 'Bir haber okuyor...' + presenceData.state = document.querySelector( + '#content > div:nth-child(2) > article > div > h1', + )?.textContent + } - if (page.startsWith("/kategori") && page !== "/kategori") { - const category = - document.querySelector( - "#content > div.page-title.hu-pad.group > h1 > span" - )?.textContent ?? "Bilinmeyen"; - makeRPC(category, "kategori"); - } + if (page.startsWith('/kategori') && page !== '/kategori') { + const category = document.querySelector( + '#content > div.page-title.hu-pad.group > h1 > span', + )?.textContent ?? 'Bilinmeyen' + makeRPC(category, 'kategori') + } - if (page.startsWith("/etiket") && page !== "/etiket") { - let category = document.querySelector("#blog-entries > header > h1") - ? document - .querySelector("#blog-entries > header > h1") - .textContent.substring(8) - : "Bilinmeyen"; - category = category.charAt(0).toUpperCase() + category.substring(1); - makeRPC(category, "etiket"); - } + if (page.startsWith('/etiket') && page !== '/etiket') { + const category = document.querySelector('#blog-entries > header > h1') + ? document + .querySelector('#blog-entries > header > h1') + ?.textContent + ?.substring(8) + : 'Bilinmeyen' + makeRPC(`${category?.charAt(0).toUpperCase()}${category?.substring(1)}`, 'etiket') + } - if (page.startsWith("/yazar")) { - makeRPC( - document.querySelector( - "#content > div.page-title.hu-pad.group > h1 > span" - )?.textContent ?? "Bilinmeyen", - "author" - ); - } + if (page.startsWith('/yazar')) { + makeRPC( + document.querySelector( + '#content > div.page-title.hu-pad.group > h1 > span', + )?.textContent ?? 'Bilinmeyen', + 'author', + ) + } - if (new URLSearchParams(window.location.search).get("s")) { - presenceData.details = "Arama sonuçları:"; - presenceData.state = new URLSearchParams(window.location.search).get("s"); - } + if (new URLSearchParams(window.location.search).get('s')) { + presenceData.details = 'Arama sonuçları:' + presenceData.state = new URLSearchParams(window.location.search).get('s') + } - if (page.startsWith("/ara")) presenceData.details = "Arama bölümünde..."; + if (page.startsWith('/ara')) + presenceData.details = 'Arama bölümünde...' - if ( - ["/kunye", "/iletisim", "/gizlilik-politikasi"].some(pac => - page.startsWith(pac) - ) - ) { - if ( - !document.querySelector("#content > div.page-title.hu-pad.group > h1") - ?.textContent - ) - return; - presenceData.details = "Bir sayfaya göz atıyor..."; - presenceData.state = document.querySelector( - "#content > div.page-title.hu-pad.group > h1" - )?.textContent; - } + if ( + ['/kunye', '/iletisim', '/gizlilik-politikasi'].some(pac => + page.startsWith(pac), + ) + ) { + if ( + !document.querySelector('#content > div.page-title.hu-pad.group > h1') + ?.textContent + ) { + return + } + presenceData.details = 'Bir sayfaya göz atıyor...' + presenceData.state = document.querySelector( + '#content > div.page-title.hu-pad.group > h1', + )?.textContent + } - if (!presenceData.details) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Teknobuk/assets/logo.png", - details: "Bilinmeyen bir sayfada...", - }); - } else presence.setActivity(presenceData); -}); + if (!presenceData.details) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Teknobuk/assets/logo.png', + details: 'Bilinmeyen bir sayfada...', + }) + } + else { + presence.setActivity(presenceData) + } +}) diff --git a/websites/T/Telegram/metadata.json b/websites/T/Telegram/metadata.json index 741e861af462..1cf0dfc74b88 100644 --- a/websites/T/Telegram/metadata.json +++ b/websites/T/Telegram/metadata.json @@ -1,42 +1,42 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kabal", - "id": "269581360316940299" - }, - "contributors": [ - { - "name": "Atlassian", - "id": "191388216509595648" - } - ], - "service": "Telegram", - "description": { - "en": "Telegram is a secure instant messaging service with multi-platform support.", - "tr": "Telegram, çoklu platform desteği sunan, güvenli anlık mesajlaşma servisidir.", - "ru": "Telegram - это безопасный сервис обмена мгновенными сообщениями с поддержкой нескольких платформ.", - "uk_UA": "Telegram - це безпечний та мультиплатформенний сервіс обміну миттєвими повідомленнями.", - "nl": "Telegram is een veilige instant messaging-service met ondersteuning voor meerdere platforms.", - "vi_VN": "Telegram là dịch vụ nhắn tin bảo mật và xuyên nền tảng." - }, - "url": "web.telegram.org", - "version": "2.0.12", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Telegram/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Telegram/assets/thumbnail.png", - "color": "#33abe0", - "category": "socials", - "tags": [ - "telegram", - "message", - "social" - ], - "settings": [ - { - "id": "name", - "title": "Show name", - "icon": "fas fa-user", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Kabal", + "id": "269581360316940299" + }, + "contributors": [ + { + "name": "Atlassian", + "id": "191388216509595648" + } + ], + "service": "Telegram", + "description": { + "en": "Telegram is a secure instant messaging service with multi-platform support.", + "tr": "Telegram, çoklu platform desteği sunan, güvenli anlık mesajlaşma servisidir.", + "ru": "Telegram - это безопасный сервис обмена мгновенными сообщениями с поддержкой нескольких платформ.", + "uk_UA": "Telegram - це безпечний та мультиплатформенний сервіс обміну миттєвими повідомленнями.", + "nl": "Telegram is een veilige instant messaging-service met ondersteuning voor meerdere platforms.", + "vi_VN": "Telegram là dịch vụ nhắn tin bảo mật và xuyên nền tảng." + }, + "url": "web.telegram.org", + "version": "2.0.12", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Telegram/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Telegram/assets/thumbnail.png", + "color": "#33abe0", + "category": "socials", + "tags": [ + "telegram", + "message", + "social" + ], + "settings": [ + { + "id": "name", + "title": "Show name", + "icon": "fas fa-user", + "value": true + } + ] +} diff --git a/websites/T/Telegram/presence.ts b/websites/T/Telegram/presence.ts index 8775af1b3a6b..18bbe830c74e 100644 --- a/websites/T/Telegram/presence.ts +++ b/websites/T/Telegram/presence.ts @@ -1,92 +1,96 @@ const presence = new Presence({ - clientId: "664595715242197008", -}); + clientId: '664595715242197008', +}) function setPresenceData( - presenceData: PresenceData, - showName: boolean, - activeChatDetails: Element, - isLoggedIn?: boolean, - textArea?: HTMLElement, - messagesCount?: number, - statusSpan?: HTMLElement + presenceData: PresenceData, + showName: boolean, + activeChatDetails?: HTMLElement, + isLoggedIn?: boolean, + textArea?: HTMLElement, + messagesCount?: number, + statusSpan?: HTMLElement, ): PresenceData { - if (activeChatDetails?.textContent) { - if (showName) { - presenceData.details = `Talking to this ${ - statusSpan?.textContent.includes("member") ? "group" : "user" - }:`; - presenceData.state = activeChatDetails.textContent; - } else presenceData.details = "Talking to someone"; - presenceData.smallImageKey = - textArea && textArea.textContent.length >= 1 - ? Assets.Writing - : Assets.Reading; - presenceData.smallImageText = - textArea && textArea.textContent.length >= 1 - ? "Typing a message" - : `Reading ${messagesCount} message${messagesCount > 1 ? "s" : ""}`; - } else if (isLoggedIn) presenceData.details = "Logged in"; - else presenceData.details = "Logging in..."; - return presenceData; + if (activeChatDetails?.textContent) { + if (showName) { + presenceData.details = `Talking to this ${ + statusSpan?.textContent?.includes('member') ? 'group' : 'user' + }:` + presenceData.state = activeChatDetails.textContent + } + else { + presenceData.details = 'Talking to someone' + } + presenceData.smallImageKey = textArea?.textContent && textArea.textContent.length >= 1 + ? Assets.Writing + : Assets.Reading + presenceData.smallImageText = textArea?.textContent && textArea.textContent.length >= 1 + ? 'Typing a message' + : `Reading ${messagesCount} message${(messagesCount ?? 0) > 1 ? 's' : ''}` + } + else if (isLoggedIn) { + presenceData.details = 'Logged in' + } + else { + presenceData.details = 'Logging in...' + } + return presenceData } -presence.on("UpdateData", async () => { - const showName: boolean = await presence.getSetting("name"); // presence settings - let presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Telegram/assets/logo.png", - }, // default PresenceData - isLoggedIn: boolean, // determine if logged in or still logging in - activeChatDetails: HTMLElement, // details of current active chat - textArea: HTMLElement, // text area where user input message, for writing indicator - messagesCount: number, // total message count inside active chat - statusSpan: HTMLElement; // additional details of active chat, just below activeChatDetails, to determine if active chat is group or user - if (document.location.href.includes("legacy=1")) { - // Telegram Web version 0.7.0 - (activeChatDetails = document.querySelector( - "body > div.page_wrap > div:nth-child(1) > div > div > div.tg_head_main_wrap > div > div.tg_head_peer_title_wrap > a > div > span.tg_head_peer_title" - )), - (isLoggedIn = - document.querySelectorAll(".im_history_not_selected_wrap")?.length > 0), - (textArea = document.querySelector("div.composer_rich_textarea")), - (messagesCount = document.querySelectorAll("div.im_message_body").length), - (statusSpan = document.querySelector(".tg_head_peer_status")); - } else if (document.location.href.includes("/k/")) { - // Telegram WebK 1.2.0 (113) - (activeChatDetails = document.querySelector( - "#column-center > div.chats-container > div.chat > div.sidebar-header > div.chat-info-container > div.chat-info > div.person > div.content > div.top > div.user-title > span.peer-title" - )), - (isLoggedIn = - document.querySelector(".chat-background-item.is-visible") - ?.childElementCount < 1), - (textArea = document.querySelector(".input-message-input")), - (messagesCount = document.querySelectorAll(".message").length), - (statusSpan = document.querySelector( - "div.content > div.bottom > div.info > span.i18n" - )); - } else if (document.location.href.includes("/z/")) { - // Telegram WebZ 1.35.1 - (activeChatDetails = document.querySelector( - "#MiddleColumn > div.messages-layout > div.MiddleHeader > div.Transition.slide-fade > div.Transition__slide--active > div.chat-info-wrapper > div.ChatInfo > div.info > div.title > h3" - )), - (isLoggedIn = !!document.querySelector("#middle-column-bg")), - (textArea = document.querySelector("#editable-message-text")), - (messagesCount = document.querySelectorAll(".Message").length), - (statusSpan = document.querySelector("span.status")); - } - presenceData = { - ...presenceData, - ...setPresenceData( - presenceData, - showName, - activeChatDetails, - isLoggedIn, - textArea, - messagesCount, - statusSpan - ), - }; +presence.on('UpdateData', async () => { + const showName: boolean = await presence.getSetting('name') // presence settings + let presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Telegram/assets/logo.png', + } // default PresenceData + let isLoggedIn: boolean | undefined // determine if logged in or still logging in + let activeChatDetails: HTMLElement | undefined // details of current active chat + let textArea: HTMLElement | undefined // text area where user input message, for writing indicator + let messagesCount: number | undefined // total message count inside active chat + let statusSpan: HTMLElement | undefined // additional details of active chat, just below activeChatDetails, to determine if active chat is group or user + if (document.location.href.includes('legacy=1')) { + // Telegram Web version 0.7.0 + activeChatDetails = document.querySelector( + 'body > div.page_wrap > div:nth-child(1) > div > div > div.tg_head_main_wrap > div > div.tg_head_peer_title_wrap > a > div > span.tg_head_peer_title', + ) ?? undefined + isLoggedIn = document.querySelectorAll('.im_history_not_selected_wrap')?.length > 0 + textArea = document.querySelector('div.composer_rich_textarea') ?? undefined + messagesCount = document.querySelectorAll('div.im_message_body').length + statusSpan = document.querySelector('.tg_head_peer_status') ?? undefined + } + else if (document.location.href.includes('/k/')) { + // Telegram WebK 1.2.0 (113) + activeChatDetails = document.querySelector( + '#column-center > div.chats-container > div.chat > div.sidebar-header > div.chat-info-container > div.chat-info > div.person > div.content > div.top > div.user-title > span.peer-title', + ) ?? undefined + isLoggedIn = (document.querySelector('.chat-background-item.is-visible')?.childElementCount ?? 0) < 1 + textArea = document.querySelector('.input-message-input') ?? undefined + messagesCount = document.querySelectorAll('.message').length + statusSpan = document.querySelector( + 'div.content > div.bottom > div.info > span.i18n', + ) ?? undefined + } + else if (document.location.href.includes('/z/')) { + // Telegram WebZ 1.35.1 + activeChatDetails = document.querySelector( + '#MiddleColumn > div.messages-layout > div.MiddleHeader > div.Transition.slide-fade > div.Transition__slide--active > div.chat-info-wrapper > div.ChatInfo > div.info > div.title > h3', + ) ?? undefined + isLoggedIn = !!document.querySelector('#middle-column-bg') + textArea = document.querySelector('#editable-message-text') ?? undefined + messagesCount = document.querySelectorAll('.Message').length + statusSpan = document.querySelector('span.status') ?? undefined + } + presenceData = { + ...presenceData, + ...setPresenceData( + presenceData, + showName, + activeChatDetails, + isLoggedIn, + textArea, + messagesCount, + statusSpan, + ), + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/Tellingtone/metadata.json b/websites/T/Tellingtone/metadata.json index d76dd3cae751..db5cc38d3b74 100644 --- a/websites/T/Tellingtone/metadata.json +++ b/websites/T/Tellingtone/metadata.json @@ -1,42 +1,42 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "RisingSunLight", - "id": "240521747852558347" - }, - "service": "Tellingtone", - "description": { - "en": "Discover our catalog of original audio series, stories designed at the start to be listened to as a podcast. Immerse yourself in our fantastic universe where suspense, magic and investigation intertwine...", - "fr": "Découvrez notre catalogue de séries audio originales, des histoires conçues dès l'écriture pour être écoutées en podcast. Plongez dans nos univers fantastiques où s'entremêlent suspense, magie et enquête…" - }, - "url": "tellingtone.com", - "version": "1.0.12", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tellingtone/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tellingtone/assets/thumbnail.png", - "color": "#f58800", - "category": "other", - "tags": [ - "superflame", - "stories", - "audio" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "time", - "title": "Show Timestamp", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "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": "RisingSunLight", + "id": "240521747852558347" + }, + "service": "Tellingtone", + "description": { + "en": "Discover our catalog of original audio series, stories designed at the start to be listened to as a podcast. Immerse yourself in our fantastic universe where suspense, magic and investigation intertwine...", + "fr": "Découvrez notre catalogue de séries audio originales, des histoires conçues dès l'écriture pour être écoutées en podcast. Plongez dans nos univers fantastiques où s'entremêlent suspense, magie et enquête…" + }, + "url": "tellingtone.com", + "version": "1.0.12", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tellingtone/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tellingtone/assets/thumbnail.png", + "color": "#f58800", + "category": "other", + "tags": [ + "superflame", + "stories", + "audio" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "time", + "title": "Show Timestamp", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "cover", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true + } + ] +} diff --git a/websites/T/Tellingtone/presence.ts b/websites/T/Tellingtone/presence.ts index 36fed4b6d633..c8398881afaf 100644 --- a/websites/T/Tellingtone/presence.ts +++ b/websites/T/Tellingtone/presence.ts @@ -1,105 +1,101 @@ -const presence = new Presence({ clientId: "1006201873985961984" }), - browsingTimestamp = Math.floor(Date.now() / 1000); +const presence = new Presence({ clientId: '1006201873985961984' }) +const browsingTimestamp = Math.floor(Date.now() / 1000) async function getStrings() { - return presence.getStrings( - { - viewHome: "general.viewHome", - paused: "general.paused", - playing: "general.playing", - episode: "general.episode", - viewPage: "general.viewPage", - buttonViewSeries: "general.buttonViewSeries", - listeningTo: "general.listeningTo", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + viewHome: 'general.viewHome', + paused: 'general.paused', + playing: 'general.playing', + episode: 'general.episode', + viewPage: 'general.viewPage', + buttonViewSeries: 'general.buttonViewSeries', + listeningTo: 'general.listeningTo', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } -let strings: Awaited>, - oldLang: string = null; +let strings: Awaited> +let oldLang: string | null = null -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Tellingtone/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, href } = document.location, - pathSplit = pathname.split("/"), - [newLang, time, showCover] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("time"), - presence.getSetting("cover"), - ]); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Tellingtone/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, href } = document.location + const pathSplit = pathname.split('/') + const [newLang, time, showCover] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('time'), + presence.getSetting('cover'), + ]) - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - switch (pathSplit[1]) { - case "": - presenceData.details = strings.viewHome; - break; - case "shop": - case "blog": - presenceData.details = `Viewing ${pathSplit[1]}`; - break; - case "series": - presenceData.details = strings.viewPage; - presenceData.state = - document.querySelector("div.head > h1").textContent; - presenceData.largeImageKey = - document.querySelector("div.head > img").src; + switch (pathSplit[1]) { + case '': + presenceData.details = strings.viewHome + break + case 'shop': + case 'blog': + presenceData.details = `Viewing ${pathSplit[1]}` + break + case 'series': + presenceData.details = strings.viewPage + presenceData.state = document.querySelector('div.head > h1')?.textContent + presenceData.largeImageKey = document.querySelector('div.head > img')?.src - presenceData.buttons = [{ label: strings.buttonViewSeries, url: href }]; - } - if (document.querySelector("div#Player")) { - presenceData.details = strings.listeningTo - .replace("{0}", " ") - .replace( - "{1}", - document.querySelector( - ".reading-media > .media-infos > .media-title" - ).textContent - ); - presenceData.state = - document.querySelector("div.media-episode").textContent; - presenceData.largeImageKey = document - .querySelector("div.media-image > svg > image") - .getAttribute("xlink:href"); + presenceData.buttons = [{ label: strings.buttonViewSeries, url: href }] + } + if (document.querySelector('div#Player')) { + presenceData.details = strings.listeningTo + .replace('{0}', ' ') + .replace( + '{1}', + document.querySelector( + '.reading-media > .media-infos > .media-title', + )?.textContent ?? '', + ) + presenceData.state = document.querySelector('div.media-episode')?.textContent + presenceData.largeImageKey = document + .querySelector('div.media-image > svg > image') + ?.getAttribute('xlink:href') - const timers: string[] = []; - for (const element of document.querySelectorAll("div.desktop > div.timer")) - timers.push(element.textContent); - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - presence.timestampFromFormat(timers[0]), - presence.timestampFromFormat(timers[1]) - ); - delete presenceData.buttons; + const timers: string[] = [] + for (const element of document.querySelectorAll('div.desktop > div.timer')) + timers.push(element.textContent!); + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + presence.timestampFromFormat(timers[0]), + presence.timestampFromFormat(timers[1]), + ) + delete presenceData.buttons - if (document.querySelector(".icon-pause")) { - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = strings.playing; - } else { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = strings.paused; - delete presenceData.endTimestamp; - delete presenceData.startTimestamp; - } - } + if (document.querySelector('.icon-pause')) { + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = strings.playing + } + else { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = strings.paused + delete presenceData.endTimestamp + delete presenceData.startTimestamp + } + } - if (!time) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - if (!showCover) { - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/T/Tellingtone/assets/logo.png"; - } + if (!time) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + if (!showCover) { + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/T/Tellingtone/assets/logo.png' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Tempest Fansub/metadata.json b/websites/T/Tempest Fansub/metadata.json index 9b711fae0ada..f91c80bdd229 100644 --- a/websites/T/Tempest Fansub/metadata.json +++ b/websites/T/Tempest Fansub/metadata.json @@ -1,34 +1,34 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "272665050672660501", - "name": "Shiroko" - }, - "service": "Tempest Fansub", - "description": { - "tr": "Tempest Fansub, türkçe altyazılı anime izleyebileceğiniz ve manga okuyabileceğiniz bir site.", - "en": "Tempest Fansub is a site where you can watch anime and read manga with Turkish subtitles." - }, - "url": [ - "tempestfansub.com", - "anime.tempestfansub.com", - "ecchi.tempestfansub.com" - ], - "version": "1.0.13", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tempest%20Fansub/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tempest%20Fansub/assets/thumbnail.png", - "color": "#349eeb", - "category": "anime", - "tags": [ - "anime", - "manga", - "ecchi", - "turk", - "türk", - "türkçe", - "tempest", - "tempestfansub", - "tempestscans" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "272665050672660501", + "name": "Shiroko" + }, + "service": "Tempest Fansub", + "description": { + "tr": "Tempest Fansub, türkçe altyazılı anime izleyebileceğiniz ve manga okuyabileceğiniz bir site.", + "en": "Tempest Fansub is a site where you can watch anime and read manga with Turkish subtitles." + }, + "url": [ + "tempestfansub.com", + "anime.tempestfansub.com", + "ecchi.tempestfansub.com" + ], + "version": "1.0.13", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tempest%20Fansub/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tempest%20Fansub/assets/thumbnail.png", + "color": "#349eeb", + "category": "anime", + "tags": [ + "anime", + "manga", + "ecchi", + "turk", + "türk", + "türkçe", + "tempest", + "tempestfansub", + "tempestscans" + ] +} diff --git a/websites/T/Tempest Fansub/presence.ts b/websites/T/Tempest Fansub/presence.ts index 0b86e4671d8d..77ebb9a4aa84 100644 --- a/websites/T/Tempest Fansub/presence.ts +++ b/websites/T/Tempest Fansub/presence.ts @@ -1,158 +1,180 @@ const presence = new Presence({ - clientId: "1047102386478534727", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1047102386478534727', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Tempest%20Fansub/assets/logo.png", - EcchiLogo = "https://cdn.rcd.gg/PreMiD/websites/T/Tempest%20Fansub/assets/0.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Tempest%20Fansub/assets/logo.png', + EcchiLogo = 'https://cdn.rcd.gg/PreMiD/websites/T/Tempest%20Fansub/assets/0.png', } -presence.on("UpdateData", async () => { - const { pathname, hostname, href } = document.location, - presenceData: PresenceData = { - startTimestamp: browsingTimestamp, - largeImageKey: Assets.Logo, - }, - searchParams = new URLSearchParams(location.search); - if ( - hostname === "tempestfansub.com" || - hostname === "ecchi.tempestfansub.com" - ) { - //Manga----------------------------------------------------------------------- - if (hostname.startsWith("ecchi")) - presenceData.largeImageKey = Assets.EcchiLogo; - else presenceData.largeImageKey = Assets.Logo; - //Manga arama - if (searchParams.get("s")) { - if (hostname.startsWith("ecchi")) - presenceData.details = "Bir ecchi manga arıyor."; - else presenceData.details = "Bir manga arıyor."; - presenceData.state = searchParams.get("s"); - //Mangalar - } else if (pathname.endsWith("/manga/") || pathname === "/") { - if (hostname.startsWith("ecchi")) - presenceData.details = "Ecchi Mangalara göz atıyor."; - else presenceData.details = "Mangalara göz atıyor."; - //Bir Manga - } else if (pathname.includes("/manga/")) { - if (hostname.startsWith("ecchi")) - presenceData.details = "Bir Ecchi mangaya bakıyor."; - else presenceData.details = "Bir Mangaya bakıyor."; - presenceData.state = document - .querySelector("h1.entry-title") - ?.textContent.trim(); - presenceData.buttons = [ - { - label: "Mangayı Aç", - url: href, - }, - ]; - presenceData.largeImageKey = document - .querySelector("div.thumb > img") - .getAttribute("src"); - //Manga a-z listesi - } else if (pathname.includes("/az-listesi/")) - presenceData.details = "Manga A-Z Listesine bakıyor."; - //Takvim - else if (pathname.includes("/takvim/")) - presenceData.details = "Takvime bakıyor."; - //kitaplik - else if (pathname.includes("/kitaplik/")) { - if (hostname.startsWith("ecchi")) - presenceData.details = "Ecchi manga kitaplığına bakıyor."; - else presenceData.details = "Manga kitaplığına bakıyor."; - //Manga EkipBaşvuru - } else if ( - pathname.includes("basvuru") || - pathname.includes("ekip-alimlari") - ) - presenceData.details = "Manga ekip başvurusuna bakıyor."; - //Manga okuyor - else if (document.querySelector("div.chapterbody")) { - try { - const title = document - .querySelector("h1.entry-title") - ?.textContent.trim(), - tsplited = title.split(" "), - _manga = document.querySelectorAll("div.allc > a"); - for (const element of _manga) { - if (element.getAttribute("href")) { - presenceData.buttons = [ - { - label: "Bölümü Aç", - url: href, - }, - { - label: "Mangayı Aç", - url: element.getAttribute("href"), - }, - ]; - break; - } - } - presenceData.details = title - .replace(tsplited[tsplited.length - 1], "") - .replace("#", ""); - presenceData.state = `Bölüm ${tsplited[tsplited.length - 1]} Okuyor.`; - const panels = document.querySelectorAll("div[id='readerarea'] > img"); - if (panels) presenceData.largeImageKey = panels[0].getAttribute("src"); - } catch { - presenceData.details = "Bilinmeyen Adres."; - delete presenceData.state; - delete presenceData.buttons; - } - } else { - presenceData.details = "Bilinmeyen Adres."; - delete presenceData.state; - delete presenceData.buttons; - } - } else if (hostname === "anime.tempestfansub.com") { - //Anime----------------------------------------------------------------------- - if (searchParams.get("s")) { - presenceData.details = "Bir anime arıyor."; - presenceData.state = searchParams.get("s"); - //Animeler - } else if (pathname === "/" || pathname.endsWith("/anime/")) - presenceData.details = "Animelere göz atıyor."; - //Bir anime - else if (!pathname.endsWith("/anime/") && pathname.includes("/anime/")) { - presenceData.details = "Bir animeye bakıyor."; - presenceData.state = document - .querySelector("h1.entry-title") - ?.textContent.trim(); - const imgs = document.querySelectorAll( - "#content > div > div > article > div:nth-child(2) > div > div.thumbook > div > img" - ); - for (const element of imgs) { - if (element.getAttribute("src")) - presenceData.largeImageKey = element.getAttribute("src"); - } - presenceData.buttons = [ - { - label: "Animeyi Aç", - url: href, - }, - ]; - //Anime a-z listesi - } else if (pathname.includes("/a-z-listesi/")) - presenceData.details = "Anime A-Z Listesine bakıyor."; - //Anime takvim - else if (pathname.includes("/takvim/")) - presenceData.details = "Anime Takvimine bakıyor."; - //Anime kitaplık - else if (pathname.includes("/kitaplik/")) - presenceData.details = "Anime kitaplığına bakıyor."; - //Anime EkipBaşvuru - else if (pathname.includes("/ekip-basvuru/")) - presenceData.details = "Anime ekip başvurusuna bakıyor."; - else { - presenceData.details = "Bilinmeyen Adres."; - delete presenceData.state; - delete presenceData.buttons; - } - } else { - presenceData.details = "Bilinmeyen Adres."; - delete presenceData.state; - delete presenceData.buttons; - } - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const { pathname, hostname, href } = document.location + const presenceData: PresenceData = { + startTimestamp: browsingTimestamp, + largeImageKey: Assets.Logo, + } + const searchParams = new URLSearchParams(location.search) + if ( + hostname === 'tempestfansub.com' + || hostname === 'ecchi.tempestfansub.com' + ) { + // Manga----------------------------------------------------------------------- + if (hostname.startsWith('ecchi')) + presenceData.largeImageKey = Assets.EcchiLogo + else presenceData.largeImageKey = Assets.Logo + // Manga arama + if (searchParams.get('s')) { + if (hostname.startsWith('ecchi')) + presenceData.details = 'Bir ecchi manga arıyor.' + else presenceData.details = 'Bir manga arıyor.' + presenceData.state = searchParams.get('s') + // Mangalar + } + else if (pathname.endsWith('/manga/') || pathname === '/') { + if (hostname.startsWith('ecchi')) + presenceData.details = 'Ecchi Mangalara göz atıyor.' + else presenceData.details = 'Mangalara göz atıyor.' + // Bir Manga + } + else if (pathname.includes('/manga/')) { + if (hostname.startsWith('ecchi')) + presenceData.details = 'Bir Ecchi mangaya bakıyor.' + else presenceData.details = 'Bir Mangaya bakıyor.' + presenceData.state = document + .querySelector('h1.entry-title') + ?.textContent + ?.trim() + presenceData.buttons = [ + { + label: 'Mangayı Aç', + url: href, + }, + ] + presenceData.largeImageKey = document + .querySelector('div.thumb > img') + ?.getAttribute('src') + // Manga a-z listesi + } + else if (pathname.includes('/az-listesi/')) { + presenceData.details = 'Manga A-Z Listesine bakıyor.' + } + // Takvim + else if (pathname.includes('/takvim/')) { + presenceData.details = 'Takvime bakıyor.' + } + // kitaplik + else if (pathname.includes('/kitaplik/')) { + if (hostname.startsWith('ecchi')) + presenceData.details = 'Ecchi manga kitaplığına bakıyor.' + else presenceData.details = 'Manga kitaplığına bakıyor.' + // Manga EkipBaşvuru + } + else if ( + pathname.includes('basvuru') + || pathname.includes('ekip-alimlari') + ) { + presenceData.details = 'Manga ekip başvurusuna bakıyor.' + } + // Manga okuyor + else if (document.querySelector('div.chapterbody')) { + try { + const title = document + .querySelector('h1.entry-title') + ?.textContent + ?.trim() + const tsplited = title?.split(' ') ?? [] + const _manga = document.querySelectorAll('div.allc > a') + for (const element of _manga) { + if (element.getAttribute('href')) { + presenceData.buttons = [ + { + label: 'Bölümü Aç', + url: href, + }, + { + label: 'Mangayı Aç', + url: element.getAttribute('href'), + }, + ] + break + } + } + presenceData.details = title + ?.replace(tsplited[tsplited.length - 1], '') + .replace('#', '') + presenceData.state = `Bölüm ${tsplited[tsplited.length - 1]} Okuyor.` + const panels = document.querySelectorAll('div[id=\'readerarea\'] > img') + if (panels) + presenceData.largeImageKey = panels[0].getAttribute('src') + } + catch { + presenceData.details = 'Bilinmeyen Adres.' + delete presenceData.state + delete presenceData.buttons + } + } + else { + presenceData.details = 'Bilinmeyen Adres.' + delete presenceData.state + delete presenceData.buttons + } + } + else if (hostname === 'anime.tempestfansub.com') { + // Anime----------------------------------------------------------------------- + if (searchParams.get('s')) { + presenceData.details = 'Bir anime arıyor.' + presenceData.state = searchParams.get('s') + // Animeler + } + else if (pathname === '/' || pathname.endsWith('/anime/')) { + presenceData.details = 'Animelere göz atıyor.' + } + // Bir anime + else if (!pathname.endsWith('/anime/') && pathname.includes('/anime/')) { + presenceData.details = 'Bir animeye bakıyor.' + presenceData.state = document + .querySelector('h1.entry-title') + ?.textContent + ?.trim() + const imgs = document.querySelectorAll( + '#content > div > div > article > div:nth-child(2) > div > div.thumbook > div > img', + ) + for (const element of imgs) { + if (element.getAttribute('src')) + presenceData.largeImageKey = element.getAttribute('src') + } + presenceData.buttons = [ + { + label: 'Animeyi Aç', + url: href, + }, + ] + // Anime a-z listesi + } + else if (pathname.includes('/a-z-listesi/')) { + presenceData.details = 'Anime A-Z Listesine bakıyor.' + } + // Anime takvim + else if (pathname.includes('/takvim/')) { + presenceData.details = 'Anime Takvimine bakıyor.' + } + // Anime kitaplık + else if (pathname.includes('/kitaplik/')) { + presenceData.details = 'Anime kitaplığına bakıyor.' + } + // Anime EkipBaşvuru + else if (pathname.includes('/ekip-basvuru/')) { + presenceData.details = 'Anime ekip başvurusuna bakıyor.' + } + else { + presenceData.details = 'Bilinmeyen Adres.' + delete presenceData.state + delete presenceData.buttons + } + } + else { + presenceData.details = 'Bilinmeyen Adres.' + delete presenceData.state + delete presenceData.buttons + } + presence.setActivity(presenceData) +}) diff --git a/websites/T/Tenor/metadata.json b/websites/T/Tenor/metadata.json index 79a322eaed5d..22329e9f0dc0 100644 --- a/websites/T/Tenor/metadata.json +++ b/websites/T/Tenor/metadata.json @@ -1,33 +1,33 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Yelo", - "id": "425326889565945856" - }, - "service": "Tenor", - "description": { - "en": "Say more with Tenor. Find the perfect Animated GIFs and videos to convey exactly what you mean in every conversation.", - "ro": "Spune mai multe cu Tenor. Găsiți GIF-urile animate și videoclipurile perfecte pentru a transmite exact ceea ce înțelegeți în fiecare conversație.", - "pt_BR": "Diga mais com o Tenor. Encontre os GIFs e vídeos animados perfeitos para transmitir exatamente o que você quer dizer em cada conversa.", - "fr": "Dites-en plus avec Tenor. Trouvez les GIF et vidéos animés parfaits pour transmettre exactement ce que vous voulez dire dans chaque conversation.", - "uk_UA": "Розкажіть більше з Тенором. Знайдіть ідеальні анімовані GIF-файли та відео, щоб точно передати, що ви маєте на увазі в кожній розмові.", - "nl": "Zeg meer met Tenor. Vind de perfecte geanimeerde GIF's en video's om precies over te brengen wat je bedoelt in elk gesprek.", - "tr": "Tenor'la daha fazlasını söyle. Her konuşmada tam olarak ne demek istediğinizi iletmek için mükemmel Animasyonlu GIF'leri ve videoları bulun.", - "zh_CN": "跟特诺多说点查找完美的动画 GIF 和视频,以准确传达您在每段对话中的意思。", - "zh_TW": "跟特諾多說點查找完美的動畫 GIF 和視頻,以準確傳達您在每段對話中的意思。", - "ga_IE": "Abair níos mó le Tenor. Faigh na GIFanna agus na físeáin beoite foirfe chun an méid atá i gceist agat i ngach comhrá a chur in iúl go díreach." - }, - "url": "tenor.com", - "version": "1.0.16", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tenor/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tenor/assets/thumbnail.png", - "color": "#3297E9", - "category": "other", - "tags": [ - "gifs", - "searchgifs", - "sharegifs", - "memes" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Yelo", + "id": "425326889565945856" + }, + "service": "Tenor", + "description": { + "en": "Say more with Tenor. Find the perfect Animated GIFs and videos to convey exactly what you mean in every conversation.", + "ro": "Spune mai multe cu Tenor. Găsiți GIF-urile animate și videoclipurile perfecte pentru a transmite exact ceea ce înțelegeți în fiecare conversație.", + "pt_BR": "Diga mais com o Tenor. Encontre os GIFs e vídeos animados perfeitos para transmitir exatamente o que você quer dizer em cada conversa.", + "fr": "Dites-en plus avec Tenor. Trouvez les GIF et vidéos animés parfaits pour transmettre exactement ce que vous voulez dire dans chaque conversation.", + "uk_UA": "Розкажіть більше з Тенором. Знайдіть ідеальні анімовані GIF-файли та відео, щоб точно передати, що ви маєте на увазі в кожній розмові.", + "nl": "Zeg meer met Tenor. Vind de perfecte geanimeerde GIF's en video's om precies over te brengen wat je bedoelt in elk gesprek.", + "tr": "Tenor'la daha fazlasını söyle. Her konuşmada tam olarak ne demek istediğinizi iletmek için mükemmel Animasyonlu GIF'leri ve videoları bulun.", + "zh_CN": "跟特诺多说点查找完美的动画 GIF 和视频,以准确传达您在每段对话中的意思。", + "zh_TW": "跟特諾多說點查找完美的動畫 GIF 和視頻,以準確傳達您在每段對話中的意思。", + "ga_IE": "Abair níos mó le Tenor. Faigh na GIFanna agus na físeáin beoite foirfe chun an méid atá i gceist agat i ngach comhrá a chur in iúl go díreach." + }, + "url": "tenor.com", + "version": "1.0.16", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tenor/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tenor/assets/thumbnail.png", + "color": "#3297E9", + "category": "other", + "tags": [ + "gifs", + "searchgifs", + "sharegifs", + "memes" + ] +} diff --git a/websites/T/Tenor/presence.ts b/websites/T/Tenor/presence.ts index d976d4286aa5..61acc9394c90 100644 --- a/websites/T/Tenor/presence.ts +++ b/websites/T/Tenor/presence.ts @@ -1,62 +1,67 @@ const presence = new Presence({ - clientId: "904304152048439296", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '904304152048439296', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/T/Tenor/assets/logo.png", - startTimestamp: browsingTimestamp, - }; - if (document.location.pathname === "/") presenceData.details = "In home page"; - else if (document.location.pathname.includes("/view/")) { - presenceData.details = "Viewing a gif:"; - presenceData.state = document.querySelector("h1").textContent; - } else if (document.location.pathname.includes("/search/")) { - presenceData.details = "Searching a GIF:"; - presenceData.state = document.querySelector("h1").textContent; - } else if (document.location.pathname.includes("/users/")) { - presenceData.details = "Viewing user profile:"; - presenceData.state = document.querySelector(".partnername").textContent; - presenceData.buttons = [ - { - label: "View User", - url: document.URL, - }, - ]; - } else { - switch (document.location.pathname) { - case "/reactions": - presenceData.details = "Viewing reaction GIFs"; - break; - case "/gif-maker": - presenceData.details = "Uploading a GIF"; - break; - case "/explore": - presenceData.details = "Exploring GIFs"; - break; - case "/mac": - presenceData.details = "Viewing Tenor for MAC"; - break; - case "/contentpartners": - presenceData.details = "Viewing partner list"; - break; - case "/gifapi": - presenceData.details = "Viewing API"; - break; - case "/gifapi/documentation": - presenceData.details = "Reading API docs"; - break; - case "/developer/keyregistration": - presenceData.details = "Registering a new api key"; - break; - case "/developer/dashboard": - presenceData.details = "Viewing developer dashboard"; - break; - default: - presenceData.details = "Browsing on the web"; - break; - } - } - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Tenor/assets/logo.png', + startTimestamp: browsingTimestamp, + } + if (document.location.pathname === '/') { + presenceData.details = 'In home page' + } + else if (document.location.pathname.includes('/view/')) { + presenceData.details = 'Viewing a gif:' + presenceData.state = document.querySelector('h1')?.textContent + } + else if (document.location.pathname.includes('/search/')) { + presenceData.details = 'Searching a GIF:' + presenceData.state = document.querySelector('h1')?.textContent + } + else if (document.location.pathname.includes('/users/')) { + presenceData.details = 'Viewing user profile:' + presenceData.state = document.querySelector('.partnername')?.textContent + presenceData.buttons = [ + { + label: 'View User', + url: document.URL, + }, + ] + } + else { + switch (document.location.pathname) { + case '/reactions': + presenceData.details = 'Viewing reaction GIFs' + break + case '/gif-maker': + presenceData.details = 'Uploading a GIF' + break + case '/explore': + presenceData.details = 'Exploring GIFs' + break + case '/mac': + presenceData.details = 'Viewing Tenor for MAC' + break + case '/contentpartners': + presenceData.details = 'Viewing partner list' + break + case '/gifapi': + presenceData.details = 'Viewing API' + break + case '/gifapi/documentation': + presenceData.details = 'Reading API docs' + break + case '/developer/keyregistration': + presenceData.details = 'Registering a new api key' + break + case '/developer/dashboard': + presenceData.details = 'Viewing developer dashboard' + break + default: + presenceData.details = 'Browsing on the web' + break + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/T/Terminal 00/metadata.json b/websites/T/Terminal 00/metadata.json index ec4c6298cfec..b9e8c43dd811 100644 --- a/websites/T/Terminal 00/metadata.json +++ b/websites/T/Terminal 00/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Pnfrl Enm", - "id": "419892518423887903" - }, - "service": "Terminal 00", - "description": { - "en": "Revived by the first Arcent, Angus Nicneven. Sol onset.", - "nl": "Nieuw leven ingeblazen door de eerste Arcent, Angus Nicneven. Sol onset." - }, - "url": "angusnicneven.com", - "version": "1.1.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Terminal%2000/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Terminal%2000/assets/thumbnail.png", - "color": "#D2738A", - "category": "other", - "tags": [ - "horror", - "pixel", - "art", - "exploration", - "reading", - "terminal", - "blog" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Pnfrl Enm", + "id": "419892518423887903" + }, + "service": "Terminal 00", + "description": { + "en": "Revived by the first Arcent, Angus Nicneven. Sol onset.", + "nl": "Nieuw leven ingeblazen door de eerste Arcent, Angus Nicneven. Sol onset." + }, + "url": "angusnicneven.com", + "version": "1.1.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Terminal%2000/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Terminal%2000/assets/thumbnail.png", + "color": "#D2738A", + "category": "other", + "tags": [ + "horror", + "pixel", + "art", + "exploration", + "reading", + "terminal", + "blog" + ] +} diff --git a/websites/T/Terminal 00/presence.ts b/websites/T/Terminal 00/presence.ts index fb7daef8ae23..41dda1a5146d 100644 --- a/websites/T/Terminal 00/presence.ts +++ b/websites/T/Terminal 00/presence.ts @@ -1,21 +1,21 @@ const presence = new Presence({ - clientId: "701863684728946799", - }), - elapsed = Math.floor(Date.now() / 1000); + clientId: '701863684728946799', +}) +const elapsed = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Terminal%2000/assets/logo.png", - startTimestamp: elapsed, - details: location.href.split(location.host)[1], - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Terminal%2000/assets/logo.png', + startTimestamp: elapsed, + details: location.href.split(location.host)[1], + } - if ( - location.pathname === "/" || - location.href.split(location.host)[1].toLowerCase() === "/index" - ) - presenceData.details = "/index"; + if ( + location.pathname === '/' + || location.href.split(location.host)[1].toLowerCase() === '/index' + ) { + presenceData.details = '/index' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/Territorial/metadata.json b/websites/T/Territorial/metadata.json index 4cb3ea8bad3d..c1974d839ba1 100644 --- a/websites/T/Territorial/metadata.json +++ b/websites/T/Territorial/metadata.json @@ -1,36 +1,36 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dark_Ville", - "id": "638080361179512853" - }, - "service": "Territorial", - "description": { - "en": "Territorial.io is a strategy io game where players fight to expand their nations. Defend your territory, expand, and conquer the map in games of up to 500 players." - }, - "url": [ - "territorial.io", - "www.territorial.io" - ], - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Territorial/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Territorial/assets/thumbnail.jpg", - "color": "#07283C", - "category": "games", - "tags": [ - "territorial", - "games" - ], - "settings": [ - { - "id": "buttons", - "if": { - "privacy": false - }, - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dark_Ville", + "id": "638080361179512853" + }, + "service": "Territorial", + "description": { + "en": "Territorial.io is a strategy io game where players fight to expand their nations. Defend your territory, expand, and conquer the map in games of up to 500 players." + }, + "url": [ + "territorial.io", + "www.territorial.io" + ], + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Territorial/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Territorial/assets/thumbnail.jpg", + "color": "#07283C", + "category": "games", + "tags": [ + "territorial", + "games" + ], + "settings": [ + { + "id": "buttons", + "if": { + "privacy": false + }, + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/T/Territorial/presence.ts b/websites/T/Territorial/presence.ts index a9aaa8b1de19..aab87650617e 100644 --- a/websites/T/Territorial/presence.ts +++ b/websites/T/Territorial/presence.ts @@ -1,57 +1,61 @@ +/* eslint-disable no-cond-assign */ const presence = new Presence({ - clientId: "1014903980410802237", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1014903980410802237', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Territorial/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { href } = document.location, - buttons = await presence.getSetting("buttons"), - context = document - .querySelector("#canvasA") - .getContext("2d"); - let tryOne: number; - const start = context.getImageData(100, 550, 400, 60).data[0]; - if (start === 57 || start === 27 || start === 45) { - tryOne = Number(context.getImageData(810, 140, 400, 60).data[0]); - tryOne === 55 - ? (presenceData.details = "Viewing clans leaderboard") - : tryOne === 4 - ? (presenceData.details = "Viewing players leaderboard") - : context.getImageData(810, 80, 400, 60).data[0] === 68 - ? (presenceData.details = "Viewing clans leaderboard") - : (tryOne = context.getImageData(780, 160, 400, 60).data[0]) === 254 || - tryOne === 8 - ? (presenceData.details = "Viewing emoji menu") - : (tryOne = context.getImageData(1380, 60, 400, 60).data[0]) === 8 || - tryOne === 56 - ? (presenceData.details = "Viewing options") - : (tryOne = context.getImageData(1400, 80, 400, 60).data[0]) === 94 || - tryOne === 46 - ? (presenceData.details = "Viewing options") - : (tryOne = context.getImageData(500, 220, 400, 60).data[0]) === 14 || - tryOne === 6 - ? (presenceData.details = "Viewing color options") - : (tryOne = context.getImageData(500, 60, 400, 60).data[0]) === 14 || - tryOne === 6 - ? (presenceData.details = "Viewing color options") - : (presenceData.details = "Viewing main menu"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Territorial/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { href } = document.location + const buttons = await presence.getSetting('buttons') + const context = document + .querySelector('#canvasA')! + .getContext('2d')! + let tryOne: number + const start = context.getImageData(100, 550, 400, 60).data[0] + if (start === 57 || start === 27 || start === 45) { + tryOne = Number(context.getImageData(810, 140, 400, 60).data[0]) + tryOne === 55 + ? (presenceData.details = 'Viewing clans leaderboard') + : tryOne === 4 + ? (presenceData.details = 'Viewing players leaderboard') + : context.getImageData(810, 80, 400, 60).data[0] === 68 + ? (presenceData.details = 'Viewing clans leaderboard') + : (tryOne = context.getImageData(780, 160, 400, 60).data[0]) === 254 + || tryOne === 8 + ? (presenceData.details = 'Viewing emoji menu') + : (tryOne = context.getImageData(1380, 60, 400, 60).data[0]) === 8 + || tryOne === 56 + ? (presenceData.details = 'Viewing options') + : (tryOne = context.getImageData(1400, 80, 400, 60).data[0]) === 94 + || tryOne === 46 + ? (presenceData.details = 'Viewing options') + : (tryOne = context.getImageData(500, 220, 400, 60).data[0]) === 14 + || tryOne === 6 + ? (presenceData.details = 'Viewing color options') + : (tryOne = context.getImageData(500, 60, 400, 60).data[0]) === 14 + || tryOne === 6 + ? (presenceData.details = 'Viewing color options') + : (presenceData.details = 'Viewing main menu') - presenceData.buttons = [{ label: "View Menu", url: href }]; - } else if ( - context.getImageData(1020, 540, 400, 60).data[0] === 255 || - context.getImageData(1116, 502, 400, 60).data[0] === 255 - ) - presenceData.details = "The game has ended"; - else { - presenceData.details = "Playing the game"; - presenceData.buttons = [{ label: "Play", url: href }]; - } - if (!buttons) delete presenceData.buttons; - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + presenceData.buttons = [{ label: 'View Menu', url: href }] + } + else if ( + context.getImageData(1020, 540, 400, 60).data[0] === 255 + || context.getImageData(1116, 502, 400, 60).data[0] === 255 + ) { + presenceData.details = 'The game has ended' + } + else { + presenceData.details = 'Playing the game' + presenceData.buttons = [{ label: 'Play', url: href }] + } + if (!buttons) + delete presenceData.buttons + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Tesla/metadata.json b/websites/T/Tesla/metadata.json index 342914ba9f98..4b7e764160fe 100644 --- a/websites/T/Tesla/metadata.json +++ b/websites/T/Tesla/metadata.json @@ -1,57 +1,57 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "N0chteil ^^", - "id": "495901098926669825" - }, - "service": "Tesla", - "description": { - "en": "Tesla is accelerating the world's transition to sustainable energy with electric cars, solar and integrated renewable energy solutions for homes and businesses.", - "nl": "Tesla versnelt de wereldwijde transitie naar duurzame energie, met elektrische auto's, zonnepanelen en geïntegreerde duurzame energieoplossingen voor woningen en bedrijven." - }, - "url": [ - "www.tesla.com", - "shop.tesla.com" - ], - "version": "1.0.28", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/thumbnail.png", - "color": "#E82127", - "category": "other", - "tags": [ - "cars" - ], - "settings": [ - { - "id": "logo", - "title": "Icon", - "icon": "fad fa-icons", - "value": 0, - "values": [ - "Red", - "Red with text", - "White", - "White with text" - ] - }, - { - "id": "timeElapsed", - "title": "Show elapsed time", - "icon": "fad fa-hourglass-half", - "value": true - }, - { - "id": "showButtons", - "title": "Show buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - }, - { - "id": "showCheckout", - "title": "Show shop summary", - "icon": "fas fa-store", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "N0chteil ^^", + "id": "495901098926669825" + }, + "service": "Tesla", + "description": { + "en": "Tesla is accelerating the world's transition to sustainable energy with electric cars, solar and integrated renewable energy solutions for homes and businesses.", + "nl": "Tesla versnelt de wereldwijde transitie naar duurzame energie, met elektrische auto's, zonnepanelen en geïntegreerde duurzame energieoplossingen voor woningen en bedrijven." + }, + "url": [ + "www.tesla.com", + "shop.tesla.com" + ], + "version": "1.0.28", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/thumbnail.png", + "color": "#E82127", + "category": "other", + "tags": [ + "cars" + ], + "settings": [ + { + "id": "logo", + "title": "Icon", + "icon": "fad fa-icons", + "value": 0, + "values": [ + "Red", + "Red with text", + "White", + "White with text" + ] + }, + { + "id": "timeElapsed", + "title": "Show elapsed time", + "icon": "fad fa-hourglass-half", + "value": true + }, + { + "id": "showButtons", + "title": "Show buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + }, + { + "id": "showCheckout", + "title": "Show shop summary", + "icon": "fas fa-store", + "value": true + } + ] +} diff --git a/websites/T/Tesla/presence.ts b/websites/T/Tesla/presence.ts index 7cdf3bf63ffa..564cd1655c59 100644 --- a/websites/T/Tesla/presence.ts +++ b/websites/T/Tesla/presence.ts @@ -1,316 +1,331 @@ const presence = new Presence({ - clientId: "829056927227969596", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '829056927227969596', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - LogoRedText = "https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/0.png", - LogoRed = "https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/1.png", - LogoWhite = "https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/2.png", - LogoWhiteText = "https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/3.png", + LogoRedText = 'https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/0.png', + LogoRed = 'https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/1.png', + LogoWhite = 'https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/2.png', + LogoWhiteText = 'https://cdn.rcd.gg/PreMiD/websites/T/Tesla/assets/3.png', } -presence.on("UpdateData", async function () { - const [timeElapsed, showButtons, logo, showCheckout] = await Promise.all([ - presence.getSetting("timeElapsed"), - presence.getSetting("showButtons"), - presence.getSetting("logo"), - presence.getSetting("showCheckout"), - ]), - logoArr = [ - Assets.LogoRed, - Assets.LogoRedText, - Assets.LogoWhite, - Assets.LogoWhiteText, - ], - urlpath = window.location.pathname.split("/"), - langs = [ - "en_ca", - "es_mx", - "en_pr", - "nl_be", - "cs_cz", - "da_dk", - "de_de", - "el_gr", - "es_es", - "fr_fr", - "hr_hr", - "en_ie", - "is_is", - "it_it", - "fr_lu", - "nl_nl", - "no_no", - "de_at", - "pl_pl", - "pt_pt", - "sl_si", - "fr_ch", - "sv_se", - "fi_fi", - "en_gb", - "en_eu", - "he_il", - "en_ae", - "en_jo", - "zh_cn", - "zh_hk", - "en_mo", - "zh_tw", - "ja_jp", - "en_sg", - "ko_kr", - "en_au", - "en_nz", - ], - urlpNum = langs.includes(urlpath[1]) ? 2 : 1, - presenceData: PresenceData = { - largeImageKey: logoArr[logo] ?? Assets.LogoRed, - }; +presence.on('UpdateData', async () => { + const [timeElapsed, showButtons, logo, showCheckout] = await Promise.all([ + presence.getSetting('timeElapsed'), + presence.getSetting('showButtons'), + presence.getSetting('logo'), + presence.getSetting('showCheckout'), + ]) + const logoArr = [ + Assets.LogoRed, + Assets.LogoRedText, + Assets.LogoWhite, + Assets.LogoWhiteText, + ] + const urlpath = window.location.pathname.split('/') + const langs = [ + 'en_ca', + 'es_mx', + 'en_pr', + 'nl_be', + 'cs_cz', + 'da_dk', + 'de_de', + 'el_gr', + 'es_es', + 'fr_fr', + 'hr_hr', + 'en_ie', + 'is_is', + 'it_it', + 'fr_lu', + 'nl_nl', + 'no_no', + 'de_at', + 'pl_pl', + 'pt_pt', + 'sl_si', + 'fr_ch', + 'sv_se', + 'fi_fi', + 'en_gb', + 'en_eu', + 'he_il', + 'en_ae', + 'en_jo', + 'zh_cn', + 'zh_hk', + 'en_mo', + 'zh_tw', + 'ja_jp', + 'en_sg', + 'ko_kr', + 'en_au', + 'en_nz', + ] + const urlpNum = langs.includes(urlpath[1]) ? 2 : 1 + const presenceData: PresenceData = { + largeImageKey: logoArr[logo] ?? Assets.LogoRed, + } - if (timeElapsed) presenceData.startTimestamp = browsingTimestamp; + if (timeElapsed) + presenceData.startTimestamp = browsingTimestamp - if (window.location.hostname === "www.tesla.com") { - if (!urlpath[urlpNum]) presenceData.details = "Home"; - else if (urlpath[urlpNum].startsWith("model")) { - const num = urlpNum + 1; - let model = null; - if (urlpath[num] === "design") { - model = document.querySelector( - ".text-loader--content.tds-text--center.text-loader--subtitle>span" - ).textContent; - presenceData.details = `Designing ${model}`; + if (window.location.hostname === 'www.tesla.com') { + if (!urlpath[urlpNum]) { + presenceData.details = 'Home' + } + else if (urlpath[urlpNum].startsWith('model')) { + const num = urlpNum + 1 + let model = null + if (urlpath[num] === 'design') { + model = document.querySelector( + '.text-loader--content.tds-text--center.text-loader--subtitle>span', + )?.textContent + presenceData.details = `Designing ${model}` - if (showButtons) { - presenceData.buttons = [ - { - label: `View ${model}`, - url: window.location.href - .replace(urlpath[num], "") - .replace("#overview", ""), - }, - { - label: `Design ${model}`, - url: window.location.href, - }, - ]; - } - } else { - model = document.querySelector( - ".header-lower.tds-animate_small--to_reveal" - ).textContent; - presenceData.details = `Viewing ${model}`; + if (showButtons) { + presenceData.buttons = [ + { + label: `View ${model}`, + url: window.location.href + .replace(urlpath[num], '') + .replace('#overview', ''), + }, + { + label: `Design ${model}`, + url: window.location.href, + }, + ] + } + } + else { + model = document.querySelector( + '.header-lower.tds-animate_small--to_reveal', + )?.textContent + presenceData.details = `Viewing ${model}` - if (showButtons) { - presenceData.buttons = [ - { - label: `View ${model}`, - url: window.location.href, - }, - ]; - } - } - } else if (urlpath[urlpNum].startsWith("cybertruck")) { - const num = urlpNum + 1; + if (showButtons) { + presenceData.buttons = [ + { + label: `View ${model}`, + url: window.location.href, + }, + ] + } + } + } + else if (urlpath[urlpNum].startsWith('cybertruck')) { + const num = urlpNum + 1 - presenceData.details = "Cybertruck"; + presenceData.details = 'Cybertruck' - if (urlpath[num] === "design") { - presenceData.state = "Designing"; + if (urlpath[num] === 'design') { + presenceData.state = 'Designing' - if (showButtons) { - presenceData.buttons = [ - { - label: "View Cybertruck", - url: window.location.href.replace(urlpath[num], ""), - }, - { - label: "Design Cybertruck", - url: window.location.href, - }, - ]; - } - } else { - presenceData.details = "Viewing Cybertruck"; + if (showButtons) { + presenceData.buttons = [ + { + label: 'View Cybertruck', + url: window.location.href.replace(urlpath[num], ''), + }, + { + label: 'Design Cybertruck', + url: window.location.href, + }, + ] + } + } + else { + presenceData.details = 'Viewing Cybertruck' - if (showButtons) { - presenceData.buttons = [ - { - label: "View Cybertruck", - url: window.location.href, - }, - ]; - } - } - } else { - switch (urlpath[urlpNum]) { - case "teslaaccount": { - presenceData.details = "Account"; + if (showButtons) { + presenceData.buttons = [ + { + label: 'View Cybertruck', + url: window.location.href, + }, + ] + } + } + } + else { + switch (urlpath[urlpNum]) { + case 'teslaaccount': { + presenceData.details = 'Account' - switch (urlpath[urlpNum + 1]) { - case "payment-history": { - presenceData.state = "Payment History"; - break; - } - case "settings": { - presenceData.state = "Settings"; - break; - } - case "ownership": - { - presenceData.state = "Ownership"; - } - break; - } + switch (urlpath[urlpNum + 1]) { + case 'payment-history': { + presenceData.state = 'Payment History' + break + } + case 'settings': { + presenceData.state = 'Settings' + break + } + case 'ownership': { + presenceData.state = 'Ownership' + break + } + } - break; - } - case "solarroof": { - presenceData.details = "Solar Roof"; + break + } + case 'solarroof': { + presenceData.details = 'Solar Roof' - if (urlpath[urlpNum + 1] === "design") - presenceData.state = "Designing"; + if (urlpath[urlpNum + 1] === 'design') + presenceData.state = 'Designing' - if (showButtons) { - presenceData.buttons = [ - { - label: "View Solar Roof", - url: window.location.href, - }, - ]; - } + if (showButtons) { + presenceData.buttons = [ + { + label: 'View Solar Roof', + url: window.location.href, + }, + ] + } - break; - } - case "solarpanels": { - presenceData.details = "Solar Panels"; + break + } + case 'solarpanels': { + presenceData.details = 'Solar Panels' - if (showButtons) { - presenceData.buttons = [ - { - label: "View Solar Panels", - url: window.location.href, - }, - ]; - } + if (showButtons) { + presenceData.buttons = [ + { + label: 'View Solar Panels', + url: window.location.href, + }, + ] + } - break; - } - case "energy": { - presenceData.details = "Energy"; + break + } + case 'energy': { + presenceData.details = 'Energy' - if (urlpath[urlpNum + 1] === "design") - presenceData.state = "Designing"; + if (urlpath[urlpNum + 1] === 'design') + presenceData.state = 'Designing' - if (showButtons) { - presenceData.buttons = [ - { - label: "View Page", - url: window.location.href, - }, - ]; - } + if (showButtons) { + presenceData.buttons = [ + { + label: 'View Page', + url: window.location.href, + }, + ] + } - break; - } - case "powerwall": { - presenceData.details = "Powerwall"; + break + } + case 'powerwall': { + presenceData.details = 'Powerwall' - if (showButtons) { - presenceData.buttons = [ - { - label: "View Powerwall", - url: window.location.href, - }, - ]; - } + if (showButtons) { + presenceData.buttons = [ + { + label: 'View Powerwall', + url: window.location.href, + }, + ] + } - break; - } - case "inventory": { - presenceData.details = "Inventory"; + break + } + case 'inventory': { + presenceData.details = 'Inventory' - if (showButtons) { - presenceData.buttons = [ - { - label: "View Inventory", - url: window.location.href, - }, - ]; - } + if (showButtons) { + presenceData.buttons = [ + { + label: 'View Inventory', + url: window.location.href, + }, + ] + } - break; - } - case "drive": { - presenceData.details = "Test drive"; - break; - } - case "charging": { - presenceData.details = "Charging"; - break; - } - case "home-charging": { - presenceData.details = "Wall Connector"; - break; - } - default: - if (document.querySelector(".error-container>.error-code")) { - if ( - document.querySelector(".error-container>.error-code") - .textContent === "404" - ) { - (presenceData.details = "Error 404"), - (presenceData.state = "Page not found"); - } - } else presenceData.details = "Other"; - } - } - } else if (window.location.hostname === "shop.tesla.com") { - const num = urlpNum + 1; + break + } + case 'drive': { + presenceData.details = 'Test drive' + break + } + case 'charging': { + presenceData.details = 'Charging' + break + } + case 'home-charging': { + presenceData.details = 'Wall Connector' + break + } + default: + if (document.querySelector('.error-container>.error-code')) { + if ( + document.querySelector('.error-container>.error-code') + ?.textContent === '404' + ) { + presenceData.details = 'Error 404' + presenceData.state = 'Page not found' + } + } + else { + presenceData.details = 'Other' + } + } + } + } + else if (window.location.hostname === 'shop.tesla.com') { + const num = urlpNum + 1 - presenceData.details = "Shop"; - if (urlpath[urlpNum] === "category" && urlpath[num]) { - presenceData.state = document.title.replace("Tesla | ", ""); + presenceData.details = 'Shop' + if (urlpath[urlpNum] === 'category' && urlpath[num]) { + presenceData.state = document.title.replace('Tesla | ', '') - if (showButtons) { - presenceData.buttons = [ - { - label: "View Category", - url: window.location.href, - }, - ]; - } - } else if (urlpath[urlpNum] === "product" && urlpath[num]) { - presenceData.state = document.querySelector( - "h2.product-title.tds-text--h1-alt" - ).textContent; + if (showButtons) { + presenceData.buttons = [ + { + label: 'View Category', + url: window.location.href, + }, + ] + } + } + else if (urlpath[urlpNum] === 'product' && urlpath[num]) { + presenceData.state = document.querySelector( + 'h2.product-title.tds-text--h1-alt', + )?.textContent - if (showButtons) { - presenceData.buttons = [ - { - label: "View Product", - url: window.location.href, - }, - ]; - } - } else if ( - urlpath[urlpNum] === "checkout" && - urlpath[num] === "billing-shipping-info" - ) { - presenceData.state = `Checkout${ - showCheckout - ? ` (${ - document.querySelector( - "span.ordersummary__container__order__details__line__total>span.inline-value" - ).textContent - })` - : "" - }`; - } else if (urlpath[urlpNum] === "orders") - presenceData.state = "Order History"; - } + if (showButtons) { + presenceData.buttons = [ + { + label: 'View Product', + url: window.location.href, + }, + ] + } + } + else if ( + urlpath[urlpNum] === 'checkout' + && urlpath[num] === 'billing-shipping-info' + ) { + presenceData.state = `Checkout${ + showCheckout + ? ` (${ + document.querySelector( + 'span.ordersummary__container__order__details__line__total>span.inline-value', + )?.textContent + })` + : '' + }` + } + else if (urlpath[urlpNum] === 'orders') { + presenceData.state = 'Order History' + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Tetris/iframe.ts b/websites/T/Tetris/iframe.ts index f666ed3e082e..c5a060b3bcd8 100644 --- a/websites/T/Tetris/iframe.ts +++ b/websites/T/Tetris/iframe.ts @@ -5,96 +5,103 @@ // are not sufficient. // It also needs to use functions to determine the current scene. function iframeInject() { - interface TetrisApp extends Record { - mSceneMgr: { - getCurrentScene: () => { - mSceneName: string; - }; - }; - } + interface TetrisApp extends Record { + mSceneMgr: { + getCurrentScene: () => { + mSceneName: string + } + } + } - interface Window { - mBPSApp: TetrisApp; - } + interface Window { + mBPSApp: TetrisApp + } - let values: Record< - string, - { - mText: string; - } - > = {}; + let values: Record< + string, + { + mText: string + } + > = {} - function recursiveSearch( - obj: Record, - seenAlready = new Set() - ) { - for (const key in obj) { - if (Object.hasOwnProperty.call(obj, key)) { - if (seenAlready.has(obj[key])) continue; - seenAlready.add(obj[key]); - if ( - new Set([ - "mLinesValueView", - "mScoreValueView", - "mLevelValueView", - ]).has(key) - ) - values[key] = obj[key] as { mText: string }; + function recursiveSearch( + obj: Record, + seenAlready = new Set(), + ) { + for (const key in obj) { + if (Object.hasOwnProperty.call(obj, key)) { + if (seenAlready.has(obj[key])) + continue + seenAlready.add(obj[key]) + if ( + new Set([ + 'mLinesValueView', + 'mScoreValueView', + 'mLevelValueView', + ]).has(key) + ) { + values[key] = obj[key] as { mText: string } + } - if (obj[key] && typeof obj[key] === "object") - recursiveSearch(obj[key] as Record, seenAlready); - } - } - } + if (obj[key] && typeof obj[key] === 'object') + recursiveSearch(obj[key] as Record, seenAlready) + } + } + } - let found = false; - setInterval(() => { - const currentScene = ( - window as unknown as Window - ).mBPSApp.mSceneMgr.getCurrentScene().mSceneName; - if (!found && currentScene === "game") { - values = {}; - recursiveSearch((window as unknown as Window).mBPSApp); - if (Object.keys(values).length === 3) found = true; - } else if (currentScene === "mainMenu" || currentScene === "gameOver") - found = false; + let found = false + setInterval(() => { + const currentScene = ( + window as unknown as Window + ).mBPSApp.mSceneMgr.getCurrentScene().mSceneName + if (!found && currentScene === 'game') { + values = {} + recursiveSearch((window as unknown as Window).mBPSApp) + if (Object.keys(values).length === 3) + found = true + } + else if (currentScene === 'mainMenu' || currentScene === 'gameOver') { + found = false + } - try { - document.querySelector( - "#PreMiD-tetris-presence-output" - ).value = JSON.stringify({ - lines: values.mLinesValueView.mText, - score: values.mScoreValueView.mText, - level: values.mLevelValueView.mText, - }); - } catch (e) { - /* ignore */ - } - }, 2000); + try { + document.querySelector( + '#PreMiD-tetris-presence-output', + )!.value = JSON.stringify({ + lines: values.mLinesValueView.mText, + score: values.mScoreValueView.mText, + level: values.mLevelValueView.mText, + }) + } + catch { + /* ignore */ + } + }, 2000) } -const template = document.createElement("template"), - script = document.createElement("script"), - output = document.createElement("textarea"); +const template = document.createElement('template') +const script = document.createElement('script') +const output = document.createElement('textarea') -output.id = "PreMiD-tetris-presence-output"; -output.style.display = "none"; -script.id = "PreMiD-tetris-presence-script"; -script.textContent = `{(${iframeInject.toString()})();}`; -template.append(script, output); -document.head.append(template.cloneNode(true)); +output.id = 'PreMiD-tetris-presence-output' +output.style.display = 'none' +script.id = 'PreMiD-tetris-presence-script' +script.textContent = `{(${iframeInject.toString()})();}` +template.append(script, output) +document.head.append(template.cloneNode(true)) -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", () => { - try { - const data = JSON.parse( - document.querySelector( - "#PreMiD-tetris-presence-output" - ).value - ); - iframe.send(data); - } catch { - /* ignore */ - } -}); +iframe.on('UpdateData', () => { + try { + const data = JSON.parse( + document.querySelector( + '#PreMiD-tetris-presence-output', + )!.value, + ) + iframe.send(data) + } + catch { + /* ignore */ + } +}) diff --git a/websites/T/Tetris/metadata.json b/websites/T/Tetris/metadata.json index 9324f41b11be..44598b8f9f4d 100644 --- a/websites/T/Tetris/metadata.json +++ b/websites/T/Tetris/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "Tetris", - "description": { - "en": "Visit the official Tetris® website to play FREE online Tetris, get game and merchandise updates, and read about global Tetris events." - }, - "url": "tetris.com", - "version": "1.0.6", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tetris/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tetris/assets/thumbnail.jpg", - "color": "#2bace2", - "category": "games", - "tags": [ - "tetris", - "game", - "events", - "merchandise", - "official" - ], - "iframe": true, - "iFrameRegExp": "tetris[.]com[/]games-content[/]play-tetris-content" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "Tetris", + "description": { + "en": "Visit the official Tetris® website to play FREE online Tetris, get game and merchandise updates, and read about global Tetris events." + }, + "url": "tetris.com", + "version": "1.0.6", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tetris/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tetris/assets/thumbnail.jpg", + "color": "#2bace2", + "category": "games", + "tags": [ + "tetris", + "game", + "events", + "merchandise", + "official" + ], + "iframe": true, + "iFrameRegExp": "tetris[.]com[/]games-content[/]play-tetris-content" +} diff --git a/websites/T/Tetris/presence.ts b/websites/T/Tetris/presence.ts index e5d789a81317..3a8db8077b0e 100644 --- a/websites/T/Tetris/presence.ts +++ b/websites/T/Tetris/presence.ts @@ -1,89 +1,89 @@ const presence = new Presence({ - clientId: "1178463662382518272", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1178463662382518272', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Tetris/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Tetris/assets/logo.png', } interface TetrisFrameData { - lines: string; - score: string; - level: string; + lines: string + score: string + level: string } let iframeData: TetrisFrameData = { - lines: "0", - score: "0", - level: "1", -}; + lines: '0', + score: '0', + level: '1', +} -presence.on("iFrameData", (data: TetrisFrameData) => { - iframeData = data; -}); +presence.on('iFrameData', (data: unknown) => { + iframeData = data as TetrisFrameData +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname, href } = document.location; - switch (pathname.split("/").find(Boolean) ?? "") { - case "": { - presenceData.details = "Browsing home page"; - break; - } - case "topic": { - presenceData.details = "Browsing a topic"; - presenceData.state = document - .querySelector("#topic-heading") - .textContent.trim(); - break; - } - case "article": { - presenceData.details = "Reading an article"; - presenceData.state = document.querySelector( - "[itemprop=headline]" - ); - presenceData.buttons = [ - { - label: "Read Article", - url: href, - }, - ]; - break; - } - case "play-tetris": { - presenceData.details = "Playing Tetris"; - presenceData.state = `Level ${iframeData.level}`; - presenceData.smallImageKey = Assets.Question; - presenceData.smallImageText = `Lines: ${iframeData.lines} | Score: ${iframeData.score}`; - break; - } - case "product-list": - case "product-list-videogames": - case "product-list-merchandise": { - presenceData.details = "Browsing products"; - break; - } - case "product": { - presenceData.details = "Viewing a product"; - presenceData.state = - document.querySelector(".product-lead h1"); - presenceData.buttons = [ - { - label: "View Product", - url: href, - }, - ]; - break; - } - default: { - presenceData.details = "Browsing"; - presenceData.state = document.title; - break; - } - } +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname, href } = document.location + switch (pathname.split('/').find(Boolean) ?? '') { + case '': { + presenceData.details = 'Browsing home page' + break + } + case 'topic': { + presenceData.details = 'Browsing a topic' + presenceData.state = document + .querySelector('#topic-heading') + ?.textContent + ?.trim() + break + } + case 'article': { + presenceData.details = 'Reading an article' + presenceData.state = document.querySelector( + '[itemprop=headline]', + ) + presenceData.buttons = [ + { + label: 'Read Article', + url: href, + }, + ] + break + } + case 'play-tetris': { + presenceData.details = 'Playing Tetris' + presenceData.state = `Level ${iframeData.level}` + presenceData.smallImageKey = Assets.Question + presenceData.smallImageText = `Lines: ${iframeData.lines} | Score: ${iframeData.score}` + break + } + case 'product-list': + case 'product-list-videogames': + case 'product-list-merchandise': { + presenceData.details = 'Browsing products' + break + } + case 'product': { + presenceData.details = 'Viewing a product' + presenceData.state = document.querySelector('.product-lead h1') + presenceData.buttons = [ + { + label: 'View Product', + url: href, + }, + ] + break + } + default: { + presenceData.details = 'Browsing' + presenceData.state = document.title + break + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/The Archon/metadata.json b/websites/T/The Archon/metadata.json index d629d90c2bff..542aae554c17 100644 --- a/websites/T/The Archon/metadata.json +++ b/websites/T/The Archon/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "The Archon", - "description": { - "en": "TheArchon is the most active Factions server on the planet that contains constant betrayals, wither raids, new defensive tactics being deployed each day, and a place where you can battle alongside some of your favorite YouTubers. Along with a variety of Factions gamemodes, TheArchon is a place where you can play an addictive Prison gamemode and an abundance of mini games.", - "nl": "TheArchon is de meest actieve Factions-server ter wereld die constant verraad heeft, wither raids, nieuwe defensieve tactieken die elke dag worden ingezet, en een plek waar je kunt vechten naast enkele van je favoriete YouTubers. Samen met een aantal Factions-gamemodes is TheArchon een plek waar je een verslavende Prison-gamemode en een overvloed aan minispellen kunt spelen." - }, - "url": [ - "thearchon.net", - "shop.thearchon.net" - ], - "version": "1.2.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Archon/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Archon/assets/thumbnail.png", - "color": "#eb2025", - "category": "games", - "tags": [ - "minecraft", - "archon" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "The Archon", + "description": { + "en": "TheArchon is the most active Factions server on the planet that contains constant betrayals, wither raids, new defensive tactics being deployed each day, and a place where you can battle alongside some of your favorite YouTubers. Along with a variety of Factions gamemodes, TheArchon is a place where you can play an addictive Prison gamemode and an abundance of mini games.", + "nl": "TheArchon is de meest actieve Factions-server ter wereld die constant verraad heeft, wither raids, nieuwe defensieve tactieken die elke dag worden ingezet, en een plek waar je kunt vechten naast enkele van je favoriete YouTubers. Samen met een aantal Factions-gamemodes is TheArchon een plek waar je een verslavende Prison-gamemode en een overvloed aan minispellen kunt spelen." + }, + "url": [ + "thearchon.net", + "shop.thearchon.net" + ], + "version": "1.2.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Archon/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Archon/assets/thumbnail.png", + "color": "#eb2025", + "category": "games", + "tags": [ + "minecraft", + "archon" + ] +} diff --git a/websites/T/The Archon/presence.ts b/websites/T/The Archon/presence.ts index 4bbad3605dc1..03fd2ddc0759 100644 --- a/websites/T/The Archon/presence.ts +++ b/websites/T/The Archon/presence.ts @@ -1,301 +1,336 @@ const presence = new Presence({ - clientId: "631990024719695901", // CLIENT ID FOR YOUR PRESENCE - }), - browsingTimestamp = Math.floor(Date.now() / 1000); - -let user: HTMLElement, search: HTMLElement, title: HTMLElement; - -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/The%20Archon/assets/logo.png", - }; - - presenceData.startTimestamp = browsingTimestamp; - if (document.location.hostname === "thearchon.net") { - if (document.location.pathname.includes("/threads/")) { - title = document.querySelector( - "#top > div.p-body > div > div.p-body-header > div.p-title > h1" - ); - presenceData.details = "Forums, viewing thread:"; - if (title.textContent.length > 128) - presenceData.state = `${title.textContent.substring(0, 125)}...`; - else presenceData.state = title.textContent; - - presenceData.smallImageKey = Assets.Reading; - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/trending/")) { - presenceData.details = "Forums, Viewing the list of"; - presenceData.state = "trending threads"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/play")) { - presenceData.details = "Play, Viewing the servers"; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/vote")) { - presenceData.details = "Vote, Viewing the voting websites"; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/bans")) { - presenceData.details = "Viewing the ban page"; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/profile")) { - user = document.querySelector( - "body > div.pagewrapper > div.container > div > div.col-md-2 > div > h2" - ); - presenceData.details = "Viewing the history of:"; - presenceData.state = user.textContent; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if ( - document.location.pathname.includes("/whats-new/") && - document.location.pathname.includes("/profile-posts") - ) { - presenceData.details = "Forums, Viewing the list of"; - presenceData.state = "latest profile posts"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if ( - document.location.pathname.includes("/whats-new/") && - document.location.pathname.includes("/posts") - ) { - presenceData.details = "Forums, Viewing the list of"; - presenceData.state = "latest posts"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if ( - document.location.pathname.includes("/whats-new/") && - document.location.pathname.includes("/news-feed") - ) { - presenceData.details = "Forums, Viewing the"; - presenceData.state = "news feed"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/whats-new/")) { - presenceData.details = "Forums, Viewing whats new"; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/conversations/")) { - if (document.location.pathname.split("/")[4]) { - title = document.querySelector( - "#top > div.p-body > div > div.uix_titlebar > div > div > div.p-title > h1" - ); - presenceData.details = "Forums, Reading DM:"; - if (title.textContent.length > 128) - presenceData.state = `${title.textContent.substring(0, 125)}...`; - else presenceData.state = title.textContent; - - presenceData.smallImageKey = Assets.Reading; - - presence.setActivity(presenceData); - } else { - presenceData.details = "Forums, Browsing"; - presenceData.state = "through their DMs"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } - } else if (document.location.pathname.includes("/watched/")) { - if (document.location.pathname.includes("/threads")) { - presenceData.details = "Forums, Viewing their"; - presenceData.state = "watched threads"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else { - presenceData.details = "Forums, Viewing their"; - presenceData.state = "watched forums"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } - } else if (document.location.pathname.includes("/search/")) { - search = document.querySelector( - "#top > div.p-body > div > div.uix_titlebar > div > div > div > h1 > a > em" - ); - if (search) { - presenceData.details = "Forums, searching for:"; - presenceData.state = search.textContent; - - presenceData.smallImageKey = Assets.Search; - - presence.setActivity(presenceData); - } else { - presenceData.details = "Forums, about to search"; - presenceData.state = "something up"; - - presenceData.smallImageKey = Assets.Search; - - presence.setActivity(presenceData); - } - } else if (document.location.pathname.includes("/account/")) { - presenceData.details = "Forums, account settings"; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/members/")) { - if (document.URL.includes("key=staff_members")) { - presenceData.details = "Viewing the list"; - presenceData.state = "of staff members"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.URL.includes("key=todays_birthdays")) { - presenceData.details = "Viewing list of members"; - presenceData.state = "with today as their birthday"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.URL.includes("key=highest_reaction_score")) { - presenceData.details = "Viewing list of members"; - presenceData.state = "with the highest ratings"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/banned")) { - presenceData.details = "Viewing the list"; - presenceData.state = "of banned users"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/list")) { - presenceData.details = "Viewing the list"; - presenceData.state = "of all users"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.URL.includes("key=most_likes")) { - presenceData.details = "Viewing list of members"; - presenceData.state = "with the most reactions"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.URL.includes("key=most_messages")) { - presenceData.details = "Viewing list of members"; - presenceData.state = "with the most messages"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if ( - document.querySelector( - "#top > div.p-body > div > div.p-body-main > div > div > div > div > div > div > div.memberHeader-main > div > h1 > span > span" - ) - ) { - user = document.querySelector( - "#top > div.p-body > div > div.p-body-main > div > div > div > div > div > div > div.memberHeader-main > div > h1 > span > span" - ); - presenceData.details = "Viewing user:"; - presenceData.state = user.textContent; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if ( - document.querySelector( - "#top > div.p-body > div > div.p-body-main > div > div > div > div > div > div > div.memberHeader-main > div > h1 > span" - ) - ) { - user = document.querySelector( - "#top > div.p-body > div > div.p-body-main > div > div > div > div > div > div > div.memberHeader-main > div > h1 > span" - ); - presenceData.details = "Viewing user:"; - presenceData.state = user.textContent; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else { - presenceData.details = "Viewing overview of members"; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } - } else if (document.location.pathname.includes("/forums/")) { - title = document.querySelector( - "#top > div.p-body > div > div.p-body-header > div.p-title > h1" - ); - if (title && title.textContent !== "THEARCHON") { - presenceData.details = "Forums, viewing category:"; - presenceData.state = title.textContent; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else { - presenceData.details = "Forums, Browsing..."; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } - } else if (document.location.pathname.includes("/staff")) { - presenceData.details = "Viewing the list"; - presenceData.state = "of staff members"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/community/")) { - presenceData.details = "Forums, Browsing..."; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname === "/") { - presenceData.details = "Viewing home page"; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else presence.setActivity(); - } else if (document.location.hostname === "shop.thearchon.net") { - title = document.querySelector("head > title"); - presenceData.details = "Store, viewing:"; - presenceData.state = title.textContent.replace("TheArchon Store | ", ""); - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else presence.setActivity(); -}); + clientId: '631990024719695901', // CLIENT ID FOR YOUR PRESENCE +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/The%20Archon/assets/logo.png', + } + + presenceData.startTimestamp = browsingTimestamp + if (document.location.hostname === 'thearchon.net') { + if (document.location.pathname.includes('/threads/')) { + const title = document.querySelector( + '#top > div.p-body > div > div.p-body-header > div.p-title > h1', + ) + presenceData.details = 'Forums, viewing thread:' + if (title?.textContent && title.textContent.length > 128) + presenceData.state = `${title.textContent.substring(0, 125)}...` + else presenceData.state = title?.textContent + + presenceData.smallImageKey = Assets.Reading + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/trending/')) { + presenceData.details = 'Forums, Viewing the list of' + presenceData.state = 'trending threads' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/play')) { + presenceData.details = 'Play, Viewing the servers' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/vote')) { + presenceData.details = 'Vote, Viewing the voting websites' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/bans')) { + presenceData.details = 'Viewing the ban page' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/profile')) { + const user = document.querySelector( + 'body > div.pagewrapper > div.container > div > div.col-md-2 > div > h2', + ) + presenceData.details = 'Viewing the history of:' + presenceData.state = user?.textContent + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if ( + document.location.pathname.includes('/whats-new/') + && document.location.pathname.includes('/profile-posts') + ) { + presenceData.details = 'Forums, Viewing the list of' + presenceData.state = 'latest profile posts' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if ( + document.location.pathname.includes('/whats-new/') + && document.location.pathname.includes('/posts') + ) { + presenceData.details = 'Forums, Viewing the list of' + presenceData.state = 'latest posts' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if ( + document.location.pathname.includes('/whats-new/') + && document.location.pathname.includes('/news-feed') + ) { + presenceData.details = 'Forums, Viewing the' + presenceData.state = 'news feed' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/whats-new/')) { + presenceData.details = 'Forums, Viewing whats new' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/conversations/')) { + if (document.location.pathname.split('/')[4]) { + const title = document.querySelector( + '#top > div.p-body > div > div.uix_titlebar > div > div > div.p-title > h1', + ) + presenceData.details = 'Forums, Reading DM:' + if (title?.textContent && title.textContent.length > 128) + presenceData.state = `${title.textContent.substring(0, 125)}...` + else presenceData.state = title?.textContent + + presenceData.smallImageKey = Assets.Reading + + presence.setActivity(presenceData) + } + else { + presenceData.details = 'Forums, Browsing' + presenceData.state = 'through their DMs' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + } + else if (document.location.pathname.includes('/watched/')) { + if (document.location.pathname.includes('/threads')) { + presenceData.details = 'Forums, Viewing their' + presenceData.state = 'watched threads' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else { + presenceData.details = 'Forums, Viewing their' + presenceData.state = 'watched forums' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + } + else if (document.location.pathname.includes('/search/')) { + const search = document.querySelector( + '#top > div.p-body > div > div.uix_titlebar > div > div > div > h1 > a > em', + ) + if (search) { + presenceData.details = 'Forums, searching for:' + presenceData.state = search.textContent + + presenceData.smallImageKey = Assets.Search + + presence.setActivity(presenceData) + } + else { + presenceData.details = 'Forums, about to search' + presenceData.state = 'something up' + + presenceData.smallImageKey = Assets.Search + + presence.setActivity(presenceData) + } + } + else if (document.location.pathname.includes('/account/')) { + presenceData.details = 'Forums, account settings' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/members/')) { + if (document.URL.includes('key=staff_members')) { + presenceData.details = 'Viewing the list' + presenceData.state = 'of staff members' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.URL.includes('key=todays_birthdays')) { + presenceData.details = 'Viewing list of members' + presenceData.state = 'with today as their birthday' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.URL.includes('key=highest_reaction_score')) { + presenceData.details = 'Viewing list of members' + presenceData.state = 'with the highest ratings' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/banned')) { + presenceData.details = 'Viewing the list' + presenceData.state = 'of banned users' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/list')) { + presenceData.details = 'Viewing the list' + presenceData.state = 'of all users' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.URL.includes('key=most_likes')) { + presenceData.details = 'Viewing list of members' + presenceData.state = 'with the most reactions' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.URL.includes('key=most_messages')) { + presenceData.details = 'Viewing list of members' + presenceData.state = 'with the most messages' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if ( + document.querySelector( + '#top > div.p-body > div > div.p-body-main > div > div > div > div > div > div > div.memberHeader-main > div > h1 > span > span', + ) + ) { + const user = document.querySelector( + '#top > div.p-body > div > div.p-body-main > div > div > div > div > div > div > div.memberHeader-main > div > h1 > span > span', + ) + presenceData.details = 'Viewing user:' + presenceData.state = user?.textContent + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if ( + document.querySelector( + '#top > div.p-body > div > div.p-body-main > div > div > div > div > div > div > div.memberHeader-main > div > h1 > span', + ) + ) { + const user = document.querySelector( + '#top > div.p-body > div > div.p-body-main > div > div > div > div > div > div > div.memberHeader-main > div > h1 > span', + ) + presenceData.details = 'Viewing user:' + presenceData.state = user?.textContent + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else { + presenceData.details = 'Viewing overview of members' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + } + else if (document.location.pathname.includes('/forums/')) { + const title = document.querySelector( + '#top > div.p-body > div > div.p-body-header > div.p-title > h1', + ) + if (title && title.textContent !== 'THEARCHON') { + presenceData.details = 'Forums, viewing category:' + presenceData.state = title.textContent + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else { + presenceData.details = 'Forums, Browsing...' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + } + else if (document.location.pathname.includes('/staff')) { + presenceData.details = 'Viewing the list' + presenceData.state = 'of staff members' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/community/')) { + presenceData.details = 'Forums, Browsing...' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname === '/') { + presenceData.details = 'Viewing home page' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else { + presence.setActivity() + } + } + else if (document.location.hostname === 'shop.thearchon.net') { + const title = document.querySelector('head > title') + presenceData.details = 'Store, viewing:' + presenceData.state = title?.textContent?.replace('TheArchon Store | ', '') + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else { + presence.setActivity() + } +}) diff --git a/websites/T/The Eternal Jukebox/metadata.json b/websites/T/The Eternal Jukebox/metadata.json index 6969c2fcd1aa..05ec57b6d15b 100644 --- a/websites/T/The Eternal Jukebox/metadata.json +++ b/websites/T/The Eternal Jukebox/metadata.json @@ -1,22 +1,22 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "The Eternal Jukebox", - "description": { - "en": "The Eternal Jukebox lets you search a song on Spotify and will then generate a never-ending and ever changing version of the song. It does what Infinite Gangnam Style did but for any song." - }, - "url": "eternalbox.dev", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Eternal%20Jukebox/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Eternal%20Jukebox/assets/thumbnail.png", - "color": "#2b3e50", - "category": "music", - "tags": [ - "audio", - "infinite" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "The Eternal Jukebox", + "description": { + "en": "The Eternal Jukebox lets you search a song on Spotify and will then generate a never-ending and ever changing version of the song. It does what Infinite Gangnam Style did but for any song." + }, + "url": "eternalbox.dev", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Eternal%20Jukebox/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Eternal%20Jukebox/assets/thumbnail.png", + "color": "#2b3e50", + "category": "music", + "tags": [ + "audio", + "infinite" + ] +} diff --git a/websites/T/The Eternal Jukebox/presence.ts b/websites/T/The Eternal Jukebox/presence.ts index e53bd28bd7c4..11d6bee5a470 100644 --- a/websites/T/The Eternal Jukebox/presence.ts +++ b/websites/T/The Eternal Jukebox/presence.ts @@ -1,128 +1,128 @@ const presence = new Presence({ - clientId: "1023713697866199052", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1023713697866199052', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/The%20Eternal%20Jukebox/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, href, search } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/The%20Eternal%20Jukebox/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, href, search } = document.location - switch (pathname) { - case "/jukebox_index.html": { - presenceData.details = "Browsing"; - presenceData.state = "The Eternal Jukebox"; - break; - } - case "/jukebox_go.html": { - const [, hours, mins, secs] = document - .querySelector("#time") - .textContent.match(/(\d+):(\d+):(\d+)/) - .map(x => +x), - totalSeconds = hours * 3600 + mins * 60 + secs, - title = document - .querySelector("#song-title") - .textContent.trim(); - if (title) { - presenceData.details = "Listening to a song"; - presenceData.state = title; - if (totalSeconds > 0) { - presenceData.startTimestamp = - Math.floor(Date.now() / 1000) - totalSeconds; - } - presenceData.buttons = [ - { - label: "Listen", - url: href, - }, - { - label: "View source", - url: - (await presence.getPageletiable( - "jukeboxData.ogAudioURL" - )) || document.querySelector("#song-url").href, - }, - ]; - } else { - presenceData.details = "Listening to a song"; - presenceData.state = "Loading..."; - } - break; - } - case "/jukebox_search.html": { - presenceData.details = "Searching for a song"; - presenceData.state = - document.querySelector("#search").value; - break; - } - case "/faq.html": { - presenceData.details = "Browsing"; - presenceData.state = "FAQ"; - break; - } - case "/retro_index.html": { - presenceData.details = "Browsing"; - presenceData.state = "The (Retro) Eternal Jukebox"; - break; - } - case "/canonizer_index.html": { - presenceData.details = "Browsing"; - presenceData.state = "The Autocanonizer"; - break; - } - case "/canonizer_go.html": { - const [, hours, mins, secs] = document - .querySelector("#mtime") - .textContent.match(/(\d+):(\d+):(\d+)/) - .map(x => +x), - totalSeconds = hours * 3600 + mins * 60 + secs, - audioSource = await presence.getPageletiable( - "canonizerData.ogAudioURL" - ); - if ( - document.querySelector("#tiles > svg")?.childElementCount > - 5 - ) { - presenceData.details = "Listening to an autocanonized song"; - presenceData.state = document - .querySelector("#info") - .textContent.trim() - .replace(/\(autocanonized\) /, ""); - if (totalSeconds > 0) { - presenceData.startTimestamp = - Math.floor(Date.now() / 1000) - totalSeconds; - } - presenceData.buttons = [ - { - label: "Listen", - url: href, - }, - { - label: "View source", - url: - audioSource ?? - `https://open.spotify.com/track/${new URLSearchParams(search).get( - "id" - )}`, - }, - ]; - } else { - presenceData.details = "Listening to an autocanonized song"; - presenceData.state = "Loading..."; - } - break; - } - case "/canonizer_search.html": { - presenceData.details = "Searching for a song"; - presenceData.state = - document.querySelector("#search").value; - break; - } - } + switch (pathname) { + case '/jukebox_index.html': { + presenceData.details = 'Browsing' + presenceData.state = 'The Eternal Jukebox' + break + } + case '/jukebox_go.html': { + const [, hours, mins, secs] = document + .querySelector('#time') + ?.textContent + ?.match(/(\d+):(\d+):(\d+)/) + ?.map(x => +x) ?? [] + const totalSeconds = hours * 3600 + mins * 60 + secs + const title = document + .querySelector('#song-title') + ?.textContent + ?.trim() + if (title) { + presenceData.details = 'Listening to a song' + presenceData.state = title + if (totalSeconds > 0) { + presenceData.startTimestamp = Math.floor(Date.now() / 1000) - totalSeconds + } + presenceData.buttons = [ + { + label: 'Listen', + url: href, + }, + { + label: 'View source', + url: (await presence.getPageletiable( + 'jukeboxData.ogAudioURL', + )) || document.querySelector('#song-url')?.href || '', + }, + ] + } + else { + presenceData.details = 'Listening to a song' + presenceData.state = 'Loading...' + } + break + } + case '/jukebox_search.html': { + presenceData.details = 'Searching for a song' + presenceData.state = document.querySelector('#search')?.value + break + } + case '/faq.html': { + presenceData.details = 'Browsing' + presenceData.state = 'FAQ' + break + } + case '/retro_index.html': { + presenceData.details = 'Browsing' + presenceData.state = 'The (Retro) Eternal Jukebox' + break + } + case '/canonizer_index.html': { + presenceData.details = 'Browsing' + presenceData.state = 'The Autocanonizer' + break + } + case '/canonizer_go.html': { + const [, hours, mins, secs] = document + .querySelector('#mtime') + ?.textContent + ?.match(/(\d+):(\d+):(\d+)/) + ?.map(x => +x) ?? [] + const totalSeconds = hours * 3600 + mins * 60 + secs + const audioSource = await presence.getPageletiable( + 'canonizerData.ogAudioURL', + ) + if ( + (document.querySelector('#tiles > svg')?.childElementCount ?? 0) + > 5 + ) { + presenceData.details = 'Listening to an autocanonized song' + presenceData.state = document + .querySelector('#info') + ?.textContent + ?.trim() + .replace(/\(autocanonized\) /, '') + if (totalSeconds > 0) { + presenceData.startTimestamp = Math.floor(Date.now() / 1000) - totalSeconds + } + presenceData.buttons = [ + { + label: 'Listen', + url: href, + }, + { + label: 'View source', + url: audioSource + ?? `https://open.spotify.com/track/${new URLSearchParams(search).get( + 'id', + )}`, + }, + ] + } + else { + presenceData.details = 'Listening to an autocanonized song' + presenceData.state = 'Loading...' + } + break + } + case '/canonizer_search.html': { + presenceData.details = 'Searching for a song' + presenceData.state = document.querySelector('#search')?.value + break + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/The Mahjong/metadata.json b/websites/T/The Mahjong/metadata.json index 176c6fb1121f..b307f96fa1b8 100644 --- a/websites/T/The Mahjong/metadata.json +++ b/websites/T/The Mahjong/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "205984221859151873", - "name": "joerkig" - }, - "service": "The Mahjong", - "description": { - "en": "Amazing free Mahjong that’ll knock your socks off. Play classic and modern Mahjong games in full screen, with lots of layouts and beautiful tiles." - }, - "url": "themahjong.com", - "version": "1.0.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Mahjong/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Mahjong/assets/thumbnail.jpg", - "color": "#577e54", - "category": "games", - "tags": [ - "game", - "mahjong", - "webgame" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "205984221859151873", + "name": "joerkig" + }, + "service": "The Mahjong", + "description": { + "en": "Amazing free Mahjong that’ll knock your socks off. Play classic and modern Mahjong games in full screen, with lots of layouts and beautiful tiles." + }, + "url": "themahjong.com", + "version": "1.0.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Mahjong/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Mahjong/assets/thumbnail.jpg", + "color": "#577e54", + "category": "games", + "tags": [ + "game", + "mahjong", + "webgame" + ] +} diff --git a/websites/T/The Mahjong/presence.ts b/websites/T/The Mahjong/presence.ts index 16c8ef5e293a..80972e4ed596 100644 --- a/websites/T/The Mahjong/presence.ts +++ b/websites/T/The Mahjong/presence.ts @@ -1,127 +1,134 @@ const presence = new Presence({ - clientId: "1229013953414299700", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1229013953414299700', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/The%20Mahjong/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/The%20Mahjong/assets/logo.png', } const SITE_LANGS = [ - "ar", - "de", - "es", - "pt", - "da", - "fr", - "ru", - "id", - "it", - "nl", - "pl", - "sv", - "tr", - "vi", - "zh", - "hi", - "ko", - "ja", -]; + 'ar', + 'de', + 'es', + 'pt', + 'da', + 'fr', + 'ru', + 'id', + 'it', + 'nl', + 'pl', + 'sv', + 'tr', + 'vi', + 'zh', + 'hi', + 'ko', + 'ja', +] -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname, href } = document.location; - let pathArr = pathname.split("/"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname, href } = document.location + let pathArr = pathname.split('/') - if (SITE_LANGS.find(lang => lang === pathname.split("/")[1])) { - pathArr = ["", ...pathArr.slice(2)]; - if (pathArr.length === 1) pathArr = ["", ""]; - } + if (SITE_LANGS.find(lang => lang === pathname.split('/')[1])) { + pathArr = ['', ...pathArr.slice(2)] + if (pathArr.length === 1) + pathArr = ['', ''] + } - if (pathArr[1] === "" || pathArr[1] === "mahjong") { - if (pathArr[1] === "mahjong" && pathArr[2] === "") - presenceData.details = "Browing layouts"; - else { - const displays = document.querySelectorAll( - "[class*='displaysStyles_counter']" - ); - presenceData.details = `Layout: ${ - document.querySelector("header > span[class*='styles_layoutName']") - ?.textContent - }`; + if (pathArr[1] === '' || pathArr[1] === 'mahjong') { + if (pathArr[1] === 'mahjong' && pathArr[2] === '') { + presenceData.details = 'Browing layouts' + } + else { + const displays = document.querySelectorAll( + '[class*=\'displaysStyles_counter\']', + ) + presenceData.details = `Layout: ${ + document.querySelector('header > span[class*=\'styles_layoutName\']') + ?.textContent + }` - presenceData.state = `Tiles: ${displays[1]?.textContent ?? "0"} Moves: ${ - displays[2]?.textContent ?? "0" - }`; - if ( - document - .querySelectorAll( - "[class*='styles_listItem'][style*='translate3d(0%, 0px, 0px)']" - )[1] - ?.querySelector("[class*='styles_preview']")?.style - .backgroundImage - ) { - presenceData.smallImageKey = `https://themahjong.com${document - .querySelectorAll( - "[class*='styles_listItem'][style*='translate3d(0%, 0px, 0px)']" - )[1] - ?.querySelector("[class*='styles_preview']") - ?.style.backgroundImage.slice(5, -2)}`; - presenceData.smallImageText = `${ - document - .querySelectorAll( - "[class*='styles_listItem'][style*='translate3d(0%, 0px, 0px)']" - )[1] - ?.querySelector("[class*='styles_tilesetDescription'] > span") - .textContent - } tileset`; - } - if (pathArr[1] === "mahjong") { - presenceData.buttons = [ - { - label: "View Layout", - url: href, - }, - ]; - } - } - } else { - switch (pathArr[1]) { - case "blog": { - if (pathArr[2] === "") presenceData.details = "Viewing blog"; - else { - presenceData.details = "Viewing blog post"; - presenceData.state = - document.querySelector("h1[class*='title']").textContent; - presenceData.buttons = [ - { - label: "View page", - url: href, - }, - ]; - } - break; - } - case "faq": { - presenceData.details = "Viewing FAQ"; - break; - } - case "how-to-play": { - presenceData.details = "Viewing game rules"; - break; - } - case "cookie-policy": { - presenceData.details = "Viewing cookie policy"; - break; - } - case "privacy": { - presenceData.details = "Viewing privacy policy"; - break; - } - } - } - presence.setActivity(presenceData); -}); + presenceData.state = `Tiles: ${displays[1]?.textContent ?? '0'} Moves: ${ + displays[2]?.textContent ?? '0' + }` + if ( + document + .querySelectorAll( + '[class*=\'styles_listItem\'][style*=\'translate3d(0%, 0px, 0px)\']', + )[1] + ?.querySelector('[class*=\'styles_preview\']') + ?.style + .backgroundImage + ) { + presenceData.smallImageKey = `https://themahjong.com${document + .querySelectorAll( + '[class*=\'styles_listItem\'][style*=\'translate3d(0%, 0px, 0px)\']', + )[1] + ?.querySelector('[class*=\'styles_preview\']') + ?.style + .backgroundImage + .slice(5, -2)}` + presenceData.smallImageText = `${ + document + .querySelectorAll( + '[class*=\'styles_listItem\'][style*=\'translate3d(0%, 0px, 0px)\']', + )[1] + ?.querySelector('[class*=\'styles_tilesetDescription\'] > span') + ?.textContent + } tileset` + } + if (pathArr[1] === 'mahjong') { + presenceData.buttons = [ + { + label: 'View Layout', + url: href, + }, + ] + } + } + } + else { + switch (pathArr[1]) { + case 'blog': { + if (pathArr[2] === '') { + presenceData.details = 'Viewing blog' + } + else { + presenceData.details = 'Viewing blog post' + presenceData.state = document.querySelector('h1[class*=\'title\']')?.textContent + presenceData.buttons = [ + { + label: 'View page', + url: href, + }, + ] + } + break + } + case 'faq': { + presenceData.details = 'Viewing FAQ' + break + } + case 'how-to-play': { + presenceData.details = 'Viewing game rules' + break + } + case 'cookie-policy': { + presenceData.details = 'Viewing cookie policy' + break + } + case 'privacy': { + presenceData.details = 'Viewing privacy policy' + break + } + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/T/The New York Times/metadata.json b/websites/T/The New York Times/metadata.json index ae77e570c269..cb6dd5af9da1 100644 --- a/websites/T/The New York Times/metadata.json +++ b/websites/T/The New York Times/metadata.json @@ -1,64 +1,64 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "John Smith", - "id": "233950379065212938" - }, - "contributors": [ - { - "name": "N0chteil ^^", - "id": "495901098926669825" - } - ], - "service": "The New York Times", - "description": { - "en": "The New York Times is an American daily newspaper based in New York City with a worldwide readership. Founded in 1851, the Times has since won 130 Pulitzer Prizes, and has long been regarded within the industry as a national 'newspaper of record'. It is ranked 18th in the world by circulation and 3rd in the U.S.", - "nl": "The New York Times is een Amerikaans dagblad gevestigd in New York City met een wereldwijd lezerspubliek. The Times, opgericht in 1851, heeft sindsdien 130 Pulitzer-prijzen gewonnen en wordt binnen de branche lange tijd beschouwd als een nationale 'krant van het record'. Het staat op de 18e plaats in de wereld door oplage en op de 3e plaats in de VS" - }, - "url": [ - "www.nytimes.com", - "myaccount.nytimes.com" - ], - "version": "2.0.15", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20New%20York%20Times/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20New%20York%20Times/assets/thumbnail.png", - "color": "#ffffff", - "category": "other", - "tags": [ - "news", - "articles" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fas fa-user-secret", - "value": false - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - }, - { - "id": "podcastLogo", - "title": "Show Podcast logo", - "icon": "fas fa-podcast", - "value": true - }, - { - "id": "articleAuthor", - "title": "Show Article Author", - "icon": "fas fa-address-card", - "value": true - }, - { - "id": "moreDetails", - "title": "Show more Details", - "icon": "fas fa-newspaper", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "John Smith", + "id": "233950379065212938" + }, + "contributors": [ + { + "name": "N0chteil ^^", + "id": "495901098926669825" + } + ], + "service": "The New York Times", + "description": { + "en": "The New York Times is an American daily newspaper based in New York City with a worldwide readership. Founded in 1851, the Times has since won 130 Pulitzer Prizes, and has long been regarded within the industry as a national 'newspaper of record'. It is ranked 18th in the world by circulation and 3rd in the U.S.", + "nl": "The New York Times is een Amerikaans dagblad gevestigd in New York City met een wereldwijd lezerspubliek. The Times, opgericht in 1851, heeft sindsdien 130 Pulitzer-prijzen gewonnen en wordt binnen de branche lange tijd beschouwd als een nationale 'krant van het record'. Het staat op de 18e plaats in de wereld door oplage en op de 3e plaats in de VS" + }, + "url": [ + "www.nytimes.com", + "myaccount.nytimes.com" + ], + "version": "2.0.15", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20New%20York%20Times/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20New%20York%20Times/assets/thumbnail.png", + "color": "#ffffff", + "category": "other", + "tags": [ + "news", + "articles" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fas fa-user-secret", + "value": false + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + }, + { + "id": "podcastLogo", + "title": "Show Podcast logo", + "icon": "fas fa-podcast", + "value": true + }, + { + "id": "articleAuthor", + "title": "Show Article Author", + "icon": "fas fa-address-card", + "value": true + }, + { + "id": "moreDetails", + "title": "Show more Details", + "icon": "fas fa-newspaper", + "value": false + } + ] +} diff --git a/websites/T/The New York Times/presence.ts b/websites/T/The New York Times/presence.ts index 7870a06303ba..db91027c93ad 100644 --- a/websites/T/The New York Times/presence.ts +++ b/websites/T/The New York Times/presence.ts @@ -1,241 +1,257 @@ const presence = new Presence({ - clientId: "813781191308083239", - }), - time = Math.floor(Date.now() / 1000); - -presence.on("UpdateData", async () => { - const title = document.title.replace(" - The New York Times", ""), - setting = await getSettings(), - { pathname, hostname, href, search } = window.location, - path = pathname.split("/"), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/The%20New%20York%20Times/assets/logo.jpg", - startTimestamp: time, - }; - - if (hostname === "www.nytimes.com") { - if (setting.buttons && !setting.privacy) { - presenceData.buttons = [ - { - label: "View Page", - url: href, - }, - ]; - } - - if ( - ((path[1] === "international" || path[1] === "ca" || path[1] === "es") && - !path[2]) || - !path[1] - ) - presenceData.details = "Viewing Home Page"; - else if (pathname.includes("/interactive/")) { - presenceData.details = "Viewing an Interactive:"; - if (!setting.privacy) presenceData.state = title; - } else if ( - pathname.includes("/section/") || - pathname.includes("/spotlight/podcasts") - ) { - presenceData.details = "Viewing a Section Page:"; - if (!setting.privacy) presenceData.state = title; - } else if (pathname.includes("/destination/")) { - presenceData.details = "Viewing a Destination Page:"; - if (!setting.privacy) presenceData.state = title; - } else if (pathname.includes("/reviews/")) { - presenceData.details = "Viewing a Review Page:"; - if (!setting.privacy) presenceData.state = title; - } else if (pathname.includes("/column/")) { - presenceData.details = "Viewing a Column Page:"; - if (!setting.privacy) presenceData.state = title; - } else if (pathname.includes("/search")) { - presenceData.details = setting.privacy ? "Searching" : "Searching for:"; - if (!setting.privacy) - presenceData.state = new URLSearchParams(search).get("query"); - - if (setting.buttons && !setting.privacy) { - presenceData.buttons = [ - { - label: "Show Search Results", - url: href, - }, - ]; - } - } else if (pathname.includes("/video/")) { - presenceData.details = "Viewing a Video Section:"; - presenceData.state = title; - } else if (hasDatePath(pathname) && pathname.includes("/podcasts/")) { - const audioPlayer = document.querySelector("audio"), - podcast = document.querySelector("span.css-1f76qa2 span"), - podcastLogo = document.querySelector( - "span.css-1f76qa2 img" - ); - - presenceData.details = setting.privacy - ? "Listening to a Podcast" - : "Listening to a Podcast:"; - if (podcast && !setting.privacy) - presenceData.state = `${podcast.textContent}: ${title}`; - - if (audioPlayer && !isNaN(audioPlayer.duration)) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(audioPlayer); - - if (audioPlayer.paused) { - delete presenceData.endTimestamp; - presenceData.startTimestamp = time; - } - } - - if (setting.buttons && !setting.privacy) { - presenceData.buttons = [ - { - label: "Listen to Podcast", - url: href, - }, - ]; - } - - if (setting.podcastLogo && !setting.privacy && podcastLogo) - presenceData.largeImageKey = await getShortURL(podcastLogo.src); - } else if (path[1] === "by" && path[2]) { - const author = - document.querySelector("h1.css-1uxfi68.e16wpn5v0")?.textContent ?? - "Unknown"; - - presenceData.details = "Viewing an Author Page:"; - presenceData.state = author; - - if (document.querySelector("div.css-cnx41t img")) { - presenceData.smallImageKey = await getShortURL( - document.querySelector("div.css-cnx41t img").src - ); - presenceData.smallImageText = author; - } - } else if (hasDatePath(pathname) && path[4]) { - const author = document.querySelector( - "img.css-1bfqq7u.ey68jwv2" - ), - authors = document.querySelector("p.css-aknsld.e1jsehar1"), - headline = - document.querySelector('h1[data-testid="headline"]')?.textContent ?? - title, - isLive = document.querySelector( - 'span span.css-bwjyn0.live-blog-header-live-label[data-active="true"]' - ), - wasLive = document.querySelector("span.css-233int.e16638kd4"); - - presenceData.details = setting.privacy - ? "Reading an Article" - : setting.moreDetails && !isLive && !wasLive - ? headline - : "Reading an Article:"; - - if (!setting.privacy) { - presenceData.state = - setting.moreDetails && !isLive && !wasLive - ? `${authors?.textContent ?? `By ${author?.title ?? "Unknown"}`}, ${ - document.querySelector("time span")?.textContent - }` - : headline; - } - - if (setting.buttons && !setting.privacy) { - presenceData.buttons = [ - { - label: "Read Article", - url: href, - }, - ]; - } - - if (isLive) { - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = "Live"; - } else if (setting.articleAuthor && !setting.privacy && author) { - presenceData.smallImageKey = await getShortURL(author.src); - presenceData.smallImageText = - authors?.textContent ?? `By ${author.title}`; - } - } - } else if (hostname === "myaccount.nytimes.com") { - presenceData.details = "Managing Account"; - - if (!setting.privacy) { - switch (path[2]) { - case "subscription": { - presenceData.state = "Subscription Overview"; - break; - } - case "billing": { - presenceData.state = "Billing History"; - break; - } - case "settings": { - presenceData.state = "Emails and Settings"; - break; - } - case "change-email": { - presenceData.state = "Change Email"; - break; - } - case "forgot-password": { - presenceData.state = "Reset Password"; - break; - } - default: - if (path[1] === "get-started" && path[2] === "manage-billing") - presenceData.state = "Payment details"; - } - } - } - - if (!presenceData.state) delete presenceData.state; - - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); - -const shortenedURLs: Record = {}; + clientId: '813781191308083239', +}) +const time = Math.floor(Date.now() / 1000) + +presence.on('UpdateData', async () => { + const title = document.title.replace(' - The New York Times', '') + const setting = await getSettings() + const { pathname, hostname, href, search } = window.location + const path = pathname.split('/') + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/The%20New%20York%20Times/assets/logo.jpg', + startTimestamp: time, + } + + if (hostname === 'www.nytimes.com') { + if (setting.buttons && !setting.privacy) { + presenceData.buttons = [ + { + label: 'View Page', + url: href, + }, + ] + } + + if ( + ((path[1] === 'international' || path[1] === 'ca' || path[1] === 'es') + && !path[2]) + || !path[1] + ) { + presenceData.details = 'Viewing Home Page' + } + else if (pathname.includes('/interactive/')) { + presenceData.details = 'Viewing an Interactive:' + if (!setting.privacy) + presenceData.state = title + } + else if ( + pathname.includes('/section/') + || pathname.includes('/spotlight/podcasts') + ) { + presenceData.details = 'Viewing a Section Page:' + if (!setting.privacy) + presenceData.state = title + } + else if (pathname.includes('/destination/')) { + presenceData.details = 'Viewing a Destination Page:' + if (!setting.privacy) + presenceData.state = title + } + else if (pathname.includes('/reviews/')) { + presenceData.details = 'Viewing a Review Page:' + if (!setting.privacy) + presenceData.state = title + } + else if (pathname.includes('/column/')) { + presenceData.details = 'Viewing a Column Page:' + if (!setting.privacy) + presenceData.state = title + } + else if (pathname.includes('/search')) { + presenceData.details = setting.privacy ? 'Searching' : 'Searching for:' + if (!setting.privacy) + presenceData.state = new URLSearchParams(search).get('query') + + if (setting.buttons && !setting.privacy) { + presenceData.buttons = [ + { + label: 'Show Search Results', + url: href, + }, + ] + } + } + else if (pathname.includes('/video/')) { + presenceData.details = 'Viewing a Video Section:' + presenceData.state = title + } + else if (hasDatePath(pathname) && pathname.includes('/podcasts/')) { + const audioPlayer = document.querySelector('audio') + const podcast = document.querySelector('span.css-1f76qa2 span') + const podcastLogo = document.querySelector( + 'span.css-1f76qa2 img', + ) + + presenceData.details = setting.privacy + ? 'Listening to a Podcast' + : 'Listening to a Podcast:' + if (podcast && !setting.privacy) + presenceData.state = `${podcast.textContent}: ${title}` + + if (audioPlayer && !Number.isNaN(audioPlayer.duration)) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(audioPlayer) + + if (audioPlayer.paused) { + delete presenceData.endTimestamp + presenceData.startTimestamp = time + } + } + + if (setting.buttons && !setting.privacy) { + presenceData.buttons = [ + { + label: 'Listen to Podcast', + url: href, + }, + ] + } + + if (setting.podcastLogo && !setting.privacy && podcastLogo) + presenceData.largeImageKey = await getShortURL(podcastLogo.src) + } + else if (path[1] === 'by' && path[2]) { + const author = document.querySelector('h1.css-1uxfi68.e16wpn5v0')?.textContent + ?? 'Unknown' + + presenceData.details = 'Viewing an Author Page:' + presenceData.state = author + + if (document.querySelector('div.css-cnx41t img')) { + presenceData.smallImageKey = await getShortURL( + document.querySelector('div.css-cnx41t img')!.src, + ) + presenceData.smallImageText = author + } + } + else if (hasDatePath(pathname) && path[4]) { + const author = document.querySelector( + 'img.css-1bfqq7u.ey68jwv2', + ) + const authors = document.querySelector('p.css-aknsld.e1jsehar1') + const headline = document.querySelector('h1[data-testid="headline"]')?.textContent + ?? title + const isLive = document.querySelector( + 'span span.css-bwjyn0.live-blog-header-live-label[data-active="true"]', + ) + const wasLive = document.querySelector('span.css-233int.e16638kd4') + + presenceData.details = setting.privacy + ? 'Reading an Article' + : setting.moreDetails && !isLive && !wasLive + ? headline + : 'Reading an Article:' + + if (!setting.privacy) { + presenceData.state = setting.moreDetails && !isLive && !wasLive + ? `${authors?.textContent ?? `By ${author?.title ?? 'Unknown'}`}, ${ + document.querySelector('time span')?.textContent + }` + : headline + } + + if (setting.buttons && !setting.privacy) { + presenceData.buttons = [ + { + label: 'Read Article', + url: href, + }, + ] + } + + if (isLive) { + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = 'Live' + } + else if (setting.articleAuthor && !setting.privacy && author) { + presenceData.smallImageKey = await getShortURL(author.src) + presenceData.smallImageText = authors?.textContent ?? `By ${author.title}` + } + } + } + else if (hostname === 'myaccount.nytimes.com') { + presenceData.details = 'Managing Account' + + if (!setting.privacy) { + switch (path[2]) { + case 'subscription': { + presenceData.state = 'Subscription Overview' + break + } + case 'billing': { + presenceData.state = 'Billing History' + break + } + case 'settings': { + presenceData.state = 'Emails and Settings' + break + } + case 'change-email': { + presenceData.state = 'Change Email' + break + } + case 'forgot-password': { + presenceData.state = 'Reset Password' + break + } + default: + if (path[1] === 'get-started' && path[2] === 'manage-billing') + presenceData.state = 'Payment details' + } + } + } + + if (!presenceData.state) + delete presenceData.state + + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) + +const shortenedURLs: Record = {} async function getShortURL(url: string) { - if (!url || url.length < 256) return url; - if (shortenedURLs[url]) return shortenedURLs[url]; - try { - const pdURL = await ( - await fetch(`https://pd.premid.app/create/${url}`) - ).text(); - shortenedURLs[url] = pdURL; - return pdURL; - } catch (err) { - presence.error(err); - return url; - } + if (!url || url.length < 256) + return url + if (shortenedURLs[url]) + return shortenedURLs[url] + try { + const pdURL = await ( + await fetch(`https://pd.premid.app/create/${url}`) + ).text() + shortenedURLs[url] = pdURL + return pdURL + } + catch (err) { + presence.error(err as string) + return url + } } function hasDatePath(pathname: string) { - return /[0-9]{4}\/[0-9]{2}\/[0-9]{2}/g.test(pathname); + return /\d{4}\/\d{2}\/\d{2}/.test(pathname) } async function getSettings() { - const settings = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("buttons"), - presence.getSetting("podcastLogo"), - presence.getSetting("articleAuthor"), - presence.getSetting("moreDetails"), - ]), - names = [ - "privacy", - "buttons", - "podcastLogo", - "articleAuthor", - "moreDetails", - ], - obj: { - [key: string]: boolean; - } = {}; - - for (const [i, name] of names.entries()) obj[name] = settings[i]; - - return obj; + const settings = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('buttons'), + presence.getSetting('podcastLogo'), + presence.getSetting('articleAuthor'), + presence.getSetting('moreDetails'), + ]) + const names = [ + 'privacy', + 'buttons', + 'podcastLogo', + 'articleAuthor', + 'moreDetails', + ] + const obj: { + [key: string]: boolean + } = {} + + for (const [i, name] of names.entries()) obj[name] = settings[i] + + return obj } diff --git a/websites/T/The Odin Project/metadata.json b/websites/T/The Odin Project/metadata.json index c91bc9d93919..4aefc92c6723 100644 --- a/websites/T/The Odin Project/metadata.json +++ b/websites/T/The Odin Project/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "dogukan", - "id": "351309620918091776" - }, - "service": "The Odin Project", - "description": { - "en": "The Odin Project is one of those \"What I wish I had when I was learning\" resources. Not everyone has access to a computer science education or the funds to attend an intensive coding school and neither of those is right for everyone anyway. This project is designed to fill in the gap for people who are trying to hack it on their own but still want a high quality education." - }, - "url": "www.theodinproject.com", - "version": "1.0.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Odin%20Project/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Odin%20Project/assets/thumbnail.png", - "color": "#e3b261", - "category": "other", - "tags": [ - "top", - "odin", - "project", - "odinproject", - "theodinproject" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "dogukan", + "id": "351309620918091776" + }, + "service": "The Odin Project", + "description": { + "en": "The Odin Project is one of those \"What I wish I had when I was learning\" resources. Not everyone has access to a computer science education or the funds to attend an intensive coding school and neither of those is right for everyone anyway. This project is designed to fill in the gap for people who are trying to hack it on their own but still want a high quality education." + }, + "url": "www.theodinproject.com", + "version": "1.0.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Odin%20Project/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Odin%20Project/assets/thumbnail.png", + "color": "#e3b261", + "category": "other", + "tags": [ + "top", + "odin", + "project", + "odinproject", + "theodinproject" + ] +} diff --git a/websites/T/The Odin Project/presence.ts b/websites/T/The Odin Project/presence.ts index f8c6fe12f9a8..51b79e998a3d 100644 --- a/websites/T/The Odin Project/presence.ts +++ b/websites/T/The Odin Project/presence.ts @@ -1,60 +1,63 @@ const presence = new Presence({ - clientId: "1013489969379152022", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1013489969379152022', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/The%20Odin%20Project/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - lesson = document.querySelector( - "body > div.page-container.lesson > header > div > div > h1" - ), - course = document.querySelector( - "body > div.gradient.odin-dark-bg > div > div:nth-child(1) > a > h1" - ), - courseTitle = document.querySelector( - "body > div.page-container.lesson > header > div > div > a > h2" - ), - path = document.location.pathname; - switch (path) { - case "/paths": { - presenceData.state = "Viewing all Paths"; - break; - } - case "/paths/full-stack-javascript": { - presenceData.state = "Viewing the Full Stack Javascript Path"; - break; - } - case "/paths/full-stack-ruby-on-rails": { - presenceData.state = "Viewing the Full Stack Ruby Path"; - break; - } - case "/paths/foundations/courses/foundations": { - presenceData.state = "Viewing the Foundations Path"; - break; - } - default: - presenceData.state = "Viewing Dashboard"; - } +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/The%20Odin%20Project/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const lesson = document.querySelector( + 'body > div.page-container.lesson > header > div > div > h1', + ) + const course = document.querySelector( + 'body > div.gradient.odin-dark-bg > div > div:nth-child(1) > a > h1', + ) + const courseTitle = document.querySelector( + 'body > div.page-container.lesson > header > div > div > a > h2', + ) + const path = document.location.pathname + switch (path) { + case '/paths': { + presenceData.state = 'Viewing all Paths' + break + } + case '/paths/full-stack-javascript': { + presenceData.state = 'Viewing the Full Stack Javascript Path' + break + } + case '/paths/full-stack-ruby-on-rails': { + presenceData.state = 'Viewing the Full Stack Ruby Path' + break + } + case '/paths/foundations/courses/foundations': { + presenceData.state = 'Viewing the Foundations Path' + break + } + default: + presenceData.state = 'Viewing Dashboard' + } - if (path.includes("/paths/full-stack-javascript/courses/")) { - presenceData.details = "Full Stack Javascript - Courses"; - presenceData.state = `${course.textContent}`; - } else if (path.includes("/paths/full-stack-ruby-on-rails/courses/")) { - presenceData.details = "Full Stack Ruby - Courses"; - presenceData.state = `${course.textContent}`; - } else if (path.includes("/foundations-")) { - presenceData.state = `${lesson.textContent}`; - presenceData.details = "Foundations - Lessons"; - } else if (path.includes("/lessons/node-")) { - presenceData.details = courseTitle.textContent; - presenceData.state = lesson.textContent; - } else if (path.includes("/lessons/ruby-")) { - presenceData.details = courseTitle.textContent; - presenceData.state = lesson.textContent; - } - presence.setActivity(presenceData); -}); + if (path.includes('/paths/full-stack-javascript/courses/')) { + presenceData.details = 'Full Stack Javascript - Courses' + presenceData.state = `${course?.textContent}` + } + else if (path.includes('/paths/full-stack-ruby-on-rails/courses/')) { + presenceData.details = 'Full Stack Ruby - Courses' + presenceData.state = `${course?.textContent}` + } + else if (path.includes('/foundations-')) { + presenceData.state = `${lesson?.textContent}` + presenceData.details = 'Foundations - Lessons' + } + else if (path.includes('/lessons/node-')) { + presenceData.details = courseTitle?.textContent + presenceData.state = lesson?.textContent + } + else if (path.includes('/lessons/ruby-')) { + presenceData.details = courseTitle?.textContent + presenceData.state = lesson?.textContent + } + presence.setActivity(presenceData) +}) diff --git a/websites/T/The Weather Channel/metadata.json b/websites/T/The Weather Channel/metadata.json index bcfa9946f8d3..95e80c208683 100644 --- a/websites/T/The Weather Channel/metadata.json +++ b/websites/T/The Weather Channel/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "The Weather Channel", - "description": { - "en": "The Weather Channel and weather.com provide a national and local weather forecast for cities, as well as weather radar, report and hurricane coverage" - }, - "url": [ - "weather.com", - "features.weather.com" - ], - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Weather%20Channel/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Weather%20Channel/assets/thumbnail.png", - "color": "#014F9D", - "category": "other", - "tags": [ - "news", - "forecase", - "weather" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "The Weather Channel", + "description": { + "en": "The Weather Channel and weather.com provide a national and local weather forecast for cities, as well as weather radar, report and hurricane coverage" + }, + "url": [ + "weather.com", + "features.weather.com" + ], + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Weather%20Channel/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Weather%20Channel/assets/thumbnail.png", + "color": "#014F9D", + "category": "other", + "tags": [ + "news", + "forecase", + "weather" + ] +} diff --git a/websites/T/The Weather Channel/presence.ts b/websites/T/The Weather Channel/presence.ts index c564d2ce88e3..a0e145d2106f 100644 --- a/websites/T/The Weather Channel/presence.ts +++ b/websites/T/The Weather Channel/presence.ts @@ -1,200 +1,205 @@ const presence = new Presence({ - clientId: "1027249400738750625", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1027249400738750625', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/The%20Weather%20Channel/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, hostname, href } = window.location, - pathSplit = pathname.split("/").filter(x => x), - locationName = document.querySelector( - "[class*='--locationName--']" - )?.textContent, - pageTitle = document.querySelector("h1")?.textContent; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/The%20Weather%20Channel/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, hostname, href } = window.location + const pathSplit = pathname.split('/').filter(x => x) + const locationName = document.querySelector( + '[class*=\'--locationName--\']', + )?.textContent + const pageTitle = document.querySelector('h1')?.textContent - function setNewsPresenceData(subPath: string[], type: string) { - if ((subPath ?? "") === "") - presenceData.details = `Browsing ${type} stories`; - else if (subPath.includes("video")) { - presenceData.details = `Watching a ${type} video`; - presenceData.state = pageTitle; - presenceData.buttons = [{ label: "Watch Video", url: href }]; - } else if (subPath.includes("news")) { - presenceData.details = `Reading a ${type} article`; - presenceData.state = pageTitle; - presenceData.buttons = [{ label: "Read Article", url: href }]; - } - } + function setNewsPresenceData(subPath: string[], type: string) { + if (subPath.length === 1) { + presenceData.details = `Browsing ${type} stories` + } + else if (subPath.includes('video')) { + presenceData.details = `Watching a ${type} video` + presenceData.state = pageTitle + presenceData.buttons = [{ label: 'Watch Video', url: href }] + } + else if (subPath.includes('news')) { + presenceData.details = `Reading a ${type} article` + presenceData.state = pageTitle + presenceData.buttons = [{ label: 'Read Article', url: href }] + } + } - if (hostname === "weather.com") { - switch (pathSplit[0] ?? "") { - case "": { - presenceData.details = "Browsing homepage"; - break; - } - case "deals": { - setNewsPresenceData(pathSplit, "deal"); - break; - } - case "forecast": { - switch (pathSplit[1]) { - case "air-quality": { - presenceData.details = "Viewing air quality forecast"; - presenceData.state = locationName; - break; - } - case "allergy": { - presenceData.details = "Viewing allergy forecast"; - presenceData.state = `${ - document.querySelector("h2").textContent - } for ${locationName}`; - break; - } - case "cold-flu": { - presenceData.details = "Viewing cold & flu forecasts"; - break; - } - default: { - setNewsPresenceData(pathSplit.slice(1), "forecast"); - } - } - break; - } - case "health": { - if (pathSplit[1] === "cold-flu") - setNewsPresenceData(pathSplit.slice(2), "cold & flu"); - else setNewsPresenceData(pathSplit.slice(1), "health"); - break; - } - case "slideshows": - case "photos": { - setNewsPresenceData(pathSplit.slice(1), "photo"); - if (pathSplit[1] === "news") { - presenceData.largeImageKey = document.querySelector( - "[id*='int-image'] img" - ).src; - } - break; - } - case "promos": { - setNewsPresenceData(pathSplit.slice(1), "promo"); - break; - } - case "login": - case "signup": { - presenceData.details = "Logging in"; - break; - } - case "maps": { - presenceData.details = "Viewing a map"; - presenceData.state = pageTitle; - presenceData.buttons = [{ label: "View Map", url: href }]; - break; - } - case "member": { - presenceData.details = "Managing account"; - break; - } - case "news": { - setNewsPresenceData(pathSplit.slice(1), "news"); - break; - } - case "safety": { - setNewsPresenceData(pathSplit.slice(1), "safety"); - break; - } - case "science": { - setNewsPresenceData(pathSplit.slice(1), "science"); - break; - } - case "sports-recreation": { - if (pathSplit[1] === "fishing") - setNewsPresenceData(pathSplit.slice(2), "fishing"); - else setNewsPresenceData(pathSplit.slice(1), "sports & recreation"); - break; - } - case "storms": { - switch (pathSplit[1]) { - case "tornado": { - setNewsPresenceData(pathSplit.slice(2), "tornado"); - break; - } - case "hurricane": { - setNewsPresenceData(pathSplit.slice(2), "hurricane"); - break; - } - } - break; - } - case "subscribe": { - presenceData.details = "Subscribing"; - break; - } - case "travel": { - setNewsPresenceData(pathSplit.slice(1), "travel"); - break; - } - case "weather": { - switch (pathSplit[1]) { - case "today": { - presenceData.details = "Browsing today's weather forecast"; - presenceData.state = locationName; - break; - } - case "hourbyhour": { - presenceData.details = "Browsing hourly weather forecast"; - presenceData.state = locationName; - break; - } - case "tenday": { - presenceData.details = "Browsing 10-day weather forecast"; - presenceData.state = locationName; - break; - } - case "weekend": { - presenceData.details = "Browsing weekend weather forecast"; - presenceData.state = locationName; - break; - } - case "monthly": { - presenceData.details = "Browsing monthly weather forecast"; - presenceData.state = locationName; - break; - } - case "radar": { - presenceData.details = "Viewing weather radar"; - presenceData.state = locationName; - break; - } - } - break; - } - default: { - presenceData.details = "Browsing"; - presenceData.state = document.title.match( - /^(.*?)( \| The Weather Channel)?$/ - )[1]; - break; - } - } - } else if (hostname === "features.weather.com") { - if (pathSplit[0] === "") { - presenceData.details = "Browsing"; - presenceData.state = "All features and stories"; - } else if (pathSplit[0] === "category") { - presenceData.details = "Browsing category"; - presenceData.state = pageTitle.match(/: (.*)$/)[1]; - } else { - presenceData.details = "Reading an article"; - presenceData.state = pageTitle; - presenceData.buttons = [{ label: "Read Article", url: href }]; - } - } + if (hostname === 'weather.com') { + switch (pathSplit[0] ?? '') { + case '': { + presenceData.details = 'Browsing homepage' + break + } + case 'deals': { + setNewsPresenceData(pathSplit, 'deal') + break + } + case 'forecast': { + switch (pathSplit[1]) { + case 'air-quality': { + presenceData.details = 'Viewing air quality forecast' + presenceData.state = locationName + break + } + case 'allergy': { + presenceData.details = 'Viewing allergy forecast' + presenceData.state = `${ + document.querySelector('h2')?.textContent + } for ${locationName}` + break + } + case 'cold-flu': { + presenceData.details = 'Viewing cold & flu forecasts' + break + } + default: { + setNewsPresenceData(pathSplit.slice(1), 'forecast') + } + } + break + } + case 'health': { + if (pathSplit[1] === 'cold-flu') + setNewsPresenceData(pathSplit.slice(2), 'cold & flu') + else setNewsPresenceData(pathSplit.slice(1), 'health') + break + } + case 'slideshows': + case 'photos': { + setNewsPresenceData(pathSplit.slice(1), 'photo') + if (pathSplit[1] === 'news') { + presenceData.largeImageKey = document.querySelector( + '[id*=\'int-image\'] img', + )?.src + } + break + } + case 'promos': { + setNewsPresenceData(pathSplit.slice(1), 'promo') + break + } + case 'login': + case 'signup': { + presenceData.details = 'Logging in' + break + } + case 'maps': { + presenceData.details = 'Viewing a map' + presenceData.state = pageTitle + presenceData.buttons = [{ label: 'View Map', url: href }] + break + } + case 'member': { + presenceData.details = 'Managing account' + break + } + case 'news': { + setNewsPresenceData(pathSplit.slice(1), 'news') + break + } + case 'safety': { + setNewsPresenceData(pathSplit.slice(1), 'safety') + break + } + case 'science': { + setNewsPresenceData(pathSplit.slice(1), 'science') + break + } + case 'sports-recreation': { + if (pathSplit[1] === 'fishing') + setNewsPresenceData(pathSplit.slice(2), 'fishing') + else setNewsPresenceData(pathSplit.slice(1), 'sports & recreation') + break + } + case 'storms': { + switch (pathSplit[1]) { + case 'tornado': { + setNewsPresenceData(pathSplit.slice(2), 'tornado') + break + } + case 'hurricane': { + setNewsPresenceData(pathSplit.slice(2), 'hurricane') + break + } + } + break + } + case 'subscribe': { + presenceData.details = 'Subscribing' + break + } + case 'travel': { + setNewsPresenceData(pathSplit.slice(1), 'travel') + break + } + case 'weather': { + switch (pathSplit[1]) { + case 'today': { + presenceData.details = 'Browsing today\'s weather forecast' + presenceData.state = locationName + break + } + case 'hourbyhour': { + presenceData.details = 'Browsing hourly weather forecast' + presenceData.state = locationName + break + } + case 'tenday': { + presenceData.details = 'Browsing 10-day weather forecast' + presenceData.state = locationName + break + } + case 'weekend': { + presenceData.details = 'Browsing weekend weather forecast' + presenceData.state = locationName + break + } + case 'monthly': { + presenceData.details = 'Browsing monthly weather forecast' + presenceData.state = locationName + break + } + case 'radar': { + presenceData.details = 'Viewing weather radar' + presenceData.state = locationName + break + } + } + break + } + default: { + presenceData.details = 'Browsing' + presenceData.state = document.title.match( + /^(.*?)( \| The Weather Channel)?$/, + )?.[1] + break + } + } + } + else if (hostname === 'features.weather.com') { + if (pathSplit[0] === '') { + presenceData.details = 'Browsing' + presenceData.state = 'All features and stories' + } + else if (pathSplit[0] === 'category') { + presenceData.details = 'Browsing category' + presenceData.state = pageTitle?.match(/: (.*)$/)?.[1] + } + else { + presenceData.details = 'Reading an article' + presenceData.state = pageTitle + presenceData.buttons = [{ label: 'Read Article', url: href }] + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TheSite/metadata.json b/websites/T/TheSite/metadata.json index d377961eef96..6ba54ed948e7 100644 --- a/websites/T/TheSite/metadata.json +++ b/websites/T/TheSite/metadata.json @@ -1,56 +1,56 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Striker", - "id": "215509157837537280" - }, - "service": "TheSite", - "description": { - "en": "TheSite is a service that provides the public with access to motion pictures, television, and other audio-visual entertainment streamed over the internet to certain internet-connected TV's, computers smartphones, tablets, and other devices.", - "nl": "TheSite is een service die het publiek toegang geeft tot films, televisie en ander audiovisueel amusement dat via internet wordt gestreamd naar bepaalde met internet verbonden tv's, computers, smartphones, tablets en andere apparaten." - }, - "url": [ - "relx.site", - "calmx.site" - ], - "version": "1.0.30", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TheSite/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TheSite/assets/thumbnail.png", - "color": "#00A0EC", - "category": "videos", - "tags": [ - "relx", - "calmx", - "movies", - "shows", - "entertainment" - ], - "settings": [ - { - "id": "search", - "title": "Display Search Info", - "icon": "fas fa-search", - "value": true - }, - { - "id": "browse", - "title": "Display Browsing Info", - "icon": "fas fa-book-open", - "value": true - }, - { - "id": "video", - "title": "Display Video Info", - "icon": "fas fa-video", - "value": true - }, - { - "id": "show-format", - "title": "TV Show Display Format", - "icon": "fas fa-pen", - "value": "%show% - S%season%E%episode%", - "placeholder": "%show%, %season% or %episode%" - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Striker", + "id": "215509157837537280" + }, + "service": "TheSite", + "description": { + "en": "TheSite is a service that provides the public with access to motion pictures, television, and other audio-visual entertainment streamed over the internet to certain internet-connected TV's, computers smartphones, tablets, and other devices.", + "nl": "TheSite is een service die het publiek toegang geeft tot films, televisie en ander audiovisueel amusement dat via internet wordt gestreamd naar bepaalde met internet verbonden tv's, computers, smartphones, tablets en andere apparaten." + }, + "url": [ + "relx.site", + "calmx.site" + ], + "version": "1.0.30", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TheSite/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TheSite/assets/thumbnail.png", + "color": "#00A0EC", + "category": "videos", + "tags": [ + "relx", + "calmx", + "movies", + "shows", + "entertainment" + ], + "settings": [ + { + "id": "search", + "title": "Display Search Info", + "icon": "fas fa-search", + "value": true + }, + { + "id": "browse", + "title": "Display Browsing Info", + "icon": "fas fa-book-open", + "value": true + }, + { + "id": "video", + "title": "Display Video Info", + "icon": "fas fa-video", + "value": true + }, + { + "id": "show-format", + "title": "TV Show Display Format", + "icon": "fas fa-pen", + "value": "%show% - S%season%E%episode%", + "placeholder": "%show%, %season% or %episode%" + } + ] +} diff --git a/websites/T/TheSite/presence.ts b/websites/T/TheSite/presence.ts index cf0c23ddddce..60cd9637065f 100644 --- a/websites/T/TheSite/presence.ts +++ b/websites/T/TheSite/presence.ts @@ -1,356 +1,365 @@ const presence = new Presence({ - clientId: "702668334990098523", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - browse: "general.browsing", - search: "general.searching", - }), - getElement = (query: string): string => { - const element = document.querySelector(query); - if (element) return element.textContent.replace(/^\s+|\s+$/g, ""); - else return "Loading..."; - }, - videoStatus = (video: HTMLVideoElement): string => { - return video.paused ? Assets.Pause : Assets.Play; - }; + clientId: '702668334990098523', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', + browse: 'general.browsing', + search: 'general.searching', +}) +function getElement(query: string): string { + const element = document.querySelector(query) + return element?.textContent?.replace(/^\s+|\s+$/g, '') ?? 'Loading...' +} +function videoStatus(video: HTMLVideoElement): string { + return video.paused ? Assets.Pause : Assets.Play +} -let oldUrl: string, - elapsed: number, - searchText = "", - searchElapsed = 0; +let oldUrl: string +let elapsed: number +let searchText = '' +let searchElapsed = 0 function setObject(path: string) { - switch (path) { - case "/": { - return { - details: "Browsing", - }; - } - case "/login/": { - return { - details: "Logging in", - }; - } - case "/password/forgot": { - return { - details: "Forgot Password", - }; - } - case "/pages/kodi_plugin": { - return { - details: "Viewing", - state: "Kodi Plugin", - }; - } - case "/pages/contact": { - return { - details: "Viewing", - state: "Contact", - }; - } - case "/pages/faq": { - return { - details: "Viewing", - state: "FAQ", - }; - } - case "/pages/terms": { - return { - details: "Viewing", - state: "Terms of Service", - }; - } - case "/pages/privacy": { - return { - details: "Viewing", - state: "Privacy Info", - }; - } - case "/pages/cookies": { - return { - details: "Viewing", - state: "Cookie Info", - }; - } - case "/pages/social_terms": { - return { - details: "Viewing", - state: "Social Terms", - }; - } - case "/account/gifts": { - return { - details: "Redeeming", - state: "Gift-Code", - }; - } - case "/account/favorites/": { - return { - details: "Viewing", - state: "Favorites", - }; - } - case "/account/playlist/wl/": { - return { - details: "Viewing", - state: "Watch Later", - }; - } - case "/account/pin": { - return { - details: "Logging In", - state: "Via PIN", - }; - } - case "/premium/primary": { - return { - details: "Buying", - state: "Premium", - }; - } - case "/movies/": { - return { - details: "Browsing", - state: "Movies", - }; - } - case "/shows/": { - return { - details: "Browsing", - state: "TV Shows", - }; - } - case "/schedule/": { - return { - details: "Viewing", - state: "Schedule", - }; - } - case "/sets/children": { - return { - details: "Viewing Set", - state: "Children", - }; - } - case "/sets/comedies": { - return { - details: "Viewing Set", - state: "Comedies", - }; - } - case "/sets/action": { - return { - details: "Viewing Set", - state: "Action", - }; - } - case "/sets/dramas": { - return { - details: "Viewing Set", - state: "Dramas", - }; - } - case "/sets/romance": { - return { - details: "Viewing Set", - state: "Romance", - }; - } - case "/sets/sci-fi": { - return { - details: "Viewing Set", - state: "Science Fiction", - }; - } - case "/sets/horror": { - return { - details: "Viewing Set", - state: "Horror", - }; - } - } + switch (path) { + case '/': { + return { + details: 'Browsing', + } + } + case '/login/': { + return { + details: 'Logging in', + } + } + case '/password/forgot': { + return { + details: 'Forgot Password', + } + } + case '/pages/kodi_plugin': { + return { + details: 'Viewing', + state: 'Kodi Plugin', + } + } + case '/pages/contact': { + return { + details: 'Viewing', + state: 'Contact', + } + } + case '/pages/faq': { + return { + details: 'Viewing', + state: 'FAQ', + } + } + case '/pages/terms': { + return { + details: 'Viewing', + state: 'Terms of Service', + } + } + case '/pages/privacy': { + return { + details: 'Viewing', + state: 'Privacy Info', + } + } + case '/pages/cookies': { + return { + details: 'Viewing', + state: 'Cookie Info', + } + } + case '/pages/social_terms': { + return { + details: 'Viewing', + state: 'Social Terms', + } + } + case '/account/gifts': { + return { + details: 'Redeeming', + state: 'Gift-Code', + } + } + case '/account/favorites/': { + return { + details: 'Viewing', + state: 'Favorites', + } + } + case '/account/playlist/wl/': { + return { + details: 'Viewing', + state: 'Watch Later', + } + } + case '/account/pin': { + return { + details: 'Logging In', + state: 'Via PIN', + } + } + case '/premium/primary': { + return { + details: 'Buying', + state: 'Premium', + } + } + case '/movies/': { + return { + details: 'Browsing', + state: 'Movies', + } + } + case '/shows/': { + return { + details: 'Browsing', + state: 'TV Shows', + } + } + case '/schedule/': { + return { + details: 'Viewing', + state: 'Schedule', + } + } + case '/sets/children': { + return { + details: 'Viewing Set', + state: 'Children', + } + } + case '/sets/comedies': { + return { + details: 'Viewing Set', + state: 'Comedies', + } + } + case '/sets/action': { + return { + details: 'Viewing Set', + state: 'Action', + } + } + case '/sets/dramas': { + return { + details: 'Viewing Set', + state: 'Dramas', + } + } + case '/sets/romance': { + return { + details: 'Viewing Set', + state: 'Romance', + } + } + case '/sets/sci-fi': { + return { + details: 'Viewing Set', + state: 'Science Fiction', + } + } + case '/sets/horror': { + return { + details: 'Viewing Set', + state: 'Horror', + } + } + } } -presence.on("UpdateData", async () => { - const path = location.pathname.replace(/\/?$/, "/"), - video = document.querySelector("video"), - search = document.querySelector("input"), - [showSearchInfo, showBrowseInfo, showVideoInfo, format] = await Promise.all( - [ - presence.getSetting("search"), - presence.getSetting("browse"), - presence.getSetting("video"), - presence.getSetting("show-format"), - ] - ), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TheSite/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const path = location.pathname.replace(/\/?$/, '/') + const video = document.querySelector('video') + const search = document.querySelector('input') + const [showSearchInfo, showBrowseInfo, showVideoInfo, format] = await Promise.all( + [ + presence.getSetting('search'), + presence.getSetting('browse'), + presence.getSetting('video'), + presence.getSetting('show-format'), + ], + ) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TheSite/assets/logo.png', + } - if (oldUrl !== path) { - oldUrl = path; - elapsed = Math.floor(Date.now() / 1000); - } + if (oldUrl !== path) { + oldUrl = path + elapsed = Math.floor(Date.now() / 1000) + } - if (elapsed) presenceData.startTimestamp = elapsed; + if (elapsed) + presenceData.startTimestamp = elapsed - const parseVideo = async (): Promise => { - const status = videoStatus(video); - presenceData.smallImageKey = status; - if (status === "play") { - const [startTimestamp, endTimestamp] = presence.getTimestamps( - video.currentTime, - video.duration - ); - [presenceData.startTimestamp, presenceData.endTimestamp] = [ - startTimestamp, - endTimestamp, - ]; - } - }; + const parseVideo = async (): Promise => { + if (video) { + const status = videoStatus(video) + presenceData.smallImageKey = status + if (status === 'play') { + const [startTimestamp, endTimestamp] = presence.getTimestamps( + video.currentTime, + video.duration, + ); + [presenceData.startTimestamp, presenceData.endTimestamp] = [ + startTimestamp, + endTimestamp, + ] + } + } + } - /* Browsing Info */ - if (showBrowseInfo) { - if (path.includes("/person")) { - presenceData.details = "Viewing Person"; - presenceData.state = getElement(".person-page-block h2"); - } - if (path.includes("/account")) { - presenceData.details = "Viewing"; - presenceData.state = `Account (${getElement(".account-nav > .active")})`; - } - if (path.includes("/request")) { - presenceData.details = "Viewing"; - presenceData.state = `Requests (${getElement(".nav-tabs > .active")})`; - } - if (path.includes("/collections")) { - const title = getElement(".page-videolist > h1"); + /* Browsing Info */ + if (showBrowseInfo) { + if (path.includes('/person')) { + presenceData.details = 'Viewing Person' + presenceData.state = getElement('.person-page-block h2') + } + if (path.includes('/account')) { + presenceData.details = 'Viewing' + presenceData.state = `Account (${getElement('.account-nav > .active')})` + } + if (path.includes('/request')) { + presenceData.details = 'Viewing' + presenceData.state = `Requests (${getElement('.nav-tabs > .active')})` + } + if (path.includes('/collections')) { + const title = getElement('.page-videolist > h1') - presenceData.details = "Browsing"; - presenceData.state = "Collections"; - if (title !== "Loading...") { - presenceData.details = "Browsing Collection"; - presenceData.state = title; - } - } + presenceData.details = 'Browsing' + presenceData.state = 'Collections' + if (title !== 'Loading...') { + presenceData.details = 'Browsing Collection' + presenceData.state = title + } + } - const detailsObj = setObject(path); - presenceData.details = detailsObj.details; - presenceData.state = detailsObj.state; - } + const detailsObj = setObject(path)! + presenceData.details = detailsObj.details + presenceData.state = detailsObj.state + } - /* Video Info */ - if (showVideoInfo) { - const wl = path.includes("/list"), - wlMovie = wl && getElement(".media-body .genre"); + /* Video Info */ + if (showVideoInfo) { + const wl = path.includes('/list') + const wlMovie = wl && getElement('.media-body .genre') - if (wlMovie || path.includes("/movies")) { - const menu: HTMLElement = document.querySelector(".mv-movie-info"), - title: string = getElement(".mv-movie-title > span"); + if (wlMovie || path.includes('/movies')) { + const menu = document.querySelector('.mv-movie-info') + const title: string = getElement('.mv-movie-title > span') - if (menu) { - if (menu.style.display === "none") { - await parseVideo(); - presenceData.details = "Watching Movie"; - presenceData.state = title; - } else { - presenceData.details = "Viewing Movie Details"; - presenceData.state = title; - } - } - } - /* Non Watch Later */ - if (path.includes("/shows")) { - const menu = document.querySelector(".mv-movie-info"), - regex = getElement(".mv-movie-title > span > span > strong").match( - /S(?\d{1,4})E(?\d{1,4})/ - ), - title: string = getElement(".mv-movie-title > span > a"); - if (title !== "Loading...") { - const { season } = regex.groups, - { episode } = regex.groups, - state = format - .replace("%show%", title) - .replace("%season%", season) - .replace("%episode%", episode); + if (menu) { + if (menu.style.display === 'none') { + await parseVideo() + presenceData.details = 'Watching Movie' + presenceData.state = title + } + else { + presenceData.details = 'Viewing Movie Details' + presenceData.state = title + } + } + } + /* Non Watch Later */ + if (path.includes('/shows')) { + const menu = document.querySelector('.mv-movie-info') + const regex = getElement('.mv-movie-title > span > span > strong').match( + /S(?\d{1,4})E(?\d{1,4})/, + ) + const title: string = getElement('.mv-movie-title > span > a') + if (title !== 'Loading...') { + const { season } = regex?.groups ?? {} + const { episode } = regex?.groups ?? {} + const state = format + .replace('%show%', title) + .replace('%season%', season) + .replace('%episode%', episode) - if (menu) { - if (menu.style.display === "none") { - await parseVideo(); - presenceData.details = "Watching TV Show"; - presenceData.state = state; - } else { - presenceData.details = "Viewing TV Show Details"; - presenceData.state = state; - } - } - } else { - presenceData.details = "Viewing TV Show Details"; - presenceData.state = getElement(".mv-movie-title > span"); - } - } - /* Watch Later */ - if (wl && !wlMovie) { - const menu: HTMLElement = document.querySelector(".mv-movie-info"), - regex: RegExpMatchArray = getElement( - ".full-title > .content > .seq > em" - ).match(/S(?\d{1,4})E(?\d{1,4})/), - title: string = getElement(".full-title > .content > .title"); - if (title !== "Loading...") { - const { season } = regex.groups, - { episode } = regex.groups, - state = format - .replace("%show%", title) - .replace("%season%", season) - .replace("%episode%", episode); + if (menu) { + if (menu.style.display === 'none') { + await parseVideo() + presenceData.details = 'Watching TV Show' + presenceData.state = state + } + else { + presenceData.details = 'Viewing TV Show Details' + presenceData.state = state + } + } + } + else { + presenceData.details = 'Viewing TV Show Details' + presenceData.state = getElement('.mv-movie-title > span') + } + } + /* Watch Later */ + if (wl && !wlMovie) { + const menu = document.querySelector('.mv-movie-info') + const regex = getElement( + '.full-title > .content > .seq > em', + ).match(/S(?\d{1,4})E(?\d{1,4})/) + const title: string = getElement('.full-title > .content > .title') + if (title !== 'Loading...') { + const { season } = regex?.groups ?? {} + const { episode } = regex?.groups ?? {} + const state = format + .replace('%show%', title) + .replace('%season%', season) + .replace('%episode%', episode) - if (menu) { - if (menu.style.display === "none") { - await parseVideo(); - presenceData.details = "Watching TV Show"; - presenceData.state = state; - } else { - presenceData.details = "Viewing TV Show Details"; - presenceData.state = state; - } - } - } else { - presenceData.details = "Viewing TV Show Details"; - presenceData.state = getElement(".mv-movie-title > span"); - } - } - } + if (menu) { + if (menu.style.display === 'none') { + await parseVideo() + presenceData.details = 'Watching TV Show' + presenceData.state = state + } + else { + presenceData.details = 'Viewing TV Show Details' + presenceData.state = state + } + } + } + else { + presenceData.details = 'Viewing TV Show Details' + presenceData.state = getElement('.mv-movie-title > span') + } + } + } - /* Search Info */ - if (showSearchInfo) { - if (search.value !== searchText) { - searchText = search.value; - searchElapsed = Date.now(); - } - if ( - (Date.now() - searchElapsed <= 5000 || path.includes("/search")) && - searchText.length > 0 - ) { - presenceData.details = "Searching"; - presenceData.state = searchText; - presenceData.startTimestamp = elapsed; - delete presenceData.endTimestamp; - } - } + /* Search Info */ + if (showSearchInfo) { + if (search?.value !== searchText) { + searchText = search?.value ?? '' + searchElapsed = Date.now() + } + if ( + (Date.now() - searchElapsed <= 5000 || path.includes('/search')) + && searchText.length > 0 + ) { + presenceData.details = 'Searching' + presenceData.state = searchText + presenceData.startTimestamp = elapsed + delete presenceData.endTimestamp + } + } - if (presenceData.details && typeof presenceData.details === "string") { - if (presenceData.details.match("(Browsing|Viewing)")) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = (await strings).browse; - } - if (presenceData.details.includes("Searching")) { - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = (await strings).search; - } + if (presenceData.details && typeof presenceData.details === 'string') { + if (presenceData.details.match('(Browsing|Viewing)')) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = (await strings).browse + } + if (presenceData.details.includes('Searching')) { + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = (await strings).search + } - presence.setActivity(presenceData); - } else presence.setActivity(); -}); + presence.setActivity(presenceData) + } + else { + presence.setActivity() + } +}) diff --git a/websites/T/Threads/metadata.json b/websites/T/Threads/metadata.json index df0fd27dd753..1bcaafe853bd 100644 --- a/websites/T/Threads/metadata.json +++ b/websites/T/Threads/metadata.json @@ -1,38 +1,38 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "241929388403195914", - "name": "Vasilis" - }, - "service": "Threads", - "description": { - "en": "Say more with Threads — Instagram’s text-based conversation app, where communities come together to discuss everything from the topics you care about today to what’ll be trending tomorrow.", - "el_GR": "Πείτε περισσότερα με το Threads — την εφαρμογή συνομιλίας με κείμενο του Instagram, όπου οι κοινότητες συγκεντρώνονται για να συζητήσουν τα πάντα, από τα θέματα που σας ενδιαφέρουν σήμερα μέχρι αυτά που θα είναι μοντέρνα αύριο." - }, - "url": "threads.net", - "version": "1.0.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Threads/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Threads/assets/thumbnail.jpeg", - "color": "#000", - "category": "socials", - "tags": [ - "instagram", - "social", - "media" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "time", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "241929388403195914", + "name": "Vasilis" + }, + "service": "Threads", + "description": { + "en": "Say more with Threads — Instagram’s text-based conversation app, where communities come together to discuss everything from the topics you care about today to what’ll be trending tomorrow.", + "el_GR": "Πείτε περισσότερα με το Threads — την εφαρμογή συνομιλίας με κείμενο του Instagram, όπου οι κοινότητες συγκεντρώνονται για να συζητήσουν τα πάντα, από τα θέματα που σας ενδιαφέρουν σήμερα μέχρι αυτά που θα είναι μοντέρνα αύριο." + }, + "url": "threads.net", + "version": "1.0.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Threads/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Threads/assets/thumbnail.jpeg", + "color": "#000", + "category": "socials", + "tags": [ + "instagram", + "social", + "media" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "time", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + } + ] +} diff --git a/websites/T/Threads/presence.ts b/websites/T/Threads/presence.ts index 89fbd3857068..c905d243725f 100644 --- a/websites/T/Threads/presence.ts +++ b/websites/T/Threads/presence.ts @@ -1,78 +1,93 @@ const presence = new Presence({ - clientId: "1237798561739968513", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - capitalize = (text: string): string => { - return text - .replace(/[[{(_)}\]]/g, " ") - .replace(/^\w/, c => c.toUpperCase()); - }; + clientId: '1237798561739968513', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +function capitalize(text: string): string { + return text + .replace(/[[{(_)}\]]/g, ' ') + .replace(/^\w/, c => c.toUpperCase()) +} -presence.on("UpdateData", async () => { - const [privacy, time] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("time"), - ]), - { pathname, href, search } = document.location, - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Threads/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const [privacy, time] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('time'), + ]) + const { pathname, href, search } = document.location + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Threads/assets/logo.png', + } - presenceData.details = "Browsing..."; + presenceData.details = 'Browsing...' - if (pathname.match("/following")) presenceData.state = "Following feed"; - else if (pathname.match("/saved")) presenceData.state = "Saved threads"; - else if (pathname.match("/liked")) presenceData.state = "Liked threads"; - else if (pathname.match("/login") || pathname.match("/nonconsent")) - presenceData.details = "Logging in"; - else if (pathname.match("/search") && !privacy) { - presenceData.details = "Searching for:"; - presenceData.state = new URLSearchParams(search).get("q"); + if (pathname.match('/following')) { + presenceData.state = 'Following feed' + } + else if (pathname.match('/saved')) { + presenceData.state = 'Saved threads' + } + else if (pathname.match('/liked')) { + presenceData.state = 'Liked threads' + } + else if (pathname.match('/login') || pathname.match('/nonconsent')) { + presenceData.details = 'Logging in' + } + else if (pathname.match('/search') && !privacy) { + presenceData.details = 'Searching for:' + presenceData.state = new URLSearchParams(search).get('q') - if (!presenceData.state) presenceData.details = "Search"; - } else if (pathname.startsWith("/@")) { - presenceData.state = pathname.split("/")[1]; + if (!presenceData.state) + presenceData.details = 'Search' + } + else if (pathname.startsWith('/@')) { + presenceData.state = pathname.split('/')[1] - if (!privacy) { - presenceData.smallImageKey = document.querySelector( - `img[alt*="${presenceData.state.split("@")[1]}"]` - ).src; + if (!privacy) { + presenceData.smallImageKey = document.querySelector( + `img[alt*="${presenceData.state.split('@')[1]}"]`, + )?.src - presenceData.smallImageText = presenceData.state.split("@")[1]; - } + presenceData.smallImageText = presenceData.state.split('@')[1] + } - if (pathname.split("/")[2] === "post") { - presenceData.details = "Viewing a thread"; + if (pathname.split('/')[2] === 'post') { + presenceData.details = 'Viewing a thread' - if (!privacy) { - presenceData.buttons = [ - { - label: "View Thread", - url: href, - }, - ]; - } - } else { - presenceData.details = "Viewing a profile"; + if (!privacy) { + presenceData.buttons = [ + { + label: 'View Thread', + url: href, + }, + ] + } + } + else { + presenceData.details = 'Viewing a profile' - if (!privacy) { - presenceData.buttons = [ - { - label: "View Profile", - url: href, - }, - ]; - } - } - } else if (pathname.split("/")[1]) { - presenceData.details = capitalize(pathname.split("/")[1]); - presenceData.state = capitalize(pathname.split("/")[2] || ""); - } else presenceData.state = "For You feed"; + if (!privacy) { + presenceData.buttons = [ + { + label: 'View Profile', + url: href, + }, + ] + } + } + } + else if (pathname.split('/')[1]) { + presenceData.details = capitalize(pathname.split('/')[1]) + presenceData.state = capitalize(pathname.split('/')[2] || '') + } + else { + presenceData.state = 'For You feed' + } - if (privacy) delete presenceData.state; + if (privacy) + delete presenceData.state - if (time) presenceData.startTimestamp = browsingTimestamp; + if (time) + presenceData.startTimestamp = browsingTimestamp - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/ThreeNow/iframe.ts b/websites/T/ThreeNow/iframe.ts index 6125103ff263..4d6179796b72 100644 --- a/websites/T/ThreeNow/iframe.ts +++ b/websites/T/ThreeNow/iframe.ts @@ -1,15 +1,15 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", () => { - const video: HTMLVideoElement = document.querySelector( - "#mw-player_player_html5_api" - ); - if (video && !isNaN(video.duration)) { - iframe.send({ - iFrameVideo: true, - currentTime: video.currentTime, - duration: video.duration, - paused: video.paused, - }); - } -}); +iframe.on('UpdateData', () => { + const video = document.querySelector( + '#mw-player_player_html5_api', + ) + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iFrameVideo: true, + currentTime: video.currentTime, + duration: video.duration, + paused: video.paused, + }) + } +}) diff --git a/websites/T/ThreeNow/metadata.json b/websites/T/ThreeNow/metadata.json index 158378aedac4..08ec04471288 100644 --- a/websites/T/ThreeNow/metadata.json +++ b/websites/T/ThreeNow/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Cairo", - "id": "208105877838888960" - }, - "service": "ThreeNow", - "description": { - "en": "Watch the latest TV On Demand episodes of all your favourite shows from Three with ThreeNow. Watch Three livestream, Newshub, Three Movies and Three shows.", - "nl": "Bekijk de nieuwste TV On Demand-afleveringen van al uw favoriete programma's van Three met ThreeNow. Bekijk Three livestream, Newshub, Three Movies en Three shows." - }, - "url": "www.threenow.co.nz", - "version": "1.2.28", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/ThreeNow/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/ThreeNow/assets/thumbnail.png", - "color": "#FF0050", - "category": "videos", - "tags": [ - "streaming", - "video", - "media" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Cairo", + "id": "208105877838888960" + }, + "service": "ThreeNow", + "description": { + "en": "Watch the latest TV On Demand episodes of all your favourite shows from Three with ThreeNow. Watch Three livestream, Newshub, Three Movies and Three shows.", + "nl": "Bekijk de nieuwste TV On Demand-afleveringen van al uw favoriete programma's van Three met ThreeNow. Bekijk Three livestream, Newshub, Three Movies en Three shows." + }, + "url": "www.threenow.co.nz", + "version": "1.2.28", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/ThreeNow/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/ThreeNow/assets/thumbnail.png", + "color": "#FF0050", + "category": "videos", + "tags": [ + "streaming", + "video", + "media" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git a/websites/T/ThreeNow/presence.ts b/websites/T/ThreeNow/presence.ts index a9b322b3c473..de08b0720c83 100644 --- a/websites/T/ThreeNow/presence.ts +++ b/websites/T/ThreeNow/presence.ts @@ -1,92 +1,98 @@ const presence = new Presence({ - clientId: "691491207356088320", -}); + clientId: '691491207356088320', +}) -let currentTime: number, duration: number, paused: boolean; +let currentTime: number, duration: number, paused: boolean interface iFrameData { - currentTime: number; - duration: number; - paused: boolean; + currentTime: number + duration: number + paused: boolean } -presence.on("iFrameData", (data: iFrameData) => { - if (data.duration) ({ currentTime, duration, paused } = data); -}); +presence.on('iFrameData', (inc: unknown) => { + const data = inc as iFrameData + if (data.duration) + ({ currentTime, duration, paused } = data) +}) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/ThreeNow/assets/logo.png", - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/ThreeNow/assets/logo.png', + } - if (document.URL === "https://www.threenow.co.nz/") { - presenceData.details = "Browsing the main page"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } else if (document.location.pathname.includes("/shows/")) { - if (document.querySelectorAll(".EpisodeSynopsis-subtitle").length >= 1) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(Math.floor(currentTime), Math.floor(duration)); - presenceData.state = document.querySelectorAll( - ".EpisodeSynopsis-title" - )[0].textContent; + if (document.URL === 'https://www.threenow.co.nz/') { + presenceData.details = 'Browsing the main page' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } + else if (document.location.pathname.includes('/shows/')) { + if (document.querySelectorAll('.EpisodeSynopsis-subtitle').length >= 1) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(Math.floor(currentTime), Math.floor(duration)) + presenceData.state = document.querySelectorAll( + '.EpisodeSynopsis-title', + )[0].textContent - if (paused) { - presenceData.details = "Watching a show"; - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - presenceData.smallImageKey = Assets.Pause; - } else { - presenceData.details = "Watching a show"; - presenceData.smallImageKey = Assets.Play; - } - } else { - presenceData.details = "Viewing a show"; - presenceData.state = document.querySelectorAll( - ".HeroSynopsis-title" - )[0].textContent; - } - } else if (document.location.pathname.includes("/search")) { - presenceData.details = "Searching shows"; - presenceData.state = ( - document.querySelectorAll(".SearchInput-input")[0] as HTMLInputElement - ).value; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } else { - switch (document.URL) { - case "https://www.threenow.co.nz/live-tv-guide": { - presenceData.details = "Viewing the Live TV guide"; - break; - } - case "https://www.threenow.co.nz/live-tv-guide/three": { - presenceData.details = "Watching Three Live"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); + if (paused) { + presenceData.details = 'Watching a show' + delete presenceData.startTimestamp + delete presenceData.endTimestamp + presenceData.smallImageKey = Assets.Pause + } + else { + presenceData.details = 'Watching a show' + presenceData.smallImageKey = Assets.Play + } + } + else { + presenceData.details = 'Viewing a show' + presenceData.state = document.querySelectorAll( + '.HeroSynopsis-title', + )[0].textContent + } + } + else if (document.location.pathname.includes('/search')) { + presenceData.details = 'Searching shows' + presenceData.state = ( + document.querySelectorAll('.SearchInput-input')[0] as HTMLInputElement + ).value + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } + else { + switch (document.URL) { + case 'https://www.threenow.co.nz/live-tv-guide': { + presenceData.details = 'Viewing the Live TV guide' + break + } + case 'https://www.threenow.co.nz/live-tv-guide/three': { + presenceData.details = 'Watching Three Live' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) - break; - } - case "https://www.threenow.co.nz/live-tv-guide/three-life": { - presenceData.details = "Watching ThreeLife Live"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); + break + } + case 'https://www.threenow.co.nz/live-tv-guide/three-life': { + presenceData.details = 'Watching ThreeLife Live' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) - break; - } - case "https://www.threenow.co.nz/live-tv-guide/bravo": { - presenceData.details = "Watching The Edge TV Live"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); + break + } + case 'https://www.threenow.co.nz/live-tv-guide/bravo': { + presenceData.details = 'Watching The Edge TV Live' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) - break; - } - default: - if ( - document.location.pathname.includes("/tv") && - document.location.pathname.includes(".html") - ) { - presenceData.details = "ThreeFans"; - presenceData.state = "Checking out information for fans!"; - } - } - } + break + } + default: + if ( + document.location.pathname.includes('/tv') + && document.location.pathname.includes('.html') + ) { + presenceData.details = 'ThreeFans' + presenceData.state = 'Checking out information for fans!' + } + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Ticketer/metadata.json b/websites/T/Ticketer/metadata.json index 4cd40e22f62f..8e7ba9e3ad73 100644 --- a/websites/T/Ticketer/metadata.json +++ b/websites/T/Ticketer/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "347077478726238228", - "name": "Dominik" - }, - "service": "Ticketer", - "description": { - "en": "Simplifies ticketing for customer support, sales, and suggestions", - "de": "Vereinfacht das Ticketing für Kundensupport, Verkauf und Vorschläge" - }, - "url": "ticketerbot.com", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Ticketer/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Ticketer/assets/thumbnail.png", - "color": "#5865f2", - "category": "other", - "tags": [ - "discord", - "bot", - "ticketer" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "347077478726238228", + "name": "Dominik" + }, + "service": "Ticketer", + "description": { + "en": "Simplifies ticketing for customer support, sales, and suggestions", + "de": "Vereinfacht das Ticketing für Kundensupport, Verkauf und Vorschläge" + }, + "url": "ticketerbot.com", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Ticketer/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Ticketer/assets/thumbnail.png", + "color": "#5865f2", + "category": "other", + "tags": [ + "discord", + "bot", + "ticketer" + ] +} diff --git a/websites/T/Ticketer/presence.ts b/websites/T/Ticketer/presence.ts index d710e092a020..e0c714663b10 100644 --- a/websites/T/Ticketer/presence.ts +++ b/websites/T/Ticketer/presence.ts @@ -1,64 +1,65 @@ const presence = new Presence({ - clientId: "1003750528242692096", - }), - browsingUnix = Math.floor((Date.now() / 1000) | 0); + clientId: '1003750528242692096', +}) +const browsingUnix = Math.floor((Date.now() / 1000) | 0) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Ticketer/assets/logo.png", - }, - { pathname } = document.location; - let title: HTMLElement, logo: HTMLElement, dashboardInfo: HTMLElement; - presenceData.startTimestamp = browsingUnix; - switch (pathname) { - case "/commands": { - presenceData.details = "Viewing the commands page"; - break; - } - case "/changelog": { - presenceData.details = "Viewing the changelog page"; - break; - } - case "/contribute": { - presenceData.details = "Viewing the contribution page"; - break; - } - case "/dashboard": { - presenceData.details = "Browsing the dashboard"; - break; - } - case `/dashboard/${document.URL.slice(34)}`: { - if (document.querySelector(".server-info > h3")) { - title = document.querySelector(".server-info > h3"); - logo = document.querySelector(".server-info > img"); - dashboardInfo = document.querySelector(".informations-nav > h2"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Ticketer/assets/logo.png', + } + const { pathname } = document.location + presenceData.startTimestamp = browsingUnix + switch (pathname) { + case '/commands': { + presenceData.details = 'Viewing the commands page' + break + } + case '/changelog': { + presenceData.details = 'Viewing the changelog page' + break + } + case '/contribute': { + presenceData.details = 'Viewing the contribution page' + break + } + case '/dashboard': { + presenceData.details = 'Browsing the dashboard' + break + } + case `/dashboard/${document.URL.slice(34)}`: { + let dashboardInfo: HTMLElement | null = null + if (document.querySelector('.server-info > h3')) { + const title = document.querySelector('.server-info > h3') + const logo = document.querySelector('.server-info > img') + dashboardInfo = document.querySelector('.informations-nav > h2') - presenceData.details = "Server Settings - Editing:"; - presenceData.state = title.textContent; - presenceData.smallImageKey = logo.getAttribute("src"); - } - if (!dashboardInfo?.textContent) return; - switch (dashboardInfo.textContent) { - case "Stats": { - presenceData.details = "Server Stats - Viewing:"; - break; - } - case "Tickets": { - presenceData.details = "Ticket History - Viewing:"; - break; - } - case "Staff": { - presenceData.details = "Staff Actvity - Viewing:"; - break; - } - } - break; - } - default: { - presenceData.details = "Viewing the homepage"; - } - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + presenceData.details = 'Server Settings - Editing:' + presenceData.state = title?.textContent + presenceData.smallImageKey = logo?.getAttribute('src') + } + if (!dashboardInfo?.textContent) + return + switch (dashboardInfo.textContent) { + case 'Stats': { + presenceData.details = 'Server Stats - Viewing:' + break + } + case 'Tickets': { + presenceData.details = 'Ticket History - Viewing:' + break + } + case 'Staff': { + presenceData.details = 'Staff Actvity - Viewing:' + break + } + } + break + } + default: { + presenceData.details = 'Viewing the homepage' + } + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Tidal/metadata.json b/websites/T/Tidal/metadata.json index 7e6832f537e9..6b64ada643aa 100644 --- a/websites/T/Tidal/metadata.json +++ b/websites/T/Tidal/metadata.json @@ -1,59 +1,59 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "The Gamerzs", - "id": "730142125181894657" - }, - "contributors": [ - { - "name": "Kyrie", - "id": "368399721494216706" - } - ], - "service": "Tidal", - "description": { - "tr": "Tidal yüksek ses kalitesi ve ucuz fiyatlarla hizmet sağlayan bir müzik sitesidir.", - "en": "Tidal is a music stream service with very high sound quality.", - "pl": "Tidal to strona do streamingowania muzyki z bardzo wysoką jakością audio.", - "nl": "Tidal is een muziekstreamdienst met een zeer hoge geluidskwaliteit.", - "vi_VN": "Tidal là dịch vụ phát nhạc với chất lượng âm thanh rất cao." - }, - "url": [ - "listen.tidal.com", - "tidal.com" - ], - "version": "3.2.1", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tidal/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tidal/assets/thumbnail.png", - "color": "#000000", - "category": "music", - "tags": [ - "tidal", - "music" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "timestamps", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "cover", - "title": "Show Cover", - "icon": "fad fa-images", - "value": true - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "The Gamerzs", + "id": "730142125181894657" + }, + "contributors": [ + { + "name": "Kyrie", + "id": "368399721494216706" + } + ], + "service": "Tidal", + "description": { + "tr": "Tidal yüksek ses kalitesi ve ucuz fiyatlarla hizmet sağlayan bir müzik sitesidir.", + "en": "Tidal is a music stream service with very high sound quality.", + "pl": "Tidal to strona do streamingowania muzyki z bardzo wysoką jakością audio.", + "nl": "Tidal is een muziekstreamdienst met een zeer hoge geluidskwaliteit.", + "vi_VN": "Tidal là dịch vụ phát nhạc với chất lượng âm thanh rất cao." + }, + "url": [ + "listen.tidal.com", + "tidal.com" + ], + "version": "3.2.1", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tidal/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tidal/assets/thumbnail.png", + "color": "#000000", + "category": "music", + "tags": [ + "tidal", + "music" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "timestamps", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "cover", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/T/Tidal/presence.ts b/websites/T/Tidal/presence.ts index c108a9d34468..3118d29c38ac 100644 --- a/websites/T/Tidal/presence.ts +++ b/websites/T/Tidal/presence.ts @@ -1,109 +1,106 @@ -const LOGO_URL = "https://cdn.rcd.gg/PreMiD/websites/T/Tidal/assets/logo.png", - presence = new Presence({ clientId: "901591802342150174" }); +const LOGO_URL = 'https://cdn.rcd.gg/PreMiD/websites/T/Tidal/assets/logo.png' +const presence = new Presence({ clientId: '901591802342150174' }) async function getStrings() { - return presence.getStrings( - { - play: "general.playing", - pause: "general.paused", - viewSong: "general.buttonViewSong", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + play: 'general.playing', + pause: 'general.paused', + viewSong: 'general.buttonViewSong', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } -let strings: Awaited>, - oldLang: string = null; +let strings: Awaited> +let oldLang: string | null = null -presence.on("UpdateData", async () => { - if (!document.querySelector("#footerPlayer")) - return presence.setActivity({ largeImageKey: LOGO_URL }); +presence.on('UpdateData', async () => { + if (!document.querySelector('#footerPlayer')) + return presence.setActivity({ largeImageKey: LOGO_URL }) - const [newLang, timestamps, cover, buttons] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("timestamps"), - presence.getSetting("cover"), - presence.getSetting("buttons"), - ]); + const [newLang, timestamps, cover, buttons] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('timestamps'), + presence.getSetting('cover'), + presence.getSetting('buttons'), + ]) - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } - const presenceData: PresenceData = { - largeImageKey: LOGO_URL, - type: ActivityType.Listening, - }, - songTitle = document.querySelector( - "[data-test='footer-track-title'] > div > a" - ), - currentTime = document.querySelector( - 'time[data-test="current-time"]' - ).textContent, - paused = - document - .querySelector('div[data-test="play-controls"] div > button') - .getAttribute("data-test") === "play", - repeatType = document - .querySelector( - 'div[data-test="play-controls"] > button[data-test="repeat"]' - ) - .getAttribute("data-type"); + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } + const presenceData: PresenceData = { + largeImageKey: LOGO_URL, + type: ActivityType.Listening, + } + const songTitle = document.querySelector( + '[data-test=\'footer-track-title\'] > div > a', + ) + const currentTime = document.querySelector( + 'time[data-test="current-time"]', + )?.textContent + const paused = document + .querySelector('div[data-test="play-controls"] div > button') + ?.getAttribute('data-test') === 'play' + const repeatType = document + .querySelector( + 'div[data-test="play-controls"] > button[data-test="repeat"]', + ) + ?.getAttribute('data-type') - presenceData.details = songTitle.textContent; - // get artists - presenceData.state = Array.from( - document.querySelectorAll("#footerPlayer .artist-link a") - ) - .map(artist => artist.textContent) - .join(", "); + presenceData.details = songTitle?.textContent + // get artists + presenceData.state = Array.from( + document.querySelectorAll('#footerPlayer .artist-link a'), + ) + .map(artist => artist.textContent) + .join(', ') - if (cover) { - presenceData.largeImageKey = document - .querySelector( - "figure[data-test=current-media-imagery] > div > div > div > img" - ) - .getAttribute("src") - .replace("80x80", "640x640"); - } - if ( - (parseFloat(currentTime[0]) * 60 + parseFloat(currentTime[1])) * 1000 > 0 || - !paused - ) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - presence.timestampFromFormat(currentTime), - presence.timestampFromFormat( - document.querySelector('time[data-test="duration"]') - .textContent - ) - ); - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = paused ? strings.pause : strings.play; - } + if (cover) { + presenceData.largeImageKey = document + .querySelector( + 'figure[data-test=current-media-imagery] > div > div > div > img', + ) + ?.getAttribute('src') + ?.replace('80x80', '640x640') + } + if ( + (Number.parseFloat(currentTime?.[0] ?? '') * 60 + Number.parseFloat(currentTime?.[1] ?? '')) * 1000 > 0 + || !paused + ) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + presence.timestampFromFormat(currentTime ?? ''), + presence.timestampFromFormat( + document.querySelector('time[data-test="duration"]') + ?.textContent ?? '', + ), + ) + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = paused ? strings.pause : strings.play + } - if ( - document - .querySelector( - 'div[data-test="play-controls"] > button[data-test="repeat"]' - ) - .getAttribute("aria-checked") === "true" - ) { - presenceData.smallImageKey = - repeatType === "button__repeatAll" ? Assets.Repeat : Assets.RepeatOne; - presenceData.smallImageText = - repeatType === "button__repeatAll" ? "Playlist on loop" : "On loop"; + if ( + document + .querySelector( + 'div[data-test="play-controls"] > button[data-test="repeat"]', + ) + ?.getAttribute('aria-checked') === 'true' + ) { + presenceData.smallImageKey = repeatType === 'button__repeatAll' ? Assets.Repeat : Assets.RepeatOne + presenceData.smallImageText = repeatType === 'button__repeatAll' ? 'Playlist on loop' : 'On loop' - delete presenceData.endTimestamp; - } - if (buttons) { - presenceData.buttons = [ - { - label: strings.viewSong, - url: songTitle.href, - }, - ]; - } - if (!timestamps) delete presenceData.endTimestamp; - presence.setActivity(presenceData); -}); + delete presenceData.endTimestamp + } + if (buttons) { + presenceData.buttons = [ + { + label: strings.viewSong, + url: songTitle?.href ?? '', + }, + ] + } + if (!timestamps) + delete presenceData.endTimestamp + presence.setActivity(presenceData) +}) diff --git a/websites/T/TikTok/metadata.json b/websites/T/TikTok/metadata.json index 34d3564e4fa3..5c9abfeeb677 100644 --- a/websites/T/TikTok/metadata.json +++ b/websites/T/TikTok/metadata.json @@ -1,65 +1,65 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "contributors": [ - { - "name": "The Gamerzs", - "id": "730142125181894657" - }, - { - "name": "Dark_Ville", - "id": "638080361179512853" - } - ], - "service": "TikTok", - "description": { - "en": "TikTok - trends start here. On a device or on the web, viewers can watch and discover millions of personalized short videos.", - "nl": "TikTok - trends beginnen hier. Kijkers kunnen op mobiele apparaten of op het web miljoenen gepersonaliseerde korte video's bekijken.", - "vi_VN": "TikTok - xu hướng bắt đầu tại đây. Trên thiết bị hay trên web, người dùng có thể xem và khám phá hàng triệu các video ngắn được cá nhân hoá." - }, - "url": "www.tiktok.com", - "version": "2.3.5", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TikTok/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TikTok/assets/thumbnail.png", - "color": "#000000", - "category": "socials", - "tags": [ - "tiktok", - "video", - "social" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "buttons", - "if": { - "privacy": false - }, - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - }, - { - "id": "show-profile-usernames", - "if": { - "privacy": false - }, - "title": "Show Profile Info", - "icon": "fad fa-user-secret", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "contributors": [ + { + "name": "The Gamerzs", + "id": "730142125181894657" + }, + { + "name": "Dark_Ville", + "id": "638080361179512853" + } + ], + "service": "TikTok", + "description": { + "en": "TikTok - trends start here. On a device or on the web, viewers can watch and discover millions of personalized short videos.", + "nl": "TikTok - trends beginnen hier. Kijkers kunnen op mobiele apparaten of op het web miljoenen gepersonaliseerde korte video's bekijken.", + "vi_VN": "TikTok - xu hướng bắt đầu tại đây. Trên thiết bị hay trên web, người dùng có thể xem và khám phá hàng triệu các video ngắn được cá nhân hoá." + }, + "url": "www.tiktok.com", + "version": "2.3.5", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TikTok/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TikTok/assets/thumbnail.png", + "color": "#000000", + "category": "socials", + "tags": [ + "tiktok", + "video", + "social" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "buttons", + "if": { + "privacy": false + }, + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + }, + { + "id": "show-profile-usernames", + "if": { + "privacy": false + }, + "title": "Show Profile Info", + "icon": "fad fa-user-secret", + "value": true + } + ] +} diff --git a/websites/T/TikTok/presence.ts b/websites/T/TikTok/presence.ts index 4daa01246723..7aa588d02b66 100644 --- a/websites/T/TikTok/presence.ts +++ b/websites/T/TikTok/presence.ts @@ -1,333 +1,342 @@ const presence = new Presence({ - clientId: "809093093600133165", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '809093093600133165', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) let cached: { - videoURL: string; - video: HTMLVideoElement; -}; + videoURL: string + video: HTMLVideoElement +} async function getStrings() { - return presence.getStrings( - { - playing: "general.playing", - paused: "general.paused", - live: "general.live", - browse: "general.browsing", - forYou: "tiktok.forYou", - following: "tiktok.following", - buttonViewProfile: "general.buttonViewProfile", - viewProfile: "general.viewProfile", - viewAProfile: "general.viewAProfile", - viewTikTok: "tiktok.viewing", - buttonViewTikTok: "tiktok.buttonViewTikTok", - browseThrough: "tiktok.browseThrough", - watchingLive: "general.watchingLive", - readingADM: "general.readingADM", - exploringWithTag: "tiktok.exploringWithTag", - viewAPlaylist: "general.viewAPlaylist", - buttonWatchStream: "general.buttonWatchStream", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + playing: 'general.playing', + paused: 'general.paused', + live: 'general.live', + browse: 'general.browsing', + forYou: 'tiktok.forYou', + following: 'tiktok.following', + buttonViewProfile: 'general.buttonViewProfile', + viewProfile: 'general.viewProfile', + viewAProfile: 'general.viewAProfile', + viewTikTok: 'tiktok.viewing', + buttonViewTikTok: 'tiktok.buttonViewTikTok', + browseThrough: 'tiktok.browseThrough', + watchingLive: 'general.watchingLive', + readingADM: 'general.readingADM', + exploringWithTag: 'tiktok.exploringWithTag', + viewAPlaylist: 'general.viewAPlaylist', + buttonWatchStream: 'general.buttonWatchStream', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } function getVideo(video: HTMLVideoElement | null) { - const videoURL = video?.src; + const videoURL = video?.src - if ( - videoURL && - (!cached?.videoURL || !cached?.video || cached?.videoURL !== videoURL) - ) { - cached = { - videoURL, - video, - }; - return; - } else if (!video && cached.video) return cached.video; + if ( + videoURL + && (!cached?.videoURL || !cached?.video || cached?.videoURL !== videoURL) + ) { + cached = { + videoURL, + video, + } + } + else if (!video && cached.video) { + return cached.video + } } -let strings: Awaited>, - oldLang: string = null; +let strings: Awaited> +let oldLang: string | null = null -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - type: ActivityType.Watching, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TikTok/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - [newLang, privacy, buttons, showProfileUsernames] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("privacy"), - presence.getSetting("buttons"), - presence.getSetting("show-profile-usernames"), - ]), - { pathname, hostname, href } = document.location, - lang = document.querySelector("html")?.getAttribute("lang"), - username = - document.querySelector('[data-e2e="user-profile-nickname"]') - ?.textContent ?? - document.querySelector('[data-e2e="user-subtitle"]')?.textContent ?? - document - .querySelector('[data-e2e="browser-nickname"]') - ?.querySelector('[class*="SpanNickName"]')?.textContent ?? - document.querySelector('[data-e2e="browser-nickname"]')?.firstElementChild - ?.textContent, // Username - userid = - document.querySelector('[data-e2e="user-profile-uid"]')?.textContent ?? - document.querySelector('[data-e2e="user-title"]')?.textContent ?? - document.querySelector('[data-e2e="browse-username"]')?.textContent, //Userid (so @userid) - description = - document.querySelector('[data-e2e="user-profile-live-title"]') - ?.textContent ?? - document.querySelector('[data-e2e="browse-video-desc"]')?.textContent; // Video/livestream description +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + type: ActivityType.Watching, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TikTok/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const [newLang, privacy, buttons, showProfileUsernames] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('privacy'), + presence.getSetting('buttons'), + presence.getSetting('show-profile-usernames'), + ]) + const { pathname, hostname, href } = document.location + const lang = document.querySelector('html')?.getAttribute('lang') + const username = document.querySelector('[data-e2e="user-profile-nickname"]') + ?.textContent + ?? document.querySelector('[data-e2e="user-subtitle"]')?.textContent + ?? document + .querySelector('[data-e2e="browser-nickname"]') + ?.querySelector('[class*="SpanNickName"]') + ?.textContent + ?? document.querySelector('[data-e2e="browser-nickname"]')?.firstElementChild?.textContent // Username + const userid = document.querySelector('[data-e2e="user-profile-uid"]')?.textContent + ?? document.querySelector('[data-e2e="user-title"]')?.textContent + ?? document.querySelector('[data-e2e="browse-username"]')?.textContent // Userid (so @userid) + const description = document.querySelector('[data-e2e="user-profile-live-title"]') + ?.textContent + ?? document.querySelector('[data-e2e="browse-video-desc"]')?.textContent // Video/livestream description - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - switch (true) { - case pathname === "/following": - case pathname.includes("foryou"): - case pathname === "/": - case pathname === `/${lang}`: - case pathname === `/${lang}/`: { - if (!privacy) delete presenceData.startTimestamp; - const videos = Array.from(document.querySelectorAll("video")).find( - video => !video.paused - ); - let video: HTMLVideoElement; - if (videos) { - video = videos; - getVideo(videos); - } else video = getVideo(null); + switch (true) { + case pathname === '/following': + case pathname.includes('foryou'): + case pathname === '/': + case pathname === `/${lang}`: + case pathname === `/${lang}/`: { + if (!privacy) + delete presenceData.startTimestamp + const videos = Array.from(document.querySelectorAll('video')).find( + video => !video.paused, + ) + let video: HTMLVideoElement | null | undefined + if (videos) { + video = videos + getVideo(videos) + } + else { + video = getVideo(null) + } - const baseEl = video?.closest( - '[data-e2e="recommend-list-item-container"]' - ), - userId = baseEl?.querySelector('h3[data-e2e="video-author-uniqueid"]'), - tiktokURL = `https://www.tiktok.com/@${userId?.textContent}/video/${ - video - ?.closest('[class="tiktok-web-player no-controls"]') - ?.getAttribute("id") - ?.split("-")?.[2] - }`, - creatorURL = `https://${hostname}${ - userId?.parentElement?.getAttribute("href") ?? "" - }/`, - tiktokURLMatch = tiktokURL.match( - /https:\/\/www[.]tiktok[.]com\/@.*\/video\/[0-9]{19}/ - ), - creatorURLMatch = creatorURL.match( - /http(s)?:\/\/(www[.])?tiktok\.com\/@([\w.]{0,23}\w)(?:\/\S*)?\// - )?.[0], - paused = - video - ?.closest('div[data-e2e="feed-video"]') - ?.querySelector('[data-e2e="video-play"]') - ?.getAttribute("aria-label") - ?.toLowerCase() === "pause"; + const baseEl = video?.closest( + '[data-e2e="recommend-list-item-container"]', + ) + const userId = baseEl?.querySelector('h3[data-e2e="video-author-uniqueid"]') + const tiktokURL = `https://www.tiktok.com/@${userId?.textContent}/video/${ + video + ?.closest('[class="tiktok-web-player no-controls"]') + ?.getAttribute('id') + ?.split('-')?.[2] + }` + const creatorURL = `https://${hostname}${ + userId?.parentElement?.getAttribute('href') ?? '' + }/` + const tiktokURLMatch = tiktokURL.match( + /https:\/\/www\.tiktok\.com\/@.*\/video\/\d{19}/, + ) + const creatorURLMatch = creatorURL.match( + /http(s)?:\/\/(www\.)?tiktok\.com\/@([\w.]{0,23}\w)(?:\/\S*)?\//, + )?.[0] + const paused = video + ?.closest('div[data-e2e="feed-video"]') + ?.querySelector('[data-e2e="video-play"]') + ?.getAttribute('aria-label') + ?.toLowerCase() === 'pause' - presenceData.details = privacy - ? strings.browseThrough - : userId && - baseEl?.querySelector('[data-e2e="video-author-nickname"]') - ?.textContent - ? `${ - baseEl?.querySelector('[data-e2e="video-author-nickname"]') - ?.textContent - } (@${userId?.textContent})` - : strings.browseThrough; - presenceData.state = baseEl?.querySelector( - '[data-e2e="video-desc"]' - )?.textContent; - if (tiktokURLMatch && creatorURLMatch) { - presenceData.buttons = [ - { label: strings.buttonViewTikTok, url: tiktokURL }, - { - label: strings.buttonViewProfile, - url: creatorURL, - }, - ]; - } else if (creatorURLMatch) { - presenceData.buttons = [ - { - label: strings.buttonViewProfile, - url: creatorURL, - }, - ]; - } else if (tiktokURLMatch) { - presenceData.buttons = [ - { label: strings.buttonViewTikTok, url: tiktokURL }, - ]; - } + presenceData.details = privacy + ? strings.browseThrough + : userId + && baseEl?.querySelector('[data-e2e="video-author-nickname"]') + ?.textContent + ? `${ + baseEl?.querySelector('[data-e2e="video-author-nickname"]') + ?.textContent + } (@${userId?.textContent})` + : strings.browseThrough + presenceData.state = baseEl?.querySelector( + '[data-e2e="video-desc"]', + )?.textContent + if (tiktokURLMatch && creatorURLMatch) { + presenceData.buttons = [ + { label: strings.buttonViewTikTok, url: tiktokURL }, + { + label: strings.buttonViewProfile, + url: creatorURL, + }, + ] + } + else if (creatorURLMatch) { + presenceData.buttons = [ + { + label: strings.buttonViewProfile, + url: creatorURL, + }, + ] + } + else if (tiktokURLMatch) { + presenceData.buttons = [ + { label: strings.buttonViewTikTok, url: tiktokURL }, + ] + } - if (!paused && video?.duration && video?.currentTime) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - } - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = paused ? strings.paused : strings.playing; + if (!paused && video?.duration && video?.currentTime) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + } + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = paused ? strings.paused : strings.playing - break; - } - case pathname.includes("/video/"): { - if (!privacy) delete presenceData.startTimestamp; - const vidEl = document.querySelector("video"); - let video: { - paused: boolean; - currentTime: number; - duration: number; - }; - if (!vidEl) { - video = { - paused: - !!document.querySelector('[aria-label="Pause"]') || - !!document.querySelector("[class*='DivPlayIconContainer']"), - currentTime: presence.timestampFromFormat( - document - .querySelector("[class*='DivSeekBarTimeContainer']") - ?.textContent?.split("/")[0] - ), - duration: presence.timestampFromFormat( - document - .querySelector("[class*='DivSeekBarTimeContainer']") - ?.textContent?.split("/")[1] - ), - }; - } else { - video = { - paused: vidEl?.paused, - currentTime: vidEl.currentTime, - duration: vidEl.duration, - }; - } - presenceData.details = privacy - ? strings.browseThrough - : `${username} (@${userid})`; - presenceData.state = description; - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? strings.paused - : strings.playing; - if (!video.paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(video.currentTime, video.duration); - } - presenceData.buttons = [ - { label: strings.buttonViewTikTok, url: href }, - { - label: strings.buttonViewProfile, - url: `https://www.tiktok.com/@${userid}`, - }, - ]; - break; - } - case pathname === "/live": { - const videos = Array.from(document.querySelectorAll("video")).find( - video => !video.paused - ); - let video: HTMLVideoElement; - if (videos) { - video = videos; - getVideo(videos); - } else video = getVideo(null); + break + } + case pathname.includes('/video/'): { + if (!privacy) + delete presenceData.startTimestamp + const vidEl = document.querySelector('video') + let video: { + paused: boolean + currentTime: number + duration: number + } + if (!vidEl) { + video = { + paused: !!document.querySelector('[aria-label="Pause"]') + || !!document.querySelector('[class*=\'DivPlayIconContainer\']'), + currentTime: presence.timestampFromFormat( + document + .querySelector('[class*=\'DivSeekBarTimeContainer\']') + ?.textContent + ?.split('/')[0] ?? '', + ), + duration: presence.timestampFromFormat( + document + .querySelector('[class*=\'DivSeekBarTimeContainer\']') + ?.textContent + ?.split('/')[1] ?? '', + ), + } + } + else { + video = { + paused: vidEl?.paused, + currentTime: vidEl.currentTime, + duration: vidEl.duration, + } + } + presenceData.details = privacy + ? strings.browseThrough + : `${username} (@${userid})` + presenceData.state = description + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? strings.paused + : strings.playing + if (!video.paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(video.currentTime, video.duration) + } + presenceData.buttons = [ + { label: strings.buttonViewTikTok, url: href }, + { + label: strings.buttonViewProfile, + url: `https://www.tiktok.com/@${userid}`, + }, + ] + break + } + case pathname === '/live': { + const videos = Array.from(document.querySelectorAll('video')).find( + video => !video.paused, + ) + let video: HTMLVideoElement | null | undefined + if (videos) { + video = videos + getVideo(videos) + } + else { + video = getVideo(null) + } - presenceData.details = privacy - ? strings.watchingLive - : `${strings.watchingLive} - ${ - video?.parentElement?.querySelector('[class*="SpanNickName"]') - ?.textContent - }`; - presenceData.state = video?.parentElement?.querySelectorAll( - '[class="css-1g1mtx-DivDetailsLine eawfp3g1"]' - )?.[1]?.textContent; - presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Live; - presenceData.smallImageText = video?.paused - ? strings.paused - : strings.live; - presenceData.buttons = [ - { - label: strings.buttonWatchStream, - url: `https://www.tiktok.com/${ - video?.parentElement?.querySelector('[class*="SpanNickName"]') - ?.textContent - }/live`, - }, - { - label: strings.buttonViewProfile, - url: `https://www.tiktok.com/${ - video?.parentElement?.querySelector('[class*="SpanNickName"]') - ?.textContent - }`, - }, - ]; - break; - } - case pathname.includes("/live"): { - const video = document.querySelector("video"); - presenceData.details = privacy - ? strings.watchingLive - : `${strings.watchingLive} - ${username} (@${userid})`; - presenceData.state = description; - presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Live; - presenceData.smallImageText = video?.paused - ? strings.paused - : strings.live; - presenceData.buttons = [ - { label: strings.buttonWatchStream, url: href }, - { - label: strings.buttonViewProfile, - url: href?.split("/live")?.[0], - }, - ]; - break; - } - case pathname.includes("/@"): { - const playlistMenu = document - .querySelector('[class*="DivModalContainer eo04fh215"]') - ?.querySelector('[class*="Title"]'); - presenceData.details = - privacy || !showProfileUsernames - ? strings.viewAProfile - : `${strings.viewProfile} ${username} (@${userid})`; - if (showProfileUsernames) { - presenceData.buttons = [ - { label: strings.buttonViewProfile, url: href }, - ]; - } + presenceData.details = privacy + ? strings.watchingLive + : `${strings.watchingLive} - ${ + video?.parentElement?.querySelector('[class*="SpanNickName"]') + ?.textContent + }` + presenceData.state = video?.parentElement?.querySelectorAll( + '[class="css-1g1mtx-DivDetailsLine eawfp3g1"]', + )?.[1]?.textContent + presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Live + presenceData.smallImageText = video?.paused + ? strings.paused + : strings.live + presenceData.buttons = [ + { + label: strings.buttonWatchStream, + url: `https://www.tiktok.com/${ + video?.parentElement?.querySelector('[class*="SpanNickName"]') + ?.textContent + }/live`, + }, + { + label: strings.buttonViewProfile, + url: `https://www.tiktok.com/${ + video?.parentElement?.querySelector('[class*="SpanNickName"]') + ?.textContent + }`, + }, + ] + break + } + case pathname.includes('/live'): { + const video = document.querySelector('video') + presenceData.details = privacy + ? strings.watchingLive + : `${strings.watchingLive} - ${username} (@${userid})` + presenceData.state = description + presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Live + presenceData.smallImageText = video?.paused + ? strings.paused + : strings.live + presenceData.buttons = [ + { label: strings.buttonWatchStream, url: href }, + { + label: strings.buttonViewProfile, + url: href?.split('/live')?.[0], + }, + ] + break + } + case pathname.includes('/@'): { + const playlistMenu = document + .querySelector('[class*="DivModalContainer eo04fh215"]') + ?.querySelector('[class*="Title"]') + presenceData.details = privacy || !showProfileUsernames + ? strings.viewAProfile + : `${strings.viewProfile} ${username} (@${userid})` + if (showProfileUsernames) { + presenceData.buttons = [ + { label: strings.buttonViewProfile, url: href }, + ] + } - presenceData.state = playlistMenu - ? `${strings.viewAPlaylist} - ${playlistMenu?.textContent}` - : document.querySelector('p[aria-selected="true"]')?.textContent; + presenceData.state = playlistMenu + ? `${strings.viewAPlaylist} - ${playlistMenu?.textContent}` + : document.querySelector('p[aria-selected="true"]')?.textContent - break; - } - case pathname.includes("/explore"): { - presenceData.details = privacy - ? strings.browseThrough - : strings.exploringWithTag; - presenceData.state = document.querySelector( - ".css-1hs87dt-ButtonCategoryItemContainer" - )?.textContent; - break; - } - case pathname.includes("/messages"): { - presenceData.details = privacy - ? strings.browseThrough - : strings.readingADM; - break; - } - } + break + } + case pathname.includes('/explore'): { + presenceData.details = privacy + ? strings.browseThrough + : strings.exploringWithTag + presenceData.state = document.querySelector( + '.css-1hs87dt-ButtonCategoryItemContainer', + )?.textContent + break + } + case pathname.includes('/messages'): { + presenceData.details = privacy + ? strings.browseThrough + : strings.readingADM + break + } + } - if ((!buttons || privacy) && presenceData.buttons) - delete presenceData.buttons; - if (privacy && presenceData.state) delete presenceData.state; - if (privacy && presenceData.endTimestamp) delete presenceData.endTimestamp; - if (privacy && presenceData.smallImageKey) delete presenceData.smallImageKey; + if ((!buttons || privacy) && presenceData.buttons) + delete presenceData.buttons + if (privacy && presenceData.state) + delete presenceData.state + if (privacy && presenceData.endTimestamp) + delete presenceData.endTimestamp + if (privacy && presenceData.smallImageKey) + delete presenceData.smallImageKey - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/Time.is/metadata.json b/websites/T/Time.is/metadata.json index 56fd12cdf7a0..9073a5c74a44 100644 --- a/websites/T/Time.is/metadata.json +++ b/websites/T/Time.is/metadata.json @@ -1,22 +1,22 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "Time.is", - "description": { - "en": "Exact time, any time zone. 7 million locations, 46 languages, synchronized with atomic clock time.", - "nl": "Exacte tijd, elke tijdzone. 7 miljoen locaties, 46 talen, gesynchroniseerd met atoomkloktijd." - }, - "url": "time.is", - "version": "2.1.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Time.is/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Time.is/assets/thumbnail.png", - "color": "#cc3355", - "category": "other", - "tags": [ - "time" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "Time.is", + "description": { + "en": "Exact time, any time zone. 7 million locations, 46 languages, synchronized with atomic clock time.", + "nl": "Exacte tijd, elke tijdzone. 7 miljoen locaties, 46 talen, gesynchroniseerd met atoomkloktijd." + }, + "url": "time.is", + "version": "2.1.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Time.is/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Time.is/assets/thumbnail.png", + "color": "#cc3355", + "category": "other", + "tags": [ + "time" + ] +} diff --git a/websites/T/Time.is/presence.ts b/websites/T/Time.is/presence.ts index 7a8d998dd241..6ae8ccbaa25a 100644 --- a/websites/T/Time.is/presence.ts +++ b/websites/T/Time.is/presence.ts @@ -1,26 +1,26 @@ const presence = new Presence({ - clientId: "642714892201230336", -}); + clientId: '642714892201230336', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Time.is/assets/logo.png", - }, - clock = - document.querySelector("#clock0_bg") || - document.querySelector("#time_section > div:nth-child(2) > div"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Time.is/assets/logo.png', + } + const clock = document.querySelector('#clock0_bg') + || document.querySelector('#time_section > div:nth-child(2) > div') - if (document.location.hostname === "time.is") { - if (document.location.pathname === "/") { - presenceData.details = "My time is:"; - presenceData.state = clock.textContent; - } else if (clock) { - presenceData.details = document.querySelector("#msgdiv > h1").textContent; - presenceData.state = clock.textContent; - } - } + if (document.location.hostname === 'time.is') { + if (document.location.pathname === '/') { + presenceData.details = 'My time is:' + presenceData.state = clock?.textContent + } + else if (clock) { + presenceData.details = document.querySelector('#msgdiv > h1')?.textContent + presenceData.state = clock.textContent + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Timeguessr/metadata.json b/websites/T/Timeguessr/metadata.json index ee9143f5d2b7..31c603f1540c 100644 --- a/websites/T/Timeguessr/metadata.json +++ b/websites/T/Timeguessr/metadata.json @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "408597063098695692", - "name": "happypossum" - }, - "service": "Timeguessr", - "description": { - "en": "Timeguessr is an interactive game that challenges you to guess the approximate year and location of a historical photo or event.", - "nl": "Timeguessr is een interactief spel dat je uitdaagt om het geschatte jaar en de locatie van een historische foto of gebeurtenis te raden." - }, - "url": "timeguessr.com", - "version": "1.0.1", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Timeguessr/assets/logo.jpeg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Timeguessr/assets/thumbnail.png", - "color": "#DB5049", - "category": "games", - "tags": [ - "games", - "timeguessr" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-shield-alt", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "408597063098695692", + "name": "happypossum" + }, + "service": "Timeguessr", + "description": { + "en": "Timeguessr is an interactive game that challenges you to guess the approximate year and location of a historical photo or event.", + "nl": "Timeguessr is een interactief spel dat je uitdaagt om het geschatte jaar en de locatie van een historische foto of gebeurtenis te raden." + }, + "url": "timeguessr.com", + "version": "1.0.1", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Timeguessr/assets/logo.jpeg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Timeguessr/assets/thumbnail.png", + "color": "#DB5049", + "category": "games", + "tags": [ + "games", + "timeguessr" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-shield-alt", + "value": false + } + ] +} diff --git a/websites/T/Timeguessr/presence.ts b/websites/T/Timeguessr/presence.ts index 279d3143f1b7..a04946c11c75 100644 --- a/websites/T/Timeguessr/presence.ts +++ b/websites/T/Timeguessr/presence.ts @@ -1,82 +1,84 @@ const presence = new Presence({ - clientId: "1327710845546922075", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1327710845546922075', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Timeguessr/assets/logo.jpeg", - startTimestamp: browsingTimestamp, - }, - privacy = await presence.getSetting("privacy"), - { pathname } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Timeguessr/assets/logo.jpeg', + startTimestamp: browsingTimestamp, + } + const privacy = await presence.getSetting('privacy') + const { pathname } = document.location - if (!privacy) { - switch (pathname) { - case "/": - presenceData.details = "Warming up the time machine"; - break; - case "/privacypolicy": - presenceData.details = "Reading the fine print of time travel"; - break; - case "/login": - presenceData.details = "Logging into the past"; - break; - case "/createaccount": - presenceData.details = "Joining the timeguessers"; - break; - case "/submit": - presenceData.details = "Contributing to the time vault"; - break; - case "/game-settings": - presenceData.details = "Tuning the time machine"; - break; - case "/account": - presenceData.details = "Managing their historical identity"; - break; - case "/friends": - presenceData.details = "Catching up with fellow guessers"; - break; - case "/subscriptions": - presenceData.details = "Supporting the time machine"; - break; - } + if (!privacy) { + switch (pathname) { + case '/': + presenceData.details = 'Warming up the time machine' + break + case '/privacypolicy': + presenceData.details = 'Reading the fine print of time travel' + break + case '/login': + presenceData.details = 'Logging into the past' + break + case '/createaccount': + presenceData.details = 'Joining the timeguessers' + break + case '/submit': + presenceData.details = 'Contributing to the time vault' + break + case '/game-settings': + presenceData.details = 'Tuning the time machine' + break + case '/account': + presenceData.details = 'Managing their historical identity' + break + case '/friends': + presenceData.details = 'Catching up with fellow guessers' + break + case '/subscriptions': + presenceData.details = 'Supporting the time machine' + break + } - if (/\/round(one|two|three|four|five)(daily)?/.test(pathname)) { - presenceData.details = "Pinpointing moments in history"; - presenceData.state = `${ - document.querySelector(".progressBarText2")?.textContent - } | Score: ${ - document.querySelector("#insertScore")?.textContent ?? 0 - } | Mode: ${ - pathname - .match(/round(one|two|three|four|five)(daily)?/)[0] - .includes("daily") - ? "Daily" - : "Normal" - }`; - } else if ( - pathname === "/roundresults" || - pathname === "/dailyroundresults" - ) { - presenceData.details = `Round results | Total score: ${ - document.querySelector("#insertTotal")?.textContent ?? 0 - }`; - presenceData.state = `Year: ${ - document.querySelector("#insertYearScore")?.textContent || "0" - } | Location: ${ - document.querySelector("#insertLocationScore")?.textContent || "0" - }`; - } else if (pathname === "/finalscore" || pathname === "/finalscoredaily") { - presenceData.details = "Guessed all the places and times"; - presenceData.state = `Final score: ${ - document.querySelector("#totalText")?.textContent - }/50,000`; - } - } else { - presenceData.details = "Playing timeguessr under the radar"; - delete presenceData.state; - } - presence.setActivity(presenceData); -}); + if (/\/round(?:one|two|three|four|five)(?:daily)?/.test(pathname)) { + presenceData.details = 'Pinpointing moments in history' + presenceData.state = `${ + document.querySelector('.progressBarText2')?.textContent + } | Score: ${ + document.querySelector('#insertScore')?.textContent ?? 0 + } | Mode: ${ + pathname + .match(/round(one|two|three|four|five)(daily)?/)?.[0] + .includes('daily') + ? 'Daily' + : 'Normal' + }` + } + else if ( + pathname === '/roundresults' + || pathname === '/dailyroundresults' + ) { + presenceData.details = `Round results | Total score: ${ + document.querySelector('#insertTotal')?.textContent ?? 0 + }` + presenceData.state = `Year: ${ + document.querySelector('#insertYearScore')?.textContent || '0' + } | Location: ${ + document.querySelector('#insertLocationScore')?.textContent || '0' + }` + } + else if (pathname === '/finalscore' || pathname === '/finalscoredaily') { + presenceData.details = 'Guessed all the places and times' + presenceData.state = `Final score: ${ + document.querySelector('#totalText')?.textContent + }/50,000` + } + } + else { + presenceData.details = 'Playing timeguessr under the radar' + delete presenceData.state + } + presence.setActivity(presenceData) +}) diff --git a/websites/T/Timolia/metadata.json b/websites/T/Timolia/metadata.json index b9d6095d008b..ee369299febd 100644 --- a/websites/T/Timolia/metadata.json +++ b/websites/T/Timolia/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Lennart™", - "id": "398101340322136075" - }, - "service": "Timolia", - "description": { - "de": "Timolia ist einer der größten deutschen Minecraft Server. Spiele noch heute einzigartige Minispiele!", - "en": "Timolia is one of the largest German Minecraft servers. Play unique minigames today!" - }, - "url": "timolia.de", - "regExp": "([a-z0-9-]+[.])*timolia[.]de[/]", - "version": "1.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Timolia/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Timolia/assets/thumbnail.png", - "color": "#6b6b6b", - "category": "games", - "tags": [ - "timolia", - "minecraft", - "timolia-de", - "minecraft-server" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Lennart™", + "id": "398101340322136075" + }, + "service": "Timolia", + "description": { + "de": "Timolia ist einer der größten deutschen Minecraft Server. Spiele noch heute einzigartige Minispiele!", + "en": "Timolia is one of the largest German Minecraft servers. Play unique minigames today!" + }, + "url": "timolia.de", + "regExp": "([a-z0-9-]+[.])*timolia[.]de[/]", + "version": "1.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Timolia/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Timolia/assets/thumbnail.png", + "color": "#6b6b6b", + "category": "games", + "tags": [ + "timolia", + "minecraft", + "timolia-de", + "minecraft-server" + ] +} diff --git a/websites/T/Timolia/presence.ts b/websites/T/Timolia/presence.ts index 2e20897216ff..07dd147ea2a3 100644 --- a/websites/T/Timolia/presence.ts +++ b/websites/T/Timolia/presence.ts @@ -1,87 +1,95 @@ const presence = new Presence({ - clientId: "872421983554502717", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '872421983554502717', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Timolia/assets/logo.png", - Minecraft = "https://cdn.rcd.gg/PreMiD/websites/T/Timolia/assets/0.png", - Gitlab = "https://cdn.rcd.gg/PreMiD/websites/T/Timolia/assets/1.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Timolia/assets/logo.png', + Minecraft = 'https://cdn.rcd.gg/PreMiD/websites/T/Timolia/assets/0.png', + Gitlab = 'https://cdn.rcd.gg/PreMiD/websites/T/Timolia/assets/1.png', } -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } - switch (document.location.hostname) { - case "www.timolia.de": { - if (document.location.pathname === "/") { - presenceData.details = "Viewing home page"; - presenceData.smallImageKey = Assets.Minecraft; - presenceData.smallImageText = `${ - document.querySelector("#liveplayercount").textContent - } online players`; - } else if (document.location.pathname.startsWith("/stats")) { - presenceData.details = "Viewing stats from:"; - presenceData.state = document.querySelector("#playername").textContent; - } else if (document.location.pathname.includes("/games")) - presenceData.details = "Viewing gamemodes"; - else if (document.location.pathname.includes("/account")) - presenceData.details = "Viewing account settings"; + switch (document.location.hostname) { + case 'www.timolia.de': { + if (document.location.pathname === '/') { + presenceData.details = 'Viewing home page' + presenceData.smallImageKey = Assets.Minecraft + presenceData.smallImageText = `${ + document.querySelector('#liveplayercount')?.textContent + } online players` + } + else if (document.location.pathname.startsWith('/stats')) { + presenceData.details = 'Viewing stats from:' + presenceData.state = document.querySelector('#playername')?.textContent + } + else if (document.location.pathname.includes('/games')) { + presenceData.details = 'Viewing gamemodes' + } + else if (document.location.pathname.includes('/account')) { + presenceData.details = 'Viewing account settings' + } - break; - } - case "howto.timolia.de": { - presenceData.details = "HowTo - Reading:"; - presenceData.state = document.querySelector( - "body > div.md-container > main > div > div.md-content > article > h1" - ).textContent; + break + } + case 'howto.timolia.de': { + presenceData.details = 'HowTo - Reading:' + presenceData.state = document.querySelector( + 'body > div.md-container > main > div > div.md-content > article > h1', + )?.textContent - break; - } - case "shop.timolia.de": { - presenceData.details = "Shop - Viewing store page"; - if (document.location.pathname.startsWith("/checkout")) { - presenceData.details = "Shop - Viewing shopping cart:"; - presenceData.state = document.querySelector( - "body > div.sections-wrapper > section > div > div > div.jumbotron > div > div.packages > form > table > tbody > tr > td.col-md-6" - ).textContent; - } + break + } + case 'shop.timolia.de': { + presenceData.details = 'Shop - Viewing store page' + if (document.location.pathname.startsWith('/checkout')) { + presenceData.details = 'Shop - Viewing shopping cart:' + presenceData.state = document.querySelector( + 'body > div.sections-wrapper > section > div > div > div.jumbotron > div > div.packages > form > table > tbody > tr > td.col-md-6', + )?.textContent + } - break; - } - case "forum.timolia.de": { - presenceData.details = "Viewing forum start page"; - if (document.location.pathname.startsWith("/members")) { - presenceData.details = "Viewing forum profile of:"; - presenceData.state = document.querySelector( - "#content > div.pageWidth > div > div > div.mainProfileColumn > div > div > h1 > span" - ).textContent; - } else if (document.location.pathname.startsWith("/threads")) { - presenceData.details = "Viewing thread:"; - presenceData.state = document.querySelector( - "#content > div.pageWidth > div > div.titleBar > h1" - ).textContent; - } else if (document.location.pathname.startsWith("/forums")) { - presenceData.details = "Viewing forum:"; - presenceData.state = document.querySelector( - "#content > div.pageWidth > div > div.titleBar > h1" - ).textContent; - } + break + } + case 'forum.timolia.de': { + presenceData.details = 'Viewing forum start page' + if (document.location.pathname.startsWith('/members')) { + presenceData.details = 'Viewing forum profile of:' + presenceData.state = document.querySelector( + '#content > div.pageWidth > div > div > div.mainProfileColumn > div > div > h1 > span', + )?.textContent + } + else if (document.location.pathname.startsWith('/threads')) { + presenceData.details = 'Viewing thread:' + presenceData.state = document.querySelector( + '#content > div.pageWidth > div > div.titleBar > h1', + )?.textContent + } + else if (document.location.pathname.startsWith('/forums')) { + presenceData.details = 'Viewing forum:' + presenceData.state = document.querySelector( + '#content > div.pageWidth > div > div.titleBar > h1', + )?.textContent + } - break; - } - default: - if (document.location.hostname.includes("wi.timolia.de")) - presenceData.details = "Viewing Webinterface"; - else if (document.location.hostname.includes("gitlab.timolia.de")) { - presenceData.details = "Viewing GitLab Server"; - presenceData.smallImageKey = Assets.Gitlab; - } - } + break + } + default: + if (document.location.hostname.includes('wi.timolia.de')) { + presenceData.details = 'Viewing Webinterface' + } + else if (document.location.hostname.includes('gitlab.timolia.de')) { + presenceData.details = 'Viewing GitLab Server' + presenceData.smallImageKey = Assets.Gitlab + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Tinkercad/dashboard.ts b/websites/T/Tinkercad/dashboard.ts index e8638aad4c7e..4ed72373696e 100644 --- a/websites/T/Tinkercad/dashboard.ts +++ b/websites/T/Tinkercad/dashboard.ts @@ -1,79 +1,76 @@ -import { Assets } from "./presence"; +import { Assets } from './presence' const enum SubPages { - dashboard = "", - classes = "classes", - designs = "designs", - collections = "collections", - tutorials = "tutorials", - challenges = "challenges", - bin = "bin", + dashboard = '', + classes = 'classes', + designs = 'designs', + collections = 'collections', + tutorials = 'tutorials', + challenges = 'challenges', + bin = 'bin', } -const handleDesigns = ( - subsubpage: string, - presenceData: PresenceData -): void => { - switch (subsubpage) { - case "3d": { - presenceData.details = "Viewing 3D designs"; - presenceData.smallImageKey = Assets.ThreeDIco; - presenceData.smallImageText = "3D"; - break; - } - case "circuits": { - presenceData.details = "Viewing circuits"; - presenceData.smallImageKey = Assets.CircuitIco; - presenceData.smallImageText = "circuit"; - break; - } - case "codeblocks": { - presenceData.details = "Viewing codeblocks"; - presenceData.smallImageKey = Assets.CodeblockIco; - presenceData.smallImageText = "code"; - break; - } - case "bin": { - presenceData.details = "Viewing Trash Can"; - presenceData.smallImageKey = Assets.TrashCanIco; - presenceData.smallImageText = "trash"; - break; - } - } -}; +function handleDesigns(subsubpage: string, presenceData: PresenceData): void { + switch (subsubpage) { + case '3d': { + presenceData.details = 'Viewing 3D designs' + presenceData.smallImageKey = Assets.ThreeDIco + presenceData.smallImageText = '3D' + break + } + case 'circuits': { + presenceData.details = 'Viewing circuits' + presenceData.smallImageKey = Assets.CircuitIco + presenceData.smallImageText = 'circuit' + break + } + case 'codeblocks': { + presenceData.details = 'Viewing codeblocks' + presenceData.smallImageKey = Assets.CodeblockIco + presenceData.smallImageText = 'code' + break + } + case 'bin': { + presenceData.details = 'Viewing Trash Can' + presenceData.smallImageKey = Assets.TrashCanIco + presenceData.smallImageText = 'trash' + break + } + } +} export function selectDashboardPage( - presenceData: PresenceData, - subpage: string, - subsubpage?: string + presenceData: PresenceData, + subpage: string, + subsubpage?: string, ): void { - switch (subpage) { - case SubPages.dashboard: - presenceData.details = "In Dashboard"; - break; + switch (subpage) { + case SubPages.dashboard: + presenceData.details = 'In Dashboard' + break - case SubPages.classes: - presenceData.details = "Viewing Classes"; - break; + case SubPages.classes: + presenceData.details = 'Viewing Classes' + break - case SubPages.designs: - handleDesigns(subsubpage, presenceData); - break; + case SubPages.designs: + handleDesigns(subsubpage ?? '', presenceData) + break - case SubPages.collections: - presenceData.details = "Viewing Collections"; - break; + case SubPages.collections: + presenceData.details = 'Viewing Collections' + break - case SubPages.tutorials: - presenceData.details = "Viewing Tutorials"; - break; + case SubPages.tutorials: + presenceData.details = 'Viewing Tutorials' + break - case SubPages.challenges: - presenceData.details = "Viewing Challenges"; - break; + case SubPages.challenges: + presenceData.details = 'Viewing Challenges' + break - case SubPages.bin: - presenceData.details = "Viewing Trash Can"; - break; - } + case SubPages.bin: + presenceData.details = 'Viewing Trash Can' + break + } } diff --git a/websites/T/Tinkercad/handleThing.ts b/websites/T/Tinkercad/handleThing.ts index b167dacbb92e..bae805fffc5b 100644 --- a/websites/T/Tinkercad/handleThing.ts +++ b/websites/T/Tinkercad/handleThing.ts @@ -1,90 +1,97 @@ export function handleThing( - presenceData: PresenceData, - link: string, - isEdit: boolean + presenceData: PresenceData, + link: string, + isEdit: boolean, ): void { - if (!link) presenceData.state = "Browing the Community Gallery"; - else { - const username = - document.querySelector("#design-detail-username")?.textContent || null, - in3d = document.querySelector(".editor-3d-container") || null, // 3D - inCircuit = document.querySelector(".editor") || null, // circuit - nameFull = document.title, - editType = nameFull.split("design")[0]?.trim() || null, - thingNameEl = - document.querySelector(".sitemenu__title__span") || - document.querySelector("#topnav-title") || - null; + if (!link) { + presenceData.state = 'Browing the Community Gallery' + } + else { + const username = document.querySelector('#design-detail-username')?.textContent || null + const in3d = document.querySelector('.editor-3d-container') || null // 3D + const inCircuit = document.querySelector('.editor') || null // circuit + const nameFull = document.title + const editType = nameFull.split('design')[0]?.trim() || null + const thingNameEl = document.querySelector('.sitemenu__title__span') + || document.querySelector('#topnav-title') + || null - // this is a preview of a post - if (!isEdit) { - const thingType = document - .querySelector(".user-lockup-type") - .textContent.replace("by", "") - .trim(); + // this is a preview of a post + if (!isEdit) { + const thingType = document + .querySelector('.user-lockup-type') + ?.textContent + ?.replace('by', '') + .trim() - if (document.querySelector(".design-detail-top-public")) { - presenceData.details = `Viewing ${nameFull}`; - presenceData.state = `By ${username}`; - if (in3d) presenceData.details += " (3D interactive)"; - else if (inCircuit) { - const activeClasses = document - .querySelector(".sitemenu__right") - .querySelector("[class*='active']") - .getAttribute("href"); - let sectActive: string; + if (document.querySelector('.design-detail-top-public')) { + presenceData.details = `Viewing ${nameFull}` + presenceData.state = `By ${username}` + if (in3d) { + presenceData.details += ' (3D interactive)' + } + else if (inCircuit) { + const activeClasses = document + .querySelector('.sitemenu__right') + ?.querySelector('[class*=\'active\']') + ?.getAttribute('href') + let sectActive: string - if (activeClasses === "#breadboard") sectActive = "Circuit View"; - else if (activeClasses === "#schematic_view") - sectActive = "Schematic View"; - else sectActive = "Component List"; - presenceData.details += ` (in ${sectActive})`; - } + if (activeClasses === '#breadboard') + sectActive = 'Circuit View' + else if (activeClasses === '#schematic_view') + sectActive = 'Schematic View' + else sectActive = 'Component List' + presenceData.details += ` (in ${sectActive})` + } - presenceData.buttons = [ - { label: `View ${thingType}`, url: document.location.href }, - ]; - } else if (document.querySelector(".design-detail-top-private")) { - presenceData.details = `Viewing Private ${thingType}`; - delete presenceData.smallImageKey; - delete presenceData.buttons; - } - } else { - // the user is editing - presenceData.details = `Editing a ${editType} design`; - presenceData.state = thingNameEl?.textContent || ""; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } - } + presenceData.buttons = [ + { label: `View ${thingType}`, url: document.location.href }, + ] + } + else if (document.querySelector('.design-detail-top-private')) { + presenceData.details = `Viewing Private ${thingType}` + delete presenceData.smallImageKey + delete presenceData.buttons + } + } + else { + // the user is editing + presenceData.details = `Editing a ${editType} design` + presenceData.state = thingNameEl?.textContent || '' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } + } } export function handleCodeblocks( - presenceData: PresenceData, - isEdit: boolean + presenceData: PresenceData, + isEdit: boolean, ): void { - const title = - document.querySelector(".design-detail-header-title")?.textContent ?? "", - username = - document.querySelector("#design-detail-username")?.textContent ?? ""; + const title = document.querySelector('.design-detail-header-title')?.textContent ?? '' + const username = document.querySelector('#design-detail-username')?.textContent ?? '' - if (isEdit) { - // get name - const blockname = document - .querySelector(".header-group") - ?.querySelector(".inline-text-input")?.textContent; + if (isEdit) { + // get name + const blockname = document + .querySelector('.header-group') + ?.querySelector('.inline-text-input') + ?.textContent - presenceData.details = `Editing ${blockname} (codeblock)`; - delete presenceData.buttons; - } else if (document.querySelector(".design-detail-top-public")) { - presenceData.details = `Viewing ${title} (codeblock)`; - presenceData.state = `By ${username}`; + presenceData.details = `Editing ${blockname} (codeblock)` + delete presenceData.buttons + } + else if (document.querySelector('.design-detail-top-public')) { + presenceData.details = `Viewing ${title} (codeblock)` + presenceData.state = `By ${username}` - presenceData.buttons = [ - { label: "View codeblock", url: document.location.href }, - ]; - } else { - delete presenceData.buttons; - delete presenceData.details; - presenceData.details = "Editing Code Block"; - } + presenceData.buttons = [ + { label: 'View codeblock', url: document.location.href }, + ] + } + else { + delete presenceData.buttons + delete presenceData.details + presenceData.details = 'Editing Code Block' + } } diff --git a/websites/T/Tinkercad/metadata.json b/websites/T/Tinkercad/metadata.json index 7b1fcd5684e1..d90042d8b921 100644 --- a/websites/T/Tinkercad/metadata.json +++ b/websites/T/Tinkercad/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "358402930191106049", - "name": "ion606" - }, - "service": "Tinkercad", - "description": { - "en": "Tinkercad is a free, easy-to-use app for 3D design, electronics, and coding" - }, - "url": "www.tinkercad.com", - "version": "1.0.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/thumbnail.png", - "color": "#0060df", - "category": "other", - "tags": [ - "tinkercad", - "autodesk", - "cad", - "3d", - "codeblocks", - "circuits" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "358402930191106049", + "name": "ion606" + }, + "service": "Tinkercad", + "description": { + "en": "Tinkercad is a free, easy-to-use app for 3D design, electronics, and coding" + }, + "url": "www.tinkercad.com", + "version": "1.0.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/thumbnail.png", + "color": "#0060df", + "category": "other", + "tags": [ + "tinkercad", + "autodesk", + "cad", + "3d", + "codeblocks", + "circuits" + ] +} diff --git a/websites/T/Tinkercad/presence.ts b/websites/T/Tinkercad/presence.ts index 27dd981bd455..04e342dbbbac 100644 --- a/websites/T/Tinkercad/presence.ts +++ b/websites/T/Tinkercad/presence.ts @@ -1,52 +1,53 @@ -import { selectDashboardPage } from "./dashboard"; -import { handleCodeblocks, handleThing } from "./handleThing"; +import { selectDashboardPage } from './dashboard' +import { handleCodeblocks, handleThing } from './handleThing' const presence = new Presence({ - clientId: "1217153856665026580", -}); + clientId: '1217153856665026580', +}) export const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/logo.png", - ThreeDIco = "https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/0.png", - CircuitIco = "https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/1.png", - CodeblockIco = "https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/2.png", - TrashCanIco = "https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/3.jpeg", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/logo.png', + ThreeDIco = 'https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/0.png', + CircuitIco = 'https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/1.png', + CodeblockIco = 'https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/2.png', + TrashCanIco = 'https://cdn.rcd.gg/PreMiD/websites/T/Tinkercad/assets/3.jpeg', } const enum Pages { - homepage = "dashboard", - things = "things", - codeblocks = "codeblocks", + homepage = 'dashboard', + things = 'things', + codeblocks = 'codeblocks', } -presence.on("UpdateData", async () => { - if (!document.location.toString()) return; - - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - name: "Tinkercad", - type: ActivityType.Playing, - }, - [, page, subpage, subsubpage] = document.location.pathname.split("/"); - - switch (page) { - case Pages.homepage: - selectDashboardPage(presenceData, subpage, subsubpage); - break; - - case Pages.things: - handleThing(presenceData, subpage, subsubpage?.includes("edit")); // can be "edit" or "editel" - break; - - case Pages.codeblocks: - handleCodeblocks(presenceData, subpage?.includes("edit")); - break; - - default: - // blog and help - presenceData.details = `Viewing ${document.title}`; - break; - } - - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + if (!document.location.toString()) + return + + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + name: 'Tinkercad', + type: ActivityType.Playing, + } + const [, page, subpage, subsubpage] = document.location.pathname.split('/') + + switch (page) { + case Pages.homepage: + selectDashboardPage(presenceData, subpage, subsubpage) + break + + case Pages.things: + handleThing(presenceData, subpage, subsubpage?.includes('edit')) // can be "edit" or "editel" + break + + case Pages.codeblocks: + handleCodeblocks(presenceData, subpage?.includes('edit')) + break + + default: + // blog and help + presenceData.details = `Viewing ${document.title}` + break + } + + presence.setActivity(presenceData) +}) diff --git a/websites/T/Tio Anime/iframe.ts b/websites/T/Tio Anime/iframe.ts index 3fa64e64f3b3..091184a8b645 100644 --- a/websites/T/Tio Anime/iframe.ts +++ b/websites/T/Tio Anime/iframe.ts @@ -1,12 +1,12 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", async () => { - const video = document.querySelector("video"); - if (video && !isNaN(video.duration)) { - iframe.send({ - duration: video.duration, - currentTime: video.currentTime, - paused: video.paused, - }); - } -}); +iframe.on('UpdateData', async () => { + const video = document.querySelector('video') + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + duration: video.duration, + currentTime: video.currentTime, + paused: video.paused, + }) + } +}) diff --git a/websites/T/Tio Anime/metadata.json b/websites/T/Tio Anime/metadata.json index 7dca30232712..9b3c054c4184 100644 --- a/websites/T/Tio Anime/metadata.json +++ b/websites/T/Tio Anime/metadata.json @@ -1,38 +1,38 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Yelo", - "id": "425326889565945856" - }, - "service": "Tio Anime", - "description": { - "en": "The best portal to watch anime online sub spanish in HD quality, download light anime in HD from Mega, Mediafire and more! TioAnime your best option.", - "es": "El mejor portal para ver anime online sub español en calidad HD, descargar anime ligero en HD desde Mega, Mediafire y más! TioAnime tu mejor opción." - }, - "url": "tioanime.com", - "version": "1.1.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tio%20Anime/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tio%20Anime/assets/thumbnail.png", - "color": "#18142f", - "category": "anime", - "tags": [ - "anime" - ], - "iframe": true, - "iFrameRegExp": ".*", - "settings": [ - { - "id": "privacy", - "title": "Modo Incógnito", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "buttons", - "title": "Mostrar botones", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Yelo", + "id": "425326889565945856" + }, + "service": "Tio Anime", + "description": { + "en": "The best portal to watch anime online sub spanish in HD quality, download light anime in HD from Mega, Mediafire and more! TioAnime your best option.", + "es": "El mejor portal para ver anime online sub español en calidad HD, descargar anime ligero en HD desde Mega, Mediafire y más! TioAnime tu mejor opción." + }, + "url": "tioanime.com", + "version": "1.1.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tio%20Anime/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tio%20Anime/assets/thumbnail.png", + "color": "#18142f", + "category": "anime", + "tags": [ + "anime" + ], + "iframe": true, + "iFrameRegExp": ".*", + "settings": [ + { + "id": "privacy", + "title": "Modo Incógnito", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "buttons", + "title": "Mostrar botones", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/T/Tio Anime/presence.ts b/websites/T/Tio Anime/presence.ts index 082d773765a2..132cb778c67c 100644 --- a/websites/T/Tio Anime/presence.ts +++ b/websites/T/Tio Anime/presence.ts @@ -1,95 +1,101 @@ const presence = new Presence({ - clientId: "896323132871299103", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '896323132871299103', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) let video = { - duration: 0, - currentTime: 0, - paused: true, -}; + duration: 0, + currentTime: 0, + paused: true, +} presence.on( - "iFrameData", - (data: { duration: number; currentTime: number; paused: boolean }) => { - video = data; - } -); + 'iFrameData', + (data: unknown) => { + video = data as typeof video + }, +) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Tio%20Anime/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - [privacy, buttons] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("buttons"), - ]), - { href, pathname } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Tio%20Anime/assets/logo.png', + startTimestamp: browsingTimestamp, + } as PresenceData + const [privacy, buttons] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('buttons'), + ]) + const { href, pathname } = document.location - if (pathname === "/") presenceData.details = "En la página de inicio"; - else if (pathname.includes("/anime/")) { - if (!privacy) { - presenceData.buttons = [ - { - label: "Ver Anime", - url: href, - }, - ]; - presenceData.details = "Viendo lista de episodios:"; - presenceData.state = document.querySelector(".title").textContent; - } else presenceData.details = "Viendo lista de episodios"; - } else if (pathname.includes("/ver/")) { - presenceData.type = ActivityType.Watching; - presenceData.buttons = [ - { - label: "Ver Capítulo", - url: href, - }, - ]; - const capt = document.querySelector("h1").textContent; - presenceData.details = "Viendo Anime:"; - presenceData.state = `${capt.substring( - 0, - document.querySelector("h1").textContent.lastIndexOf(" ") - )} capítulo ${capt.split(" ").pop()}`; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ); - presenceData.smallImageKey = video.paused ? Assets.Stop : Assets.Play; - presenceData.smallImageText = video.paused - ? "Capítulo pausado" - : "Reproduciendo capítulo"; - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else { - presenceData.type = ActivityType.Watching; - presenceData.details = "Viendo anime"; - presenceData.smallImageKey = video.paused ? Assets.Stop : Assets.Play; - presenceData.smallImageText = video.paused - ? "Capítulo pausado" - : "Reproduciendo capítulo"; - } + if (pathname === '/') { + presenceData.details = 'En la página de inicio' + } + else if (pathname.includes('/anime/')) { + if (!privacy) { + presenceData.buttons = [ + { + label: 'Ver Anime', + url: href, + }, + ] + presenceData.details = 'Viendo lista de episodios:' + presenceData.state = document.querySelector('.title')?.textContent + } + else { + presenceData.details = 'Viendo lista de episodios' + } + } + else if (pathname.includes('/ver/')) { + presenceData.type = ActivityType.Watching + presenceData.buttons = [ + { + label: 'Ver Capítulo', + url: href, + }, + ] + const capt = document.querySelector('h1')?.textContent + presenceData.details = 'Viendo Anime:' + presenceData.state = `${capt?.substring( + 0, + document.querySelector('h1')?.textContent?.lastIndexOf(' ') ?? 0, + )} capítulo ${capt?.split(' ').pop()}`; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) + presenceData.smallImageKey = video.paused ? Assets.Stop : Assets.Play + presenceData.smallImageText = video.paused + ? 'Capítulo pausado' + : 'Reproduciendo capítulo' + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else { + presenceData.type = ActivityType.Watching + presenceData.details = 'Viendo anime' + presenceData.smallImageKey = video.paused ? Assets.Stop : Assets.Play + presenceData.smallImageText = video.paused + ? 'Capítulo pausado' + : 'Reproduciendo capítulo' + } - switch (pathname) { - case "/directorio": - presenceData.details = "Viendo el directorio de animes"; - break; - case "/programacion": - presenceData.details = "Viendo la programación Semanal"; - break; - case "/peticiones": - presenceData.details = "Viendo peticiones"; - break; - } + switch (pathname) { + case '/directorio': + presenceData.details = 'Viendo el directorio de animes' + break + case '/programacion': + presenceData.details = 'Viendo la programación Semanal' + break + case '/peticiones': + presenceData.details = 'Viendo peticiones' + break + } - if ((privacy || !buttons) && presenceData.buttons) - delete presenceData.buttons; - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if ((privacy || !buttons) && presenceData.buttons) + delete presenceData.buttons + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Tofugu/metadata.json b/websites/T/Tofugu/metadata.json index 6d2cd8dc50eb..807c7ba7674f 100644 --- a/websites/T/Tofugu/metadata.json +++ b/websites/T/Tofugu/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "theusaf", - "id": "193714715631812608" - }, - "service": "Tofugu", - "description": { - "en": "A Japanese Culture & Language Blog" - }, - "url": [ - "www.tofugu.com", - "kana-quiz.tofugu.com" - ], - "version": "1.0.11", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tofugu/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tofugu/assets/thumbnail.jpg", - "color": "#EE0144", - "category": "other", - "tags": [ - "japan", - "japanese", - "culture", - "learning", - "language", - "blog" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "theusaf", + "id": "193714715631812608" + }, + "service": "Tofugu", + "description": { + "en": "A Japanese Culture & Language Blog" + }, + "url": [ + "www.tofugu.com", + "kana-quiz.tofugu.com" + ], + "version": "1.0.11", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tofugu/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tofugu/assets/thumbnail.jpg", + "color": "#EE0144", + "category": "other", + "tags": [ + "japan", + "japanese", + "culture", + "learning", + "language", + "blog" + ] +} diff --git a/websites/T/Tofugu/presence.ts b/websites/T/Tofugu/presence.ts index a9d2eac92f93..ec907afa0531 100644 --- a/websites/T/Tofugu/presence.ts +++ b/websites/T/Tofugu/presence.ts @@ -1,166 +1,167 @@ const presence = new Presence({ - clientId: "958766344311025786", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '958766344311025786', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Tofugu/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Tofugu/assets/logo.png', + startTimestamp: browsingTimestamp, + } - switch (location.host) { - case "www.tofugu.com": { - const [, category, path] = location.pathname.split("/"); - switch (category) { - case "": { - presenceData.details = "Viewing the homepage"; - break; - } - case "japanese": { - if (path) { - presenceData.details = "Viewing a Japanese article"; - presenceData.state = - document.querySelector(".article-highlight").textContent; - } else { - presenceData.details = "Viewing category"; - presenceData.state = document.querySelector("h1 > a").textContent; - } - break; - } - case "interviews": { - if (path) { - presenceData.details = "Viewing an interview article"; - presenceData.state = - document.querySelector(".article-highlight").textContent; - } else { - presenceData.details = "Viewing category"; - presenceData.state = document.querySelector("h1 > a").textContent; - } - break; - } - case "reviews": { - if (path) { - presenceData.details = "Viewing a review article"; - presenceData.state = - document.querySelector(".article-highlight").textContent; - } else { - presenceData.details = "Viewing category"; - presenceData.state = document.querySelector("h1 > a").textContent; - } - break; - } - case "news": { - if (path) { - presenceData.details = "Viewing a news article"; - presenceData.state = document.querySelector("h2").textContent; - } else { - presenceData.details = "Viewing category"; - presenceData.state = document.querySelector("h1 > a").textContent; - } - break; - } - case "travel": { - if (path) { - presenceData.details = "Viewing a travel article"; - presenceData.state = - document.querySelector(".article-highlight").textContent; - } else { - presenceData.details = "Viewing category"; - presenceData.state = document.querySelector("h1 > a").textContent; - } - break; - } - case "japanese-grammar": { - if (path) { - presenceData.details = "Viewing a Japanese grammar article"; - presenceData.state = - document.querySelector(".article-highlight").textContent; - } else { - presenceData.details = "Viewing category"; - presenceData.state = document.querySelector("h1 > a").textContent; - } - break; - } - case "japanese-learning-resources-database": { - if (path) { - presenceData.details = - "Viewing a Japanese learning resource article"; - presenceData.state = - document.querySelector(".article-highlight").textContent; - } else { - presenceData.details = "Viewing category"; - presenceData.state = document.querySelector("h1 > a").textContent; - } - break; - } - case "japan": { - if (path) { - presenceData.details = "Viewing a Japan article"; - presenceData.state = - document.querySelector(".article-highlight").textContent; - } else { - presenceData.details = "Viewing category"; - presenceData.state = document.querySelector("h1 > a").textContent; - } - break; - } - case "series": { - if (path) { - presenceData.details = "Viewing an article series"; - presenceData.state = - document.querySelector(".article-highlight").textContent; - } else { - presenceData.details = "Viewing category"; - presenceData.state = document.querySelector("h1 > a").textContent; - } - break; - } - case "jobs": { - if (path) { - presenceData.details = "Viewing a job listing"; - presenceData.state = document.querySelector("h2").textContent; - } else presenceData.details = "Viewing job listings"; + switch (location.host) { + case 'www.tofugu.com': { + const [, category, path] = location.pathname.split('/') + switch (category) { + case '': { + presenceData.details = 'Viewing the homepage' + break + } + case 'japanese': { + if (path) { + presenceData.details = 'Viewing a Japanese article' + presenceData.state = document.querySelector('.article-highlight')?.textContent + } + else { + presenceData.details = 'Viewing category' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + break + } + case 'interviews': { + if (path) { + presenceData.details = 'Viewing an interview article' + presenceData.state = document.querySelector('.article-highlight')?.textContent + } + else { + presenceData.details = 'Viewing category' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + break + } + case 'reviews': { + if (path) { + presenceData.details = 'Viewing a review article' + presenceData.state = document.querySelector('.article-highlight')?.textContent + } + else { + presenceData.details = 'Viewing category' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + break + } + case 'news': { + if (path) { + presenceData.details = 'Viewing a news article' + presenceData.state = document.querySelector('h2')?.textContent + } + else { + presenceData.details = 'Viewing category' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + break + } + case 'travel': { + if (path) { + presenceData.details = 'Viewing a travel article' + presenceData.state = document.querySelector('.article-highlight')?.textContent + } + else { + presenceData.details = 'Viewing category' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + break + } + case 'japanese-grammar': { + if (path) { + presenceData.details = 'Viewing a Japanese grammar article' + presenceData.state = document.querySelector('.article-highlight')?.textContent + } + else { + presenceData.details = 'Viewing category' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + break + } + case 'japanese-learning-resources-database': { + if (path) { + presenceData.details = 'Viewing a Japanese learning resource article' + presenceData.state = document.querySelector('.article-highlight')?.textContent + } + else { + presenceData.details = 'Viewing category' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + break + } + case 'japan': { + if (path) { + presenceData.details = 'Viewing a Japan article' + presenceData.state = document.querySelector('.article-highlight')?.textContent + } + else { + presenceData.details = 'Viewing category' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + break + } + case 'series': { + if (path) { + presenceData.details = 'Viewing an article series' + presenceData.state = document.querySelector('.article-highlight')?.textContent + } + else { + presenceData.details = 'Viewing category' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + break + } + case 'jobs': { + if (path) { + presenceData.details = 'Viewing a job listing' + presenceData.state = document.querySelector('h2')?.textContent + } + else { + presenceData.details = 'Viewing job listings' + } - break; - } - default: { - presenceData.details = "Browsing"; - presenceData.state = document.querySelector("h1 > a").textContent; - } - } - break; - } - case "kana-quiz.tofugu.com": { - switch (document.querySelector(".App > div").className) { - case "start": { - presenceData.details = "Preparing to practice kana"; - presenceData.state = - document.querySelector(".check").htmlFor === - "practice-hiragana" - ? "Hiragana" - : "Katakana"; - break; - } - case "quiz-page": { - presenceData.details = "Practicing kana"; - presenceData.state = - document.querySelector(".focused-card span").textContent; - break; - } - case "results": { - const [, correct, total, percent] = document - .querySelector(".results > h3") - .textContent.match(/.*?(\d+)\/(\d+).*?([\d.]+)/); - presenceData.details = "Viewing kana quiz results"; - presenceData.state = `${correct}/${total} (${percent}%)`; - break; - } - } - break; - } - } + break + } + default: { + presenceData.details = 'Browsing' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + } + break + } + case 'kana-quiz.tofugu.com': { + switch (document.querySelector('.App > div')?.className) { + case 'start': { + presenceData.details = 'Preparing to practice kana' + presenceData.state = document.querySelector('.check')?.htmlFor === 'practice-hiragana' + ? 'Hiragana' + : 'Katakana' + break + } + case 'quiz-page': { + presenceData.details = 'Practicing kana' + presenceData.state = document.querySelector('.focused-card span')?.textContent + break + } + case 'results': { + const [, correct, total, percent] = document + .querySelector('.results > h3') + ?.textContent + // eslint-disable-next-line regexp/no-super-linear-backtracking, regexp/no-misleading-capturing-group + ?.match(/.*?(\d+)\/(\d+).*?([\d.]+)/) ?? [] + presenceData.details = 'Viewing kana quiz results' + presenceData.state = `${correct}/${total} (${percent}%)` + break + } + } + break + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/Tokopedia/metadata.json b/websites/T/Tokopedia/metadata.json index db4b902d28e7..943d357a8482 100644 --- a/websites/T/Tokopedia/metadata.json +++ b/websites/T/Tokopedia/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "WilloIzCitron", - "id": "735410445409845251" - }, - "service": "Tokopedia", - "description": { - "en": "The Indonesian E-Commerce Site", - "nl": "De Indonesische e-commerce-site" - }, - "url": [ - "www.tokopedia.com", - "seller.tokopedia.com" - ], - "version": "1.1.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tokopedia/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tokopedia/assets/thumbnail.png", - "color": "#90ee90", - "category": "other", - "tags": [ - "e-commerce", - "shopping" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "WilloIzCitron", + "id": "735410445409845251" + }, + "service": "Tokopedia", + "description": { + "en": "The Indonesian E-Commerce Site", + "nl": "De Indonesische e-commerce-site" + }, + "url": [ + "www.tokopedia.com", + "seller.tokopedia.com" + ], + "version": "1.1.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tokopedia/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tokopedia/assets/thumbnail.png", + "color": "#90ee90", + "category": "other", + "tags": [ + "e-commerce", + "shopping" + ] +} diff --git a/websites/T/Tokopedia/presence.ts b/websites/T/Tokopedia/presence.ts index ff0fb9f7944e..b6f9b7c3f552 100644 --- a/websites/T/Tokopedia/presence.ts +++ b/websites/T/Tokopedia/presence.ts @@ -1,51 +1,57 @@ const presence = new Presence({ - clientId: "798368817318330400", -}); + clientId: '798368817318330400', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Tokopedia/assets/logo.png", - }, - elapsed = Math.floor(Date.now() / 1000); - if (document.location.hostname === "www.tokopedia.com") { - if (document.location.pathname.includes("/p?nref=")) { - presenceData.details = "Viewing Product List...."; - presenceData.startTimestamp = elapsed; - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/mitra")) { - presenceData.details = "Viewing a Tokopedia Partner...."; - presenceData.startTimestamp = elapsed; - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/promo")) { - presenceData.details = "Viewing a Promo...."; - presenceData.startTimestamp = elapsed; - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/edu")) { - presenceData.details = "Viewing on EduMart...."; - presenceData.startTimestamp = elapsed; - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/search")) { - presenceData.details = "Searching for a product...."; - presenceData.state = new URL(document.location.href).searchParams.get( - "q" - ); - presenceData.startTimestamp = elapsed; - presence.setActivity(presenceData); - } else { - presenceData.details = "Viewing a Homepage"; - presenceData.startTimestamp = elapsed; - presence.setActivity(presenceData); - } - } else if (document.location.hostname === "seller.tokopedia.com") { - if (document.location.pathname.includes("/edu")) { - presenceData.details = "Viewing a Seller Education Center...."; - presenceData.startTimestamp = elapsed; - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/home")) { - presenceData.details = "Viewing a Seller Homepage"; - presenceData.startTimestamp = elapsed; - presence.setActivity(presenceData); - } - } -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Tokopedia/assets/logo.png', + } + const elapsed = Math.floor(Date.now() / 1000) + if (document.location.hostname === 'www.tokopedia.com') { + if (document.location.pathname.includes('/p?nref=')) { + presenceData.details = 'Viewing Product List....' + presenceData.startTimestamp = elapsed + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/mitra')) { + presenceData.details = 'Viewing a Tokopedia Partner....' + presenceData.startTimestamp = elapsed + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/promo')) { + presenceData.details = 'Viewing a Promo....' + presenceData.startTimestamp = elapsed + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/edu')) { + presenceData.details = 'Viewing on EduMart....' + presenceData.startTimestamp = elapsed + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/search')) { + presenceData.details = 'Searching for a product....' + presenceData.state = new URL(document.location.href).searchParams.get( + 'q', + ) + presenceData.startTimestamp = elapsed + presence.setActivity(presenceData) + } + else { + presenceData.details = 'Viewing a Homepage' + presenceData.startTimestamp = elapsed + presence.setActivity(presenceData) + } + } + else if (document.location.hostname === 'seller.tokopedia.com') { + if (document.location.pathname.includes('/edu')) { + presenceData.details = 'Viewing a Seller Education Center....' + presenceData.startTimestamp = elapsed + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/home')) { + presenceData.details = 'Viewing a Seller Homepage' + presenceData.startTimestamp = elapsed + presence.setActivity(presenceData) + } + } +}) diff --git a/websites/T/Toloka/metadata.json b/websites/T/Toloka/metadata.json index c555f9ca9d17..547342f0e9bf 100644 --- a/websites/T/Toloka/metadata.json +++ b/websites/T/Toloka/metadata.json @@ -1,45 +1,45 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "PlayDay", - "id": "249952042557243402" - }, - "service": "Toloka", - "altnames": [ - "Толока" - ], - "description": { - "en": "Toloka.to is the largest BitTorrent tracker of UKRnet, specializing in the distribution of content exclusively in Ukrainian language.", - "ru": "Toloka.to - крупнейший BitTorrent-трекер в УКРнете, специализирующаяся на распространении контента исключительно на украинском языке", - "uk_UA": "Toloka.to — найбільший BitTorrent-трекер УКРнету, що спеціалізується на поширенні контенту виключно українською мовою.", - "nl": "Toloka.to is de grootste BitTorrent-tracker van UKRnet, gespecialiseerd in de distributie van inhoud uitsluitend in de Oekraïense taal." - }, - "url": "toloka.to", - "version": "1.0.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/thumbnail.png", - "color": "#9FB820", - "category": "other", - "tags": [ - "torrent", - "toloka", - "ua", - "ukranian", - "ukraine" - ], - "settings": [ - { - "id": "name", - "title": "Показувати нікнейми співрозмовників в ПП", - "icon": "fas fa-user", - "value": true - }, - { - "id": "search", - "title": "Показувати пошукові запити", - "icon": "fas fa-search", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "PlayDay", + "id": "249952042557243402" + }, + "service": "Toloka", + "altnames": [ + "Толока" + ], + "description": { + "en": "Toloka.to is the largest BitTorrent tracker of UKRnet, specializing in the distribution of content exclusively in Ukrainian language.", + "ru": "Toloka.to - крупнейший BitTorrent-трекер в УКРнете, специализирующаяся на распространении контента исключительно на украинском языке", + "uk_UA": "Toloka.to — найбільший BitTorrent-трекер УКРнету, що спеціалізується на поширенні контенту виключно українською мовою.", + "nl": "Toloka.to is de grootste BitTorrent-tracker van UKRnet, gespecialiseerd in de distributie van inhoud uitsluitend in de Oekraïense taal." + }, + "url": "toloka.to", + "version": "1.0.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/thumbnail.png", + "color": "#9FB820", + "category": "other", + "tags": [ + "torrent", + "toloka", + "ua", + "ukranian", + "ukraine" + ], + "settings": [ + { + "id": "name", + "title": "Показувати нікнейми співрозмовників в ПП", + "icon": "fas fa-user", + "value": true + }, + { + "id": "search", + "title": "Показувати пошукові запити", + "icon": "fas fa-search", + "value": true + } + ] +} diff --git a/websites/T/Toloka/presence.ts b/websites/T/Toloka/presence.ts index 7fc031c59f51..797764999bb2 100644 --- a/websites/T/Toloka/presence.ts +++ b/websites/T/Toloka/presence.ts @@ -1,294 +1,341 @@ const presence = new Presence({ - clientId: "798502531847421962", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); - -let title: HTMLElement, search: HTMLInputElement; + clientId: '798502531847421962', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Toloka = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/0.png", - Film = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/1.png", - Video = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/2.png", - Home = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/3.png", - Music = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/4.png", - Reply = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/5.png", - Archive = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/6.png", - User = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/7.png", - Book = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/8.png", - Gamepad = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/9.png", - Desktop = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/10.png", - Sms = "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/11.png", + Toloka = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/0.png', + Film = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/1.png', + Video = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/2.png', + Home = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/3.png', + Music = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/4.png', + Reply = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/5.png', + Archive = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/6.png', + User = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/7.png', + Book = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/8.png', + Gamepad = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/9.png', + Desktop = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/10.png', + Sms = 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/11.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/logo.png", - }, - showUseramePM = await presence.getSetting("name"), - showSearchQuery = await presence.getSetting("search"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Toloka/assets/logo.png', + } + const showUseramePM = await presence.getSetting('name') + const showSearchQuery = await presence.getSetting('search') - switch (document.location.pathname) { - case "/": { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю головну"; - presenceData.state = "сторінку"; - presenceData.smallImageKey = Assets.Home; - presenceData.smallImageText = "Головна"; + switch (document.location.pathname) { + case '/': { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю головну' + presenceData.state = 'сторінку' + presenceData.smallImageKey = Assets.Home + presenceData.smallImageText = 'Головна' - break; - } - case `/${encodeURIComponent("новини.html")}`: { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю розділ:"; - presenceData.state = "Загальне"; - presenceData.smallImageKey = Assets.Home; - presenceData.smallImageText = "Загальне"; + break + } + case `/${encodeURIComponent('новини.html')}`: { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю розділ:' + presenceData.state = 'Загальне' + presenceData.smallImageKey = Assets.Home + presenceData.smallImageText = 'Загальне' - break; - } - case `/${encodeURIComponent("відео-гуртом.html")}`: { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю розділ:"; - presenceData.state = "Проект Відео Гуртом"; - presenceData.smallImageKey = Assets.Video; - presenceData.smallImageText = "Відео Гуртом"; + break + } + case `/${encodeURIComponent('відео-гуртом.html')}`: { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю розділ:' + presenceData.state = 'Проект Відео Гуртом' + presenceData.smallImageKey = Assets.Video + presenceData.smallImageText = 'Відео Гуртом' - break; - } - case `/${encodeURIComponent("фільми-українською.html")}`: { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю розділ:"; - presenceData.state = "Фільми українською"; - presenceData.smallImageKey = Assets.Film; - presenceData.smallImageText = "Фільми"; + break + } + case `/${encodeURIComponent('фільми-українською.html')}`: { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю розділ:' + presenceData.state = 'Фільми українською' + presenceData.smallImageKey = Assets.Film + presenceData.smallImageText = 'Фільми' - break; - } - case `/${encodeURIComponent("українська-музика.html")}`: { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю розділ:"; - presenceData.state = "Українська музика"; - presenceData.smallImageKey = Assets.Music; - presenceData.smallImageText = "Музика"; + break + } + case `/${encodeURIComponent('українська-музика.html')}`: { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю розділ:' + presenceData.state = 'Українська музика' + presenceData.smallImageKey = Assets.Music + presenceData.smallImageText = 'Музика' - break; - } - case `/${encodeURIComponent("література-українською.html")}`: { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю розділ:"; - presenceData.state = "Література українською"; - presenceData.smallImageKey = Assets.Book; - presenceData.smallImageText = "Література"; + break + } + case `/${encodeURIComponent('література-українською.html')}`: { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю розділ:' + presenceData.state = 'Література українською' + presenceData.smallImageKey = Assets.Book + presenceData.smallImageText = 'Література' - break; - } - case `/${encodeURIComponent("програми-українською.html")}`: { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю розділ:"; - presenceData.state = "Програми українською"; - presenceData.smallImageKey = Assets.Desktop; - presenceData.smallImageText = "Програми"; + break + } + case `/${encodeURIComponent('програми-українською.html')}`: { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю розділ:' + presenceData.state = 'Програми українською' + presenceData.smallImageKey = Assets.Desktop + presenceData.smallImageText = 'Програми' - break; - } - case `/${encodeURIComponent("ігри-українською.html")}`: { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю розділ:"; - presenceData.state = "Ігри українською"; - presenceData.smallImageKey = Assets.Gamepad; - presenceData.smallImageText = "Ігри"; + break + } + case `/${encodeURIComponent('ігри-українською.html')}`: { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю розділ:' + presenceData.state = 'Ігри українською' + presenceData.smallImageKey = Assets.Gamepad + presenceData.smallImageText = 'Ігри' - break; - } - case `/${encodeURIComponent("архів.html")}`: { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю розділ:"; - presenceData.state = "Архів та смітник"; - presenceData.smallImageKey = Assets.Archive; - presenceData.smallImageText = "Архів"; + break + } + case `/${encodeURIComponent('архів.html')}`: { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю розділ:' + presenceData.state = 'Архів та смітник' + presenceData.smallImageKey = Assets.Archive + presenceData.smallImageText = 'Архів' - break; - } - default: - if (RegExp("\\/f\\d+", "g").test(document.location.pathname)) { - title = document.querySelector( - "body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > table:nth-child(1) > tbody > tr > td > h1 > a.maintitle" - ); - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю категорію:"; - presenceData.state = title.textContent; - } else if (RegExp("\\/u\\d+", "g").test(document.location.pathname)) { - title = document.querySelector( - "body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > table.forumline:nth-child(2) > tbody > tr:nth-child(3) > td.row1:nth-child(2) > table > tbody > tr:nth-child(3) > td:nth-child(2) > span.genmed:nth-child(5) > a.genmed > b" - ); - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю профіль:"; - presenceData.state = title.textContent; - presenceData.smallImageKey = Assets.User; - presenceData.smallImageText = "Профіль"; - } else if (RegExp("\\/t\\d+", "g").test(document.location.pathname)) { - title = document.querySelector( - "body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > table:nth-child(1) > tbody > tr:nth-child(1) > td:nth-child(1) > h1 > a.maintitle" - ); - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю тему:"; - presenceData.state = title.textContent; - } else if (document.location.pathname.includes("/rightholders.php")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю сторінку"; - presenceData.state = "Для правовласників"; - } else if (document.location.pathname.includes("/faq.php")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Читаю FAQ"; - presenceData.smallImageKey = Assets.Question; - presenceData.smallImageText = "FAQ"; - } else if (document.location.pathname.includes("/tracker.php")) { - search = document.querySelector( - "body > div.maxwidth > table > tbody > tr > td.bodyline > form#form > table.forumline:nth-child(18) > tbody > tr:nth-child(2) > td.row4 > table:nth-child(3) > tbody > tr > td.row4:nth-child(3) > div > fieldset.fieldset > div > input.post" - ); - presenceData.startTimestamp = browsingTimestamp; - if (search.value === "" || !showSearchQuery) - presenceData.details = "Щось шукаю"; - else { - presenceData.details = "Шукаю:"; - presenceData.state = search.value; - } - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Пошук"; - } else if (document.location.pathname.includes("/featured")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю авторські"; - presenceData.state = "релізи"; - } else if (document.location.pathname.includes("/privmsg.php")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.smallImageKey = Assets.Sms; - presenceData.smallImageText = "ПП"; - if (document.location.search.includes("?folder=inbox&mode=read")) { - title = document.querySelector( - "body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > form > table.forumline > tbody > tr:nth-child(2) > td.row2:nth-child(2) > span.genmed" - ); - if (showUseramePM) { - presenceData.details = "Читаю ПП від:"; - presenceData.state = title.textContent; - } else presenceData.details = "Читаю ПП"; - } else if ( - document.location.search.includes("?folder=sentbox&mode=read") - ) { - title = document.querySelector( - "body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > form > table.forumline > tbody > tr:nth-child(3) > td.row2:nth-child(2) > span.genmed" - ); - if (showUseramePM) { - presenceData.details = "Читаю ПП для:"; - presenceData.state = title.textContent; - } else presenceData.details = "Читаю ПП"; - } else if ( - document.location.search.includes("?folder=outbox&mode=read") - ) { - title = document.querySelector( - "body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > form > table.forumline > tbody > tr:nth-child(3) > td.row2:nth-child(2) > span.genmed" - ); - if (showUseramePM) { - presenceData.details = "Читаю ПП для:"; - presenceData.state = title.textContent; - } else presenceData.details = "Читаю ПП"; - } else if ( - document.location.search.includes("?folder=savebox&mode=read") - ) { - title = document.querySelector( - "body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > form > table.forumline > tbody > tr:nth-child(3) > td.row2:nth-child(2) > span.genmed" - ); - if (showUseramePM) { - presenceData.details = "Читаю збережене ПП"; - presenceData.state = `від:${title.textContent}`; - } else presenceData.details = "Читаю ПП"; - } else if (document.location.search.includes("?folder=inbox")) { - presenceData.details = "Переглядаю"; - presenceData.state = "вхідні ПП"; - } else if (document.location.search.includes("?folder=sentbox")) { - presenceData.details = "Переглядаю"; - presenceData.state = "відіслані ПП"; - } else if (document.location.search.includes("?folder=outbox")) { - presenceData.details = "Переглядаю"; - presenceData.state = "вихідні ПП"; - } else if (document.location.search.includes("?folder=savebox")) { - presenceData.details = "Переглядаю"; - presenceData.state = "збережені ПП"; - } else if (document.location.search.includes("?mode=reply")) { - title = document.querySelector( - "body > div.maxwidth > table > tbody > tr > td.bodyline > form > table.forumline > tbody > tr > td.row2 > span.genmed > input.post" - ); - if (showUseramePM) { - presenceData.details = "Відповідаю на ПП від:"; - presenceData.state = title.textContent; - } else presenceData.details = "Відповідаю на ПП"; - } else if (document.location.search.includes("?mode=quote")) { - title = document.querySelector( - "body > div.maxwidth > table > tbody > tr > td.bodyline > form > table.forumline > tbody > tr > td.row2 > span.genmed > input.post" - ); - if (showUseramePM) { - presenceData.details = "Цитую ПП від:"; - presenceData.state = title.textContent; - } else presenceData.details = "Цитую ПП"; - } else if (document.location.search.includes("?mode=post")) - presenceData.details = "Пишу нове ПП"; - } else if (document.location.pathname.includes("/watched_topics.php")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю"; - presenceData.state = "відстежуввні теми"; - } else if (document.location.pathname.includes("/search.php")) { - presenceData.startTimestamp = browsingTimestamp; - if (document.location.search.includes("?mode=searchuser")) { - presenceData.details = "Шукаю співрозмовника"; - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Пошук"; - } else if (document.location.search.includes("?search_id=newposts")) { - presenceData.details = "Переглядаю нові"; - presenceData.state = "повідомлення"; - } else if (document.location.search.includes("?search_id=egosearch")) { - presenceData.details = "Переглядаю свої"; - presenceData.state = "повідомлення"; - } else if (document.location.search.includes("?search_id=unanswered")) { - presenceData.details = "Переглядаю теми"; - presenceData.state = "без відповідей"; - } - } else if (document.location.pathname.includes("/posting.php")) { - presenceData.startTimestamp = browsingTimestamp; - if (document.location.search.includes("?mode=newtopic")) { - presenceData.details = "Створюю нову"; - presenceData.state = "тему"; - } else if (document.location.search.includes("?mode=reply")) - presenceData.details = "Відповідаю на тему"; - } else if (document.location.pathname.includes("/helptoseed.php")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Переглядаю роздачі"; - presenceData.state = "яким можна допомогти"; - } else if (document.location.pathname.includes("/googlesearch.php")) { - search = document.querySelector( - "body > div.maxwidth > table > tbody > tr > td.bodyline > table.forumline > tbody > tr > td.row1 > div#___gcse_0 > div.gsc-control-cse.gsc-control-cse-uk > div.gsc-control-wrapper-cse > form.gsc-search-box.gsc-search-box-tools > table.gsc-search-box > tbody > tr > td.gsc-input > div#gsc-iw-id1.gsc-input-box > table#gs_id50.gstl_50.gsc-input > tbody > tr > td#gs_tti50.gsib_a > input#gsc-i-id1.gsc-input" - ); - presenceData.startTimestamp = browsingTimestamp; - if (search.textContent === "" || !showSearchQuery) - presenceData.details = "Щось шукаю"; - else { - presenceData.details = "Шукаю:"; - presenceData.state = search.value; - } - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Пошук"; - } else if (document.location.pathname.includes("/release.php")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Додаю торрент"; - if (document.location.search.includes("?what=")) { - title = document.querySelector( - "body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > form > table.forumline > tbody > tr:nth-child(2) > td.row2 > b" - ); - presenceData.details += " в:"; - presenceData.state = title.textContent; - } - } - } + break + } + default: + if (/\/f\d+/.test(document.location.pathname)) { + const title = document.querySelector( + 'body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > table:nth-child(1) > tbody > tr > td > h1 > a.maintitle', + ) + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю категорію:' + presenceData.state = title?.textContent + } + else if (/\/u\d+/.test(document.location.pathname)) { + const title = document.querySelector( + 'body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > table.forumline:nth-child(2) > tbody > tr:nth-child(3) > td.row1:nth-child(2) > table > tbody > tr:nth-child(3) > td:nth-child(2) > span.genmed:nth-child(5) > a.genmed > b', + ) + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю профіль:' + presenceData.state = title?.textContent + presenceData.smallImageKey = Assets.User + presenceData.smallImageText = 'Профіль' + } + else if (/\/t\d+/.test(document.location.pathname)) { + const title = document.querySelector( + 'body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > table:nth-child(1) > tbody > tr:nth-child(1) > td:nth-child(1) > h1 > a.maintitle', + ) + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю тему:' + presenceData.state = title?.textContent + } + else if (document.location.pathname.includes('/rightholders.php')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю сторінку' + presenceData.state = 'Для правовласників' + } + else if (document.location.pathname.includes('/faq.php')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Читаю FAQ' + presenceData.smallImageKey = Assets.Question + presenceData.smallImageText = 'FAQ' + } + else if (document.location.pathname.includes('/tracker.php')) { + const search = document.querySelector( + 'body > div.maxwidth > table > tbody > tr > td.bodyline > form#form > table.forumline:nth-child(18) > tbody > tr:nth-child(2) > td.row4 > table:nth-child(3) > tbody > tr > td.row4:nth-child(3) > div > fieldset.fieldset > div > input.post', + ) + presenceData.startTimestamp = browsingTimestamp + if (search?.value === '' || !showSearchQuery) { + presenceData.details = 'Щось шукаю' + } + else { + presenceData.details = 'Шукаю:' + presenceData.state = search?.value + } + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Пошук' + } + else if (document.location.pathname.includes('/featured')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю авторські' + presenceData.state = 'релізи' + } + else if (document.location.pathname.includes('/privmsg.php')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.smallImageKey = Assets.Sms + presenceData.smallImageText = 'ПП' + if (document.location.search.includes('?folder=inbox&mode=read')) { + const title = document.querySelector( + 'body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > form > table.forumline > tbody > tr:nth-child(2) > td.row2:nth-child(2) > span.genmed', + ) + if (showUseramePM) { + presenceData.details = 'Читаю ПП від:' + presenceData.state = title?.textContent + } + else { + presenceData.details = 'Читаю ПП' + } + } + else if ( + document.location.search.includes('?folder=sentbox&mode=read') + ) { + const title = document.querySelector( + 'body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > form > table.forumline > tbody > tr:nth-child(3) > td.row2:nth-child(2) > span.genmed', + ) + if (showUseramePM) { + presenceData.details = 'Читаю ПП для:' + presenceData.state = title?.textContent + } + else { + presenceData.details = 'Читаю ПП' + } + } + else if ( + document.location.search.includes('?folder=outbox&mode=read') + ) { + const title = document.querySelector( + 'body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > form > table.forumline > tbody > tr:nth-child(3) > td.row2:nth-child(2) > span.genmed', + ) + if (showUseramePM) { + presenceData.details = 'Читаю ПП для:' + presenceData.state = title?.textContent + } + else { + presenceData.details = 'Читаю ПП' + } + } + else if ( + document.location.search.includes('?folder=savebox&mode=read') + ) { + const title = document.querySelector( + 'body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > form > table.forumline > tbody > tr:nth-child(3) > td.row2:nth-child(2) > span.genmed', + ) + if (showUseramePM) { + presenceData.details = 'Читаю збережене ПП' + presenceData.state = `від:${title?.textContent}` + } + else { + presenceData.details = 'Читаю ПП' + } + } + else if (document.location.search.includes('?folder=inbox')) { + presenceData.details = 'Переглядаю' + presenceData.state = 'вхідні ПП' + } + else if (document.location.search.includes('?folder=sentbox')) { + presenceData.details = 'Переглядаю' + presenceData.state = 'відіслані ПП' + } + else if (document.location.search.includes('?folder=outbox')) { + presenceData.details = 'Переглядаю' + presenceData.state = 'вихідні ПП' + } + else if (document.location.search.includes('?folder=savebox')) { + presenceData.details = 'Переглядаю' + presenceData.state = 'збережені ПП' + } + else if (document.location.search.includes('?mode=reply')) { + const title = document.querySelector( + 'body > div.maxwidth > table > tbody > tr > td.bodyline > form > table.forumline > tbody > tr > td.row2 > span.genmed > input.post', + ) + if (showUseramePM) { + presenceData.details = 'Відповідаю на ПП від:' + presenceData.state = title?.textContent + } + else { + presenceData.details = 'Відповідаю на ПП' + } + } + else if (document.location.search.includes('?mode=quote')) { + const title = document.querySelector( + 'body > div.maxwidth > table > tbody > tr > td.bodyline > form > table.forumline > tbody > tr > td.row2 > span.genmed > input.post', + ) + if (showUseramePM) { + presenceData.details = 'Цитую ПП від:' + presenceData.state = title?.textContent + } + else { + presenceData.details = 'Цитую ПП' + } + } + else if (document.location.search.includes('?mode=post')) { + presenceData.details = 'Пишу нове ПП' + } + } + else if (document.location.pathname.includes('/watched_topics.php')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю' + presenceData.state = 'відстежуввні теми' + } + else if (document.location.pathname.includes('/search.php')) { + presenceData.startTimestamp = browsingTimestamp + if (document.location.search.includes('?mode=searchuser')) { + presenceData.details = 'Шукаю співрозмовника' + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Пошук' + } + else if (document.location.search.includes('?search_id=newposts')) { + presenceData.details = 'Переглядаю нові' + presenceData.state = 'повідомлення' + } + else if (document.location.search.includes('?search_id=egosearch')) { + presenceData.details = 'Переглядаю свої' + presenceData.state = 'повідомлення' + } + else if (document.location.search.includes('?search_id=unanswered')) { + presenceData.details = 'Переглядаю теми' + presenceData.state = 'без відповідей' + } + } + else if (document.location.pathname.includes('/posting.php')) { + presenceData.startTimestamp = browsingTimestamp + if (document.location.search.includes('?mode=newtopic')) { + presenceData.details = 'Створюю нову' + presenceData.state = 'тему' + } + else if (document.location.search.includes('?mode=reply')) { + presenceData.details = 'Відповідаю на тему' + } + } + else if (document.location.pathname.includes('/helptoseed.php')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Переглядаю роздачі' + presenceData.state = 'яким можна допомогти' + } + else if (document.location.pathname.includes('/googlesearch.php')) { + const search = document.querySelector( + 'body > div.maxwidth > table > tbody > tr > td.bodyline > table.forumline > tbody > tr > td.row1 > div#___gcse_0 > div.gsc-control-cse.gsc-control-cse-uk > div.gsc-control-wrapper-cse > form.gsc-search-box.gsc-search-box-tools > table.gsc-search-box > tbody > tr > td.gsc-input > div#gsc-iw-id1.gsc-input-box > table#gs_id50.gstl_50.gsc-input > tbody > tr > td#gs_tti50.gsib_a > input#gsc-i-id1.gsc-input', + ) + presenceData.startTimestamp = browsingTimestamp + if (search?.textContent === '' || !showSearchQuery) { + presenceData.details = 'Щось шукаю' + } + else { + presenceData.details = 'Шукаю:' + presenceData.state = search?.value + } + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Пошук' + } + else if (document.location.pathname.includes('/release.php')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Додаю торрент' + if (document.location.search.includes('?what=')) { + const title = document.querySelector( + 'body > div.maxwidth > table:nth-child(3) > tbody > tr > td.bodyline > form > table.forumline > tbody > tr:nth-child(2) > td.row2 > b', + ) + presenceData.details += ' в:' + presenceData.state = title?.textContent + } + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TomsHardware/metadata.json b/websites/T/TomsHardware/metadata.json index 976872b969aa..732bbd5dd3c1 100644 --- a/websites/T/TomsHardware/metadata.json +++ b/websites/T/TomsHardware/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "bakzkndd", - "id": "343103632453009408" - }, - "service": "TomsHardware", - "description": { - "nl": "TomsHardware is de leidende bestemming voor technologie fans van alle skill levels.", - "en": "TomsHardware is the leading destination for tech enthusiasts of all skill levels." - }, - "url": "tomshardware.com", - "regExp": "([a-z0-9-]+[.])*tomshardware[.]com[/]", - "version": "1.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TomsHardware/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TomsHardware/assets/thumbnail.png", - "color": "#e03c3c", - "category": "other", - "tags": [ - "tomshardware", - "technology", - "electronics", - "reviews", - "hardware", - "software" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "bakzkndd", + "id": "343103632453009408" + }, + "service": "TomsHardware", + "description": { + "nl": "TomsHardware is de leidende bestemming voor technologie fans van alle skill levels.", + "en": "TomsHardware is the leading destination for tech enthusiasts of all skill levels." + }, + "url": "tomshardware.com", + "regExp": "([a-z0-9-]+[.])*tomshardware[.]com[/]", + "version": "1.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TomsHardware/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TomsHardware/assets/thumbnail.png", + "color": "#e03c3c", + "category": "other", + "tags": [ + "tomshardware", + "technology", + "electronics", + "reviews", + "hardware", + "software" + ] +} diff --git a/websites/T/TomsHardware/presence.ts b/websites/T/TomsHardware/presence.ts index 544d31d2c405..50a98662da3d 100644 --- a/websites/T/TomsHardware/presence.ts +++ b/websites/T/TomsHardware/presence.ts @@ -1,95 +1,131 @@ const presence = new Presence({ - clientId: "889780989386170420", -}); + clientId: '889780989386170420', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TomsHardware/assets/logo.png", - }, - { href } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TomsHardware/assets/logo.png', + } + const { href } = document.location - let { pathname } = document.location; + let { pathname } = document.location - if (pathname.includes("uk/")) pathname = pathname.replace("uk/", ""); - if (pathname.includes("uk")) pathname = pathname.replace("uk", ""); + if (pathname.includes('uk/')) + pathname = pathname.replace('uk/', '') + if (pathname.includes('uk')) + pathname = pathname.replace('uk', '') - if (href.includes("news")) { - if (pathname.split("/")[2]) { - presenceData.details = "Reading an article..."; - presenceData.state = `Article: '${pathname - .split("/")[2] - .replace(".html", "")}'`; - } else presenceData.details = "Scrolling through news articles..."; - } else if (href.includes("reviews")) { - if (pathname.split("/")[2]) { - presenceData.details = "Reading a review..."; - presenceData.state = `Review: '${pathname - .split("/")[2] - .replace(".html", "")}'`; - } else presenceData.details = "Scrolling through reviews..."; - } else if (href.includes("best-picks")) { - if (pathname.split("/")[2]) { - presenceData.details = "Looking at best picks..."; - presenceData.state = `The best picks for: '${pathname - .split("/")[3] - .replace(".html", "") - .replace("best-", "")}'`; - } else presenceData.details = "Scrolling through best picks..."; - } else if (href.includes("coupons")) { - if (pathname.includes("?")) presenceData.details = "Looking at a coupon..."; - else if (pathname.split("/")[2]) { - presenceData.details = "Looking at coupons..."; - presenceData.state = `Coupons for: '${pathname - .split("/")[3] - .replace(".html", "")}'`; - } else presenceData.details = "Scrolling through coupons..."; - } else if (href.includes("forums.")) { - if (pathname.includes("forums")) { - presenceData.state = `Category: '${pathname - .split("/")[2] - .split(".")[0] - .replace(".html", "")}'`; - } else if (pathname.includes("threads")) { - presenceData.state = `Category: '${pathname - .split("/")[2] - .split(".")[0] - .replace(".html", "")}'`; - } else if (pathname.includes("featured")) - presenceData.state = "Looking at featured threads..."; - else if (pathname.includes("whats-new")) - presenceData.state = "Looking at new threads..."; - else if (pathname.includes("members")) - presenceData.state = "Looking at members..."; - else if (pathname.includes("help")) presenceData.state = "Getting help..."; - else if (pathname.includes("search")) - presenceData.state = "Searching the forums..."; - else if (pathname.includes("billboard")) - presenceData.state = "Looking at the billboard..."; - else if (pathname.includes("register")) - presenceData.state = "Registering an account..."; + if (href.includes('news')) { + if (pathname.split('/')[2]) { + presenceData.details = 'Reading an article...' + presenceData.state = `Article: '${pathname + .split('/')[2] + .replace('.html', '')}'` + } + else { + presenceData.details = 'Scrolling through news articles...' + } + } + else if (href.includes('reviews')) { + if (pathname.split('/')[2]) { + presenceData.details = 'Reading a review...' + presenceData.state = `Review: '${pathname + .split('/')[2] + .replace('.html', '')}'` + } + else { + presenceData.details = 'Scrolling through reviews...' + } + } + else if (href.includes('best-picks')) { + if (pathname.split('/')[2]) { + presenceData.details = 'Looking at best picks...' + presenceData.state = `The best picks for: '${pathname + .split('/')[3] + .replace('.html', '') + .replace('best-', '')}'` + } + else { + presenceData.details = 'Scrolling through best picks...' + } + } + else if (href.includes('coupons')) { + if (pathname.includes('?')) { + presenceData.details = 'Looking at a coupon...' + } + else if (pathname.split('/')[2]) { + presenceData.details = 'Looking at coupons...' + presenceData.state = `Coupons for: '${pathname + .split('/')[3] + .replace('.html', '')}'` + } + else { + presenceData.details = 'Scrolling through coupons...' + } + } + else if (href.includes('forums.')) { + if (pathname.includes('forums')) { + presenceData.state = `Category: '${pathname + .split('/')[2] + .split('.')[0] + .replace('.html', '')}'` + } + else if (pathname.includes('threads')) { + presenceData.state = `Category: '${pathname + .split('/')[2] + .split('.')[0] + .replace('.html', '')}'` + } + else if (pathname.includes('featured')) { + presenceData.state = 'Looking at featured threads...' + } + else if (pathname.includes('whats-new')) { + presenceData.state = 'Looking at new threads...' + } + else if (pathname.includes('members')) { + presenceData.state = 'Looking at members...' + } + else if (pathname.includes('help')) { + presenceData.state = 'Getting help...' + } + else if (pathname.includes('search')) { + presenceData.state = 'Searching the forums...' + } + else if (pathname.includes('billboard')) { + presenceData.state = 'Looking at the billboard...' + } + else if (pathname.includes('register')) { + presenceData.state = 'Registering an account...' + } - presenceData.details = "Visiting the forums..."; - } else if (href.includes("topics")) { - if (pathname.split("/")[3]) { - presenceData.state = `Subcategory: '${pathname - .split("/")[3] - .replace(".html", "")}'`; - } - presenceData.details = `Looking at the topic: ${pathname.split("/")[2]}`; - } else if (href.includes("feeds")) - presenceData.details = "Visiting the RSS page..."; - else if (href.includes("search")) { - if (pathname.split("=")[1]) { - presenceData.state = `Searching Term: '${pathname - .split("=")[1] - .replace(".html", "")}'`; - } - presenceData.details = "Searching the site..."; - } else if (pathname && pathname.length > 2) { - presenceData.details = "Browsing..."; - presenceData.state = `On the page '${pathname.split("/")[1]}'`; - } else presenceData.details = "Visiting the front page..."; + presenceData.details = 'Visiting the forums...' + } + else if (href.includes('topics')) { + if (pathname.split('/')[3]) { + presenceData.state = `Subcategory: '${pathname + .split('/')[3] + .replace('.html', '')}'` + } + presenceData.details = `Looking at the topic: ${pathname.split('/')[2]}` + } + else if (href.includes('feeds')) { + presenceData.details = 'Visiting the RSS page...' + } + else if (href.includes('search')) { + if (pathname.split('=')[1]) { + presenceData.state = `Searching Term: '${pathname + .split('=')[1] + .replace('.html', '')}'` + } + presenceData.details = 'Searching the site...' + } + else if (pathname && pathname.length > 2) { + presenceData.details = 'Browsing...' + presenceData.state = `On the page '${pathname.split('/')[1]}'` + } + else { + presenceData.details = 'Visiting the front page...' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/Toonily/iframe.ts b/websites/T/Toonily/iframe.ts index 9c7a9cf1fc1e..860592de6d68 100644 --- a/websites/T/Toonily/iframe.ts +++ b/websites/T/Toonily/iframe.ts @@ -1,12 +1,12 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", async () => { - const comment = document.querySelector("div.textarea"); - if (comment) { - iframe.send({ - writing: comment.textContent.length > 1, - details: "Writing Comment", - smallImageKey: Assets.Writing, - }); - } -}); +iframe.on('UpdateData', async () => { + const comment = document.querySelector('div.textarea') + if (comment) { + iframe.send({ + writing: comment.textContent && comment.textContent.length > 1, + details: 'Writing Comment', + smallImageKey: Assets.Writing, + }) + } +}) diff --git a/websites/T/Toonily/metadata.json b/websites/T/Toonily/metadata.json index e09803669069..d13fc7be2ce6 100644 --- a/websites/T/Toonily/metadata.json +++ b/websites/T/Toonily/metadata.json @@ -1,36 +1,36 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "वाह्य", - "id": "819696394180100106" - }, - "service": "Toonily", - "description": { - "en": "Read your favorite Manhua and Manhwa translated to English for free. Read Manga, Manhua, Manhwa Online, Free webtoon Online, Updated Daily!" - }, - "url": [ - "toonily.net", - "toonily.com" - ], - "version": "1.1.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Toonily/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Toonily/assets/thumbnail.png", - "color": "#2f063e", - "category": "other", - "tags": [ - "manga", - "english-translation", - "manhwa" - ], - "iframe": true, - "iFrameRegExp": ".*", - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "वाह्य", + "id": "819696394180100106" + }, + "service": "Toonily", + "description": { + "en": "Read your favorite Manhua and Manhwa translated to English for free. Read Manga, Manhua, Manhwa Online, Free webtoon Online, Updated Daily!" + }, + "url": [ + "toonily.net", + "toonily.com" + ], + "version": "1.1.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Toonily/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Toonily/assets/thumbnail.png", + "color": "#2f063e", + "category": "other", + "tags": [ + "manga", + "english-translation", + "manhwa" + ], + "iframe": true, + "iFrameRegExp": ".*", + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/T/Toonily/presence.ts b/websites/T/Toonily/presence.ts index 89fe8802c9f8..e42c83c0fc77 100644 --- a/websites/T/Toonily/presence.ts +++ b/websites/T/Toonily/presence.ts @@ -1,130 +1,146 @@ const presence = new Presence({ - clientId: "878203434468245545", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '878203434468245545', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) let data: { - writing: boolean; - details: string; - smallImageKey: string; -} = null; + writing: boolean + details: string + smallImageKey: string +} | null = null presence.on( - "iFrameData", - async (recievedData: { - writing: boolean; - details: string; - smallImageKey: string; - }) => { - data = recievedData; - } -); + 'iFrameData', + async (recievedData: unknown) => { + data = recievedData as typeof data + }, +) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Toonily/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, href, search, hostname } = document.location, - buttons = await presence.getSetting("buttons"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Toonily/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, href, search, hostname } = document.location + const buttons = await presence.getSetting('buttons') - if (document.querySelector("ul.search-main-menu.active")) { - const searchBar = document.querySelector( - "input.manga-search-field.ui-autocomplete-input" - ); - presenceData.details = "Searching"; - if (searchBar && searchBar.value) presenceData.state = searchBar.value; - presenceData.smallImageText = presenceData.smallImageKey = Assets.Search; - } else if (pathname === "/") { - if (search) { - const results = document.querySelector("h1.h4"); - presenceData.details = "Looking at"; - if (results) presenceData.state = results.textContent; - presenceData.smallImageText = presenceData.smallImageKey = Assets.Search; - } else presenceData.details = "At homepage"; - } else if ( - pathname === "/manga/" || - pathname.startsWith("/manga-genre/") || - pathname === "/webtoons" || - pathname.startsWith("/webtoon-genre/") || - pathname.startsWith("/webtoon-tag") - ) { - const order = document.querySelector( - "div.c-nav-tabs > ul > li.active" - ), - category = document.querySelector("h1.item-title.h4"); - presenceData.details = `Looking for ${ - (pathname.startsWith("/manga-genre") || - pathname.startsWith("/webtoon-genre") || - pathname.startsWith("/webtoon-tag")) && - category - ? category.textContent - : "" - } ${hostname.endsWith(".com") ? "Manhwas" : "Mangas"}`; - if (order) presenceData.state = `Ordered By ${order.textContent}`; - presenceData.smallImageText = presenceData.smallImageKey = Assets.Viewing; - } else if ( - pathname.startsWith("/manga/") || - pathname.startsWith("/webtoon/") - ) { - const title = document.querySelector( - "div.post-title > h1" - ), - chapterHeading = - document.querySelector("h1#chapter-heading"); - if (chapterHeading) { - const [title, chapter] = chapterHeading.textContent.split("-"); - presenceData.details = `Reading ${title}`; - if (data && data.writing) { - presenceData.state = data.details; - presenceData.smallImageText = presenceData.smallImageKey = - data.smallImageKey; - } else { - presenceData.state = chapter; - presenceData.smallImageText = presenceData.smallImageKey = - Assets.Reading; - } - if (buttons) { - presenceData.buttons = [ - { label: "Read Manga", url: href }, - { - label: "Read Summary", - url: href.substring(0, href.lastIndexOf("chapter")), - }, - ]; - } - } else if (location.hash) { - presenceData.details = title.textContent; - if (data && data.writing) { - presenceData.state = data.details; - presenceData.smallImageText = presenceData.smallImageKey = - data.smallImageKey; - } else { - presenceData.state = "Reading Commments"; - presenceData.smallImageText = presenceData.smallImageKey = - Assets.Reading; - } - if (buttons) - presenceData.buttons = [{ label: "See Comments", url: href }]; - } else { - presenceData.details = "Reading Summary"; - if (title) presenceData.state = title.textContent; - if (buttons) - presenceData.buttons = [{ label: "Read Summary", url: href }]; - } - } else if (pathname.startsWith("/user-settings")) { - const tab = document.querySelector("li.active"); - presenceData.details = "Viewing User Settings"; - if (tab) presenceData.state = tab.textContent; - } else if (pathname === "/legal-disclaimer/") - presenceData.details = "Legal Disclaimer"; - else if (pathname.startsWith("/privacy-policy")) - presenceData.details = "Privacy Policy"; - else if (pathname === "/about-us/") presenceData.details = "About Us"; - else if (pathname.startsWith("/contact")) presenceData.details = "Contact Us"; - else if (pathname === "/terms") presenceData.details = "Terms of Service"; + if (document.querySelector('ul.search-main-menu.active')) { + const searchBar = document.querySelector( + 'input.manga-search-field.ui-autocomplete-input', + ) + presenceData.details = 'Searching' + if (searchBar && searchBar.value) + presenceData.state = searchBar.value + presenceData.smallImageText = presenceData.smallImageKey = Assets.Search + } + else if (pathname === '/') { + if (search) { + const results = document.querySelector('h1.h4') + presenceData.details = 'Looking at' + if (results) + presenceData.state = results.textContent + presenceData.smallImageText = presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = 'At homepage' + } + } + else if ( + pathname === '/manga/' + || pathname.startsWith('/manga-genre/') + || pathname === '/webtoons' + || pathname.startsWith('/webtoon-genre/') + || pathname.startsWith('/webtoon-tag') + ) { + const order = document.querySelector( + 'div.c-nav-tabs > ul > li.active', + ) + const category = document.querySelector('h1.item-title.h4') + presenceData.details = `Looking for ${ + (pathname.startsWith('/manga-genre') + || pathname.startsWith('/webtoon-genre') + || pathname.startsWith('/webtoon-tag')) + && category + ? category.textContent + : '' + } ${hostname.endsWith('.com') ? 'Manhwas' : 'Mangas'}` + if (order) + presenceData.state = `Ordered By ${order.textContent}` + presenceData.smallImageText = presenceData.smallImageKey = Assets.Viewing + } + else if ( + pathname.startsWith('/manga/') + || pathname.startsWith('/webtoon/') + ) { + const title = document.querySelector( + 'div.post-title > h1', + ) + const chapterHeading = document.querySelector('h1#chapter-heading') + if (chapterHeading) { + const [title, chapter] = chapterHeading.textContent?.split('-') ?? [] + presenceData.details = `Reading ${title}` + if (data && data.writing) { + presenceData.state = data.details + presenceData.smallImageText = presenceData.smallImageKey = data.smallImageKey + } + else { + presenceData.state = chapter + presenceData.smallImageText = presenceData.smallImageKey = Assets.Reading + } + if (buttons) { + presenceData.buttons = [ + { label: 'Read Manga', url: href }, + { + label: 'Read Summary', + url: href.substring(0, href.lastIndexOf('chapter')), + }, + ] + } + } + else if (location.hash) { + presenceData.details = title?.textContent + if (data && data.writing) { + presenceData.state = data.details + presenceData.smallImageText = presenceData.smallImageKey = data.smallImageKey + } + else { + presenceData.state = 'Reading Commments' + presenceData.smallImageText = presenceData.smallImageKey = Assets.Reading + } + if (buttons) + presenceData.buttons = [{ label: 'See Comments', url: href }] + } + else { + presenceData.details = 'Reading Summary' + if (title) + presenceData.state = title.textContent + if (buttons) + presenceData.buttons = [{ label: 'Read Summary', url: href }] + } + } + else if (pathname.startsWith('/user-settings')) { + const tab = document.querySelector('li.active') + presenceData.details = 'Viewing User Settings' + if (tab) + presenceData.state = tab.textContent + } + else if (pathname === '/legal-disclaimer/') { + presenceData.details = 'Legal Disclaimer' + } + else if (pathname.startsWith('/privacy-policy')) { + presenceData.details = 'Privacy Policy' + } + else if (pathname === '/about-us/') { + presenceData.details = 'About Us' + } + else if (pathname.startsWith('/contact')) { + presenceData.details = 'Contact Us' + } + else if (pathname === '/terms') { + presenceData.details = 'Terms of Service' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TopFlix/iframe.ts b/websites/T/TopFlix/iframe.ts index 1b22d3761131..d04e369a9271 100644 --- a/websites/T/TopFlix/iframe.ts +++ b/websites/T/TopFlix/iframe.ts @@ -1,223 +1,235 @@ -const iframe = new iFrame(); -iframe.on("UpdateData", async () => { - let video: HTMLVideoElement; - if (document.querySelector("#dogevideo_html5_api")) { - video = document.querySelector("#dogevideo_html5_api"); +const iframe = new iFrame() +iframe.on('UpdateData', async () => { + if (document.querySelector('#dogevideo_html5_api')) { + const video = document.querySelector('#dogevideo_html5_api') - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if ( - document.querySelector( - "#player > div > div.container.pointer-enabled > video" - ) - ) { - video = document.querySelector( - "#player > div > div.container.pointer-enabled > video" - ); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if ( + document.querySelector( + '#player > div > div.container.pointer-enabled > video', + ) + ) { + const video = document.querySelector( + '#player > div > div.container.pointer-enabled > video', + ) - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if ( - document.querySelector( - "#mediaplayer > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video" - ) - ) { - video = document.querySelector( - "#mediaplayer > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video" - ); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if ( + document.querySelector( + '#mediaplayer > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video', + ) + ) { + const video = document.querySelector( + '#mediaplayer > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video', + ) - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if (document.querySelector("#vid_html5_api")) { - video = document.querySelector("#vid_html5_api"); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if (document.querySelector('#vid_html5_api')) { + const video = document.querySelector('#vid_html5_api') - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if ( - document.querySelector("#myElement > div.jw-media.jw-reset > video") - ) { - video = document.querySelector( - "#myElement > div.jw-media.jw-reset > video" - ); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if ( + document.querySelector('#myElement > div.jw-media.jw-reset > video') + ) { + const video = document.querySelector( + '#myElement > div.jw-media.jw-reset > video', + ) - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if (document.querySelector("#mgvideo > div.vjs-poster")) { - video = document.querySelector("#mgvideo > div.vjs-poster"); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if (document.querySelector('#mgvideo > div.vjs-poster')) { + const video = document.querySelector('#mgvideo > div.vjs-poster') - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if (document.querySelector("#olvideo_html5_api")) { - video = document.querySelector("#olvideo_html5_api"); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if (document.querySelector('#olvideo_html5_api')) { + const video = document.querySelector('#olvideo_html5_api') - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if (document.querySelector("#videojs_html5_api")) { - video = document.querySelector("#videojs_html5_api"); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if (document.querySelector('#videojs_html5_api')) { + const video = document.querySelector('#videojs_html5_api') - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if ( - document.querySelector( - "#myVideo > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video" - ) - ) { - video = document.querySelector( - "#myVideo > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video" - ); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if ( + document.querySelector( + '#myVideo > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video', + ) + ) { + const video = document.querySelector( + '#myVideo > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video', + ) - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if (document.querySelector("#mgvideo_html5_api")) { - video = document.querySelector("#mgvideo_html5_api"); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if (document.querySelector('#mgvideo_html5_api')) { + const video = document.querySelector('#mgvideo_html5_api') - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if ( - document.querySelector("#player > div.jw-media.jw-reset > video") - ) { - video = document.querySelector("#player > div.jw-media.jw-reset > video"); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if ( + document.querySelector('#player > div.jw-media.jw-reset > video') + ) { + const video = document.querySelector('#player > div.jw-media.jw-reset > video') - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if ( - document.querySelector( - "#vstr > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video" - ) - ) { - video = document.querySelector( - "#vstr > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video" - ); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if ( + document.querySelector( + '#vstr > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video', + ) + ) { + const video = document.querySelector( + '#vstr > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video', + ) - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if ( - document.querySelector( - "#player > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video" - ) - ) { - video = document.querySelector( - "#player > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video" - ); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if ( + document.querySelector( + '#player > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video', + ) + ) { + const video = document.querySelector( + '#player > div.jw-wrapper.jw-reset > div.jw-media.jw-reset > video', + ) - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } else if (document.querySelector(".video")) { - video = document.querySelector(".video"); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } + else if (document.querySelector('.video')) { + const video = document.querySelector('.video') - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } -}); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } +}) diff --git a/websites/T/TopFlix/metadata.json b/websites/T/TopFlix/metadata.json index 70e2bad52b4b..0acc4bd7ead9 100644 --- a/websites/T/TopFlix/metadata.json +++ b/websites/T/TopFlix/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "TopFlix", - "description": { - "en": "TopFlix - Watch Free HD Movies Online", - "nl": "TopFlix - Bekijk gratis online HD-films", - "pt_BR": "TopFlix - Assistir filmes online grátis HD" - }, - "url": "topflix.tv", - "version": "1.0.27", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TopFlix/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TopFlix/assets/thumbnail.png", - "color": "#df003f", - "category": "videos", - "tags": [ - "series", - "anime", - "movies" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "TopFlix", + "description": { + "en": "TopFlix - Watch Free HD Movies Online", + "nl": "TopFlix - Bekijk gratis online HD-films", + "pt_BR": "TopFlix - Assistir filmes online grátis HD" + }, + "url": "topflix.tv", + "version": "1.0.27", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TopFlix/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TopFlix/assets/thumbnail.png", + "color": "#df003f", + "category": "videos", + "tags": [ + "series", + "anime", + "movies" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git a/websites/T/TopFlix/presence.ts b/websites/T/TopFlix/presence.ts index 9194ebee5981..fcbb49b135dd 100644 --- a/websites/T/TopFlix/presence.ts +++ b/websites/T/TopFlix/presence.ts @@ -1,126 +1,144 @@ const presence = new Presence({ - clientId: "684410680392286247", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - search: "general.searching", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '684410680392286247', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', + search: 'general.searching', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) let iFrameVideo: boolean, - currentTime: number, - duration: number, - playback: boolean; + currentTime: number, + duration: number, + playback: boolean presence.on( - "iFrameData", - (data: { - iframeVideo: { - duration: number; - iFrameVideo?: boolean; - currentTime?: number; - }; - }) => { - playback = data.iframeVideo.duration ? true : false; + 'iFrameData', + (inc: unknown) => { + const data = inc as { + iframeVideo: { + duration: number + iFrameVideo: boolean + currentTime: number + } + } + playback = !!data.iframeVideo.duration - if (playback) ({ iFrameVideo, currentTime, duration } = data.iframeVideo); - } -); + if (playback) + ({ iFrameVideo, currentTime, duration } = data.iframeVideo) + }, +) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TopFlix/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TopFlix/assets/logo.png', + } - let title; + let title - presenceData.startTimestamp = browsingTimestamp; + presenceData.startTimestamp = browsingTimestamp - if (document.location.pathname.includes("/serie")) { - title = document.querySelector(".bd-hd"); + if (document.location.pathname.includes('/serie')) { + title = document.querySelector('.bd-hd') - if (title) { - title = title.textContent.replace( - document.querySelector(".bd-hd > span").textContent, - "" - ); + if (title) { + title = title.textContent?.replace( + document.querySelector('.bd-hd > span')?.textContent ?? '', + '', + ) - const season = document.querySelector(".accordion > li.open > div"); + const season = document.querySelector('.accordion > li.open > div') - if ( - document - .querySelector(".tabs > ul > li.active") - .textContent.includes("Temporadas") && - season - ) { - if (document.querySelector("body > .modal.fade.in")) { - presenceData.details = title; - presenceData.state = season.textContent; + if ( + document + .querySelector('.tabs > ul > li.active') + ?.textContent + ?.includes('Temporadas') + && season + ) { + if (document.querySelector('body > .modal.fade.in')) { + presenceData.details = title + presenceData.state = season.textContent - if (iFrameVideo === true && !isNaN(duration)) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - Math.floor(currentTime), - Math.floor(duration) - ); - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = (await strings).play; - } else { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = (await strings).pause; - } - } else { - presenceData.details = `Vendo temporada ${season.textContent.replace( - "ª Temporada", - "" - )} da série:`; - presenceData.state = title; - } - } else { - presenceData.details = "Vendo série:"; - presenceData.state = title; - } - } else presenceData.details = "Navegando pelas séries..."; - } else if (document.location.pathname.includes("/filme")) { - title = document.querySelector(".bd-hd"); - if (title) { - const year = document.querySelector(".bd-hd > span"); - let rating = document.querySelector(".rate > p > span").textContent; - rating = `${rating}/10`; - title = title.textContent.replace(year.textContent, ""); + if (iFrameVideo === true && !Number.isNaN(duration)) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + Math.floor(currentTime), + Math.floor(duration), + ) + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = (await strings).play + } + else { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = (await strings).pause + } + } + else { + presenceData.details = `Vendo temporada ${season.textContent?.replace( + 'ª Temporada', + '', + )} da série:` + presenceData.state = title + } + } + else { + presenceData.details = 'Vendo série:' + presenceData.state = title + } + } + else { + presenceData.details = 'Navegando pelas séries...' + } + } + else if (document.location.pathname.includes('/filme')) { + title = document.querySelector('.bd-hd') + if (title) { + const year = document.querySelector('.bd-hd > span') + let rating = document.querySelector('.rate > p > span')?.textContent + rating = `${rating}/10` + title = title.textContent?.replace(year?.textContent ?? '', '') - if (document.querySelector("body > .modal.fade.in")) { - presenceData.details = title; - presenceData.state = `${year.textContent} - ${rating}`; + if (document.querySelector('body > .modal.fade.in')) { + presenceData.details = title + presenceData.state = `${year?.textContent} - ${rating}` - if (iFrameVideo === true && !isNaN(duration)) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - Math.floor(currentTime), - Math.floor(duration) - ); - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = (await strings).play; - } else { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = (await strings).pause; - } - } else { - presenceData.details = "Vendo filme:"; - presenceData.state = title; - } - } else presenceData.details = "Navegando pelos filmes..."; - } else if (document.location.pathname.includes("/lancamentos")) - presenceData.details = "Navegando lançamentos..."; - else if (document.location.pathname.includes("/app")) - presenceData.details = "Vendo os aplicativos"; - else if (document.location.pathname.includes("/imdb")) - presenceData.details = "Navegando IMDb..."; - else if (document.location.pathname === "/") - presenceData.details = "Navegando..."; + if (iFrameVideo === true && !Number.isNaN(duration)) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + Math.floor(currentTime), + Math.floor(duration), + ) + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = (await strings).play + } + else { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = (await strings).pause + } + } + else { + presenceData.details = 'Vendo filme:' + presenceData.state = title + } + } + else { + presenceData.details = 'Navegando pelos filmes...' + } + } + else if (document.location.pathname.includes('/lancamentos')) { + presenceData.details = 'Navegando lançamentos...' + } + else if (document.location.pathname.includes('/app')) { + presenceData.details = 'Vendo os aplicativos' + } + else if (document.location.pathname.includes('/imdb')) { + presenceData.details = 'Navegando IMDb...' + } + else if (document.location.pathname === '/') { + presenceData.details = 'Navegando...' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Toradora Wikia/metadata.json b/websites/T/Toradora Wikia/metadata.json index 89605792e23e..391fd865aee4 100644 --- a/websites/T/Toradora Wikia/metadata.json +++ b/websites/T/Toradora Wikia/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "CRUGG", - "id": "228965621478588416" - }, - "service": "Toradora Wikia", - "description": { - "en": "Presence for the english & german wikias of the anime Toradora!", - "de": "Präsenz für die englischen & deutschen Wikias über den Anime Toradora!", - "nl": "Aanwezigheid voor de Engelse en Duitse wikia's van de anime Toradora!" - }, - "url": [ - "tora-dora.fandom.com", - "toradora.fandom.com" - ], - "version": "1.1.26", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Toradora%20Wikia/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Toradora%20Wikia/assets/thumbnail.png", - "color": "#F9304B", - "category": "anime", - "tags": [ - "anime", - "toradora", - "wikia" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "CRUGG", + "id": "228965621478588416" + }, + "service": "Toradora Wikia", + "description": { + "en": "Presence for the english & german wikias of the anime Toradora!", + "de": "Präsenz für die englischen & deutschen Wikias über den Anime Toradora!", + "nl": "Aanwezigheid voor de Engelse en Duitse wikia's van de anime Toradora!" + }, + "url": [ + "tora-dora.fandom.com", + "toradora.fandom.com" + ], + "version": "1.1.26", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Toradora%20Wikia/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Toradora%20Wikia/assets/thumbnail.png", + "color": "#F9304B", + "category": "anime", + "tags": [ + "anime", + "toradora", + "wikia" + ] +} diff --git a/websites/T/Toradora Wikia/presence.ts b/websites/T/Toradora Wikia/presence.ts index 6d60465470ac..7cfa73679c67 100644 --- a/websites/T/Toradora Wikia/presence.ts +++ b/websites/T/Toradora Wikia/presence.ts @@ -4,55 +4,55 @@ */ const presence = new Presence({ - clientId: "613417749489778689", - }), - germanPresence = new Presence({ - clientId: "613418400042975329", - }); + clientId: '613417749489778689', +}) +const germanPresence = new Presence({ + clientId: '613418400042975329', +}) -presence.on("UpdateData", async () => { - if ( - document.location.href.includes("tora-dora.fandom.com") && // English Wiki - document.location.pathname.startsWith("/wiki/") - ) { - // Making 100% sure it's the english wiki - let page = "N/A"; - try { - page = document.querySelectorAll(".page-header__title")[0].textContent; - } catch (err) { - presence.info( - `An error occured in the PreMiD Presence, please send this to CRUGG#0001 ::: TWIKI_WIKIEN_GETPAGETITLE ::: ${err}` - ); - } +presence.on('UpdateData', async () => { + if ( + document.location.href.includes('tora-dora.fandom.com') // English Wiki + && document.location.pathname.startsWith('/wiki/') + ) { + // Making 100% sure it's the english wiki + let page = 'N/A' + try { + page = document.querySelectorAll('.page-header__title')[0].textContent ?? 'N/A' + } + catch (err) { + presence.info( + `An error occured in the PreMiD Presence, please send this to CRUGG#0001 ::: TWIKI_WIKIEN_GETPAGETITLE ::: ${err}`, + ) + } - presence.setActivity({ - details: "Viewing a page...", - state: page, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Toradora%20Wikia/assets/logo.png", - }); - } - germanPresence.on("UpdateData", async () => { - if ( - document.location.href.includes("toradora.fandom.com") && // German Wiki - document.location.pathname.startsWith("/de/wiki/") - ) { - // Making 100% sure it's the german wiki - let page = "N/A"; - try { - page = document.querySelectorAll(".page-header__title")[0].textContent; - } catch (err) { - germanPresence.info( - `An error occured in the PreMiD Presence, please send this to CRUGG#0001 ::: TWIKI_WIKIDE_GETPAGETITLE ::: ${err}` - ); - } + presence.setActivity({ + details: 'Viewing a page...', + state: page, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Toradora%20Wikia/assets/logo.png', + }) + } + germanPresence.on('UpdateData', async () => { + if ( + document.location.href.includes('toradora.fandom.com') // German Wiki + && document.location.pathname.startsWith('/de/wiki/') + ) { + // Making 100% sure it's the german wiki + let page = 'N/A' + try { + page = document.querySelectorAll('.page-header__title')[0].textContent ?? 'N/A' + } + catch (err) { + germanPresence.info( + `An error occured in the PreMiD Presence, please send this to CRUGG#0001 ::: TWIKI_WIKIDE_GETPAGETITLE ::: ${err}`, + ) + } - germanPresence.setActivity({ - details: "Schaut eine Seite an...", - state: page, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Toradora%20Wikia/assets/logo.png", - }); - } - }); -}); + germanPresence.setActivity({ + details: 'Schaut eine Seite an...', + state: page, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Toradora%20Wikia/assets/logo.png', + }) + } + }) +}) diff --git a/websites/T/Touhou Wiki/metadata.json b/websites/T/Touhou Wiki/metadata.json index 7cf27dd18c4d..c594edcc1226 100644 --- a/websites/T/Touhou Wiki/metadata.json +++ b/websites/T/Touhou Wiki/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "fror", - "id": "515668127829458945" - }, - "service": "Touhou Wiki", - "description": { - "en": "Touhou Wiki covers the official Touhou Project games and materials and any fan-made games and media, along with other related games developed by the former members of Amusement Makers or in conjunction with Team Shanghai Alice.", - "nl": "Touhou Wiki behandelt de officiële spellen en materialen van het Touhou Project en alle door fans gemaakte spellen en media, samen met andere gerelateerde spellen die zijn ontwikkeld door de voormalige leden van Amusement Makers of in samenwerking met Team Shanghai Alice." - }, - "url": "touhouwiki.net", - "regExp": "([a-z0-9-]+[.])*touhouwiki[.]net[/]", - "version": "1.3.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Touhou%20Wiki/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Touhou%20Wiki/assets/thumbnail.png", - "color": "#9B0101", - "category": "games", - "tags": [ - "wiki", - "touhou-project", - "touhou", - "東方project", - "video-game-encyclopedia", - "encyclopedia" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "fror", + "id": "515668127829458945" + }, + "service": "Touhou Wiki", + "description": { + "en": "Touhou Wiki covers the official Touhou Project games and materials and any fan-made games and media, along with other related games developed by the former members of Amusement Makers or in conjunction with Team Shanghai Alice.", + "nl": "Touhou Wiki behandelt de officiële spellen en materialen van het Touhou Project en alle door fans gemaakte spellen en media, samen met andere gerelateerde spellen die zijn ontwikkeld door de voormalige leden van Amusement Makers of in samenwerking met Team Shanghai Alice." + }, + "url": "touhouwiki.net", + "regExp": "([a-z0-9-]+[.])*touhouwiki[.]net[/]", + "version": "1.3.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Touhou%20Wiki/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Touhou%20Wiki/assets/thumbnail.png", + "color": "#9B0101", + "category": "games", + "tags": [ + "wiki", + "touhou-project", + "touhou", + "東方project", + "video-game-encyclopedia", + "encyclopedia" + ] +} diff --git a/websites/T/Touhou Wiki/presence.ts b/websites/T/Touhou Wiki/presence.ts index c2ad7e883589..6d4866811354 100644 --- a/websites/T/Touhou Wiki/presence.ts +++ b/websites/T/Touhou Wiki/presence.ts @@ -1,57 +1,60 @@ const presence = new Presence({ - clientId: "651135297756856339", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '651135297756856339', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let title; -const actionURL = new URL(document.location.href), - title2URL = new URL(document.location.href); +let title +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/T/Touhou%20Wiki/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Touhou%20Wiki/assets/logo.png', + } - title = document.querySelector("h1#firstHeading"); - const actionResult = actionURL.searchParams.get("action"), - title2Result = title2URL.searchParams.get("title"); - if ( - document.location.pathname === "/wiki/Touhou_Wiki" || - document.location.pathname === "/wiki/Заглавная_страница" || - document.location.pathname === "/wiki/东方维基" || - document.location.pathname === "/wiki/동방위키:대문" - ) { - presenceData.state = "Main Page | Home"; - presenceData.startTimestamp = browsingTimestamp; - } else if (title && document.location.pathname.includes("/wiki/")) { - presenceData.details = "Reading about:"; - presenceData.state = title.textContent; - presenceData.startTimestamp = browsingTimestamp; - } 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; + title = document.querySelector('h1#firstHeading') + const actionResult = actionURL.searchParams.get('action') + const title2Result = title2URL.searchParams.get('title') + if ( + document.location.pathname === '/wiki/Touhou_Wiki' + || document.location.pathname === '/wiki/Заглавная_страница' + || document.location.pathname === '/wiki/东方维基' + || document.location.pathname === '/wiki/동방위키:대문' + ) { + presenceData.state = 'Main Page | Home' + presenceData.startTimestamp = browsingTimestamp + } + else if (title && document.location.pathname.includes('/wiki/')) { + presenceData.details = 'Reading about:' + presenceData.state = title.textContent + presenceData.startTimestamp = browsingTimestamp + } + 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 - presenceData.startTimestamp = browsingTimestamp; - } 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; + presenceData.startTimestamp = browsingTimestamp + } + 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 - presenceData.startTimestamp = browsingTimestamp; - } + presenceData.startTimestamp = browsingTimestamp + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Town of Salem/metadata.json b/websites/T/Town of Salem/metadata.json index 2c518611d07c..0664b2254634 100644 --- a/websites/T/Town of Salem/metadata.json +++ b/websites/T/Town of Salem/metadata.json @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "theusaf", - "id": "193714715631812608" - }, - "service": "Town of Salem", - "description": { - "en": "Town of Salem is a browser-based game that challenges players on their ability to convincingly lie as well as detect when other players are lying.", - "nl": "Town of Salem is een browsergebaseerd spel dat spelers uitdaagt op hun vermogen om overtuigend te liegen en om te detecteren wanneer andere spelers liegen." - }, - "url": [ - "blankmediagames.com", - "www.blankmediagames.com" - ], - "version": "1.1.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/thumbnail.jpg", - "color": "#F0B450", - "category": "games", - "tags": [ - "mafia", - "town", - "game", - "deception", - "popular", - "mafia", - "salem" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "theusaf", + "id": "193714715631812608" + }, + "service": "Town of Salem", + "description": { + "en": "Town of Salem is a browser-based game that challenges players on their ability to convincingly lie as well as detect when other players are lying.", + "nl": "Town of Salem is een browsergebaseerd spel dat spelers uitdaagt op hun vermogen om overtuigend te liegen en om te detecteren wanneer andere spelers liegen." + }, + "url": [ + "blankmediagames.com", + "www.blankmediagames.com" + ], + "version": "1.1.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/thumbnail.jpg", + "color": "#F0B450", + "category": "games", + "tags": [ + "mafia", + "town", + "game", + "deception", + "popular", + "mafia", + "salem" + ] +} diff --git a/websites/T/Town of Salem/presence.ts b/websites/T/Town of Salem/presence.ts index e159ceff387f..b519ca7c197d 100644 --- a/websites/T/Town of Salem/presence.ts +++ b/websites/T/Town of Salem/presence.ts @@ -1,142 +1,147 @@ const presence = new Presence({ - clientId: "754771926857285782", -}); + clientId: '754771926857285782', +}) const enum Assets { - Day = "https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/0.png", - Discussion = "https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/1.png", - Night = "https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/2.png", - Voting = "https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/3.png", - Judgement = "https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/4.png", - Defense = "https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/5.png", - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/logo.jpg", + Day = 'https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/0.png', + Discussion = 'https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/1.png', + Night = 'https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/2.png', + Voting = 'https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/3.png', + Judgement = 'https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/4.png', + Defense = 'https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/5.png', + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Town%20of%20Salem/assets/logo.jpg', } enum GameState { - Night = "night", - Day = "day", - End = "end", - AfterGame = "afterGame", - PreGame = "preGame", + Night = 'night', + Day = 'day', + End = 'end', + AfterGame = 'afterGame', + PreGame = 'preGame', } enum GameType { - Classic = "Classic", - Ranked = "Ranked", + Classic = 'Classic', + Ranked = 'Ranked', } interface GameData { - scene: string; - page: string; - day: number; - gameMode: string; - state: GameState; + scene?: string + page?: string + day: number + gameMode?: string + state: GameState } interface Log { - content: string; - id: number; + content: string + id: number } const gameTypeNames: Record = { - RankedPractice: "Ranked Practice", - RapidMode: "Custom Rapid Mode", - DraculasPalace: "Dracula's Palace", - ClassicTownTraitor: "Town Traitor", - CovenClassic: "Classic Coven", - CovenRankedPractice: "Coven Ranked Practice", - CovenMafia: "Mafia Returns", - CovenCustom: "Custom Coven", - CovenTownTraitor: "Coven Town Traitor", - CovenAllAny: "Coven All Any", - AllAny: "All Any", - }, - oldState: GameData = { - scene: "BigLogin", - page: "", - day: 1, - gameMode: GameType.Classic, - state: GameState.Day, - }, - currentState = Object.assign({}, oldState); + RankedPractice: 'Ranked Practice', + RapidMode: 'Custom Rapid Mode', + DraculasPalace: 'Dracula\'s Palace', + ClassicTownTraitor: 'Town Traitor', + CovenClassic: 'Classic Coven', + CovenRankedPractice: 'Coven Ranked Practice', + CovenMafia: 'Mafia Returns', + CovenCustom: 'Custom Coven', + CovenTownTraitor: 'Coven Town Traitor', + CovenAllAny: 'Coven All Any', + AllAny: 'All Any', +} +const oldState: GameData = { + scene: 'BigLogin', + page: '', + day: 1, + gameMode: GameType.Classic, + state: GameState.Day, +} +const currentState = Object.assign({}, oldState) -let elapsed = Math.round(Date.now() / 1000), - lastId: number = null; +let elapsed = Math.round(Date.now() / 1000) +let lastId: number | null = null function handleLog(log: string) { - if ( - log.startsWith("Switched to ") || - log.startsWith("Switched additively to") - ) { - const scene = log - .match(/^Switched(?: additively)? to(?: scene)? (.*) Scene/m)[1] - .trim(); - currentState.scene = scene; - if (scene === "BigPreGame") currentState.state = GameState.PreGame; - } else if (log.startsWith("Entered HomeSceneController.ShowView()")) { - currentState.page = log - .match( - /^Entered HomeSceneController.ShowView\(\) - View passed in: (.*)$/m - )[1] - .trim(); - } else if (log.startsWith("Entered ")) { - switch (log.match(/^Entered (.*)$/m)[1].trim()) { - case "HandleStartRanked": { - currentState.scene = "BigLobby"; - currentState.gameMode = GameType.Ranked; - break; - } - case "HandleOnLeaveRankedQueue": { - currentState.scene = "BigHome"; - currentState.gameMode = GameType.Classic; - break; - } - } - } else if (log.startsWith("Creating lobby:")) - currentState.gameMode = log.match(/^Creating lobby: (.*?) \|/)[1]; - else if (/\[Network\] \[Received\] /.test(log)) { - const action = log.match( - /\[Network\] \[Received\] (.*?)<\/b>/ - )[1]; - switch (action) { - case "PickNames": - case "RoleAndPosition": { - currentState.page = action; - currentState.state = GameState.PreGame; - break; - } - case "StartFirstDay": { - currentState.day = 1; - currentState.state = GameState.Day; - currentState.page = "StartDiscussion"; - break; - } - case "StartDay": { - currentState.day++; - currentState.state = GameState.Day; - currentState.page = ""; - break; - } - case "StartNight": { - currentState.state = GameState.Night; - currentState.page = ""; - break; - } - case "FullMoonNight": - case "StartDiscussion": - case "StartDefense": - case "StartJudgement": - case "StartVoting": - case "WhoDiedAndHow": { - currentState.page = action; - break; - } - case "SomeoneHasWon": { - currentState.state = GameState.End; - break; - } - } - } + if ( + log.startsWith('Switched to ') + || log.startsWith('Switched additively to') + ) { + const scene = log + .match(/^Switched(?: additively)? to(?: scene)? (.*) Scene/m)?.[1] + .trim() + currentState.scene = scene + if (scene === 'BigPreGame') + currentState.state = GameState.PreGame + } + else if (log.startsWith('Entered HomeSceneController.ShowView()')) { + currentState.page = log + .match( + /^Entered HomeSceneController.ShowView\(\) - View passed in: (.*)$/m, + )?.[1] + .trim() + } + else if (log.startsWith('Entered ')) { + switch (log.match(/^Entered (.*)$/m)?.[1].trim()) { + case 'HandleStartRanked': { + currentState.scene = 'BigLobby' + currentState.gameMode = GameType.Ranked + break + } + case 'HandleOnLeaveRankedQueue': { + currentState.scene = 'BigHome' + currentState.gameMode = GameType.Classic + break + } + } + } + else if (log.startsWith('Creating lobby:')) { + currentState.gameMode = log.match(/^Creating lobby: (.*?) \|/)?.[1] + } + else if (/\[Network\] \[Received\] /.test(log)) { + const action = log.match( + /\[Network\] \[Received\] (.*?)<\/b>/, + )?.[1] + switch (action) { + case 'PickNames': + case 'RoleAndPosition': { + currentState.page = action + currentState.state = GameState.PreGame + break + } + case 'StartFirstDay': { + currentState.day = 1 + currentState.state = GameState.Day + currentState.page = 'StartDiscussion' + break + } + case 'StartDay': { + currentState.day++ + currentState.state = GameState.Day + currentState.page = '' + break + } + case 'StartNight': { + currentState.state = GameState.Night + currentState.page = '' + break + } + case 'FullMoonNight': + case 'StartDiscussion': + case 'StartDefense': + case 'StartJudgement': + case 'StartVoting': + case 'WhoDiedAndHow': { + currentState.page = action + break + } + case 'SomeoneHasWon': { + currentState.state = GameState.End + break + } + } + } } /** @@ -144,171 +149,172 @@ function handleLog(log: string) { * Built-in readLogs causes performance problems, as hundreds of logs can be created in half a second. * It is also hard to determine which logs have not been read yet. */ -const injectedLoggerScript = document.createElement("script"); -injectedLoggerScript.type = "text/javascript"; +const injectedLoggerScript = document.createElement('script') +injectedLoggerScript.type = 'text/javascript' injectedLoggerScript.textContent = ` { - let counter = 0; - console.stdlog = console.log.bind(console); - console.logs = []; - console.log = function() { - const log = arguments[0]; - if (/^Switched |^Entered |^Creating |\\[Network\\] \\[Received\\] /.test(log)) { - console.logs.push({ - content: log, - id: counter, - }); - counter++; - if (counter > 10000) counter = 0; - } - while (console.logs.length > 100) console.logs.shift(); - console.stdlog.apply(console, arguments); - }; + let counter = 0; + console.stdlog = console.log.bind(console); + console.logs = []; + console.log = function() { + const log = arguments[0]; + if (/^Switched |^Entered |^Creating |\\[Network\\] \\[Received\\] /.test(log)) { + console.logs.push({ + content: log, + id: counter, + }); + counter++; + if (counter > 10000) counter = 0; + } + while (console.logs.length > 100) console.logs.shift(); + console.stdlog.apply(console, arguments); + }; } -`; -document.head.appendChild(injectedLoggerScript); +` +document.head.appendChild(injectedLoggerScript) setInterval(async () => { - const logs: Log[] = await presence.getPageletiable('console"]["logs'); - let lastUnreadLogIndex = 0; - for (let i = logs.length - 1; i >= 0; i--) { - if (logs[i].id === lastId) { - lastUnreadLogIndex = i + 1; - break; - } - } - for (let i = lastUnreadLogIndex; i < logs.length; i++) - handleLog(logs[i].content); - if (logs.length > 0) lastId = logs[logs.length - 1].id; -}, 1000); + const logs: Log[] = await presence.getPageletiable('console"]["logs') + let lastUnreadLogIndex = 0 + for (let i = logs.length - 1; i >= 0; i--) { + if (logs[i].id === lastId) { + lastUnreadLogIndex = i + 1 + break + } + } + for (let i = lastUnreadLogIndex; i < logs.length; i++) + handleLog(logs[i].content) + if (logs.length > 0) + lastId = logs[logs.length - 1].id +}, 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } - if (window.location.pathname !== "/TownOfSalem/") { - presenceData.details = "Browsing BlankMediaGames"; - presenceData.state = document.title; - presenceData.startTimestamp = elapsed; - } else { - if (oldState.scene !== currentState.scene) - elapsed = Math.round(Date.now() / 1000); - presenceData.startTimestamp = elapsed; - Object.assign(oldState, currentState); - switch (currentState.scene) { - case "BigLogin": { - presenceData.details = "Logging in"; - break; - } - case "BigHome": { - switch (currentState.page) { - case "GameModeSelect": { - presenceData.details = "Selecting Game Mode"; - break; - } - case "Customization": { - presenceData.details = "Customizing Character"; - break; - } - case "Party": { - presenceData.details = "In a Party"; - break; - } - default: { - presenceData.details = "Browsing Main Menu"; - presenceData.state = currentState.page; - } - } - break; - } - case "BigLobby": { - presenceData.details = "Waiting in a Lobby"; - presenceData.state = - gameTypeNames[currentState.gameMode] ?? currentState.gameMode; - break; - } - case "BigPreGame": { - presenceData.details = "Loading Game"; - presenceData.state = - gameTypeNames[currentState.gameMode] ?? currentState.gameMode; - break; - } - case "BigGame": { - presenceData.details = `Playing a ${ - gameTypeNames[currentState.gameMode] ?? currentState.gameMode - } Game`; - switch (currentState.state) { - case GameState.PreGame: { - switch (currentState.page) { - case "PickNames": { - presenceData.state = "Choosing Names"; - break; - } - case "RoleAndPosition": { - presenceData.state = "Getting a Role"; - break; - } - } - break; - } - case GameState.Day: { - presenceData.smallImageKey = Assets.Day; - switch (currentState.page) { - case "StartDiscussion": { - presenceData.state = `Discussion | Day ${currentState.day}`; - presenceData.smallImageKey = Assets.Discussion; - break; - } - case "StartVoting": { - presenceData.state = `Voting | Day ${currentState.day}`; - presenceData.smallImageKey = Assets.Voting; - break; - } - case "WhoDiedAndHow": { - presenceData.state = `Viewing a Death | Day ${currentState.day}`; - break; - } - case "StartDefense": { - presenceData.state = `Defense | Day ${currentState.day}`; - presenceData.smallImageKey = Assets.Defense; - break; - } - case "StartJudgement": { - presenceData.state = `Judgement | Day ${currentState.day}`; - presenceData.smallImageKey = Assets.Judgement; - break; - } - default: { - presenceData.state = `Day ${currentState.day}`; - } - } - break; - } - case GameState.Night: { - presenceData.smallImageKey = Assets.Night; - if (currentState.page === "FullMoonNight") - presenceData.state = `Night ${currentState.day} (Full Moon)`; - else presenceData.state = `Night ${currentState.day}`; - break; - } - case GameState.End: { - presenceData.state = "Viewing End Screen"; - break; - } - } - break; - } - case "BigEndGame": { - presenceData.details = `Playing a ${ - gameTypeNames[currentState.gameMode] ?? currentState.gameMode - } Game`; - presenceData.state = "Viewing After Game Screen"; - break; - } - } - } + if (window.location.pathname !== '/TownOfSalem/') { + presenceData.details = 'Browsing BlankMediaGames' + presenceData.state = document.title + presenceData.startTimestamp = elapsed + } + else { + if (oldState.scene !== currentState.scene) + elapsed = Math.round(Date.now() / 1000) + presenceData.startTimestamp = elapsed + Object.assign(oldState, currentState) + switch (currentState.scene) { + case 'BigLogin': { + presenceData.details = 'Logging in' + break + } + case 'BigHome': { + switch (currentState.page) { + case 'GameModeSelect': { + presenceData.details = 'Selecting Game Mode' + break + } + case 'Customization': { + presenceData.details = 'Customizing Character' + break + } + case 'Party': { + presenceData.details = 'In a Party' + break + } + default: { + presenceData.details = 'Browsing Main Menu' + presenceData.state = currentState.page + } + } + break + } + case 'BigLobby': { + presenceData.details = 'Waiting in a Lobby' + presenceData.state = gameTypeNames[currentState.gameMode!] ?? currentState.gameMode + break + } + case 'BigPreGame': { + presenceData.details = 'Loading Game' + presenceData.state = gameTypeNames[currentState.gameMode!] ?? currentState.gameMode + break + } + case 'BigGame': { + presenceData.details = `Playing a ${ + gameTypeNames[currentState.gameMode!] ?? currentState.gameMode + } Game` + switch (currentState.state) { + case GameState.PreGame: { + switch (currentState.page) { + case 'PickNames': { + presenceData.state = 'Choosing Names' + break + } + case 'RoleAndPosition': { + presenceData.state = 'Getting a Role' + break + } + } + break + } + case GameState.Day: { + presenceData.smallImageKey = Assets.Day + switch (currentState.page) { + case 'StartDiscussion': { + presenceData.state = `Discussion | Day ${currentState.day}` + presenceData.smallImageKey = Assets.Discussion + break + } + case 'StartVoting': { + presenceData.state = `Voting | Day ${currentState.day}` + presenceData.smallImageKey = Assets.Voting + break + } + case 'WhoDiedAndHow': { + presenceData.state = `Viewing a Death | Day ${currentState.day}` + break + } + case 'StartDefense': { + presenceData.state = `Defense | Day ${currentState.day}` + presenceData.smallImageKey = Assets.Defense + break + } + case 'StartJudgement': { + presenceData.state = `Judgement | Day ${currentState.day}` + presenceData.smallImageKey = Assets.Judgement + break + } + default: { + presenceData.state = `Day ${currentState.day}` + } + } + break + } + case GameState.Night: { + presenceData.smallImageKey = Assets.Night + if (currentState.page === 'FullMoonNight') + presenceData.state = `Night ${currentState.day} (Full Moon)` + else presenceData.state = `Night ${currentState.day}` + break + } + case GameState.End: { + presenceData.state = 'Viewing End Screen' + break + } + } + break + } + case 'BigEndGame': { + presenceData.details = `Playing a ${ + gameTypeNames[currentState.gameMode!] ?? currentState.gameMode + } Game` + presenceData.state = 'Viewing After Game Screen' + break + } + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Toyhouse/metadata.json b/websites/T/Toyhouse/metadata.json index 44927a7c596d..d9ca23e2d7b2 100644 --- a/websites/T/Toyhouse/metadata.json +++ b/websites/T/Toyhouse/metadata.json @@ -1,34 +1,34 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "RisingSunLight", - "id": "240521747852558347" - }, - "service": "Toyhouse", - "description": { - "en": "A community for collaborative character creation and trading, worldbuilding and roleplay.", - "fr": "Une communauté pour collaborer dans la création et l'échange de personnages, le worldbuilding et le roleplay." - }, - "url": "toyhou.se", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Toyhouse/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Toyhouse/assets/thumbnail.png", - "color": "#5ab5d1", - "category": "other", - "tags": [ - "community", - "toyhouse", - "worldbuilding", - "roleplay", - "trading" - ], - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "RisingSunLight", + "id": "240521747852558347" + }, + "service": "Toyhouse", + "description": { + "en": "A community for collaborative character creation and trading, worldbuilding and roleplay.", + "fr": "Une communauté pour collaborer dans la création et l'échange de personnages, le worldbuilding et le roleplay." + }, + "url": "toyhou.se", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Toyhouse/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Toyhouse/assets/thumbnail.png", + "color": "#5ab5d1", + "category": "other", + "tags": [ + "community", + "toyhouse", + "worldbuilding", + "roleplay", + "trading" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/T/Toyhouse/presence.ts b/websites/T/Toyhouse/presence.ts index 16fd866a488a..a6d285e516b6 100644 --- a/websites/T/Toyhouse/presence.ts +++ b/websites/T/Toyhouse/presence.ts @@ -1,70 +1,75 @@ -const presence = new Presence({ clientId: "1014873319419424869" }), - browsingTimestamp = Math.floor(Date.now() / 1000), - staticsPages: { [name: string]: string } = { - "": "Viewing homepage", - "~rules": "Reading rules", - "~tos": "Reading ToS", - "~account": "Managing their account", - }; +const presence = new Presence({ clientId: '1014873319419424869' }) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const staticsPages: { [name: string]: string } = { + '': 'Viewing homepage', + '~rules': 'Reading rules', + '~tos': 'Reading ToS', + '~account': 'Managing their account', +} const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Toyhouse/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Toyhouse/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname } = document.location, - pathArr = pathname.split("/"), - showButtons = await presence.getSetting("buttons"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname } = document.location + const pathArr = pathname.split('/') + const showButtons = await presence.getSetting('buttons') - switch (pathArr[1]) { - case "~faq": - case "~browse": { - const condition = pathArr[1] === "~faq"; - presenceData.details = condition ? "Browsing characters" : "Reading FAQ"; - presenceData.state = `Category: ${pathArr[2]}`; - if (condition) presenceData.largeImageKey = Assets.Reading; - break; - } - default: { - const pageType = document.querySelector("li.header").textContent.trim(); - if (Object.keys(staticsPages).includes(pathArr[1])) - presenceData.details = staticsPages[pathArr[1]]; - else if (pageType === "User") { - presenceData.details = "Viewing an user page"; - presenceData.state = document.querySelector( - ".display-user-username" - ).textContent; - presenceData.buttons = [ - { - label: "View User", - url: document.querySelector("span > a").href, - }, - ]; - } else if (pageType === "Character") { - const characterQuery = document.querySelector( - ".display-character > a" - ); - presenceData.details = "Viewing a character"; - presenceData.state = characterQuery.textContent; - presenceData.buttons = [ - { - label: "View Character", - url: characterQuery.href, - }, - { - label: "View Possessor", - url: document.querySelector("span > a").href, - }, - ]; - } - } - } + switch (pathArr[1]) { + case '~faq': + case '~browse': { + const condition = pathArr[1] === '~faq' + presenceData.details = condition ? 'Browsing characters' : 'Reading FAQ' + presenceData.state = `Category: ${pathArr[2]}` + if (condition) + presenceData.largeImageKey = Assets.Reading + break + } + default: { + const pageType = document.querySelector('li.header')?.textContent?.trim() + if (Object.keys(staticsPages).includes(pathArr[1])) { + presenceData.details = staticsPages[pathArr[1]] + } + else if (pageType === 'User') { + presenceData.details = 'Viewing an user page' + presenceData.state = document.querySelector( + '.display-user-username', + )?.textContent + presenceData.buttons = [ + { + label: 'View User', + url: document.querySelector('span > a')!.href, + }, + ] + } + else if (pageType === 'Character') { + const characterQuery = document.querySelector( + '.display-character > a', + ) + presenceData.details = 'Viewing a character' + presenceData.state = characterQuery?.textContent + presenceData.buttons = [ + { + label: 'View Character', + url: characterQuery!.href, + }, + { + label: 'View Possessor', + url: document.querySelector('span > a')!.href, + }, + ] + } + } + } - if (!showButtons) delete presenceData.buttons; + if (!showButtons) + delete presenceData.buttons - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TrackMania Exchange/metadata.json b/websites/T/TrackMania Exchange/metadata.json index e77336beeee7..7f1e52812eb9 100644 --- a/websites/T/TrackMania Exchange/metadata.json +++ b/websites/T/TrackMania Exchange/metadata.json @@ -1,46 +1,46 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Hans5958", - "id": "279855717203050496" - }, - "service": "TrackMania Exchange", - "altnames": [ - "TM-Exchange" - ], - "description": { - "en": "TrackMania Exchange (TMX) is the biggest and best TrackMania track-swapping website in the world. This one is not for the newer, TrackmaniaExchange, which is for the 2020 Trackmania. Use the ManiaExchange presence for that.", - "nl": "TrackMania Exchange (TMX) is de grootste en beste TrackMania track-swapping-website ter wereld. Deze is niet voor de nieuwere TrackmaniaExchange, die voor de Trackmania 2020 is. Gebruik daarvoor de aanwezigheid van ManiaExchange." - }, - "url": [ - "tm-exchange.com", - "www.tm-exchange.com", - "united.tm-exchange.com", - "tmnforever.tm-exchange.com", - "nations.tm-exchange.com", - "sunrise.tm-exchange.com", - "original.tm-exchange.com", - "blog.tm-exchange.com" - ], - "version": "1.1.20", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/thumbnail.png", - "color": "#c8c8c8", - "category": "games", - "tags": [ - "cars", - "racing", - "tm", - "tmnf", - "tmuf", - "tmx", - "trackmania-nations-eswc", - "trackmania-nations-forever", - "trackmania-nations", - "trackmania-original", - "trackmania-sunrise", - "trackmania-united-forever", - "trackmania" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Hans5958", + "id": "279855717203050496" + }, + "service": "TrackMania Exchange", + "altnames": [ + "TM-Exchange" + ], + "description": { + "en": "TrackMania Exchange (TMX) is the biggest and best TrackMania track-swapping website in the world. This one is not for the newer, TrackmaniaExchange, which is for the 2020 Trackmania. Use the ManiaExchange presence for that.", + "nl": "TrackMania Exchange (TMX) is de grootste en beste TrackMania track-swapping-website ter wereld. Deze is niet voor de nieuwere TrackmaniaExchange, die voor de Trackmania 2020 is. Gebruik daarvoor de aanwezigheid van ManiaExchange." + }, + "url": [ + "tm-exchange.com", + "www.tm-exchange.com", + "united.tm-exchange.com", + "tmnforever.tm-exchange.com", + "nations.tm-exchange.com", + "sunrise.tm-exchange.com", + "original.tm-exchange.com", + "blog.tm-exchange.com" + ], + "version": "1.1.20", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/thumbnail.png", + "color": "#c8c8c8", + "category": "games", + "tags": [ + "cars", + "racing", + "tm", + "tmnf", + "tmuf", + "tmx", + "trackmania-nations-eswc", + "trackmania-nations-forever", + "trackmania-nations", + "trackmania-original", + "trackmania-sunrise", + "trackmania-united-forever", + "trackmania" + ] +} diff --git a/websites/T/TrackMania Exchange/presence.ts b/websites/T/TrackMania Exchange/presence.ts index af1422ecabff..e9261a35421e 100644 --- a/websites/T/TrackMania Exchange/presence.ts +++ b/websites/T/TrackMania Exchange/presence.ts @@ -1,420 +1,440 @@ const presence = new Presence({ - clientId: "721986767322087464", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '721986767322087464', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - United = "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/0.png", - Nforever = "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/1.png", - Sunrise = "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/2.png", - Original = "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/3.png", - Nations = "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/4.png", - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/logo.png", + United = 'https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/0.png', + Nforever = 'https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/1.png', + Sunrise = 'https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/2.png', + Original = 'https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/3.png', + Nations = 'https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/4.png', + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/logo.png', } -let currentURL = new URL(document.location.href), - currentPath = currentURL.pathname.replace(/^\/|\/$/g, "").split("/"), - presenceData: PresenceData = { - details: "Viewing an unsupported page", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +let currentURL = new URL(document.location.href) +let currentPath = currentURL.pathname.replace(/^\/|\/$/g, '').split('/') +let presenceData: PresenceData = { + details: 'Viewing an unsupported page', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/logo.png', + startTimestamp: browsingTimestamp, +} const updateCallback = { - _function: null as () => void, - get function(): () => void { - return this._function; - }, - set function(parameter) { - this._function = parameter; - }, - get present(): boolean { - return this._function !== null; - }, - }, - /** - * Initialize/reset presenceData. - */ - resetData = ( - defaultData: PresenceData = { - details: "Viewing an unsupported page", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/logo.png", - startTimestamp: browsingTimestamp, - } - ): void => { - currentURL = new URL(document.location.href); - currentPath = currentURL.pathname.replace(/^\/|\/$/g, "").split("/"); - presenceData = { ...defaultData }; - }, - /** - * Search for URL parameters. - * @param urlParam The parameter that you want to know about the value. - */ - getURLParam = (urlParam: string): string => { - return currentURL.searchParams.get(urlParam); - }; + _function: null as unknown as () => void, + get function(): () => void { + return this._function + }, + set function(parameter) { + this._function = parameter + }, + get present(): boolean { + return this._function !== null + }, +} +/** + * Initialize/reset presenceData. + */ +function resetData(defaultData: PresenceData = { + details: 'Viewing an unsupported page', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TrackMania%20Exchange/assets/logo.png', + startTimestamp: browsingTimestamp, +}): void { + currentURL = new URL(document.location.href) + currentPath = currentURL.pathname.replace(/^\/|\/$/g, '').split('/') + presenceData = { ...defaultData } +} +/** + * Search for URL parameters. + * @param urlParam The parameter that you want to know about the value. + */ +function getURLParam(urlParam: string): string { + return currentURL.searchParams.get(urlParam)! +} ((): void => { - if ( - currentURL.hostname === "tm-exchange.com" || - currentURL.hostname === "www.tm-exchange.com" - ) - presenceData.details = "On the home page"; - else if (currentURL.hostname === "blog.tm-exchange.com") { - if (currentPath[0] === "post") { - presenceData.details = "Reading a blog post"; - presenceData.state = document.querySelector(".WindowHeader1").textContent; - } else if (currentPath[0] === "archive.aspx") - presenceData.details = "Viewing the blog archive"; - else presenceData.details = "Viewing the blog"; - } else { - let pageType: string, - idPrefix = "ctl03"; + if ( + currentURL.hostname === 'tm-exchange.com' + || currentURL.hostname === 'www.tm-exchange.com' + ) { + presenceData.details = 'On the home page' + } + else if (currentURL.hostname === 'blog.tm-exchange.com') { + if (currentPath[0] === 'post') { + presenceData.details = 'Reading a blog post' + presenceData.state = document.querySelector('.WindowHeader1')?.textContent + } + else if (currentPath[0] === 'archive.aspx') { + presenceData.details = 'Viewing the blog archive' + } + else { + presenceData.details = 'Viewing the blog' + } + } + else { + let pageType: string | null = null + let idPrefix = 'ctl03' - /* + /* - This part figures out the page type. - There are three ways for getting it's type. + This part figures out the page type. + There are three ways for getting it's type. - The old structure are done as below. + The old structure are done as below. - 1. From the "action" parameter on the current URL. - 2. From the "action" parameter on the URL located on the "External Link" part on the top left corner. - 3. From the "Location" part on the top left corner, specifically the bolded part. + 1. From the "action" parameter on the current URL. + 2. From the "action" parameter on the URL located on the "External Link" part on the top left corner. + 3. From the "Location" part on the top left corner, specifically the bolded part. - The new structure (only TMNF and TMUF) are done as below. + The new structure (only TMNF and TMUF) are done as below. - 1. From the "action" path on the URL located on the "External Link" part on the top left corner. - 2. From the "Location" part on the top left corner, specifically the bolded part. - 3. From the "action" path on the current URL. (This is done last because the unrealibilty of the URL in some cases.) + 1. From the "action" path on the URL located on the "External Link" part on the top left corner. + 2. From the "Location" part on the top left corner, specifically the bolded part. + 3. From the "action" path on the current URL. (This is done last because the unrealibilty of the URL in some cases.) - */ + */ - const locationType: { [index: string]: string } = { - Home: "home", - Login: "login", // action guessed - Registration: "register", // action guessed - "Lost Login": "forget", // action guessed - "Track Info": "trackshow", - "Search Tracks": "tracksearch", - "Nadeo Tracks": "tracksearch", - "Your AOI": "tracksearch", - "User's Tracks": "tracksearch", - "Track Signs": "tracksigns", - "Track Upload": "trackuploadtrack", - "Submit Replays": "recordmassupload", - Leaderboards: "userrecords", - "Your Tracks": "tracksearch", - "Your Replays": "tracksearch", - "Your Downloads": "tracksearch", - PlayPal: "playpal", - "PlayPal On-Line": "playpalonline", - TrackBeta: "trackbeta", - "Find Users": "usersearch", - "User Info": "usershow", - "User Packs": "trackpacksearch", - "Pack Info": "trackpackshow", - "Your Account": "usershow", - "Send Private Message": "postupdate", - "Edit Post": "postedit", - "Report Problem": "reportproblem", - "News Archive": "newssearch", - "Track Replay Info": "trackreplayshow", - }; + const locationType: { [index: string]: string } = { + 'Home': 'home', + 'Login': 'login', // action guessed + 'Registration': 'register', // action guessed + 'Lost Login': 'forget', // action guessed + 'Track Info': 'trackshow', + 'Search Tracks': 'tracksearch', + 'Nadeo Tracks': 'tracksearch', + 'Your AOI': 'tracksearch', + 'User\'s Tracks': 'tracksearch', + 'Track Signs': 'tracksigns', + 'Track Upload': 'trackuploadtrack', + 'Submit Replays': 'recordmassupload', + 'Leaderboards': 'userrecords', + 'Your Tracks': 'tracksearch', + 'Your Replays': 'tracksearch', + 'Your Downloads': 'tracksearch', + 'PlayPal': 'playpal', + 'PlayPal On-Line': 'playpalonline', + 'TrackBeta': 'trackbeta', + 'Find Users': 'usersearch', + 'User Info': 'usershow', + 'User Packs': 'trackpacksearch', + 'Pack Info': 'trackpackshow', + 'Your Account': 'usershow', + 'Send Private Message': 'postupdate', + 'Edit Post': 'postedit', + 'Report Problem': 'reportproblem', + 'News Archive': 'newssearch', + 'Track Replay Info': 'trackreplayshow', + } - if ( - currentURL.host === "united.tm-exchange.com" || - currentURL.host === "tmnforever.tm-exchange.com" - ) { - if (document.querySelector(".BookmarkCell a")) { - currentURL = new URL( - document.querySelector(".BookmarkCell a").textContent - ); - currentPath = currentURL.pathname.replace(/^\/|\/$/g, "").split("/"); - [pageType] = currentPath; - } else { - try { - pageType = - locationType[ - document.querySelector(".NavigatorCell b").textContent - ]; - } catch (e) { - pageType = currentPath[0] || null; - } - } - } else if ( - getURLParam("action") !== null && - getURLParam("action") !== "auto#auto" - ) - pageType = getURLParam("action"); - else if (document.querySelector(".BookmarkCell a")) { - currentURL = new URL( - document.querySelector(".BookmarkCell a").textContent - ); - pageType = getURLParam("action"); - } else { - try { - pageType = - locationType[document.querySelector(".NavigatorCell b").textContent]; - } catch (e) { - pageType = null; - } - } + if ( + currentURL.host === 'united.tm-exchange.com' + || currentURL.host === 'tmnforever.tm-exchange.com' + ) { + if (document.querySelector('.BookmarkCell a')) { + currentURL = new URL( + document.querySelector('.BookmarkCell a')!.textContent!, + ) + currentPath = currentURL.pathname.replace(/^\/|\/$/g, '').split('/'); + [pageType] = currentPath + } + else { + try { + pageType = locationType[ + document.querySelector('.NavigatorCell b')!.textContent! + ] + } + catch { + pageType = currentPath[0] || null + } + } + } + else if ( + getURLParam('action') !== null + && getURLParam('action') !== 'auto#auto' + ) { + pageType = getURLParam('action') + } + else if (document.querySelector('.BookmarkCell a')) { + currentURL = new URL( + document.querySelector('.BookmarkCell a')!.textContent!, + ) + pageType = getURLParam('action') + } + else { + try { + pageType = locationType[document.querySelector('.NavigatorCell b')!.textContent!] + } + catch { + pageType = null + } + } - if (document.querySelector(".NavigatorCell b").textContent === "Login") - pageType = "login"; + if (document.querySelector('.NavigatorCell b')?.textContent === 'Login') + pageType = 'login' - /* This parts gives suffix to the top text of the activity (aka details), to differentiate the different sites on the network. */ + /* This parts gives suffix to the top text of the activity (aka details), to differentiate the different sites on the network. */ - switch (currentURL.host) { - case "united.tm-exchange.com": - presenceData.smallImageKey = Assets.United; - presenceData.smallImageText = "United (TMUF-X)"; - idPrefix = "_ctl1"; - break; - case "tmnforever.tm-exchange.com": - presenceData.smallImageKey = Assets.Nforever; - presenceData.smallImageText = "Nations Forever (TMNF-X)"; - idPrefix = "ctl01"; - break; - case "nations.tm-exchange.com": - presenceData.smallImageKey = Assets.Nations; - presenceData.smallImageText = "Nations"; - break; - case "sunrise.tm-exchange.com": - presenceData.smallImageKey = Assets.Sunrise; - presenceData.smallImageText = "Sunrise"; - break; - case "original.tm-exchange.com": - presenceData.smallImageKey = Assets.Original; - presenceData.smallImageText = "Original"; - break; - } + switch (currentURL.host) { + case 'united.tm-exchange.com': + presenceData.smallImageKey = Assets.United + presenceData.smallImageText = 'United (TMUF-X)' + idPrefix = '_ctl1' + break + case 'tmnforever.tm-exchange.com': + presenceData.smallImageKey = Assets.Nforever + presenceData.smallImageText = 'Nations Forever (TMNF-X)' + idPrefix = 'ctl01' + break + case 'nations.tm-exchange.com': + presenceData.smallImageKey = Assets.Nations + presenceData.smallImageText = 'Nations' + break + case 'sunrise.tm-exchange.com': + presenceData.smallImageKey = Assets.Sunrise + presenceData.smallImageText = 'Sunrise' + break + case 'original.tm-exchange.com': + presenceData.smallImageKey = Assets.Original + presenceData.smallImageText = 'Original' + break + } - /* This part sets the details to be given to PreMID. */ + /* This part sets the details to be given to PreMID. */ - if ( - currentPath[0] === "error" || - currentPath[0] === "errorhandler" || - (document.querySelector(".WindowTitle") && - document.querySelector(".WindowTitle").textContent === "Error") || - (document.querySelector("h1") && - document.querySelector("h1").textContent === "Server Error") - ) - presenceData.details = "On a non-existent page"; - else { - switch (pageType) { - case "home": { - presenceData.details = "On the home page"; - break; - } - case "login": { - presenceData.details = "Logging in"; - break; - } - case "register": { - presenceData.details = "Registering an account"; - break; - } - case "forget": { - presenceData.details = "Figuring out the password"; - break; - } - case "trackshow": { - presenceData.details = document.querySelector( - `#${idPrefix}_ShowTrackName` - ).textContent; - presenceData.state = document.querySelector( - "tr.WindowTableCell1:nth-child(3) > td:nth-child(2) > a:nth-child(3)" - ).textContent; + if ( + currentPath[0] === 'error' + || currentPath[0] === 'errorhandler' + || (document.querySelector('.WindowTitle') + && document.querySelector('.WindowTitle')?.textContent === 'Error') + || (document.querySelector('h1') + && document.querySelector('h1')?.textContent === 'Server Error') + ) { + presenceData.details = 'On a non-existent page' + } + else { + switch (pageType) { + case 'home': { + presenceData.details = 'On the home page' + break + } + case 'login': { + presenceData.details = 'Logging in' + break + } + case 'register': { + presenceData.details = 'Registering an account' + break + } + case 'forget': { + presenceData.details = 'Figuring out the password' + break + } + case 'trackshow': { + presenceData.details = document.querySelector( + `#${idPrefix}_ShowTrackName`, + )?.textContent + presenceData.state = document.querySelector( + 'tr.WindowTableCell1:nth-child(3) > td:nth-child(2) > a:nth-child(3)', + )?.textContent - break; - } - case "tracksearch": { - let searchSummary: string; - if ( - document.querySelector(`#${idPrefix}_ShowSummary > b:nth-child(1)`) - .textContent === "tracks" - ) { - searchSummary = document - .querySelector(`#${idPrefix}_ShowSummary`) - .textContent.slice(15, this.length - 4); - } else { - searchSummary = document - .querySelector(`#${idPrefix}_ShowSummary`) - .textContent.slice(8, this.length - 4); - } - presenceData.details = "Searching for a track"; - if (document.querySelector(".TextFilter")) { - presenceData.state = `${document - .querySelector(".TextFilter") - .textContent.slice(9, this.length - 1)}, ${searchSummary}`; - } else { - presenceData.state = - searchSummary[0].toUpperCase() + searchSummary.slice(1); - } + break + } + case 'tracksearch': { + let searchSummary: string | undefined + if ( + document.querySelector(`#${idPrefix}_ShowSummary > b:nth-child(1)`) + ?.textContent === 'tracks' + ) { + const summary = document + .querySelector(`#${idPrefix}_ShowSummary`) + ?.textContent + searchSummary = summary + ?.slice(15, summary.length - 4) + } + else { + const summary = document + .querySelector(`#${idPrefix}_ShowSummary`) + ?.textContent + searchSummary = summary + ?.slice(8, summary.length - 4) + } + presenceData.details = 'Searching for a track' + const textFilter = document.querySelector('.TextFilter') + if (textFilter) { + presenceData.state = `${textFilter + .textContent + ?.slice(9, textFilter.textContent.length - 1)}, ${searchSummary}` + } + else { + presenceData.state = `${searchSummary?.[0].toUpperCase()}${searchSummary?.slice(1)}` + } - break; - } - case "tracksigns": { - presenceData.details = "Viewing track signs"; - break; - } - case "trackuploadtrack": { - presenceData.details = "Uploading a track"; - break; - } - case "recordmassupload": { - presenceData.details = "Submitting replays"; - break; - } - case "userrecords": { - const searchSummary = document - .querySelector(`#${idPrefix}_ShowSummary`) - .textContent.slice(16, this.length - 4); - presenceData.details = "Viewing the leaderboards"; - if ( - (document.querySelector(`#${idPrefix}_GetUser`) as HTMLInputElement) - .value - ) { - presenceData.state = `${ - ( - document.querySelector( - `#${idPrefix}_GetUser` - ) as HTMLInputElement - ).value - }, ${searchSummary}`; - } else { - presenceData.state = - searchSummary[0].toUpperCase() + searchSummary.slice(1); - } + break + } + case 'tracksigns': { + presenceData.details = 'Viewing track signs' + break + } + case 'trackuploadtrack': { + presenceData.details = 'Uploading a track' + break + } + case 'recordmassupload': { + presenceData.details = 'Submitting replays' + break + } + case 'userrecords': { + const summary = document + .querySelector(`#${idPrefix}_ShowSummary`) + ?.textContent + const searchSummary = summary + ?.slice(16, summary.length - 4) + presenceData.details = 'Viewing the leaderboards' + if ( + (document.querySelector(`#${idPrefix}_GetUser`) as HTMLInputElement) + .value + ) { + presenceData.state = `${ + ( + document.querySelector( + `#${idPrefix}_GetUser`, + ) as HTMLInputElement + ).value + }, ${searchSummary}` + } + else { + presenceData.state = `${searchSummary?.[0].toUpperCase()}${searchSummary?.slice(1)}` + } - break; - } - case "forumshow": - case "forumsshow": { - presenceData.details = "Viewing the forums"; - if (pageType === "forumshow") { - presenceData.state = document - .querySelector(".WindowTitle") - .textContent.trim(); - } + break + } + case 'forumshow': + case 'forumsshow': { + presenceData.details = 'Viewing the forums' + if (pageType === 'forumshow') { + presenceData.state = document + .querySelector('.WindowTitle') + ?.textContent + ?.trim() + } - break; - } - case "threadshow": { - presenceData.details = "Viewing a thread"; - presenceData.state = document.querySelector( - `#${idPrefix}_ShowSubject` - ).textContent; + break + } + case 'threadshow': { + presenceData.details = 'Viewing a thread' + presenceData.state = document.querySelector( + `#${idPrefix}_ShowSubject`, + )?.textContent - break; - } - case "playpal": { - presenceData.details = "Viewing PlayPal"; - break; - } - case "playpalonline": { - presenceData.details = "Viewing PlayPal Online"; - break; - } - case "trackbeta": { - presenceData.details = "Viewing TrackBeta"; - break; - } - case "usersearch": { - const searchSummary = document - .querySelector(`#${idPrefix}_ShowSummary`) - .textContent.slice(15, this.length - 4); - presenceData.details = "Searching for a user"; - if (document.querySelector(`#${idPrefix}_ShowName`)) { - presenceData.state = `${ - document.querySelector(`#${idPrefix}_ShowName`).textContent - }, ${searchSummary}`; - } else { - presenceData.state = - searchSummary[0].toUpperCase() + searchSummary.slice(1); - } + break + } + case 'playpal': { + presenceData.details = 'Viewing PlayPal' + break + } + case 'playpalonline': { + presenceData.details = 'Viewing PlayPal Online' + break + } + case 'trackbeta': { + presenceData.details = 'Viewing TrackBeta' + break + } + case 'usersearch': { + const summary = document + .querySelector(`#${idPrefix}_ShowSummary`) + ?.textContent + const searchSummary = summary + ?.slice(15, summary.length - 4) + presenceData.details = 'Searching for a user' + if (document.querySelector(`#${idPrefix}_ShowName`)) { + presenceData.state = `${ + document.querySelector(`#${idPrefix}_ShowName`)?.textContent + }, ${searchSummary}` + } + else { + presenceData.state = `${searchSummary?.[0].toUpperCase()}${searchSummary?.slice(1)}` + } - break; - } - case "usershow": { - presenceData.details = "Viewing a user's info"; - presenceData.state = document.querySelector( - `#${idPrefix}_ShowLoginId` - ).textContent; + break + } + case 'usershow': { + presenceData.details = 'Viewing a user\'s info' + presenceData.state = document.querySelector( + `#${idPrefix}_ShowLoginId`, + )?.textContent - break; - } - case "trackpacksearch": { - const searchSummary = document - .querySelector(`#${idPrefix}_ShowSummary`) - .textContent.slice(20, this.length - 4); - presenceData.details = "Searching for a user pack"; - if (document.querySelector(`#${idPrefix}_ShowName`)) { - presenceData.state = `${ - document.querySelector(`#${idPrefix}_ShowName`).textContent - }, ${searchSummary}`; - } else { - presenceData.state = - searchSummary[0].toUpperCase() + searchSummary.slice(1); - } + break + } + case 'trackpacksearch': { + const summary = document + .querySelector(`#${idPrefix}_ShowSummary`) + ?.textContent + const searchSummary = summary + ?.slice(20, summary.length - 4) + presenceData.details = 'Searching for a user pack' + if (document.querySelector(`#${idPrefix}_ShowName`)) { + presenceData.state = `${ + document.querySelector(`#${idPrefix}_ShowName`)?.textContent + }, ${searchSummary}` + } + else { + presenceData.state = `${searchSummary?.[0].toUpperCase()}${searchSummary?.slice(1)}` + } - break; - } - case "postupdate": { - presenceData.details = "Writing a private message"; - break; - } - case "trackpackshow": { - presenceData.details = "Viewing a track pack"; - presenceData.state = `${ - document.querySelector(`#${idPrefix}_ShowPackName`).textContent - } by ${ - document.querySelector( - "#Table7 > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(2) > a:nth-child(3)" - ).textContent - }`; + break + } + case 'postupdate': { + presenceData.details = 'Writing a private message' + break + } + case 'trackpackshow': { + presenceData.details = 'Viewing a track pack' + presenceData.state = `${ + document.querySelector(`#${idPrefix}_ShowPackName`)?.textContent + } by ${ + document.querySelector( + '#Table7 > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(2) > a:nth-child(3)', + )?.textContent + }` - break; - } - case "postedit": { - presenceData.details = "Editing a post"; - break; - } - case "reportproblem": { - presenceData.details = "Reporting something"; - break; - } - case "newssearch": { - presenceData.details = "Viewing the news archive"; - break; - } - case "trackreplayshow": { - presenceData.details = "Viewing the replay history"; - presenceData.state = document.querySelector( - `#${idPrefix}_Windowrow10 a` - ).textContent; + break + } + case 'postedit': { + presenceData.details = 'Editing a post' + break + } + case 'reportproblem': { + presenceData.details = 'Reporting something' + break + } + case 'newssearch': { + presenceData.details = 'Viewing the news archive' + break + } + case 'trackreplayshow': { + presenceData.details = 'Viewing the replay history' + presenceData.state = document.querySelector( + `#${idPrefix}_Windowrow10 a`, + )?.textContent - break; - } - // No default - } - } - } -})(); + break + } + } + } + } +})() if (updateCallback.present) { - const defaultData = { ...presenceData }; - presence.on("UpdateData", async () => { - resetData(defaultData); - updateCallback.function(); - presence.setActivity(presenceData); - }); -} else { - presence.on("UpdateData", async () => { - presence.setActivity(presenceData); - }); + const defaultData = { ...presenceData } + presence.on('UpdateData', async () => { + resetData(defaultData) + updateCallback.function() + presence.setActivity(presenceData) + }) +} +else { + presence.on('UpdateData', async () => { + presence.setActivity(presenceData) + }) } diff --git a/websites/T/Tracker.gg/metadata.json b/websites/T/Tracker.gg/metadata.json index c1413a402add..374e8a82db97 100644 --- a/websites/T/Tracker.gg/metadata.json +++ b/websites/T/Tracker.gg/metadata.json @@ -1,42 +1,42 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "OGMatrix", - "id": "657290880947978241" - }, - "service": "Tracker.gg", - "description": { - "en": "Tracker Network provides stats, global and regional leaderboards and much more to gamers around the world.", - "de": "Tracker Network bietet Spielern auf der ganzen Welt Statistiken, globale und regionale Bestenlisten und vieles mehr." - }, - "url": [ - "tracker.gg", - "fortnitetracker.com", - "thetrackernetwork.com" - ], - "version": "1.0.15", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/thumbnail.png", - "color": "#e2263c", - "category": "games", - "tags": [ - "tracker", - "games", - "stats" - ], - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "value": true, - "icon": "fas fa-compress-arrows-alt" - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fas fa-user-secret", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "OGMatrix", + "id": "657290880947978241" + }, + "service": "Tracker.gg", + "description": { + "en": "Tracker Network provides stats, global and regional leaderboards and much more to gamers around the world.", + "de": "Tracker Network bietet Spielern auf der ganzen Welt Statistiken, globale und regionale Bestenlisten und vieles mehr." + }, + "url": [ + "tracker.gg", + "fortnitetracker.com", + "thetrackernetwork.com" + ], + "version": "1.0.15", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/thumbnail.png", + "color": "#e2263c", + "category": "games", + "tags": [ + "tracker", + "games", + "stats" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "value": true, + "icon": "fas fa-compress-arrows-alt" + }, + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fas fa-user-secret", + "value": false + } + ] +} diff --git a/websites/T/Tracker.gg/presence.ts b/websites/T/Tracker.gg/presence.ts index 4b8e578ad806..1c1e67f39022 100644 --- a/websites/T/Tracker.gg/presence.ts +++ b/websites/T/Tracker.gg/presence.ts @@ -1,681 +1,704 @@ -const presence = new Presence({ clientId: "929349462365704222" }), - browsingTimestamp = Math.floor(Date.now() / 1000); +const presence = new Presence({ clientId: '929349462365704222' }) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/logo.png", - Valorant = "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/0.png", - Hyperscape = "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/1.png", - Apex = "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/2.png", - Fn = "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/3.png", - Csgo = "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/4.png", - Lol = "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/5.png", - Splitgate = "https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/6.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/logo.png', + Valorant = 'https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/0.png', + Hyperscape = 'https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/1.png', + Apex = 'https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/2.png', + Fn = 'https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/3.png', + Csgo = 'https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/4.png', + Lol = 'https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/5.png', + Splitgate = 'https://cdn.rcd.gg/PreMiD/websites/T/Tracker.gg/assets/6.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname } = window.location, - botHost = document.location.hostname; - - switch (botHost) { - case "tracker.gg": { - switch (pathname) { - case "/": { - presenceData.details = "Viewing Page:"; - presenceData.state = "Homepage"; - - break; - } - case "/apps": { - presenceData.details = "Viewing Page:"; - presenceData.state = "Tracker Apps"; - - break; - } - case "/developers": { - presenceData.details = "Viewing Page:"; - presenceData.state = "Developers"; - - break; - } - case "/developers/apps/create": { - presenceData.details = "Creating"; - presenceData.state = "Tracker Dev App"; - - break; - } - default: - if (pathname.includes("/developers/apps/")) { - try { - const appName = document - .querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.apps > div.content-container > div > div > div > div > div.dashboard__analytics.card.bordered.responsive > header > div > div.left > div:nth-child(2) > div.title" - ) - .textContent.replace("Dashboard", ""); - presenceData.details = "Editing App"; - presenceData.state = appName; - presenceData.smallImageText = appName; - presenceData.largeImageKey = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.apps > div.content-container > div > div > div > div > div.dashboard__details.card.responsive > div > div:nth-child(1) > div > img" - ).src; - } catch (e) { - presenceData.details = "Viewing:"; - presenceData.state = "Developer Apps"; - } - } else if (pathname.includes("/developers/docs")) { - try { - presenceData.details = "Viewing Docs"; - presenceData.state = document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.docs > div.content-container > div > div > h1" - ).textContent; - } catch { - presenceData.details = "Viewing API"; - presenceData.state = document - .querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.docs > div.content-container > div > div > header > h1" - ) - .textContent.replace("apex", "") - .replace("csgo", "") - .replace("division-2", "") - .replace("splitgate", "") - .replace("hyper-scape", "") - .replace("fortnite", ""); - } - } else { - switch (pathname) { - case "/overlays": { - presenceData.details = "Viewing Page:"; - presenceData.state = "Overlays"; - - break; - } - case "/overlays/editor": { - presenceData.details = "Creating"; - presenceData.state = "Tracker Overlay"; - - break; - } - case "/premium": { - presenceData.details = "Viewing Page:"; - presenceData.state = "Premium"; - - break; - } - case "/partners": { - presenceData.details = "Viewing Page:"; - presenceData.state = "Partners"; - - break; - } - case "/shop": { - presenceData.details = "Viewing Page:"; - presenceData.state = "Shop"; - - break; - } - case "/valorant": { - presenceData.details = "Viewing Valorant Page"; - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - - break; - } - default: - if (pathname.includes("/valorant/profile")) { - presenceData.details = "Viewing Valorant Profile:"; - presenceData.state = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span.trn-ign__username" - ).textContent + - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span.trn-ign__discriminator" - ).textContent; - presenceData.smallImageKey = Assets.Valorant; - presenceData.smallImageText = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span.trn-ign__username" - ).textContent; - presenceData.largeImageKey = document - .querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-avatar > svg > image" - ) - .getAttribute("href"); - } else if (pathname.includes("/valorant/leaderboards")) { - if (pathname.includes("/valorant/leaderboards/ranked")) { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Leaderboards Ranked"; - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } else if ( - pathname.includes("/valorant/leaderboards/stats") - ) { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Leaderboards Seasonal"; - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } - } else if (pathname.includes("/valorant/guides")) { - if (pathname.includes("/clips/submit")) { - presenceData.details = "Submitting Valorant Clip"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } else if (pathname.includes("/clips")) { - try { - const stream: Element = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > div.container.guide-tile__modal > div.content.animated > div > div > iframe" - ); - if (stream) { - presenceData.details = "Watching:"; - presenceData.state = "Valorant Lineup Clip"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } else { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Lineup Guides"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } - } catch { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Lineup Guides"; - presenceData.smallImageKey = Assets.Valorant; - presenceData.smallImageText = "Valorant"; - } - } else if (pathname.includes("/dashboard")) { - presenceData.details = "Viewing:"; - presenceData.state = "own Valorant Guides"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } else { - try { - presenceData.details = "Reading Guide:"; - presenceData.state = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > article > div.guide__header > h1" - ).textContent; - - presenceData.smallImageText = `Written by ${ - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > article > div.guide__main > div > div.guide-main__hero.card.header-bordered.responsive > div.guide-main-metadata > div.guide-main__author.guide-main-metadata__author > span.guide-main__author-username" - ).textContent - }`; - presenceData.largeImageKey = Assets.Valorant; - } catch { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Guides"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } - } - } else { - switch (pathname) { - case "/valorant/lfg": { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Looking for Group"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - - break; - } - case "/valorant/insights/agents": { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Insights"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - - break; - } - case "/valorant/agents": { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Agents"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - - break; - } - default: - if (pathname.includes("/valorant/agents")) { - presenceData.details = "Viewing Valorant Agent:"; - presenceData.state = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div:nth-child(2) > div.site-container.no-card-margin > div.agent-breadcrumbs > ol > li:nth-child(3) > a > span" - ).textContent; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } else if (pathname === "/valorant/weapons") { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Weapons"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } else if (pathname.includes("/valorant/weapons")) { - presenceData.details = "Viewing Valorant Weapon:"; - presenceData.state = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div:nth-child(2) > div.site-container.no-card-margin > ol > li:nth-child(4) > a > span" - ).textContent; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } else if (pathname === "/valorant/maps") { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Maps"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } else if (pathname.includes("/valorant/maps")) { - presenceData.details = "Viewing Valorant Map:"; - presenceData.state = document - .querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div:nth-child(2) > div.no-card-margin.site-container.site-container--mobile-margin.site-container--background-fade.map-grid > div:nth-child(3) > div.map-info > h1" - ) - .textContent.replace(" - Valorant Map", ""); - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - } else { - switch (pathname) { - case "/valorant/cards": { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Cards"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - - break; - } - case "/valorant/buddies": { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Buddies"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - - break; - } - case "/valorant/sprays": { - presenceData.details = "Viewing:"; - presenceData.state = "Valorant Sprays"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Valorant; - - break; - } - case "/hyper-scape": { - presenceData.details = "Viewing Game:"; - presenceData.state = "Hyper Scape"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Hyperscape; - - break; - } - default: - if (pathname.includes("/hyper-scape/profile")) { - const playerName: string = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span" - ).textContent; - - presenceData.details = - "Viewing HyperScape Profile:"; - presenceData.state = playerName; - presenceData.smallImageKey = Assets.Hyperscape; - presenceData.smallImageText = playerName; - presenceData.largeImageKey = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-avatar > img" - ).src; - } else if ( - pathname.includes("/hyper-scape/leaderboards/") - ) { - if (pathname.includes("/stats/")) { - presenceData.details = "Viewing:"; - presenceData.state = - "HyperScape Leaderboards Lifetime"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Hyperscape; - } else if (pathname.includes("/career-bests/")) { - presenceData.details = "Viewing:"; - presenceData.state = - "HyperScape Leaderboards Career Bests"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Hyperscape; - } else if (pathname.includes("/playlists/")) { - presenceData.details = "Viewing:"; - presenceData.state = - "HyperScape Leaderboards Playlists"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Hyperscape; - } else if (pathname.includes("/weapons/")) { - presenceData.details = "Viewing:"; - presenceData.state = - "HyperScape Leaderboards Weapons"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Hyperscape; - } - } else if (pathname === "/csgo") { - presenceData.details = "Viewing Game:"; - presenceData.state = "CS:GO"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Csgo; - } else if (pathname.includes("/csgo/profile/")) { - const playerName: string = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span" - ).textContent; - - presenceData.details = "Viewing CSGO Profile:"; - presenceData.state = playerName; - presenceData.smallImageKey = Assets.Csgo; - presenceData.smallImageText = playerName; - presenceData.largeImageKey = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-avatar > img" - ).src; - } else if ( - pathname.includes("/csgo/leaderboards/stats/all/") - ) { - presenceData.details = "Viewing:"; - presenceData.state = "CSGO Leaderboard"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Csgo; - } else if (pathname === "/lol") { - presenceData.details = "Viewing Game:"; - presenceData.state = "Leage of Legends"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Lol; - } else if (pathname.includes("/lol/profile")) { - const playerName: string = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span" - ).textContent; - - presenceData.details = "Viewing LoL Profile:"; - presenceData.state = playerName; - presenceData.smallImageKey = Assets.Lol; - presenceData.smallImageText = playerName; - presenceData.largeImageKey = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-avatar > img" - ).src; - } else if ( - pathname.includes("/lol/leaderboards/stats/") - ) { - presenceData.details = "Viewing:"; - presenceData.state = "LoL Leaderboard"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Lol; - } else if (pathname === "/splitgate") { - presenceData.details = "Viewing Game:"; - presenceData.state = "Splitgate"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Splitgate; - } else if ( - pathname.includes("/splitgate/profile/") - ) { - const playerName: string = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span" - ).textContent; - - presenceData.details = - "Viewing Splitgate Profile:"; - presenceData.state = playerName; - presenceData.smallImageKey = Assets.Splitgate; - presenceData.smallImageText = playerName; - presenceData.largeImageKey = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-avatar > img.ph-avatar__image" - ).src; - } else if ( - pathname.includes("/splitgate/leaderboards/") - ) { - if (pathname.includes("/playlist/")) { - presenceData.details = "Viewing Leaderboard:"; - presenceData.state = "Playlist"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Splitgate; - } else if (pathname.includes("/stats/")) { - presenceData.details = "Viewing Leaderboard:"; - presenceData.state = "Overall"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Splitgate; - } - } else if (pathname === "/splitgate/challenges") { - presenceData.details = "Viewing:"; - presenceData.state = "Splitgate Challenges"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Splitgate; - } else if ( - pathname.includes("/splitgate/challenges/") - ) { - const challengeTitle: string = - document.querySelector( - "#app > div.trn-wrapper > div.trn-container > div > main > div.challenge > div.challenge__header > div > div.challenge__meta > h1" - ).textContent; - - presenceData.details = "Viewing Challenge:"; - presenceData.state = challengeTitle; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Splitgate; - } - } - } - } - } - } - } - } - - break; - } - case "fortnitetracker.com": { - if (pathname === "/") { - presenceData.details = "Viewing Fortnite Page"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - } else if (pathname.includes("/profile/all/")) { - const playerName: string = document.querySelector( - "#profile > div.trn-card.trn-profile-header > div > h1 > span" - ).textContent; - - presenceData.details = "Viewing Fortnite Profile:"; - presenceData.state = playerName; - presenceData.smallImageKey = Assets.Fn; - presenceData.smallImageText = playerName; - presenceData.largeImageKey = document.querySelector( - "#profile > div.trn-card.trn-profile-header > div > div.trn-profile-header__avatar.trn-roundavatar.trn-roundavatar--white > img" - ).src; - } else { - switch (pathname) { - case "/event-lfp": { - presenceData.details = "Viewing:"; - presenceData.state = "Looking for Player"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - - break; - } - case "/events": { - presenceData.details = "Viewing:"; - presenceData.state = "Events"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - - break; - } - case "/events/powerrankings": { - presenceData.details = "Viewing:"; - presenceData.state = "Power Ranking"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - - break; - } - case "/arena/leaderboards": { - presenceData.details = "Viewing Leaderboard:"; - presenceData.state = "Hype"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - - break; - } - case "/events/earnings": { - presenceData.details = "Viewing Leaderboard:"; - presenceData.state = "Earnings"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - - break; - } - case "/bests/win-streaks": { - presenceData.details = "Viewing Leaderboard:"; - presenceData.state = "Win Streak"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - - break; - } - default: - if (pathname.includes("/bests/high-kills/")) { - presenceData.details = "Viewing Leaderboard:"; - presenceData.state = "Single Match Kills"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - } else if (pathname.includes("/leaderboards/")) { - if (pathname.includes("/TRNRating")) { - presenceData.details = "Viewing Leaderboard:"; - presenceData.state = "Tracker Network Rating"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - } - } else if (pathname === "/challenges") { - presenceData.details = "Viewing:"; - presenceData.state = "Challanges"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - } else if (pathname.includes("/challenges/")) { - presenceData.details = "Viewing Challange:"; - presenceData.state = document.querySelector( - "#app > div > div.ftr-challenges > div:nth-child(1) > div.trn-card__header > h3" - ).textContent; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - } else if (pathname === "/creative") { - presenceData.details = "Viewing:"; - presenceData.state = "Creative Maps"; - - presenceData.smallImageText = "TRN"; - presenceData.largeImageKey = Assets.Fn; - } - } - } - - break; - } - case "thetrackernetwork.com": { - if (pathname.includes("/manage/")) { - presenceData.details = "Editing Profile"; - presenceData.state = document.querySelector( - "body > div > div.trn-wrapper > div > div > main > div > div:nth-child(2) > div.mgn-header" - ).textContent; - } else { - switch (pathname) { - case "/contact": { - presenceData.details = "Viewing:"; - presenceData.state = "Contact Page"; - - break; - } - case "/home/privacypolicy": { - presenceData.details = "Viewing:"; - presenceData.state = "Privacy Policy"; - - break; - } - case "/home/tos": { - presenceData.details = "Viewing:"; - presenceData.state = "Terms of Service"; - - break; - } - case "/home": { - presenceData.details = "Viewing:"; - presenceData.state = "Homepage"; - - break; - } - // No default - } - } - break; - } - // No default - } - - if ( - !(await presence.getSetting("buttons")) || - presenceData.details === "Editing App:" - ) - delete presenceData.buttons; - else { - presenceData.buttons = [ - { - label: "Open Page", - url: document.URL, - }, - ]; - } - - if ( - pathname.includes("/manage/") && - (await presence.getSetting("privacy")) && - botHost === "thetrackernetwork.com" - ) { - presenceData.details = "Viewing Page:"; - presenceData.state = "Homepage"; - } - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname } = window.location + const botHost = document.location.hostname + + switch (botHost) { + case 'tracker.gg': { + switch (pathname) { + case '/': { + presenceData.details = 'Viewing Page:' + presenceData.state = 'Homepage' + + break + } + case '/apps': { + presenceData.details = 'Viewing Page:' + presenceData.state = 'Tracker Apps' + + break + } + case '/developers': { + presenceData.details = 'Viewing Page:' + presenceData.state = 'Developers' + + break + } + case '/developers/apps/create': { + presenceData.details = 'Creating' + presenceData.state = 'Tracker Dev App' + + break + } + default: + if (pathname.includes('/developers/apps/')) { + try { + const appName = document + .querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.apps > div.content-container > div > div > div > div > div.dashboard__analytics.card.bordered.responsive > header > div > div.left > div:nth-child(2) > div.title', + ) + ?.textContent + ?.replace('Dashboard', '') + presenceData.details = 'Editing App' + presenceData.state = appName + presenceData.smallImageText = appName + presenceData.largeImageKey = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.apps > div.content-container > div > div > div > div > div.dashboard__details.card.responsive > div > div:nth-child(1) > div > img', + )?.src + } + catch { + presenceData.details = 'Viewing:' + presenceData.state = 'Developer Apps' + } + } + else if (pathname.includes('/developers/docs')) { + try { + presenceData.details = 'Viewing Docs' + presenceData.state = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.docs > div.content-container > div > div > h1', + )?.textContent + } + catch { + presenceData.details = 'Viewing API' + presenceData.state = document + .querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.docs > div.content-container > div > div > header > h1', + ) + ?.textContent + ?.replace('apex', '') + .replace('csgo', '') + .replace('division-2', '') + .replace('splitgate', '') + .replace('hyper-scape', '') + .replace('fortnite', '') + } + } + else { + switch (pathname) { + case '/overlays': { + presenceData.details = 'Viewing Page:' + presenceData.state = 'Overlays' + + break + } + case '/overlays/editor': { + presenceData.details = 'Creating' + presenceData.state = 'Tracker Overlay' + + break + } + case '/premium': { + presenceData.details = 'Viewing Page:' + presenceData.state = 'Premium' + + break + } + case '/partners': { + presenceData.details = 'Viewing Page:' + presenceData.state = 'Partners' + + break + } + case '/shop': { + presenceData.details = 'Viewing Page:' + presenceData.state = 'Shop' + + break + } + case '/valorant': { + presenceData.details = 'Viewing Valorant Page' + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + + break + } + default: + if (pathname.includes('/valorant/profile')) { + presenceData.details = 'Viewing Valorant Profile:' + presenceData.state = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span.trn-ign__username', + )!.textContent! + + document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span.trn-ign__discriminator', + )!.textContent + presenceData.smallImageKey = Assets.Valorant + presenceData.smallImageText = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span.trn-ign__username', + )?.textContent + presenceData.largeImageKey = document + .querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-avatar > svg > image', + ) + ?.getAttribute('href') + } + else if (pathname.includes('/valorant/leaderboards')) { + if (pathname.includes('/valorant/leaderboards/ranked')) { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Leaderboards Ranked' + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + else if ( + pathname.includes('/valorant/leaderboards/stats') + ) { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Leaderboards Seasonal' + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + } + else if (pathname.includes('/valorant/guides')) { + if (pathname.includes('/clips/submit')) { + presenceData.details = 'Submitting Valorant Clip' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + else if (pathname.includes('/clips')) { + try { + const stream = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > div.container.guide-tile__modal > div.content.animated > div > div > iframe', + ) + if (stream) { + presenceData.details = 'Watching:' + presenceData.state = 'Valorant Lineup Clip' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + else { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Lineup Guides' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + } + catch { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Lineup Guides' + presenceData.smallImageKey = Assets.Valorant + presenceData.smallImageText = 'Valorant' + } + } + else if (pathname.includes('/dashboard')) { + presenceData.details = 'Viewing:' + presenceData.state = 'own Valorant Guides' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + else { + try { + presenceData.details = 'Reading Guide:' + presenceData.state = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > article > div.guide__header > h1', + )?.textContent + + presenceData.smallImageText = `Written by ${ + document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > article > div.guide__main > div > div.guide-main__hero.card.header-bordered.responsive > div.guide-main-metadata > div.guide-main__author.guide-main-metadata__author > span.guide-main__author-username', + )?.textContent + }` + presenceData.largeImageKey = Assets.Valorant + } + catch { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Guides' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + } + } + else { + switch (pathname) { + case '/valorant/lfg': { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Looking for Group' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + + break + } + case '/valorant/insights/agents': { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Insights' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + + break + } + case '/valorant/agents': { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Agents' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + + break + } + default: + if (pathname.includes('/valorant/agents')) { + presenceData.details = 'Viewing Valorant Agent:' + presenceData.state = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div:nth-child(2) > div.site-container.no-card-margin > div.agent-breadcrumbs > ol > li:nth-child(3) > a > span', + )?.textContent + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + else if (pathname === '/valorant/weapons') { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Weapons' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + else if (pathname.includes('/valorant/weapons')) { + presenceData.details = 'Viewing Valorant Weapon:' + presenceData.state = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div:nth-child(2) > div.site-container.no-card-margin > ol > li:nth-child(4) > a > span', + )?.textContent + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + else if (pathname === '/valorant/maps') { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Maps' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + else if (pathname.includes('/valorant/maps')) { + presenceData.details = 'Viewing Valorant Map:' + presenceData.state = document + .querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div:nth-child(2) > div.no-card-margin.site-container.site-container--mobile-margin.site-container--background-fade.map-grid > div:nth-child(3) > div.map-info > h1', + ) + ?.textContent + ?.replace(' - Valorant Map', '') + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + } + else { + switch (pathname) { + case '/valorant/cards': { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Cards' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + + break + } + case '/valorant/buddies': { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Buddies' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + + break + } + case '/valorant/sprays': { + presenceData.details = 'Viewing:' + presenceData.state = 'Valorant Sprays' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Valorant + + break + } + case '/hyper-scape': { + presenceData.details = 'Viewing Game:' + presenceData.state = 'Hyper Scape' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Hyperscape + + break + } + default: + if (pathname.includes('/hyper-scape/profile')) { + const playerName = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span', + )?.textContent + + presenceData.details = 'Viewing HyperScape Profile:' + presenceData.state = playerName + presenceData.smallImageKey = Assets.Hyperscape + presenceData.smallImageText = playerName + presenceData.largeImageKey = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-avatar > img', + )?.src + } + else if ( + pathname.includes('/hyper-scape/leaderboards/') + ) { + if (pathname.includes('/stats/')) { + presenceData.details = 'Viewing:' + presenceData.state = 'HyperScape Leaderboards Lifetime' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Hyperscape + } + else if (pathname.includes('/career-bests/')) { + presenceData.details = 'Viewing:' + presenceData.state = 'HyperScape Leaderboards Career Bests' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Hyperscape + } + else if (pathname.includes('/playlists/')) { + presenceData.details = 'Viewing:' + presenceData.state = 'HyperScape Leaderboards Playlists' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Hyperscape + } + else if (pathname.includes('/weapons/')) { + presenceData.details = 'Viewing:' + presenceData.state = 'HyperScape Leaderboards Weapons' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Hyperscape + } + } + else if (pathname === '/csgo') { + presenceData.details = 'Viewing Game:' + presenceData.state = 'CS:GO' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Csgo + } + else if (pathname.includes('/csgo/profile/')) { + const playerName = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span', + )?.textContent + + presenceData.details = 'Viewing CSGO Profile:' + presenceData.state = playerName + presenceData.smallImageKey = Assets.Csgo + presenceData.smallImageText = playerName + presenceData.largeImageKey = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-avatar > img', + )?.src + } + else if ( + pathname.includes('/csgo/leaderboards/stats/all/') + ) { + presenceData.details = 'Viewing:' + presenceData.state = 'CSGO Leaderboard' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Csgo + } + else if (pathname === '/lol') { + presenceData.details = 'Viewing Game:' + presenceData.state = 'Leage of Legends' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Lol + } + else if (pathname.includes('/lol/profile')) { + const playerName = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span', + )?.textContent + + presenceData.details = 'Viewing LoL Profile:' + presenceData.state = playerName + presenceData.smallImageKey = Assets.Lol + presenceData.smallImageText = playerName + presenceData.largeImageKey = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-avatar > img', + )?.src + } + else if ( + pathname.includes('/lol/leaderboards/stats/') + ) { + presenceData.details = 'Viewing:' + presenceData.state = 'LoL Leaderboard' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Lol + } + else if (pathname === '/splitgate') { + presenceData.details = 'Viewing Game:' + presenceData.state = 'Splitgate' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Splitgate + } + else if ( + pathname.includes('/splitgate/profile/') + ) { + const playerName = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-details > div.ph-details__identifier > span > span', + )?.textContent + + presenceData.details = 'Viewing Splitgate Profile:' + presenceData.state = playerName + presenceData.smallImageKey = Assets.Splitgate + presenceData.smallImageText = playerName + presenceData.largeImageKey = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.content.no-card-margin > div.ph > div.ph__container > div.ph-avatar > img.ph-avatar__image', + )?.src + } + else if ( + pathname.includes('/splitgate/leaderboards/') + ) { + if (pathname.includes('/playlist/')) { + presenceData.details = 'Viewing Leaderboard:' + presenceData.state = 'Playlist' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Splitgate + } + else if (pathname.includes('/stats/')) { + presenceData.details = 'Viewing Leaderboard:' + presenceData.state = 'Overall' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Splitgate + } + } + else if (pathname === '/splitgate/challenges') { + presenceData.details = 'Viewing:' + presenceData.state = 'Splitgate Challenges' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Splitgate + } + else if ( + pathname.includes('/splitgate/challenges/') + ) { + const challengeTitle = document.querySelector( + '#app > div.trn-wrapper > div.trn-container > div > main > div.challenge > div.challenge__header > div > div.challenge__meta > h1', + )?.textContent + + presenceData.details = 'Viewing Challenge:' + presenceData.state = challengeTitle + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Splitgate + } + } + } + } + } + } + } + } + + break + } + case 'fortnitetracker.com': { + if (pathname === '/') { + presenceData.details = 'Viewing Fortnite Page' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + } + else if (pathname.includes('/profile/all/')) { + const playerName = document.querySelector( + '#profile > div.trn-card.trn-profile-header > div > h1 > span', + )?.textContent + + presenceData.details = 'Viewing Fortnite Profile:' + presenceData.state = playerName + presenceData.smallImageKey = Assets.Fn + presenceData.smallImageText = playerName + presenceData.largeImageKey = document.querySelector( + '#profile > div.trn-card.trn-profile-header > div > div.trn-profile-header__avatar.trn-roundavatar.trn-roundavatar--white > img', + )?.src + } + else { + switch (pathname) { + case '/event-lfp': { + presenceData.details = 'Viewing:' + presenceData.state = 'Looking for Player' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + + break + } + case '/events': { + presenceData.details = 'Viewing:' + presenceData.state = 'Events' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + + break + } + case '/events/powerrankings': { + presenceData.details = 'Viewing:' + presenceData.state = 'Power Ranking' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + + break + } + case '/arena/leaderboards': { + presenceData.details = 'Viewing Leaderboard:' + presenceData.state = 'Hype' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + + break + } + case '/events/earnings': { + presenceData.details = 'Viewing Leaderboard:' + presenceData.state = 'Earnings' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + + break + } + case '/bests/win-streaks': { + presenceData.details = 'Viewing Leaderboard:' + presenceData.state = 'Win Streak' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + + break + } + default: + if (pathname.includes('/bests/high-kills/')) { + presenceData.details = 'Viewing Leaderboard:' + presenceData.state = 'Single Match Kills' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + } + else if (pathname.includes('/leaderboards/')) { + if (pathname.includes('/TRNRating')) { + presenceData.details = 'Viewing Leaderboard:' + presenceData.state = 'Tracker Network Rating' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + } + } + else if (pathname === '/challenges') { + presenceData.details = 'Viewing:' + presenceData.state = 'Challanges' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + } + else if (pathname.includes('/challenges/')) { + presenceData.details = 'Viewing Challange:' + presenceData.state = document.querySelector( + '#app > div > div.ftr-challenges > div:nth-child(1) > div.trn-card__header > h3', + )?.textContent + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + } + else if (pathname === '/creative') { + presenceData.details = 'Viewing:' + presenceData.state = 'Creative Maps' + + presenceData.smallImageText = 'TRN' + presenceData.largeImageKey = Assets.Fn + } + } + } + + break + } + case 'thetrackernetwork.com': { + if (pathname.includes('/manage/')) { + presenceData.details = 'Editing Profile' + presenceData.state = document.querySelector( + 'body > div > div.trn-wrapper > div > div > main > div > div:nth-child(2) > div.mgn-header', + )?.textContent + } + else { + switch (pathname) { + case '/contact': { + presenceData.details = 'Viewing:' + presenceData.state = 'Contact Page' + + break + } + case '/home/privacypolicy': { + presenceData.details = 'Viewing:' + presenceData.state = 'Privacy Policy' + + break + } + case '/home/tos': { + presenceData.details = 'Viewing:' + presenceData.state = 'Terms of Service' + + break + } + case '/home': { + presenceData.details = 'Viewing:' + presenceData.state = 'Homepage' + + break + } + } + } + break + } + } + + if ( + !(await presence.getSetting('buttons')) + || presenceData.details === 'Editing App:' + ) { + delete presenceData.buttons + } + else { + presenceData.buttons = [ + { + label: 'Open Page', + url: document.URL, + }, + ] + } + + if ( + pathname.includes('/manage/') + && (await presence.getSetting('privacy')) + && botHost === 'thetrackernetwork.com' + ) { + presenceData.details = 'Viewing Page:' + presenceData.state = 'Homepage' + } + + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Trackmania.io/metadata.json b/websites/T/Trackmania.io/metadata.json index de4c1b5b3d7a..9df33bac0ea4 100644 --- a/websites/T/Trackmania.io/metadata.json +++ b/websites/T/Trackmania.io/metadata.json @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Greep", - "id": "330030648456642562" - }, - "service": "Trackmania.io", - "description": { - "en": "Trackmania.io is an overview of the Trackmania Live services into your website. This service is provided by OpenPlanet.", - "fr": "Trackmania.io est une vue d'ensemble sur les services live de Trackmania dans votre navigateur. Ce service est offert par OpenPlanet.", - "nl": "Trackmania.io is een overzicht van de Trackmania Live-services op uw website. Deze dienst wordt geleverd door OpenPlanet." - }, - "url": [ - "trackmania.io", - "www.trackmania.io" - ], - "version": "1.2.15", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Trackmania.io/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Trackmania.io/assets/thumbnail.jpg", - "color": "#0A7FB4", - "category": "games", - "tags": [ - "cars", - "racing", - "tm", - "trackmania", - "ubisoft", - "nadeo" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Greep", + "id": "330030648456642562" + }, + "service": "Trackmania.io", + "description": { + "en": "Trackmania.io is an overview of the Trackmania Live services into your website. This service is provided by OpenPlanet.", + "fr": "Trackmania.io est une vue d'ensemble sur les services live de Trackmania dans votre navigateur. Ce service est offert par OpenPlanet.", + "nl": "Trackmania.io is een overzicht van de Trackmania Live-services op uw website. Deze dienst wordt geleverd door OpenPlanet." + }, + "url": [ + "trackmania.io", + "www.trackmania.io" + ], + "version": "1.2.15", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Trackmania.io/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Trackmania.io/assets/thumbnail.jpg", + "color": "#0A7FB4", + "category": "games", + "tags": [ + "cars", + "racing", + "tm", + "trackmania", + "ubisoft", + "nadeo" + ] +} diff --git a/websites/T/Trackmania.io/presence.ts b/websites/T/Trackmania.io/presence.ts index 34f084338e4d..6048af06a434 100644 --- a/websites/T/Trackmania.io/presence.ts +++ b/websites/T/Trackmania.io/presence.ts @@ -1,184 +1,202 @@ const presence = new Presence({ - clientId: "822176609753628742", - }), - monthsList = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", - ]; -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - details: "An overview of the Trackmania Live Services.", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Trackmania.io/assets/logo.jpg", - state: `Unsupported page (${window.location.hash})`, - startTimestamp: Math.floor(Date.now() / 1000), - }; + clientId: '822176609753628742', +}) +const monthsList = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December', +] +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + details: 'An overview of the Trackmania Live Services.', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Trackmania.io/assets/logo.jpg', + state: `Unsupported page (${window.location.hash})`, + startTimestamp: Math.floor(Date.now() / 1000), + } - if (window.location.hash.startsWith("#")) { - if (window.location.hash.startsWith("#/totd")) { - if (!window.location.hash.includes("leaderboard")) { - const title = document.querySelectorAll(".title")[1].textContent; - presenceData.details = "Track Of The Day"; - presenceData.state = title.substring(title.indexOf("-") + 2); - } else { - presenceData.details = "Leaderboard - Track Of The Day"; - presenceData.state = `${ - document.querySelector(".game-text").textContent - } (${document.querySelector(".subtitle").textContent})`; - const storageID = document - .querySelector(".thumbnail") - .getAttribute("src") - .replace(/^[a-z:/.]*\/([^]*)\.[a-z]*$$/gi, "$1"); - presenceData.largeImageKey = `https://trackmania.io/api/download/jpg/${storageID}`; - } - } else if (window.location.hash.startsWith("#/cotd")) { - presenceData.state = "Cup Of The Day"; - if (!window.location.hash.endsWith("cotd")) { - presenceData.details = "Cup Of The Day"; - const text = document.querySelector(".game-text").textContent, - cotdDate = new Date( - text.substring(presenceData.details.length, text.length) - ); + if (window.location.hash.startsWith('#')) { + if (window.location.hash.startsWith('#/totd')) { + if (!window.location.hash.includes('leaderboard')) { + const title = document.querySelectorAll('.title')[1].textContent + presenceData.details = 'Track Of The Day' + presenceData.state = title?.substring(title.indexOf('-') + 2) + } + else { + presenceData.details = 'Leaderboard - Track Of The Day' + presenceData.state = `${ + document.querySelector('.game-text')?.textContent + } (${document.querySelector('.subtitle')?.textContent})` + const storageID = document + .querySelector('.thumbnail') + ?.getAttribute('src') + // eslint-disable-next-line regexp/no-super-linear-backtracking + ?.replace(/^[a-z:/.]*\/([\s\S]*)\.[a-z]*$/gi, '$1') + presenceData.largeImageKey = `https://trackmania.io/api/download/jpg/${storageID}` + } + } + else if (window.location.hash.startsWith('#/cotd')) { + presenceData.state = 'Cup Of The Day' + if (!window.location.hash.endsWith('cotd')) { + presenceData.details = 'Cup Of The Day' + const text = document.querySelector('.game-text')?.textContent + const cotdDate = new Date( + text?.substring(presenceData.details.length, text.length) ?? '', + ) - presenceData.state = `${ - monthsList[cotdDate.getMonth()] - } ${cotdDate.getDate()}, ${cotdDate.getFullYear()}`; - } - } else if (window.location.hash.startsWith("#/campaigns")) { - presenceData.state = "Campaigns"; - if (!window.location.hash.endsWith("campaigns")) { - if (!window.location.hash.includes("leaderboard")) { - if (window.location.hash.startsWith("#/campaigns/0")) - presenceData.details = "Official Campaign"; - else { - presenceData.details = "Campaign"; - presenceData.largeImageKey = document - .querySelector(".campaign-media") - .getAttribute("src"); - } - presenceData.state = document.querySelector(".game-text").textContent; - } else { - presenceData.details = "Leaderboard"; - presenceData.state = `${ - document.querySelector(".game-text").textContent - } (${document.querySelector(".subtitle").textContent})`; - const storageID = document - .querySelector(".thumbnail") - .getAttribute("src") - .replace(/^[a-z:/.]*\/([^]*)\.[a-z]*$$/gi, "$1"); - presenceData.largeImageKey = `https://trackmania.io/api/download/jpg/${storageID}`; - } - } - } else if (window.location.hash.startsWith("#/rooms")) { - presenceData.state = "Club Rooms"; - if (!window.location.hash.endsWith("rooms")) { - presenceData.details = "Club Room"; + presenceData.state = `${ + monthsList[cotdDate.getMonth()] + } ${cotdDate.getDate()}, ${cotdDate.getFullYear()}` + } + } + else if (window.location.hash.startsWith('#/campaigns')) { + presenceData.state = 'Campaigns' + if (!window.location.hash.endsWith('campaigns')) { + if (!window.location.hash.includes('leaderboard')) { + if (window.location.hash.startsWith('#/campaigns/0')) { + presenceData.details = 'Official Campaign' + } + else { + presenceData.details = 'Campaign' + presenceData.largeImageKey = document + .querySelector('.campaign-media') + ?.getAttribute('src') + } + presenceData.state = document.querySelector('.game-text')?.textContent + } + else { + presenceData.details = 'Leaderboard' + presenceData.state = `${ + document.querySelector('.game-text')?.textContent + } (${document.querySelector('.subtitle')?.textContent})` + const storageID = document + .querySelector('.thumbnail') + ?.getAttribute('src') + // eslint-disable-next-line regexp/no-super-linear-backtracking + ?.replace(/^[a-z:/.]*\/([\s\S]*)\.[a-z]*$/gi, '$1') + presenceData.largeImageKey = `https://trackmania.io/api/download/jpg/${storageID}` + } + } + } + else if (window.location.hash.startsWith('#/rooms')) { + presenceData.state = 'Club Rooms' + if (!window.location.hash.endsWith('rooms')) { + presenceData.details = 'Club Room' - presenceData.state = `${ - document.querySelector(".game-text").textContent - } (${document.querySelector(".subtitle").textContent})`; + presenceData.state = `${ + document.querySelector('.game-text')?.textContent + } (${document.querySelector('.subtitle')?.textContent})` - presenceData.largeImageKey = document - .querySelector(".room-media") - .getAttribute("src"); - } - } else if (window.location.hash.startsWith("#/clubs")) { - presenceData.state = "Clubs"; - if (!window.location.hash.endsWith("clubs")) { - presenceData.details = "Club"; + presenceData.largeImageKey = document + .querySelector('.room-media') + ?.getAttribute('src') + } + } + else if (window.location.hash.startsWith('#/clubs')) { + presenceData.state = 'Clubs' + if (!window.location.hash.endsWith('clubs')) { + presenceData.details = 'Club' - presenceData.state = `${ - document.querySelector(".game-text").textContent - } (${document.querySelector(".subtitle").textContent})`; + presenceData.state = `${ + document.querySelector('.game-text')?.textContent + } (${document.querySelector('.subtitle')?.textContent})` - const clubImagesArray: string[] = []; + const clubImagesArray: string[] = [] - Array.prototype.forEach.call( - document.querySelectorAll(".is-small"), - function (el: Element) { - if (el.tagName === "IMG") - clubImagesArray.push(el.getAttribute("src")); - } - ); + Array.prototype.forEach.call( + document.querySelectorAll('.is-small'), + (el: Element) => { + if (el.tagName === 'IMG') + clubImagesArray.push(el.getAttribute('src')!) + }, + ) - if (clubImagesArray.length > 0) - [presenceData.largeImageKey] = clubImagesArray; - } - } else if (window.location.hash.startsWith("#/competitions")) { - presenceData.state = "Events"; - if (!window.location.hash.endsWith("competitions")) { - presenceData.details = "Event"; + if (clubImagesArray.length > 0) + [presenceData.largeImageKey] = clubImagesArray + } + } + else if (window.location.hash.startsWith('#/competitions')) { + presenceData.state = 'Events' + if (!window.location.hash.endsWith('competitions')) { + presenceData.details = 'Event' - presenceData.state = `${ - document.querySelector(".game-text").textContent - } (${document.querySelector(".subtitle").textContent})`; + presenceData.state = `${ + document.querySelector('.game-text')?.textContent + } (${document.querySelector('.subtitle')?.textContent})` - let eventLogo = document.querySelector(".logo").getAttribute("src"); + let eventLogo = document.querySelector('.logo')?.getAttribute('src') - if (!eventLogo.startsWith("http")) - eventLogo = `https://trackmania.io${eventLogo}`; + if (!eventLogo?.startsWith('http')) + eventLogo = `https://trackmania.io${eventLogo}` - presenceData.largeImageKey = eventLogo; - } - } else if (window.location.hash.startsWith("#/top")) { - presenceData.details = document.querySelectorAll(".title")[1].textContent; - presenceData.state = "Leaderboard"; - } else if (window.location.hash.startsWith("#/matches")) - presenceData.state = "Matches"; - else if (window.location.hash.startsWith("#/match")) { - presenceData.state = "Matches"; - if (!window.location.hash.endsWith("match")) { - presenceData.details = "Match"; - presenceData.state = document.querySelectorAll(".title")[1].textContent; - } - } else if (window.location.hash.startsWith("#/players")) { - presenceData.state = "Player search"; - if ( - !window.location.hash.endsWith("players") || - !window.location.hash.endsWith("players/") - ) { - presenceData.details = "Player search"; - const text = window.location.hash, - name = text.substring(text.lastIndexOf("/") + 1); + presenceData.largeImageKey = eventLogo + } + } + else if (window.location.hash.startsWith('#/top')) { + presenceData.details = document.querySelectorAll('.title')[1].textContent + presenceData.state = 'Leaderboard' + } + else if (window.location.hash.startsWith('#/matches')) { + presenceData.state = 'Matches' + } + else if (window.location.hash.startsWith('#/match')) { + presenceData.state = 'Matches' + if (!window.location.hash.endsWith('match')) { + presenceData.details = 'Match' + presenceData.state = document.querySelectorAll('.title')[1].textContent + } + } + else if (window.location.hash.startsWith('#/players')) { + presenceData.state = 'Player search' + if ( + !window.location.hash.endsWith('players') + || !window.location.hash.endsWith('players/') + ) { + presenceData.details = 'Player search' + const text = window.location.hash + const name = text.substring(text.lastIndexOf('/') + 1) - presenceData.state = name.charAt(0).toUpperCase() + name.slice(1); - } - } else if (window.location.hash.startsWith("#/player")) { - presenceData.state = "Player"; - if (!window.location.hash.endsWith("player")) { - presenceData.details = "Player"; - presenceData.state = document.querySelectorAll(".title")[1].textContent; - } - } else if ( - window.location.hash.startsWith("#/news") || - window.location.hash.startsWith("#/ads") - ) - presenceData.state = document.querySelectorAll(".title")[1].textContent; - else if (window.location.hash.startsWith("#/leaderboard")) { - presenceData.details = "Leaderboard"; - presenceData.state = `${ - document.querySelector(".game-text").textContent - } (${document.querySelector(".subtitle").textContent})`; - const storageID = document - .querySelector(".thumbnail") - .getAttribute("src") - .replace(/^[a-z:/.]*\/([^]*)\.[a-z]*$$/gi, "$1"); - presenceData.largeImageKey = `https://trackmania.io/api/download/jpg/${storageID}`; - } - } else if (window.location.pathname.startsWith("/api")) { - presenceData.state = `Viewing API (${window.location.pathname.substring( - "/api/".length - )})`; - } - presence.setActivity(presenceData); -}); + presenceData.state = name.charAt(0).toUpperCase() + name.slice(1) + } + } + else if (window.location.hash.startsWith('#/player')) { + presenceData.state = 'Player' + if (!window.location.hash.endsWith('player')) { + presenceData.details = 'Player' + presenceData.state = document.querySelectorAll('.title')[1].textContent + } + } + else if ( + window.location.hash.startsWith('#/news') + || window.location.hash.startsWith('#/ads') + ) { + presenceData.state = document.querySelectorAll('.title')[1].textContent + } + else if (window.location.hash.startsWith('#/leaderboard')) { + presenceData.details = 'Leaderboard' + presenceData.state = `${ + document.querySelector('.game-text')?.textContent + } (${document.querySelector('.subtitle')?.textContent})` + const storageID = document + .querySelector('.thumbnail') + ?.getAttribute('src') + // eslint-disable-next-line regexp/no-super-linear-backtracking + ?.replace(/^[a-z:/.]*\/([\s\S]*)\.[a-z]*$/gi, '$1') + presenceData.largeImageKey = `https://trackmania.io/api/download/jpg/${storageID}` + } + } + else if (window.location.pathname.startsWith('/api')) { + presenceData.state = `Viewing API (${window.location.pathname.substring( + '/api/'.length, + )})` + } + presence.setActivity(presenceData) +}) diff --git a/websites/T/TradingView/metadata.json b/websites/T/TradingView/metadata.json index 3ca4ac8c81bc..3949c8ce6ddf 100644 --- a/websites/T/TradingView/metadata.json +++ b/websites/T/TradingView/metadata.json @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Hibanka", - "id": "467658348158779393" - }, - "service": "TradingView", - "description": { - "en": "Free Stock Charts, Stock Quotes and Trade Ideas", - "ru": "Бесплатные онлайн-графики акций, котировки и идеи", - "nl": "Gratis voorraadgrafieken, aandelenkoersen en handelsideeën" - }, - "url": [ - "www.tradingview.com", - "status.tradingview.com" - ], - "regExp": "([a-z0-9]+)[.]tradingview[.]com", - "version": "1.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TradingView/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TradingView/assets/thumbnail.png", - "color": "#2196f3", - "category": "other", - "tags": [ - "markets", - "exchange", - "currency", - "crypto", - "stocks" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Hibanka", + "id": "467658348158779393" + }, + "service": "TradingView", + "description": { + "en": "Free Stock Charts, Stock Quotes and Trade Ideas", + "ru": "Бесплатные онлайн-графики акций, котировки и идеи", + "nl": "Gratis voorraadgrafieken, aandelenkoersen en handelsideeën" + }, + "url": [ + "www.tradingview.com", + "status.tradingview.com" + ], + "regExp": "([a-z0-9]+)[.]tradingview[.]com", + "version": "1.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TradingView/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TradingView/assets/thumbnail.png", + "color": "#2196f3", + "category": "other", + "tags": [ + "markets", + "exchange", + "currency", + "crypto", + "stocks" + ] +} diff --git a/websites/T/TradingView/presence.ts b/websites/T/TradingView/presence.ts index 18d56a6b4295..3ebcef5cb389 100644 --- a/websites/T/TradingView/presence.ts +++ b/websites/T/TradingView/presence.ts @@ -1,191 +1,238 @@ const presence = new Presence({ - clientId: "809817256686649344", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '809817256686649344', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TradingView/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TradingView/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (window.location.hostname.startsWith("status")) - presenceData.details = "Status Page"; - else if (window.location.pathname === "/") presenceData.details = "Home Page"; - else if (window.location.pathname.startsWith("/markets/cryptocurrencies")) { - presenceData.details = "Cryptocurrency Market"; - if (window.location.pathname.includes("/ideas")) - presenceData.state = "Ideas"; - else if (window.location.pathname.includes("/prices-all")) - presenceData.state = "Prices"; - else if (window.location.pathname.includes("/prices")) { - presenceData.state = `Prices: ${document - .querySelector( - "#js-category-content > header > div > div.tv-category-header__title-line > div > h1" - ) - .textContent.trim()}`; - } else if (window.location.pathname.includes("/global-charts")) - presenceData.state = "Market Cap"; - else presenceData.state = "Overview"; - } else if (window.location.pathname.startsWith("/markets/currencies")) { - presenceData.details = "Forex Market"; - if (window.location.pathname.includes("/ideas")) - presenceData.state = "Ideas"; - else if (window.location.pathname.includes("/rates-all")) - presenceData.state = "Rates"; - else if (window.location.pathname.includes("/rates-major")) - presenceData.state = "Rates: Major"; - else if (window.location.pathname.includes("/rates-minor")) - presenceData.state = "Rates: Minor"; - else if (window.location.pathname.includes("/rates-exotic")) - presenceData.state = "Rates: Exotic"; - else if (window.location.pathname.includes("/rates-americas")) - presenceData.state = "Rates: Americas"; - else if (window.location.pathname.includes("/rates-europe")) - presenceData.state = "Rates: Europe"; - else if (window.location.pathname.includes("/rates-asia")) - presenceData.state = "Rates: Asia"; - else if (window.location.pathname.includes("/rates-pacific")) - presenceData.state = "Rates: Pacific"; - else if (window.location.pathname.includes("/rates-middle-east")) - presenceData.state = "Rates: Middle East"; - else if (window.location.pathname.includes("/rates-africa")) - presenceData.state = "Rates: Africa"; - else if (window.location.pathname.includes("/cross-rates")) - presenceData.state = "Cross Rates"; - else if (window.location.pathname.includes("/indices")) - presenceData.state = "Currency Indices"; - else if (window.location.pathname.includes("/economic-calendar")) - presenceData.state = "Economic Calendar"; - else presenceData.state = "Overview"; - } else if (window.location.pathname.startsWith("/markets/stocks")) { - presenceData.details = document - .querySelector( - "#js-category-content > header > div > div.tv-category-header__title-line > div > span > span > h1" - ) - .textContent.trim(); - if (window.location.pathname.includes("/ideas")) - presenceData.state = "Ideas"; - else if (window.location.pathname.includes("/market-movers")) - presenceData.state = "Market Movers"; - else if (window.location.pathname.includes("/highs-and-lows")) - presenceData.state = "Highs & Lows"; - else if (window.location.pathname.includes("/earnings")) - presenceData.state = "Earnings Calendar"; - else if (window.location.pathname.includes("/sectorandindustry")) - presenceData.state = "Sector & Industry"; - else presenceData.state = "Overview"; - } else if (window.location.pathname.startsWith("/markets/indices")) { - presenceData.details = "Market Indices"; - if (window.location.pathname.includes("/ideas")) - presenceData.state = "Ideas"; - else if (window.location.pathname.includes("/quotes")) - presenceData.state = "Quotes"; - else presenceData.state = "Overview"; - } else if (window.location.pathname.startsWith("/markets/futures")) { - presenceData.details = "Futures Market"; - if (window.location.pathname.includes("/ideas")) - presenceData.state = "Ideas"; - else if (window.location.pathname.includes("/quotes")) - presenceData.state = "Quotes"; - else presenceData.state = "Overview"; - } else if (window.location.pathname.startsWith("/markets/bonds")) { - presenceData.details = "Bond Market"; - if (window.location.pathname.includes("/ideas")) - presenceData.state = "Ideas"; - else if (window.location.pathname.includes("/rates")) - presenceData.state = "Rates"; - else presenceData.state = "Overview"; - } else if (window.location.pathname.startsWith("/markets")) - presenceData.details = "Markets"; - else if (window.location.pathname.startsWith("/symbols")) { - presenceData.details = "Viewing Market..."; - presenceData.state = document - .querySelector( - "#anchor-page-1 > div > div.tv-category-header__title-line > div.tv-category-header__title > h1 > div > div" - ) - .textContent.trim(); - } else if (window.location.pathname.startsWith("/chart")) { - presenceData.details = "Viewing Chart..."; + if (window.location.hostname.startsWith('status')) { + presenceData.details = 'Status Page' + } + else if (window.location.pathname === '/') { + presenceData.details = 'Home Page' + } + else if (window.location.pathname.startsWith('/markets/cryptocurrencies')) { + presenceData.details = 'Cryptocurrency Market' + if (window.location.pathname.includes('/ideas')) { + presenceData.state = 'Ideas' + } + else if (window.location.pathname.includes('/prices-all')) { + presenceData.state = 'Prices' + } + else if (window.location.pathname.includes('/prices')) { + presenceData.state = `Prices: ${document + .querySelector( + '#js-category-content > header > div > div.tv-category-header__title-line > div > h1', + ) + ?.textContent + ?.trim()}` + } + else if (window.location.pathname.includes('/global-charts')) { + presenceData.state = 'Market Cap' + } + else { + presenceData.state = 'Overview' + } + } + else if (window.location.pathname.startsWith('/markets/currencies')) { + presenceData.details = 'Forex Market' + if (window.location.pathname.includes('/ideas')) + presenceData.state = 'Ideas' + else if (window.location.pathname.includes('/rates-all')) + presenceData.state = 'Rates' + else if (window.location.pathname.includes('/rates-major')) + presenceData.state = 'Rates: Major' + else if (window.location.pathname.includes('/rates-minor')) + presenceData.state = 'Rates: Minor' + else if (window.location.pathname.includes('/rates-exotic')) + presenceData.state = 'Rates: Exotic' + else if (window.location.pathname.includes('/rates-americas')) + presenceData.state = 'Rates: Americas' + else if (window.location.pathname.includes('/rates-europe')) + presenceData.state = 'Rates: Europe' + else if (window.location.pathname.includes('/rates-asia')) + presenceData.state = 'Rates: Asia' + else if (window.location.pathname.includes('/rates-pacific')) + presenceData.state = 'Rates: Pacific' + else if (window.location.pathname.includes('/rates-middle-east')) + presenceData.state = 'Rates: Middle East' + else if (window.location.pathname.includes('/rates-africa')) + presenceData.state = 'Rates: Africa' + else if (window.location.pathname.includes('/cross-rates')) + presenceData.state = 'Cross Rates' + else if (window.location.pathname.includes('/indices')) + presenceData.state = 'Currency Indices' + else if (window.location.pathname.includes('/economic-calendar')) + presenceData.state = 'Economic Calendar' + else presenceData.state = 'Overview' + } + else if (window.location.pathname.startsWith('/markets/stocks')) { + presenceData.details = document + .querySelector( + '#js-category-content > header > div > div.tv-category-header__title-line > div > span > span > h1', + ) + ?.textContent + ?.trim() + if (window.location.pathname.includes('/ideas')) + presenceData.state = 'Ideas' + else if (window.location.pathname.includes('/market-movers')) + presenceData.state = 'Market Movers' + else if (window.location.pathname.includes('/highs-and-lows')) + presenceData.state = 'Highs & Lows' + else if (window.location.pathname.includes('/earnings')) + presenceData.state = 'Earnings Calendar' + else if (window.location.pathname.includes('/sectorandindustry')) + presenceData.state = 'Sector & Industry' + else presenceData.state = 'Overview' + } + else if (window.location.pathname.startsWith('/markets/indices')) { + presenceData.details = 'Market Indices' + if (window.location.pathname.includes('/ideas')) + presenceData.state = 'Ideas' + else if (window.location.pathname.includes('/quotes')) + presenceData.state = 'Quotes' + else presenceData.state = 'Overview' + } + else if (window.location.pathname.startsWith('/markets/futures')) { + presenceData.details = 'Futures Market' + if (window.location.pathname.includes('/ideas')) + presenceData.state = 'Ideas' + else if (window.location.pathname.includes('/quotes')) + presenceData.state = 'Quotes' + else presenceData.state = 'Overview' + } + else if (window.location.pathname.startsWith('/markets/bonds')) { + presenceData.details = 'Bond Market' + if (window.location.pathname.includes('/ideas')) + presenceData.state = 'Ideas' + else if (window.location.pathname.includes('/rates')) + presenceData.state = 'Rates' + else presenceData.state = 'Overview' + } + else if (window.location.pathname.startsWith('/markets')) { + presenceData.details = 'Markets' + } + else if (window.location.pathname.startsWith('/symbols')) { + presenceData.details = 'Viewing Market...' + presenceData.state = document + .querySelector( + '#anchor-page-1 > div > div.tv-category-header__title-line > div.tv-category-header__title > h1 > div > div', + ) + ?.textContent + ?.trim() + } + else if (window.location.pathname.startsWith('/chart')) { + presenceData.details = 'Viewing Chart...' - const title = - // Full Interactive Chart - document - .querySelector( - "body > div.js-rootresizer__contents > div.layout__area--right > div > div.widgetbar-pages > div.widgetbar-pagescontent > div.widgetbar-page.active > div.widget-1UXejvkz.widgetbar-widget.widgetbar-widget-detail > div.widgetbar-widgetbody > div > div.wrapper-1CeUhfBr > div:nth-child(1) > div:nth-child(1) > span > a > span.text-H5Jbe1VB" - ) - ?.textContent?.trim() || - // Popup Chart Idea - document - .querySelector( - "#overlap-manager-root > div > div.tv-dialog__modal-wrap > div > div > div > div:nth-child(1) > div > div > div > div:nth-child(1) > div.tv-chart-view__header > div.tv-chart-view__title.selectable > div > div.tv-chart-view__title-row.tv-chart-view__title-row--symbol.tv-chart-view__symbol.js-chart-view__symbol.js-chart-view__ticker.quote-ticker-inited > a:nth-child(1)" - ) - ?.textContent?.trim() || - // Full Chart Idea Page - document - .querySelector( - "body > div.tv-main > div.tv-content > div > div > div:nth-child(1) > div.tv-chart-view__header > div.tv-chart-view__title.selectable > div > div.tv-chart-view__title-row.tv-chart-view__title-row--symbol.tv-chart-view__symbol.js-chart-view__symbol.js-chart-view__ticker.quote-ticker-inited > a:nth-child(1)" - ) - ?.textContent?.trim(); + // Full Interactive Chart + const title = document + .querySelector( + 'body > div.js-rootresizer__contents > div.layout__area--right > div > div.widgetbar-pages > div.widgetbar-pagescontent > div.widgetbar-page.active > div.widget-1UXejvkz.widgetbar-widget.widgetbar-widget-detail > div.widgetbar-widgetbody > div > div.wrapper-1CeUhfBr > div:nth-child(1) > div:nth-child(1) > span > a > span.text-H5Jbe1VB', + ) + ?.textContent + ?.trim() + // Popup Chart Idea + || document + .querySelector( + '#overlap-manager-root > div > div.tv-dialog__modal-wrap > div > div > div > div:nth-child(1) > div > div > div > div:nth-child(1) > div.tv-chart-view__header > div.tv-chart-view__title.selectable > div > div.tv-chart-view__title-row.tv-chart-view__title-row--symbol.tv-chart-view__symbol.js-chart-view__symbol.js-chart-view__ticker.quote-ticker-inited > a:nth-child(1)', + ) + ?.textContent + ?.trim() + // Full Chart Idea Page + || document + .querySelector( + 'body > div.tv-main > div.tv-content > div > div > div:nth-child(1) > div.tv-chart-view__header > div.tv-chart-view__title.selectable > div > div.tv-chart-view__title-row.tv-chart-view__title-row--symbol.tv-chart-view__symbol.js-chart-view__symbol.js-chart-view__ticker.quote-ticker-inited > a:nth-child(1)', + ) + ?.textContent + ?.trim() - if (title) presenceData.state = title; - } else if (window.location.pathname.startsWith("/script")) - presenceData.details = "Viewing Script..."; - else if (window.location.pathname.startsWith("/ideas")) - presenceData.details = "Trading Ideas"; - else if (window.location.pathname.startsWith("/education")) - presenceData.details = "Educational Ideas"; - else if (window.location.pathname.startsWith("/scripts")) - presenceData.details = "Scripts"; - else if (window.location.pathname.startsWith("/screener")) - presenceData.details = "Stock Screener"; - else if (window.location.pathname.startsWith("/forex-screener")) - presenceData.details = "Forex Screener"; - else if (window.location.pathname.startsWith("/crypto-screener")) - presenceData.details = "Crypto Screener"; - else if (window.location.pathname.startsWith("/streams")) - presenceData.details = "Streams"; - else if (window.location.pathname.startsWith("/broker-awards")) - presenceData.details = "Broker Awards"; - else if (window.location.pathname.startsWith("/brokers")) - presenceData.details = "Brokers"; - else if (window.location.pathname.startsWith("/broker/")) { - presenceData.details = "Broker Profile"; - presenceData.state = document - .querySelector( - "#anchor-page-1 > div > div.tv-category-header__title-line > div.tv-category-header__title > div > h1" - ) - .textContent.trim(); - } else if (window.location.pathname.startsWith("/u/")) { - presenceData.details = "User Profile"; - presenceData.state = document - .querySelector( - "#tv-profile > div > div > div.tv-profile__name-block > span > h1" - ) - .textContent.trim(); - } else if (window.location.pathname.startsWith("/chat")) - presenceData.details = "Chatting..."; - else if (window.location.pathname.startsWith("/contacts")) - presenceData.details = "About"; - else if (window.location.pathname.startsWith("/policies")) - presenceData.details = "Terms of Use"; - else if (window.location.pathname.startsWith("/privacy-policy")) - presenceData.details = "Privacy Policy"; - else if (window.location.pathname.startsWith("/cookies-policy")) - presenceData.details = "Cookies Policy"; - else if (window.location.pathname.startsWith("/disclaimer")) - presenceData.details = "Disclaimer"; - else if (window.location.pathname.startsWith("/moderators")) - presenceData.details = "Moderators"; - else if (window.location.pathname.startsWith("/people")) - presenceData.details = "Top Authors"; - else if (window.location.pathname.startsWith("/house-rules")) - presenceData.details = "TradingView House Rules"; - else if (window.location.pathname.startsWith("/blog")) - presenceData.details = "TradingView Blog"; + if (title) + presenceData.state = title + } + else if (window.location.pathname.startsWith('/script')) { + presenceData.details = 'Viewing Script...' + } + else if (window.location.pathname.startsWith('/ideas')) { + presenceData.details = 'Trading Ideas' + } + else if (window.location.pathname.startsWith('/education')) { + presenceData.details = 'Educational Ideas' + } + else if (window.location.pathname.startsWith('/scripts')) { + presenceData.details = 'Scripts' + } + else if (window.location.pathname.startsWith('/screener')) { + presenceData.details = 'Stock Screener' + } + else if (window.location.pathname.startsWith('/forex-screener')) { + presenceData.details = 'Forex Screener' + } + else if (window.location.pathname.startsWith('/crypto-screener')) { + presenceData.details = 'Crypto Screener' + } + else if (window.location.pathname.startsWith('/streams')) { + presenceData.details = 'Streams' + } + else if (window.location.pathname.startsWith('/broker-awards')) { + presenceData.details = 'Broker Awards' + } + else if (window.location.pathname.startsWith('/brokers')) { + presenceData.details = 'Brokers' + } + else if (window.location.pathname.startsWith('/broker/')) { + presenceData.details = 'Broker Profile' + presenceData.state = document + .querySelector( + '#anchor-page-1 > div > div.tv-category-header__title-line > div.tv-category-header__title > div > h1', + ) + ?.textContent + ?.trim() + } + else if (window.location.pathname.startsWith('/u/')) { + presenceData.details = 'User Profile' + presenceData.state = document + .querySelector( + '#tv-profile > div > div > div.tv-profile__name-block > span > h1', + ) + ?.textContent + ?.trim() + } + else if (window.location.pathname.startsWith('/chat')) { + presenceData.details = 'Chatting...' + } + else if (window.location.pathname.startsWith('/contacts')) { + presenceData.details = 'About' + } + else if (window.location.pathname.startsWith('/policies')) { + presenceData.details = 'Terms of Use' + } + else if (window.location.pathname.startsWith('/privacy-policy')) { + presenceData.details = 'Privacy Policy' + } + else if (window.location.pathname.startsWith('/cookies-policy')) { + presenceData.details = 'Cookies Policy' + } + else if (window.location.pathname.startsWith('/disclaimer')) { + presenceData.details = 'Disclaimer' + } + else if (window.location.pathname.startsWith('/moderators')) { + presenceData.details = 'Moderators' + } + else if (window.location.pathname.startsWith('/people')) { + presenceData.details = 'Top Authors' + } + else if (window.location.pathname.startsWith('/house-rules')) { + presenceData.details = 'TradingView House Rules' + } + else if (window.location.pathname.startsWith('/blog')) { + presenceData.details = 'TradingView Blog' + } - presenceData.details ??= "Browsing..."; + presenceData.details ??= 'Browsing...' - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/Trakt/metadata.json b/websites/T/Trakt/metadata.json index de3cf8aa8a38..58aecd23c4d7 100644 --- a/websites/T/Trakt/metadata.json +++ b/websites/T/Trakt/metadata.json @@ -1,21 +1,21 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "xKubson_", - "id": "404217213873029120" - }, - "service": "Trakt", - "description": { - "en": "Track what you watch and when. Discover what's hot and where you can watch it. Share comments, ratings and recommendations." - }, - "url": "trakt.tv", - "version": "1.0.11", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Trakt/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Trakt/assets/thumbnail.png", - "color": "#ff0000", - "category": "videos", - "tags": [ - "videos" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "xKubson_", + "id": "404217213873029120" + }, + "service": "Trakt", + "description": { + "en": "Track what you watch and when. Discover what's hot and where you can watch it. Share comments, ratings and recommendations." + }, + "url": "trakt.tv", + "version": "1.0.11", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Trakt/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Trakt/assets/thumbnail.png", + "color": "#ff0000", + "category": "videos", + "tags": [ + "videos" + ] +} diff --git a/websites/T/Trakt/presence.ts b/websites/T/Trakt/presence.ts index 689fd87a59ef..baccbb002ab2 100644 --- a/websites/T/Trakt/presence.ts +++ b/websites/T/Trakt/presence.ts @@ -1,179 +1,191 @@ const presence = new Presence({ - clientId: "968880591003082783", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '968880591003082783', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Trakt/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Trakt/assets/logo.png', } -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } - const { pathname, href } = document.location, - pages: Record = { - "/": { details: "Browsing the home page" }, - "/dashboard": { details: "Browsing dashboard" }, - "/shows/trending": { state: "Trending shows" }, - "/shows/popular": { state: "Popular shows" }, - "/shows/recommended": { state: "Recommended shows" }, - "/shows/anticipated": { state: "Anticipated shows" }, - "/shows/watched": { state: "The most watched shows" }, - "/shows/collected": { state: "The most collected shows" }, - "/movies/trending": { state: "Trending movies" }, - "/movies/popular": { state: "Popular movies" }, - "/movies/recommended": { state: "Recommended movies" }, - "/movies/anticipated": { state: "Anticipated movies" }, - "/movies/watched": { state: "The most watched movies" }, - "/movies/collected": { state: "The most collected movies" }, - "/movies/boxoffice": { state: "Top 10 grossing movies" }, - "/calendars/my": { details: "Browsing my calendar" }, - "/calendars/my/shows": { - details: "Browsing their calendar", - state: "Shows", - }, - "/calendars/my/premieres": { - details: "Browsing their calendar", - state: "Premieres", - }, - "/calendars/my/new-shows": { - details: "Browsing their calendar", - state: "New shows", - }, - "/calendars/my/movies": { - details: "Browsing their calendar", - state: "Movies", - }, - "/calendars/my/dvd": { - details: "Browsing their calendar", - state: "DVD & Blu-ray", - }, - "/calendars/shows": { - details: "Browsing calendar", - state: "Shows", - }, - "/calendars/premieres": { - details: "Browsing calendar", - state: "Premieres", - }, - "/calendars/new-shows": { - details: "Browsing calendar", - state: "New shows", - }, - "/calendars/movies": { - details: "Browsing calendar", - state: "Movies", - }, - "/calendars/dvd": { - details: "Browsing calendar", - state: "DVD & Blu-ray", - }, - "/discover": { details: "Finding new shows/movies" }, - "/apps": { details: "Browsing apps" }, - "/vip": { details: "Browsing VIP features" }, - "/settings": { details: "Browsing settings" }, - "/auth/signin": { details: "Registering on Trakt" }, - "/auth/login": { details: "Logging in to Trakt" }, - "/widgets": { details: "Browsing widgets" }, - }, - imagePath = document.querySelector("img.real")?.getAttribute("src"); + const { pathname, href } = document.location + const pages: Record = { + '/': { details: 'Browsing the home page' }, + '/dashboard': { details: 'Browsing dashboard' }, + '/shows/trending': { state: 'Trending shows' }, + '/shows/popular': { state: 'Popular shows' }, + '/shows/recommended': { state: 'Recommended shows' }, + '/shows/anticipated': { state: 'Anticipated shows' }, + '/shows/watched': { state: 'The most watched shows' }, + '/shows/collected': { state: 'The most collected shows' }, + '/movies/trending': { state: 'Trending movies' }, + '/movies/popular': { state: 'Popular movies' }, + '/movies/recommended': { state: 'Recommended movies' }, + '/movies/anticipated': { state: 'Anticipated movies' }, + '/movies/watched': { state: 'The most watched movies' }, + '/movies/collected': { state: 'The most collected movies' }, + '/movies/boxoffice': { state: 'Top 10 grossing movies' }, + '/calendars/my': { details: 'Browsing my calendar' }, + '/calendars/my/shows': { + details: 'Browsing their calendar', + state: 'Shows', + }, + '/calendars/my/premieres': { + details: 'Browsing their calendar', + state: 'Premieres', + }, + '/calendars/my/new-shows': { + details: 'Browsing their calendar', + state: 'New shows', + }, + '/calendars/my/movies': { + details: 'Browsing their calendar', + state: 'Movies', + }, + '/calendars/my/dvd': { + details: 'Browsing their calendar', + state: 'DVD & Blu-ray', + }, + '/calendars/shows': { + details: 'Browsing calendar', + state: 'Shows', + }, + '/calendars/premieres': { + details: 'Browsing calendar', + state: 'Premieres', + }, + '/calendars/new-shows': { + details: 'Browsing calendar', + state: 'New shows', + }, + '/calendars/movies': { + details: 'Browsing calendar', + state: 'Movies', + }, + '/calendars/dvd': { + details: 'Browsing calendar', + state: 'DVD & Blu-ray', + }, + '/discover': { details: 'Finding new shows/movies' }, + '/apps': { details: 'Browsing apps' }, + '/vip': { details: 'Browsing VIP features' }, + '/settings': { details: 'Browsing settings' }, + '/auth/signin': { details: 'Registering on Trakt' }, + '/auth/login': { details: 'Logging in to Trakt' }, + '/widgets': { details: 'Browsing widgets' }, + } + const imagePath = document.querySelector('img.real')?.getAttribute('src') - for (const [path, data] of Object.entries(pages)) - if (pathname.includes(path)) presenceData = { ...presenceData, ...data }; + for (const [path, data] of Object.entries(pages)) { + if (pathname.includes(path)) + presenceData = { ...presenceData, ...data } as PresenceData + } - if (pathname.includes("/users")) { - const username = document.querySelector( - "#avatar-wrapper > .emojis-supported > a" - ).textContent; - presenceData.buttons = [{ label: "Check profile", url: href }]; - if (pathname.includes("/history")) - presenceData.details = `Browsing ${username}'s history`; - else if (pathname.includes("/progress")) - presenceData.details = `Browsing ${username}'s progress`; - else if (pathname.includes("/collection")) - presenceData.details = `Browsing ${username}'s collection`; - else if (pathname.includes("/ratings")) - presenceData.details = `Browsing ${username}'s ratings`; - else if (pathname.includes("/lists")) - presenceData.details = `Browsing ${username}'s lists`; - else if (pathname.includes("/comments")) - presenceData.details = `Browsing ${username}'s comments`; - else if (pathname.includes("/network")) - presenceData.details = `Browsing ${username}'s friends`; - else presenceData.details = `Browsing ${username}'s profile`; - } else if (pathname.includes("/shows/")) { - if (pathname.includes("/episodes/")) { - presenceData.details = document - .querySelector( - "#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h2 > a:nth-child(1)" - ) - .textContent.replace(":", ""); - presenceData.state = `${ - document.querySelector( - "#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1 > span.main-title-sxe" - ).textContent - }: ${ - document.querySelector( - "#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1 > span.main-title" - ).textContent - }`; - presenceData.largeImageKey = imagePath; - presenceData.smallImageKey = Assets.Logo; - presenceData.buttons = [{ label: "Check episode", url: href }]; - } else if (pathname.includes("/seasons/")) { - presenceData.details = "Browsing season"; - presenceData.state = `${ - document.querySelector("#level-up-link").textContent - }: ${ - document.querySelector( - "#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1" - ).firstChild.textContent - }`; - presenceData.largeImageKey = imagePath; - presenceData.smallImageKey = Assets.Logo; - presenceData.buttons = [{ label: "Check season", url: href }]; - } else { - try { - presenceData.details = "Browsing TV show"; - presenceData.state = document.querySelector( - "#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1" - ).firstChild.textContent; - presenceData.largeImageKey = imagePath; - presenceData.smallImageKey = Assets.Logo; - presenceData.buttons = [{ label: "Check TV show", url: href }]; - } catch { - presenceData.details = "Browsing"; - } - } - } else if (pathname.includes("/movies")) { - try { - presenceData.details = "Browsing movie"; - presenceData.state = document.querySelector( - "#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1" - ).childNodes[0].textContent; - presenceData.largeImageKey = imagePath; - presenceData.smallImageKey = Assets.Logo; - presenceData.buttons = [{ label: "Check movie", url: href }]; - } catch { - presenceData.details = "Browsing"; - } - } else if (pathname.includes("/people")) { - presenceData.details = "Browsing actor"; - presenceData.state = document.querySelector( - "#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1" - ).textContent; - presenceData.largeImageKey = imagePath; - presenceData.smallImageKey = Assets.Logo; - presenceData.buttons = [{ label: "Check actor", url: href }]; - } else if (pathname.includes("/search")) { - presenceData.details = "Searching for"; - presenceData.state = new URLSearchParams(window.location.search).get( - "query" - ); - } + if (pathname.includes('/users')) { + const username = document.querySelector( + '#avatar-wrapper > .emojis-supported > a', + )?.textContent + presenceData.buttons = [{ label: 'Check profile', url: href }] + if (pathname.includes('/history')) + presenceData.details = `Browsing ${username}'s history` + else if (pathname.includes('/progress')) + presenceData.details = `Browsing ${username}'s progress` + else if (pathname.includes('/collection')) + presenceData.details = `Browsing ${username}'s collection` + else if (pathname.includes('/ratings')) + presenceData.details = `Browsing ${username}'s ratings` + else if (pathname.includes('/lists')) + presenceData.details = `Browsing ${username}'s lists` + else if (pathname.includes('/comments')) + presenceData.details = `Browsing ${username}'s comments` + else if (pathname.includes('/network')) + presenceData.details = `Browsing ${username}'s friends` + else presenceData.details = `Browsing ${username}'s profile` + } + else if (pathname.includes('/shows/')) { + if (pathname.includes('/episodes/')) { + presenceData.details = document + .querySelector( + '#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h2 > a:nth-child(1)', + ) + ?.textContent + ?.replace(':', '') + presenceData.state = `${ + document.querySelector( + '#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1 > span.main-title-sxe', + )?.textContent + }: ${ + document.querySelector( + '#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1 > span.main-title', + )?.textContent + }` + presenceData.largeImageKey = imagePath + presenceData.smallImageKey = Assets.Logo + presenceData.buttons = [{ label: 'Check episode', url: href }] + } + else if (pathname.includes('/seasons/')) { + presenceData.details = 'Browsing season' + presenceData.state = `${ + document.querySelector('#level-up-link')?.textContent + }: ${ + document.querySelector( + '#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1', + )?.firstChild?.textContent + }` + presenceData.largeImageKey = imagePath + presenceData.smallImageKey = Assets.Logo + presenceData.buttons = [{ label: 'Check season', url: href }] + } + else { + try { + presenceData.details = 'Browsing TV show' + presenceData.state = document.querySelector( + '#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1', + )?.firstChild?.textContent + presenceData.largeImageKey = imagePath + presenceData.smallImageKey = Assets.Logo + presenceData.buttons = [{ label: 'Check TV show', url: href }] + } + catch { + presenceData.details = 'Browsing' + } + } + } + else if (pathname.includes('/movies')) { + try { + presenceData.details = 'Browsing movie' + presenceData.state = document.querySelector( + '#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1', + )?.childNodes[0]?.textContent + presenceData.largeImageKey = imagePath + presenceData.smallImageKey = Assets.Logo + presenceData.buttons = [{ label: 'Check movie', url: href }] + } + catch { + presenceData.details = 'Browsing' + } + } + else if (pathname.includes('/people')) { + presenceData.details = 'Browsing actor' + presenceData.state = document.querySelector( + '#summary-wrapper > div.container.summary > div > div > div.col-md-10.col-md-offset-2.col-sm-9.col-sm-offset-3.mobile-title > h1', + )?.textContent + presenceData.largeImageKey = imagePath + presenceData.smallImageKey = Assets.Logo + presenceData.buttons = [{ label: 'Check actor', url: href }] + } + else if (pathname.includes('/search')) { + presenceData.details = 'Searching for' + presenceData.state = new URLSearchParams(window.location.search).get( + 'query', + ) + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Trello/metadata.json b/websites/T/Trello/metadata.json index 1e749dea3631..76e4f8e752e2 100644 --- a/websites/T/Trello/metadata.json +++ b/websites/T/Trello/metadata.json @@ -1,39 +1,39 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "Trello", - "description": { - "en": "Trello keeps track of everything, from the big picture to the minute details.", - "nl": "Trello houdt alles bij, van het grote geheel tot de kleine details." - }, - "url": [ - "trello.com", - "help.trello.com", - "blog.trello.com", - "developers.trello.com" - ], - "version": "2.2.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Trello/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Trello/assets/thumbnail.png", - "color": "#0080cb", - "category": "other", - "tags": [ - "projects", - "board", - "card", - "list", - "management" - ], - "settings": [ - { - "id": "displayPrivateBoards", - "title": "Display Private Boards", - "icon": "fas fa-lock", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "Trello", + "description": { + "en": "Trello keeps track of everything, from the big picture to the minute details.", + "nl": "Trello houdt alles bij, van het grote geheel tot de kleine details." + }, + "url": [ + "trello.com", + "help.trello.com", + "blog.trello.com", + "developers.trello.com" + ], + "version": "2.2.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Trello/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Trello/assets/thumbnail.png", + "color": "#0080cb", + "category": "other", + "tags": [ + "projects", + "board", + "card", + "list", + "management" + ], + "settings": [ + { + "id": "displayPrivateBoards", + "title": "Display Private Boards", + "icon": "fas fa-lock", + "value": false + } + ] +} diff --git a/websites/T/Trello/presence.ts b/websites/T/Trello/presence.ts index 30218f3384f4..ecd5df08d328 100644 --- a/websites/T/Trello/presence.ts +++ b/websites/T/Trello/presence.ts @@ -1,167 +1,187 @@ const presence = new Presence({ - clientId: "614583717951963137", // CLIENT ID FOR YOUR PRESENCE - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '614583717951963137', // CLIENT ID FOR YOUR PRESENCE +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let board: HTMLElement, profile: string; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Trello/assets/logo.png', + } + const displayPrivateBoards = await presence.getSetting( + 'displayPrivateBoards', + ) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Trello/assets/logo.png", - }, - displayPrivateBoards = await presence.getSetting( - "displayPrivateBoards" - ); + presenceData.startTimestamp = browsingTimestamp - presenceData.startTimestamp = browsingTimestamp; + switch (document.location.hostname) { + case 'trello.com': { + if (document.location.pathname.includes('/b/')) { + if ( + document.querySelector( + '[data-testid="workspace-navigation-nav"] a > p', + ) + ) { + if ( + document.querySelector( + '.board-main-content [data-testid="PrivateIcon"]', + ) + && !displayPrivateBoards + ) { + presenceData.details = 'Viewing private board' + } + else { + presenceData.details = `Viewing board: ${document.querySelector( + '[data-testid="board-name-display"]', + )?.textContent}` + presenceData.state = `In workspace: ${ + document.querySelector( + '[data-testid="workspace-navigation-nav"] a > p', + )?.textContent + }` + } + } + else { + presenceData.details = 'Viewing board:' + if ( + document.querySelector( + '.board-main-content [data-testid="PrivateIcon"]', + ) + && !displayPrivateBoards + ) { + presenceData.details = 'Viewing private board' + } + else { + presenceData.state = document.querySelector( + '[data-testid="board-name-display"]', + )?.textContent + } + } + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/c/')) { + if ( + document.querySelector( + '.board-main-content [data-testid="PrivateIcon"]', + ) + && !displayPrivateBoards + ) { + presenceData.details = 'Viewing private card' + presenceData.state = 'Private Board' + } + else { + presenceData.details = `Viewing card: ${ + document.querySelector('.window-title')?.textContent + }` + presenceData.state = `Board: ${ + document.querySelector('[data-testid="board-name-display"]') + ?.textContent + }` + presenceData.smallImageKey = Assets.Reading + } + } + else if (document.location.pathname.includes('/activity')) { + const [profile] = document.location.pathname.split('/', 3).slice(2) + presenceData.details = `Viewing @${profile}'s` + presenceData.state = 'recent activites' + } + else if (document.location.pathname.includes('/cards')) { + const [profile] = document.location.pathname.split('/', 3).slice(2) + presenceData.details = `Viewing @${profile}'s` + presenceData.state = 'recent cards' + } + else if (document.location.pathname.includes('/boards')) { + const [profile] = document.location.pathname.split('/', 3).slice(2) + presenceData.details = `Viewing @${profile}'s boards` + } + else if (document.location.pathname.includes('/home')) { + presenceData.details = `Viewing Workspace: ${ + document.querySelector('.all-boards h2')?.textContent + }` + } + else if ( + document.location.pathname.includes('/account') + || document.location.pathname.includes('/billing') + ) { + presenceData.details = 'Changing account settings' + } + else if (document.location.pathname.includes('/u/')) { + const [profile] = document.location.pathname.split('/', 3).slice(2) + presenceData.details = `Viewing @${profile}'s profile` + } + else if (document.location.pathname.includes('/shortcuts')) { + presenceData.details = 'Viewing shortcut settings' + } + else if (document.location.pathname.includes('/tour')) { + presenceData.details = 'Viewing Trello\'s Tour' + } + else if (document.location.pathname.includes('/pricing')) { + presenceData.details = 'Viewing Trello\'s Pricing' + } + else if (document.location.pathname.includes('/platforms')) { + presenceData.details = 'Viewing Trello\'s Platforms' + } + else if (document.location.pathname.includes('/about')) { + presenceData.details = 'Viewing Trello\'s' + presenceData.state = 'About page' + } + else { + presenceData.details = 'Viewing home page' + } - switch (document.location.hostname) { - case "trello.com": { - if (document.location.pathname.includes("/b/")) { - if ( - document.querySelector( - '[data-testid="workspace-navigation-nav"] a > p' - ) - ) { - if ( - document.querySelector( - '.board-main-content [data-testid="PrivateIcon"]' - ) && - !displayPrivateBoards - ) - presenceData.details = "Viewing private board"; - else { - presenceData.details = `Viewing board: ${(presenceData.state = - document.querySelector( - '[data-testid="board-name-display"]' - ).textContent)}`; - presenceData.state = `In workspace: ${ - document.querySelector( - '[data-testid="workspace-navigation-nav"] a > p' - ).textContent - }`; - } - } else { - presenceData.details = "Viewing board:"; - if ( - document.querySelector( - '.board-main-content [data-testid="PrivateIcon"]' - ) && - !displayPrivateBoards - ) - presenceData.details = "Viewing private board"; - else { - presenceData.state = document.querySelector( - '[data-testid="board-name-display"]' - ).textContent; - } - } - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/c/")) { - if ( - document.querySelector( - '.board-main-content [data-testid="PrivateIcon"]' - ) && - !displayPrivateBoards - ) { - presenceData.details = "Viewing private card"; - presenceData.state = "Private Board"; - } else { - presenceData.details = `Viewing card: ${ - document.querySelector(".window-title").textContent - }`; - presenceData.state = `Board: ${ - document.querySelector('[data-testid="board-name-display"]') - .textContent - }`; - presenceData.smallImageKey = Assets.Reading; - } - } else if (document.location.pathname.includes("/activity")) { - [profile] = document.location.pathname.split("/", 3).slice(2); - presenceData.details = `Viewing @${profile}'s`; - presenceData.state = "recent activites"; - } else if (document.location.pathname.includes("/cards")) { - [profile] = document.location.pathname.split("/", 3).slice(2); - presenceData.details = `Viewing @${profile}'s`; - presenceData.state = "recent cards"; - } else if (document.location.pathname.includes("/boards")) { - [profile] = document.location.pathname.split("/", 3).slice(2); - presenceData.details = `Viewing @${profile}'s boards`; - } else if (document.location.pathname.includes("/home")) { - presenceData.details = `Viewing Workspace: ${ - document.querySelector(".all-boards h2").textContent - }`; - } else if ( - document.location.pathname.includes("/account") || - document.location.pathname.includes("/billing") - ) - presenceData.details = "Changing account settings"; - else if (document.location.pathname.includes("/u/")) { - [profile] = document.location.pathname.split("/", 3).slice(2); - presenceData.details = `Viewing @${profile}'s profile`; - } else if (document.location.pathname.includes("/shortcuts")) - presenceData.details = "Viewing shortcut settings"; - else if (document.location.pathname.includes("/tour")) - presenceData.details = "Viewing Trello's Tour"; - else if (document.location.pathname.includes("/pricing")) - presenceData.details = "Viewing Trello's Pricing"; - else if (document.location.pathname.includes("/platforms")) - presenceData.details = "Viewing Trello's Platforms"; - else if (document.location.pathname.includes("/about")) { - presenceData.details = "Viewing Trello's"; - presenceData.state = "About page"; - } else presenceData.details = "Viewing home page"; + break + } + case 'blog.trello.com': { + if (document.location.pathname.includes('/topic/')) { + const board = document.querySelector( + 'body > div.body-container-wrapper > div > div > div > div > div > div.row-fluid > div > div.row-fluid-wrapper.row-depth-1.row-number-3 > div > div > div > h2', + ) + presenceData.details = 'Blog, topic:' + presenceData.state = board?.textContent + } + else if (document.location.pathname.includes('/author/')) { + const profile = document.querySelector( + 'body > div.body-container-wrapper > div > div > div > div > div > div.row-fluid > div > div.row-fluid-wrapper.row-depth-1.row-number-6 > div > div > div > div > div > div:nth-child(1) > div > h2', + )?.textContent + presenceData.details = 'Blog, viewing profile:' + presenceData.state = profile + } + else if (document.location.pathname.includes('/search')) { + const profile = document.querySelector('#gsc-i-id1')?.value + presenceData.details = 'Blog, searching for:' + presenceData.state = profile + presenceData.smallImageKey = Assets.Search + } + else if (document.location.pathname.includes('/')) { + const board = document.querySelector('#hs_cos_wrapper_name') + if (board) { + presenceData.details = 'Blog, article:' + presenceData.state = board.textContent + presenceData.smallImageKey = Assets.Reading + } + else { + presenceData.details = 'Viewing Trello\'s' + presenceData.state = 'Blog page' + } + } - break; - } - case "blog.trello.com": { - if (document.location.pathname.includes("/topic/")) { - board = document.querySelector( - "body > div.body-container-wrapper > div > div > div > div > div > div.row-fluid > div > div.row-fluid-wrapper.row-depth-1.row-number-3 > div > div > div > h2" - ); - presenceData.details = "Blog, topic:"; - presenceData.state = board.textContent; - } else if (document.location.pathname.includes("/author/")) { - profile = document.querySelector( - "body > div.body-container-wrapper > div > div > div > div > div > div.row-fluid > div > div.row-fluid-wrapper.row-depth-1.row-number-6 > div > div > div > div > div > div:nth-child(1) > div > h2" - )?.textContent; - presenceData.details = "Blog, viewing profile:"; - presenceData.state = profile; - } else if (document.location.pathname.includes("/search")) { - profile = document.querySelector("#gsc-i-id1").value; - presenceData.details = "Blog, searching for:"; - presenceData.state = profile; - presenceData.smallImageKey = Assets.Search; - } else if (document.location.pathname.includes("/")) { - board = document.querySelector("#hs_cos_wrapper_name"); - if (board) { - presenceData.details = "Blog, article:"; - presenceData.state = board.textContent; - presenceData.smallImageKey = Assets.Reading; - } else { - presenceData.details = "Viewing Trello's"; - presenceData.state = "Blog page"; - } - } + break + } + case 'developers.trello.com': { + if (document.location.pathname.includes('/reference')) { + const [, profile] = document.URL.split('#', 2) + presenceData.details = 'Developers, API Docs:' + presenceData.state = profile + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/docs')) { + presenceData.details = 'Developers, Reading guide' + presenceData.smallImageKey = Assets.Reading + } - break; - } - case "developers.trello.com": { - if (document.location.pathname.includes("/reference")) { - [, profile] = document.URL.split("#", 2); - presenceData.details = "Developers, API Docs:"; - presenceData.state = profile; - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/docs")) { - presenceData.details = "Developers, Reading guide"; - presenceData.smallImageKey = Assets.Reading; - } - - break; - } - // No default - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + break + } + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Trendyol/metadata.json b/websites/T/Trendyol/metadata.json index e45f175232e8..9e325839dcaf 100644 --- a/websites/T/Trendyol/metadata.json +++ b/websites/T/Trendyol/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "EGGSY", - "id": "162969778699501569" - }, - "service": "Trendyol", - "description": { - "en": "Trendyol is a popular shopping website in Turkey.", - "tr": "Trendyol, Türkiye'de hizmet gösteren en büyük alışveriş sitelerinden birisidir.", - "nl": "Trendyol is een populaire winkelwebsite in Turkije." - }, - "url": "www.trendyol.com", - "version": "1.1.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/thumbnail.png", - "color": "#f28232", - "category": "other", - "tags": [ - "trendyol", - "shopping", - "turkish" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "EGGSY", + "id": "162969778699501569" + }, + "service": "Trendyol", + "description": { + "en": "Trendyol is a popular shopping website in Turkey.", + "tr": "Trendyol, Türkiye'de hizmet gösteren en büyük alışveriş sitelerinden birisidir.", + "nl": "Trendyol is een populaire winkelwebsite in Turkije." + }, + "url": "www.trendyol.com", + "version": "1.1.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/thumbnail.png", + "color": "#f28232", + "category": "other", + "tags": [ + "trendyol", + "shopping", + "turkish" + ] +} diff --git a/websites/T/Trendyol/presence.ts b/websites/T/Trendyol/presence.ts index 278e4f9e75f5..e5edef77dc47 100644 --- a/websites/T/Trendyol/presence.ts +++ b/websites/T/Trendyol/presence.ts @@ -1,121 +1,118 @@ const presence = new Presence({ - clientId: "643758670131363840", - }), - pages: { [key: string]: string } = { - "/butik/liste/erkek": "Erkek Giyim", - "/butik/liste/kadin": "Kadın Giyim", - "/butik/liste/cocuk": "Çocuk Giyim", - "/butik/liste/ayakkabi--canta": "Ayakkabı & Çanta", - "/butik/liste/saat--aksesuar": "Saat & Aksesuar", - "/kozmetik": "Kozmetik", - "/ev--yasam": "Ev & Yaşam", - "/elektronik": "Elektronik", - "/supermarket": "Süper Market", - "/yardim/sorular": "Yardım & Destek", - "/sepetim": "Sepet", - "/bizeulasin": "Bize Ulaşın", - "/saticibasvuru": "Satıcı Başvuru", - "/s/kampanyalar": "Aktif Kampanyalar", - "/s/elite": "En Trend Ürünler", - "/login": "Giriş Yap", - "/Hesabim": "Hesabım", - "/Hesabim/Degerlendirmelerim": "Değerlendirmelerim", - "/Hesabim/KullaniciBilgileri": "Kullanıcı Bilgileri", - "/Hesabim/IndirimKuponlari": "İndirim Kuponları", - "/Hesabim/AdresBilgileri": "Adres Bilgileri", - "/Hesabim/KrediKartlarim": "Kredi Kartları", - "/Hesabim/Elite": "Trendyol Elite", - "/Hesabim/DuyuruTercihleri": "Duyuru Tercihleri", - "/Hesabim/Favoriler": "Favoriler", - }; + clientId: '643758670131363840', +}) +const pages: { [key: string]: string } = { + '/butik/liste/erkek': 'Erkek Giyim', + '/butik/liste/kadin': 'Kadın Giyim', + '/butik/liste/cocuk': 'Çocuk Giyim', + '/butik/liste/ayakkabi--canta': 'Ayakkabı & Çanta', + '/butik/liste/saat--aksesuar': 'Saat & Aksesuar', + '/kozmetik': 'Kozmetik', + '/ev--yasam': 'Ev & Yaşam', + '/elektronik': 'Elektronik', + '/supermarket': 'Süper Market', + '/yardim/sorular': 'Yardım & Destek', + '/sepetim': 'Sepet', + '/bizeulasin': 'Bize Ulaşın', + '/saticibasvuru': 'Satıcı Başvuru', + '/s/kampanyalar': 'Aktif Kampanyalar', + '/s/elite': 'En Trend Ürünler', + '/login': 'Giriş Yap', + '/Hesabim': 'Hesabım', + '/Hesabim/Degerlendirmelerim': 'Değerlendirmelerim', + '/Hesabim/KullaniciBilgileri': 'Kullanıcı Bilgileri', + '/Hesabim/IndirimKuponlari': 'İndirim Kuponları', + '/Hesabim/AdresBilgileri': 'Adres Bilgileri', + '/Hesabim/KrediKartlarim': 'Kredi Kartları', + '/Hesabim/Elite': 'Trendyol Elite', + '/Hesabim/DuyuruTercihleri': 'Duyuru Tercihleri', + '/Hesabim/Favoriler': 'Favoriler', +} -presence.on("UpdateData", async () => { - const page = document.location.pathname, - category = - document.querySelector( - "#root > div > div:nth-child(2) > div.filter-sticky-container > div.boutique-detail-component.v-2.timer-none > ul > li.boutique-title > h1" - ) || - document.querySelector( - "#root > div > div:nth-child(2) > div.filter-sticky-container > div.boutique-detail-component.v-2 > ul > li.boutique-title > h1" - ), - product = document.querySelector( - "#product-detail-app > div > div.pr-cn > div.pr-cn-in > div.pr-in-w > div:nth-child(1) > div.pr-in-cn > h1 > a" - ), - product2 = document.querySelector( - "#product-detail-app > div > div.pr-cn > div.pr-cn-in > div.pr-in-w > div:nth-child(1) > div.pr-in-cn > h1 > span" - ), - price = - document.querySelector( - "#product-detail-app > div > div.pr-cn > div.pr-cn-in > div.pr-in-w > div:nth-child(1) > div.pr-in-cn > div.pr-bx-w > div > span.prc-slg" - ) || - document.querySelector( - "#product-detail-app > div > div.pr-cn > div.pr-cn-in > div.pr-in-w > div:nth-child(1) > div.pr-in-cn > div.pr-bx-w > div > span" - ) || - document.querySelector( - "#product-detail-app > div > div.pr-cn > div.pr-cn-in > div.pr-in-w > div:nth-child(1) > div.pr-in-cn > div.pr-bx-w > div > div.pr-bx-pr-dsc > span" - ), - searchingFor = document.querySelector( - "#search-app > div > div.srch-rslt-cntnt > div.srch-prdcts-cntnr > div.srch-rslt-title > div.srch-ttl-cntnr-wrppr > div > h1" - ); +presence.on('UpdateData', async () => { + const page = document.location.pathname + const category = document.querySelector( + '#root > div > div:nth-child(2) > div.filter-sticky-container > div.boutique-detail-component.v-2.timer-none > ul > li.boutique-title > h1', + ) + || document.querySelector( + '#root > div > div:nth-child(2) > div.filter-sticky-container > div.boutique-detail-component.v-2 > ul > li.boutique-title > h1', + ) + const product = document.querySelector( + '#product-detail-app > div > div.pr-cn > div.pr-cn-in > div.pr-in-w > div:nth-child(1) > div.pr-in-cn > h1 > a', + ) + const product2 = document.querySelector( + '#product-detail-app > div > div.pr-cn > div.pr-cn-in > div.pr-in-w > div:nth-child(1) > div.pr-in-cn > h1 > span', + ) + const price = document.querySelector( + '#product-detail-app > div > div.pr-cn > div.pr-cn-in > div.pr-in-w > div:nth-child(1) > div.pr-in-cn > div.pr-bx-w > div > span.prc-slg', + ) + || document.querySelector( + '#product-detail-app > div > div.pr-cn > div.pr-cn-in > div.pr-in-w > div:nth-child(1) > div.pr-in-cn > div.pr-bx-w > div > span', + ) + || document.querySelector( + '#product-detail-app > div > div.pr-cn > div.pr-cn-in > div.pr-in-w > div:nth-child(1) > div.pr-in-cn > div.pr-bx-w > div > div.pr-bx-pr-dsc > span', + ) + const searchingFor = document.querySelector( + '#search-app > div > div.srch-rslt-cntnt > div.srch-prdcts-cntnr > div.srch-rslt-title > div.srch-ttl-cntnr-wrppr > div > h1', + ) - if (page.includes("/yardim/sorular/")) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png", - details: "Bir sayfaya göz atıyor:", - state: "Yardım & Sorular", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if ( - (page === "/tum--urunler" && document.location.search.includes("?q=")) || - (searchingFor && searchingFor.textContent !== "") - ) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png", - details: "Bir şey arıyor:", - state: searchingFor.textContent || "Belirsiz", - smallImageKey: Assets.Search, - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (category && category.textContent !== "") { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png", - details: "Bir kategoriye göz atıyor:", - state: category.textContent || "Belirsiz", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if ( - product && - product2 && - product.textContent !== "" && - product2.textContent !== "" - ) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png", - details: "Bir ürüne göz atıyor:", - state: `${product.textContent} | ${product2.textContent} ${ - price && price.textContent !== "" ? `(${price.textContent})` : null - }`, - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (pages[page] || pages[page.slice(0, -1)]) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png", - details: "Bir sayfaya göz atıyor:", - state: pages[page] || pages[page.slice(0, -1)], - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png", - details: "Bir sayfaya göz atıyor:", - state: "Ana Sayfa", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } -}); + if (page.includes('/yardim/sorular/')) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png', + details: 'Bir sayfaya göz atıyor:', + state: 'Yardım & Sorular', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if ( + (page === '/tum--urunler' && document.location.search.includes('?q=')) + || (searchingFor && searchingFor.textContent !== '') + ) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png', + details: 'Bir şey arıyor:', + state: searchingFor?.textContent || 'Belirsiz', + smallImageKey: Assets.Search, + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (category && category.textContent !== '') { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png', + details: 'Bir kategoriye göz atıyor:', + state: category.textContent || 'Belirsiz', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if ( + product + && product2 + && product.textContent !== '' + && product2.textContent !== '' + ) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png', + details: 'Bir ürüne göz atıyor:', + state: `${product.textContent} | ${product2.textContent} ${ + price && price.textContent !== '' ? `(${price.textContent})` : null + }`, + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (pages[page] || pages[page.slice(0, -1)]) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png', + details: 'Bir sayfaya göz atıyor:', + state: pages[page] || pages[page.slice(0, -1)], + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Trendyol/assets/logo.png', + details: 'Bir sayfaya göz atıyor:', + state: 'Ana Sayfa', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } +}) diff --git a/websites/T/TrickSplit.io/iframe.ts b/websites/T/TrickSplit.io/iframe.ts index 21f9d70f4e60..cf05a6133a59 100644 --- a/websites/T/TrickSplit.io/iframe.ts +++ b/websites/T/TrickSplit.io/iframe.ts @@ -1,28 +1,29 @@ -const iframe = new iFrame(); +const iframe = new iFrame() interface TrickSplitWindow { - game?: { - aliveTime: number; - lbPosition: number; - playerCells: Map; - }; - menuHandler?: { - gameMode: string; - loggedIn: boolean; - region: string; - selectedServer: string; - }; + game?: { + aliveTime: number + lbPosition: number + playerCells: Map + } + menuHandler?: { + gameMode: string + loggedIn: boolean + region: string + selectedServer: string + } } -iframe.on("UpdateData", async () => { - const ts = window as TrickSplitWindow; - if (!ts.game || !ts.menuHandler) return; - iframe.send({ - gameMode: ts.menuHandler.gameMode, - region: ts.menuHandler.region, - aliveTime: ts.game.aliveTime, - pos: ts.game.lbPosition, - cellCount: ts.game.playerCells.size, - connected: !!ts.menuHandler.selectedServer, - }); -}); +iframe.on('UpdateData', async () => { + const ts = window as TrickSplitWindow + if (!ts.game || !ts.menuHandler) + return + iframe.send({ + gameMode: ts.menuHandler.gameMode, + region: ts.menuHandler.region, + aliveTime: ts.game.aliveTime, + pos: ts.game.lbPosition, + cellCount: ts.game.playerCells.size, + connected: !!ts.menuHandler.selectedServer, + }) +}) diff --git a/websites/T/TrickSplit.io/metadata.json b/websites/T/TrickSplit.io/metadata.json index 582e6315ce06..9396ad6a3769 100644 --- a/websites/T/TrickSplit.io/metadata.json +++ b/websites/T/TrickSplit.io/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Snazzah", - "id": "158049329150427136" - }, - "service": "TrickSplit.io", - "description": { - "en": "Alternative Agar.io website, with different modes.", - "nl": "Alternatieve Agar.io-website, met verschillende modi." - }, - "url": "tricksplit.io", - "version": "1.0.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrickSplit.io/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrickSplit.io/assets/thumbnail.png", - "color": "#ABCF44", - "category": "games", - "tags": [ - "agario", - "game", - "miniclip" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Snazzah", + "id": "158049329150427136" + }, + "service": "TrickSplit.io", + "description": { + "en": "Alternative Agar.io website, with different modes.", + "nl": "Alternatieve Agar.io-website, met verschillende modi." + }, + "url": "tricksplit.io", + "version": "1.0.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrickSplit.io/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrickSplit.io/assets/thumbnail.png", + "color": "#ABCF44", + "category": "games", + "tags": [ + "agario", + "game", + "miniclip" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git a/websites/T/TrickSplit.io/presence.ts b/websites/T/TrickSplit.io/presence.ts index d937b5d507c4..c33215030849 100644 --- a/websites/T/TrickSplit.io/presence.ts +++ b/websites/T/TrickSplit.io/presence.ts @@ -1,47 +1,57 @@ const presence = new Presence({ - clientId: "719732079180644424", -}); + clientId: '719732079180644424', +}) interface TrickSplitData { - gameMode?: string; - region?: string; - aliveTime: number; - pos: number; - cellCount: number; - connected: boolean; + gameMode?: string + region?: string + aliveTime: number + pos: number + cellCount: number + connected: boolean } -let tsData: TrickSplitData = null; +let tsData: TrickSplitData | null = null -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TrickSplit.io/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TrickSplit.io/assets/logo.png', + } - if (tsData && tsData.connected) { - presenceData.state = `${tsData.gameMode} on ${tsData.region}`; + if (tsData && tsData.connected) { + presenceData.state = `${tsData.gameMode} on ${tsData.region}` - // In game? - if (!document.querySelector(".end[style*=flex],.menu:not([style*=none])")) { - // Spectating? - if (tsData.cellCount === 0) presenceData.details = "Spectating"; - else { - presenceData.details = `Playing as ${ - localStorage.getItem("nick") || "TrickSplit.io" - } (#${tsData.pos})`; - presenceData.startTimestamp = tsData.aliveTime; - } - } else presenceData.details = "Main Menu"; - } else presenceData.details = "Connecting..."; + // In game? + if (!document.querySelector('.end[style*=flex],.menu:not([style*=none])')) { + // Spectating? + if (tsData.cellCount === 0) { + presenceData.details = 'Spectating' + } + else { + presenceData.details = `Playing as ${ + localStorage.getItem('nick') || 'TrickSplit.io' + } (#${tsData.pos})` + presenceData.startTimestamp = tsData.aliveTime + } + } + else { + presenceData.details = 'Main Menu' + } + } + else { + presenceData.details = 'Connecting...' + } - // If data doesn't exist clear else set activity to the presence data - if (!presenceData.details) { - // Clear tray - presence.setActivity(); // Clear activity - } else presence.setActivity(presenceData); -}); + // If data doesn't exist clear else set activity to the presence data + if (!presenceData.details) { + // Clear tray + presence.setActivity() // Clear activity + } + else { + presence.setActivity(presenceData) + } +}) -presence.on("iFrameData", (data: TrickSplitData) => { - tsData = data; -}); +presence.on('iFrameData', (data: unknown) => { + tsData = data as TrickSplitData +}) diff --git a/websites/T/TruckSimFM/metadata.json b/websites/T/TruckSimFM/metadata.json index 47a84c9cec19..044552a409f0 100644 --- a/websites/T/TruckSimFM/metadata.json +++ b/websites/T/TruckSimFM/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "TruckSimFM", - "description": { - "en": "TruckSimFM is an online radio station, dedicated to the Simulation Community, live 24/7 with nothing but great music, Online, On Mobile, and On Your Smart Speaker.", - "nl": "TruckSimFM is een online radiostation, gewijd aan de Simulation Community, 24/7 live met niets dan geweldige muziek, online, op mobiel en op je slimme luidspreker." - }, - "url": "trucksim.fm", - "version": "1.2.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TruckSimFM/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TruckSimFM/assets/thumbnail.png", - "color": "#5398ee", - "category": "music", - "tags": [ - "radio", - "ets2", - "ats" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "TruckSimFM", + "description": { + "en": "TruckSimFM is an online radio station, dedicated to the Simulation Community, live 24/7 with nothing but great music, Online, On Mobile, and On Your Smart Speaker.", + "nl": "TruckSimFM is een online radiostation, gewijd aan de Simulation Community, 24/7 live met niets dan geweldige muziek, online, op mobiel en op je slimme luidspreker." + }, + "url": "trucksim.fm", + "version": "1.2.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TruckSimFM/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TruckSimFM/assets/thumbnail.png", + "color": "#5398ee", + "category": "music", + "tags": [ + "radio", + "ets2", + "ats" + ] +} diff --git a/websites/T/TruckSimFM/presence.ts b/websites/T/TruckSimFM/presence.ts index ec6be47fff37..b26c9346e0a0 100644 --- a/websites/T/TruckSimFM/presence.ts +++ b/websites/T/TruckSimFM/presence.ts @@ -1,87 +1,98 @@ const presence = new Presence({ - clientId: "640538683392655370", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '640538683392655370', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let title: HTMLElement, - player: HTMLAudioElement, - dj: HTMLElement, - listeners: HTMLElement; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TruckSimFM/assets/logo.png', + } + // presenceData.startTimestamp = browsingTimestamp; + const player = document.querySelector('#player') + if (!player?.paused) { + const title = document.querySelector('#song') + const dj = document.querySelector('#djname') + const listeners = document.querySelector('#listeners') + presenceData.details = title?.textContent + presenceData.state = `DJ: ${ + dj?.textContent + } Listeners: ${listeners?.textContent?.replace(' Listeners', '')}` + presenceData.smallImageKey = Assets.Play + } + else if (document.location.pathname.includes('/recent')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing the recently' + presenceData.state = 'played songs' + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/team')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing the staff team' + } + else if (document.location.pathname.includes('/request')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Requesting a song' + } + else if (document.location.pathname.includes('/applications')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Applying for staff' + } + else if (document.location.pathname.includes('/about')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Reading about TSFM' + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/schedule')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing the schedule' + } + else if (document.location.pathname.includes('/convoys')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing the convoys' + } + else if (document.location.pathname.includes('/streamers')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing the streamers' + } + else if (document.location.pathname.includes('/partner')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing the partners' + } + else if (document.location.pathname.includes('/vtc')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing the VTC' + } + else if (document.location.pathname.includes('/weekly')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing the weekly' + presenceData.state = 'shows on TSFM' + } + else if (document.location.pathname.includes('/tuneoftheweek')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing the tune' + presenceData.state = 'of the week' + } + else if (document.location.pathname.includes('/contact')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Contacting TSR' + presenceData.smallImageKey = Assets.Writing + } + else if (document.location.pathname.includes('/modifications')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing the offical' + presenceData.state = 'modifications list' + } + else if (document.location.pathname.includes('/advertisements')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing the' + presenceData.state = 'advertisements packages' + } + else if (document.location.pathname === '/') { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Browsing...' + } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TruckSimFM/assets/logo.png", - }; - //presenceData.startTimestamp = browsingTimestamp; - player = document.querySelector("#player"); - if (!player.paused) { - title = document.querySelector("#song"); - dj = document.querySelector("#djname"); - listeners = document.querySelector("#listeners"); - presenceData.details = title.textContent; - presenceData.state = `DJ: ${ - dj.textContent - } Listeners: ${listeners.textContent.replace(" Listeners", "")}`; - presenceData.smallImageKey = Assets.Play; - } else if (document.location.pathname.includes("/recent")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing the recently"; - presenceData.state = "played songs"; - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/team")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing the staff team"; - } else if (document.location.pathname.includes("/request")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Requesting a song"; - } else if (document.location.pathname.includes("/applications")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Applying for staff"; - } else if (document.location.pathname.includes("/about")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Reading about TSFM"; - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/schedule")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing the schedule"; - } else if (document.location.pathname.includes("/convoys")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing the convoys"; - } else if (document.location.pathname.includes("/streamers")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing the streamers"; - } else if (document.location.pathname.includes("/partner")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing the partners"; - } else if (document.location.pathname.includes("/vtc")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing the VTC"; - } else if (document.location.pathname.includes("/weekly")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing the weekly"; - presenceData.state = "shows on TSFM"; - } else if (document.location.pathname.includes("/tuneoftheweek")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing the tune"; - presenceData.state = "of the week"; - } else if (document.location.pathname.includes("/contact")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Contacting TSR"; - presenceData.smallImageKey = Assets.Writing; - } else if (document.location.pathname.includes("/modifications")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing the offical"; - presenceData.state = "modifications list"; - } else if (document.location.pathname.includes("/advertisements")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing the"; - presenceData.state = "advertisements packages"; - } else if (document.location.pathname === "/") { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Browsing..."; - } - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TruckStopRadio/metadata.json b/websites/T/TruckStopRadio/metadata.json index 465bd5b4cf6a..722edca6fc1a 100644 --- a/websites/T/TruckStopRadio/metadata.json +++ b/websites/T/TruckStopRadio/metadata.json @@ -1,78 +1,78 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "contributors": [ - { - "name": "ItsHarryUK", - "id": "695355328753041410" - } - ], - "service": "TruckStopRadio", - "description": { - "en": "Truck Stop Radio, is a popular radio station for Euro Truck Simulator and American Truck Simulator.", - "nl": "Truck Stop Radio, is een populair radiostation voor Euro Truck Simulator en American Truck Simulator." - }, - "url": "truckstopradio.co.uk", - "version": "2.0.13", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TruckStopRadio/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TruckStopRadio/assets/thumbnail.png", - "color": "#2056f8", - "category": "music", - "tags": [ - "truckstopradio", - "truckersmp", - "tsr", - "radio", - "music", - "ets2", - "ats" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "details", - "title": "Music Details row1", - "icon": "fas fa-comment-alt-edit", - "value": "\"%title%\" by %artist%", - "placeholder": "Use %artist% or %title% or %presenter% or %description% or {0} to delete the row completely" - }, - { - "id": "state", - "title": "Music Details row2", - "icon": "fas fa-comment-alt-edit", - "value": "Presented by %presenter%", - "placeholder": "Use %artist% or %title% or %presenter% or %description% or {0} to delete the row completely" - }, - { - "id": "browse", - "title": "Show Browsing Status", - "icon": "fad fa-book-reader", - "value": true - }, - { - "id": "timestamp", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - }, - { - "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": "Bas950", + "id": "241278257335500811" + }, + "contributors": [ + { + "name": "ItsHarryUK", + "id": "695355328753041410" + } + ], + "service": "TruckStopRadio", + "description": { + "en": "Truck Stop Radio, is a popular radio station for Euro Truck Simulator and American Truck Simulator.", + "nl": "Truck Stop Radio, is een populair radiostation voor Euro Truck Simulator en American Truck Simulator." + }, + "url": "truckstopradio.co.uk", + "version": "2.0.13", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TruckStopRadio/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TruckStopRadio/assets/thumbnail.png", + "color": "#2056f8", + "category": "music", + "tags": [ + "truckstopradio", + "truckersmp", + "tsr", + "radio", + "music", + "ets2", + "ats" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "details", + "title": "Music Details row1", + "icon": "fas fa-comment-alt-edit", + "value": "\"%title%\" by %artist%", + "placeholder": "Use %artist% or %title% or %presenter% or %description% or {0} to delete the row completely" + }, + { + "id": "state", + "title": "Music Details row2", + "icon": "fas fa-comment-alt-edit", + "value": "Presented by %presenter%", + "placeholder": "Use %artist% or %title% or %presenter% or %description% or {0} to delete the row completely" + }, + { + "id": "browse", + "title": "Show Browsing Status", + "icon": "fad fa-book-reader", + "value": true + }, + { + "id": "timestamp", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + }, + { + "id": "cover", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true + } + ] +} diff --git a/websites/T/TruckStopRadio/presence.ts b/websites/T/TruckStopRadio/presence.ts index a86bb7b7b3fd..6070a52b1779 100644 --- a/websites/T/TruckStopRadio/presence.ts +++ b/websites/T/TruckStopRadio/presence.ts @@ -1,185 +1,191 @@ const presence = new Presence({ - clientId: "639107568672702484", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '639107568672702484', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) async function getStrings() { - return presence.getStrings( - { - play: "general.playing", - pause: "general.paused", - browse: "general.browsing", - listen: "general.buttonListenAlong", - viewPage: "general.viewPage", - btnViewPage: "general.buttonViewPage", - readArticle: "general.readingArticle", - btnReadArticle: "general.buttonReadArticle", - viewProfile: "general.viewProfile", - btnViewProfile: "general.buttonViewProfile", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + play: 'general.playing', + pause: 'general.paused', + browse: 'general.browsing', + listen: 'general.buttonListenAlong', + viewPage: 'general.viewPage', + btnViewPage: 'general.buttonViewPage', + readArticle: 'general.readingArticle', + btnReadArticle: 'general.buttonReadArticle', + viewProfile: 'general.viewProfile', + btnViewProfile: 'general.buttonViewProfile', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } -let strings: Awaited> = null, - oldLang: string = null; +let strings: Awaited> +let oldLang: string | null = null -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TruckStopRadio/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TruckStopRadio/assets/logo.png', + startTimestamp: browsingTimestamp, + } - const [newLang, details, state, browse, timestamp, buttons, cover] = - await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("details"), - presence.getSetting("state"), - presence.getSetting("browse"), - presence.getSetting("timestamp"), - presence.getSetting("buttons"), - presence.getSetting("cover"), - ]), - playing = document - .querySelector(".play-btn") - .textContent.toLowerCase() - .includes("pause"); + const [newLang, details, state, browse, timestamp, buttons, cover] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('details'), + presence.getSetting('state'), + presence.getSetting('browse'), + presence.getSetting('timestamp'), + presence.getSetting('buttons'), + presence.getSetting('cover'), + ]) + const playing = document + .querySelector('.play-btn') + ?.textContent + ?.toLowerCase() + .includes('pause') - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - if (!browse || playing) { - if (details !== "{0}") presenceData.details = replacePlaceholders(details); - if (state !== "{0}") presenceData.state = replacePlaceholders(state); + if (!browse || playing) { + if (details !== '{0}') + presenceData.details = replacePlaceholders(details) + if (state !== '{0}') + presenceData.state = replacePlaceholders(state) - presenceData.smallImageKey = playing ? Assets.Play : Assets.Pause; - presenceData.smallImageText = playing ? strings.play : strings.pause; + presenceData.smallImageKey = playing ? Assets.Play : Assets.Pause + presenceData.smallImageText = playing ? strings.play : strings.pause - if (cover) { - presenceData.largeImageKey = document - .querySelector(".now-playing-img") - .style.backgroundImage.match(/url\("(.*)"\)/)[1]; - } + if (cover) { + presenceData.largeImageKey = document + .querySelector('.now-playing-img') + ?.style + ?.backgroundImage + ?.match(/url\("(.*)"\)/)?.[1] + } - presenceData.buttons = [ - { - label: strings.listen, - url: "https://truckstopradio.co.uk/", - }, - ]; - } else { - for (const [k, v] of Object.entries( - ((): { - [name: string]: PresenceData; - } => ({ - "/": { - details: strings.browse, - }, - "/timetable": { - details: strings.viewPage, - state: "Timetable", - buttons: [ - { - label: strings.btnViewPage, - url: location.href, - }, - ], - }, - "/team": { - details: strings.viewPage, - state: "Team", - buttons: [ - { - label: strings.btnViewPage, - url: location.href, - }, - ], - }, - "/applications": { - details: strings.viewPage, - state: "Applications", - buttons: [ - { - label: strings.btnViewPage, - url: location.href, - }, - ], - }, - "/contact": { - details: strings.viewPage, - state: "Contact", - buttons: [ - { - label: strings.btnViewPage, - url: location.href, - }, - ], - }, - "/news": { - details: strings.viewPage, - state: "News", - buttons: [ - { - label: strings.btnViewPage, - url: location.href, - }, - ], - }, - "/article": { - details: strings.readArticle, - state: document.querySelector(".post-header > h1")?.textContent, - smallImageKey: Assets.Reading, - buttons: [ - { - label: strings.btnReadArticle, - url: location.href, - }, - ], - }, - "/presenter": { - details: strings.viewProfile, - state: document.querySelector(".presenter-name")?.textContent, - buttons: [ - { - label: strings.btnViewProfile, - url: location.href, - }, - ], - }, - }))() - )) { - if ( - location.href - .replace(/\/?$/, "/") - .replace(`https://${document.location.hostname}`, "") - .replace("?", "/") - .replace("=", "/") - .match(k) - ) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - presenceData = { ...presenceData, ...v }; - } - } - } + presenceData.buttons = [ + { + label: strings.listen, + url: 'https://truckstopradio.co.uk/', + }, + ] + } + else { + for (const [k, v] of Object.entries( + ((): { + [name: string]: PresenceData + } => ({ + '/': { + details: strings.browse, + }, + '/timetable': { + details: strings.viewPage, + state: 'Timetable', + buttons: [ + { + label: strings.btnViewPage, + url: location.href, + }, + ], + }, + '/team': { + details: strings.viewPage, + state: 'Team', + buttons: [ + { + label: strings.btnViewPage, + url: location.href, + }, + ], + }, + '/applications': { + details: strings.viewPage, + state: 'Applications', + buttons: [ + { + label: strings.btnViewPage, + url: location.href, + }, + ], + }, + '/contact': { + details: strings.viewPage, + state: 'Contact', + buttons: [ + { + label: strings.btnViewPage, + url: location.href, + }, + ], + }, + '/news': { + details: strings.viewPage, + state: 'News', + buttons: [ + { + label: strings.btnViewPage, + url: location.href, + }, + ], + }, + '/article': { + details: strings.readArticle, + state: document.querySelector('.post-header > h1')?.textContent, + smallImageKey: Assets.Reading, + buttons: [ + { + label: strings.btnReadArticle, + url: location.href, + }, + ], + }, + '/presenter': { + details: strings.viewProfile, + state: document.querySelector('.presenter-name')?.textContent, + buttons: [ + { + label: strings.btnViewProfile, + url: location.href, + }, + ], + }, + }))(), + )) { + if ( + location.href + .replace(/\/?$/, '/') + .replace(`https://${document.location.hostname}`, '') + .replace('?', '/') + .replace('=', '/') + .match(k) + ) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + presenceData = { ...presenceData, ...v } as PresenceData + } + } + } - if (!timestamp) delete presenceData.startTimestamp; - if (!buttons) delete presenceData.buttons; + if (!timestamp) + delete presenceData.startTimestamp + if (!buttons) + delete presenceData.buttons - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) function replacePlaceholders(string: string): string { - for (const [k, v] of Object.entries({ - "%artist%": ".now-playing-artist", - "%title%": ".now-playing-title", - "%presenter%": ".live-presenter", - "%description%": ".live-description", - })) - string = string.replace(k, document.querySelector(v).textContent); + for (const [k, v] of Object.entries({ + '%artist%': '.now-playing-artist', + '%title%': '.now-playing-title', + '%presenter%': '.live-presenter', + '%description%': '.live-description', + })) + string = string.replace(k, document.querySelector(v)?.textContent ?? '') - return string; + return string } diff --git a/websites/T/TruckersFM/metadata.json b/websites/T/TruckersFM/metadata.json index a73a31059ce5..3e0a9e760935 100644 --- a/websites/T/TruckersFM/metadata.json +++ b/websites/T/TruckersFM/metadata.json @@ -1,33 +1,33 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Ninja", - "id": "150987570715688960" - }, - "contributors": [ - { - "name": "Pascal", - "id": "156560379089125376" - } - ], - "service": "TruckersFM", - "description": { - "en": "Truckers.FM is the No.1 Hit Music Station as voted by the TruckersMP Community 5 years, providing round the clock entertainment broadcasting a variety of shows, ranging from the Top 40 to the biggest throwbacks.", - "nl": "Truckers.FM is de nummer 1 Hit Music Station zoals gestemd door de TruckersMP Community 5 jaar, en biedt 24 uur per dag entertainment met een verscheidenheid aan shows, variërend van de Top 40 tot de grootste erfenis." - }, - "url": "truckers.fm", - "version": "1.4.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TruckersFM/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TruckersFM/assets/thumbnail.png", - "color": "#C82372", - "category": "music", - "tags": [ - "tfm", - "truckersmp", - "radio", - "music", - "ets2", - "ats" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Ninja", + "id": "150987570715688960" + }, + "contributors": [ + { + "name": "Pascal", + "id": "156560379089125376" + } + ], + "service": "TruckersFM", + "description": { + "en": "Truckers.FM is the No.1 Hit Music Station as voted by the TruckersMP Community 5 years, providing round the clock entertainment broadcasting a variety of shows, ranging from the Top 40 to the biggest throwbacks.", + "nl": "Truckers.FM is de nummer 1 Hit Music Station zoals gestemd door de TruckersMP Community 5 jaar, en biedt 24 uur per dag entertainment met een verscheidenheid aan shows, variërend van de Top 40 tot de grootste erfenis." + }, + "url": "truckers.fm", + "version": "1.4.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TruckersFM/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TruckersFM/assets/thumbnail.png", + "color": "#C82372", + "category": "music", + "tags": [ + "tfm", + "truckersmp", + "radio", + "music", + "ets2", + "ats" + ] +} diff --git a/websites/T/TruckersFM/presence.ts b/websites/T/TruckersFM/presence.ts index 090c58a80af2..75c9b15637cf 100644 --- a/websites/T/TruckersFM/presence.ts +++ b/websites/T/TruckersFM/presence.ts @@ -1,37 +1,35 @@ const presence = new Presence({ - clientId: "640914619082211338", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '640914619082211338', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TruckersFM/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TruckersFM/assets/logo.png', + startTimestamp: browsingTimestamp, + } - presenceData.details = `${ - document.querySelector(".player-artist-text").textContent - } - ${document.querySelector(".player-title-text").textContent}`; - presenceData.state = - document.querySelector(".live-name").textContent ?? "AutoDJ"; + presenceData.details = `${ + document.querySelector('.player-artist-text')?.textContent + } - ${document.querySelector('.player-title-text')?.textContent}` + presenceData.state = document.querySelector('.live-name')?.textContent ?? 'AutoDJ' - presenceData.buttons = [ - { - label: "Tune into TFM", - url: "https://truckers.fm/listen", - }, - ]; + presenceData.buttons = [ + { + label: 'Tune into TFM', + url: 'https://truckers.fm/listen', + }, + ] - const spotifyUrl = document - .querySelector(".player-artist-text a") - .getAttribute("href"); - if (spotifyUrl) { - presenceData.buttons.push({ - label: "Listen on Spotify", - url: spotifyUrl, - }); - } + const spotifyUrl = document + .querySelector('.player-artist-text a') + ?.getAttribute('href') + if (spotifyUrl) { + presenceData.buttons.push({ + label: 'Listen on Spotify', + url: spotifyUrl, + }) + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/TruckersMP/metadata.json b/websites/T/TruckersMP/metadata.json index 49372d60006b..739a8d30237e 100644 --- a/websites/T/TruckersMP/metadata.json +++ b/websites/T/TruckersMP/metadata.json @@ -1,60 +1,60 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Encrypted", - "id": "564434085708038144" - }, - "contributors": [ - { - "name": "Bas950", - "id": "241278257335500811" - } - ], - "service": "TruckersMP", - "description": { - "en": "TruckersMP is a multiplayer truckers experience for SCS Software's Euro Truck Simulator 2 and American Truck Simulator.", - "nl": "TruckersMP is een Multiplayer Truckers ervaring voor SCS Software's Euro Truck Simulator 2 en American Truck Simulator." - }, - "url": [ - "truckersmp.com", - "forum.truckersmp.com", - "stats.truckersmp.com", - "map.truckersmp.com" - ], - "version": "3.0.17", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TruckersMP/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TruckersMP/assets/thumbnail.png", - "color": "#B92025", - "category": "games", - "tags": [ - "ets2", - "ats", - "scs", - "drive", - "truck" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "buttons", - "if": { - "privacy": false - }, - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - }, - { - "id": "timestamp", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Encrypted", + "id": "564434085708038144" + }, + "contributors": [ + { + "name": "Bas950", + "id": "241278257335500811" + } + ], + "service": "TruckersMP", + "description": { + "en": "TruckersMP is a multiplayer truckers experience for SCS Software's Euro Truck Simulator 2 and American Truck Simulator.", + "nl": "TruckersMP is een Multiplayer Truckers ervaring voor SCS Software's Euro Truck Simulator 2 en American Truck Simulator." + }, + "url": [ + "truckersmp.com", + "forum.truckersmp.com", + "stats.truckersmp.com", + "map.truckersmp.com" + ], + "version": "3.0.17", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TruckersMP/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TruckersMP/assets/thumbnail.png", + "color": "#B92025", + "category": "games", + "tags": [ + "ets2", + "ats", + "scs", + "drive", + "truck" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "buttons", + "if": { + "privacy": false + }, + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + }, + { + "id": "timestamp", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + } + ] +} diff --git a/websites/T/TruckersMP/presence.ts b/websites/T/TruckersMP/presence.ts index 546cae92408b..4ed50e601c87 100644 --- a/websites/T/TruckersMP/presence.ts +++ b/websites/T/TruckersMP/presence.ts @@ -1,136 +1,134 @@ const presence = new Presence({ - clientId: "821104573329440848", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '821104573329440848', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TruckersMP/assets/logo.png", - }; - const [buttons, timestamp, privacy] = await Promise.all([ - presence.getSetting("buttons"), - presence.getSetting("timestamp"), - presence.getSetting("privacy"), - ]), - pages: Record = { - "/team": { details: "Viewing the staff team" }, - "/status": { details: "Viewing the server status" }, - "/knowledge-base": { details: "Browsing the knowledge base" }, - "/support": { details: "Viewing the support center" }, - "/rules": { details: "Reading the rules" }, - "/download": { details: "Viewing the downloads page" }, - "/profile/settings": { details: "Viewing profile settings" }, - "/vtc": { details: "Viewing the VTC center" }, - "/vtc/search": { details: "Searching for a VTC" }, - "/vtc/create": { details: "Creating a VTC" }, - "/blog": { details: "Browsing the blog" }, - "/events": { details: "Viewing the events system" }, - "/events/manage": { details: "Managing their events" }, - "/events/manage/past": { details: "Viewing their past events" }, - "/events/create": { details: "Creating an event" }, - "/events/search": { details: "Searching for an event" }, - "/api": { details: "Viewing the API" }, - "/live": { details: "Viewing the live stats" }, - "/history": { details: "Viewing the history" }, - "/settings": { details: "Viewing the settings" }, - }; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TruckersMP/assets/logo.png', + } + const [buttons, timestamp, privacy] = await Promise.all([ + presence.getSetting('buttons'), + presence.getSetting('timestamp'), + presence.getSetting('privacy'), + ]) + const pages: Record = { + '/team': { details: 'Viewing the staff team' }, + '/status': { details: 'Viewing the server status' }, + '/knowledge-base': { details: 'Browsing the knowledge base' }, + '/support': { details: 'Viewing the support center' }, + '/rules': { details: 'Reading the rules' }, + '/download': { details: 'Viewing the downloads page' }, + '/profile/settings': { details: 'Viewing profile settings' }, + '/vtc': { details: 'Viewing the VTC center' }, + '/vtc/search': { details: 'Searching for a VTC' }, + '/vtc/create': { details: 'Creating a VTC' }, + '/blog': { details: 'Browsing the blog' }, + '/events': { details: 'Viewing the events system' }, + '/events/manage': { details: 'Managing their events' }, + '/events/manage/past': { details: 'Viewing their past events' }, + '/events/create': { details: 'Creating an event' }, + '/events/search': { details: 'Searching for an event' }, + '/api': { details: 'Viewing the API' }, + '/live': { details: 'Viewing the live stats' }, + '/history': { details: 'Viewing the history' }, + '/settings': { details: 'Viewing the settings' }, + } - for (const [path, data] of Object.entries(pages)) { - if (document.location.pathname.includes(path)) - presenceData = { ...presenceData, ...data }; - } + for (const [path, data] of Object.entries(pages)) { + if (document.location.pathname.includes(path)) + presenceData = { ...presenceData, ...data } as PresenceData + } - switch (document.location.host) { - case "truckersmp.com": - switch (true) { - case document.location.pathname.includes("/blog/"): - presenceData.details = "Reading a blog post"; - presenceData.state = document.querySelector( - "div.container-fluid > h1" - ).textContent; - presenceData.buttons = [{ label: "Read Post", url: document.URL }]; - break; - case document.location.pathname.includes("/events/"): - presenceData.details = "Viewing an event"; - presenceData.state = - document.querySelectorAll("h1")[1].textContent; - presenceData.buttons = [{ label: "View Event", url: document.URL }]; - break; - case document.location.pathname.includes("/members/"): - presenceData.details = "Viewing a VTC members list"; - presenceData.state = - document.querySelector("h2").textContent; - break; - case document.location.pathname.includes("/vtc/"): - presenceData.details = "Viewing a VTC"; - presenceData.state = - document.querySelector("h2").textContent; - presenceData.buttons = [{ label: "View VTC", url: document.URL }]; - break; - case document.location.pathname.includes("/user/"): - presenceData.details = "Viewing a user's profile"; - presenceData.state = document.querySelector( - "div.col-md-12 > h1 > span" - ).textContent; - presenceData.buttons = [{ label: "View Profile", url: document.URL }]; - break; - case document.location.pathname.includes("/article/"): - presenceData.details = "Viewing a knowledge base article"; - presenceData.state = - document.querySelector("h1").textContent; - presenceData.buttons = [{ label: "Read Article", url: document.URL }]; - break; - case document.location.pathname === "/": - presenceData.details = "Browsing the homepage"; - } - break; - case "forum.truckersmp.com": - switch (true) { - case document.location.pathname.includes("/index.php?/profile"): - presenceData.details = "Viewing a forum user"; - presenceData.state = document - .querySelectorAll( - "main > div > div > div> div > header > div > div > div" - )[1] - .querySelector("div > h1 > span").textContent; - presenceData.buttons = [{ label: "View Profile", url: document.URL }]; - break; - case document.location.pathname.includes("/index.php?/topic"): - presenceData.details = "Viewing a forum topic"; - presenceData.state = document.querySelector( - "main > div > div > div > div > header > div > div > div > h1" - ).textContent; - presenceData.buttons = [{ label: "View Topic", url: document.URL }]; - break; - case document.location.pathname.includes("/forum"): - presenceData.details = "Browsing the forum"; - presenceData.state = - document.querySelector( - "header > h1" - ).textContent; - presenceData.buttons = [ - { label: "View Forum Category", url: document.URL }, - ]; - break; - default: - presenceData.details = "Browsing the forum"; - } - break; - case "map.truckersmp.com": - presenceData.details = "Viewing the TruckersMP Map"; - if (document.location.pathname.includes("?follow=")) { - presenceData.details = "TruckersMP Map"; - presenceData.state = `Following ${ - document.querySelector("div.player-name").textContent - }`; - } - break; - } + switch (document.location.host) { + case 'truckersmp.com': + switch (true) { + case document.location.pathname.includes('/blog/'): + presenceData.details = 'Reading a blog post' + presenceData.state = document.querySelector( + 'div.container-fluid > h1', + )?.textContent + presenceData.buttons = [{ label: 'Read Post', url: document.URL }] + break + case document.location.pathname.includes('/events/'): + presenceData.details = 'Viewing an event' + presenceData.state = document.querySelectorAll('h1')[1].textContent + presenceData.buttons = [{ label: 'View Event', url: document.URL }] + break + case document.location.pathname.includes('/members/'): + presenceData.details = 'Viewing a VTC members list' + presenceData.state = document.querySelector('h2')?.textContent + break + case document.location.pathname.includes('/vtc/'): + presenceData.details = 'Viewing a VTC' + presenceData.state = document.querySelector('h2')?.textContent + presenceData.buttons = [{ label: 'View VTC', url: document.URL }] + break + case document.location.pathname.includes('/user/'): + presenceData.details = 'Viewing a user\'s profile' + presenceData.state = document.querySelector( + 'div.col-md-12 > h1 > span', + )?.textContent + presenceData.buttons = [{ label: 'View Profile', url: document.URL }] + break + case document.location.pathname.includes('/article/'): + presenceData.details = 'Viewing a knowledge base article' + presenceData.state = document.querySelector('h1')?.textContent + presenceData.buttons = [{ label: 'Read Article', url: document.URL }] + break + case document.location.pathname === '/': + presenceData.details = 'Browsing the homepage' + } + break + case 'forum.truckersmp.com': + switch (true) { + case document.location.pathname.includes('/index.php?/profile'): + presenceData.details = 'Viewing a forum user' + presenceData.state = document + .querySelectorAll( + 'main > div > div > div> div > header > div > div > div', + )[1] + ?.querySelector('div > h1 > span') + ?.textContent + presenceData.buttons = [{ label: 'View Profile', url: document.URL }] + break + case document.location.pathname.includes('/index.php?/topic'): + presenceData.details = 'Viewing a forum topic' + presenceData.state = document.querySelector( + 'main > div > div > div > div > header > div > div > div > h1', + )?.textContent + presenceData.buttons = [{ label: 'View Topic', url: document.URL }] + break + case document.location.pathname.includes('/forum'): + presenceData.details = 'Browsing the forum' + presenceData.state = document.querySelector( + 'header > h1', + )?.textContent + presenceData.buttons = [ + { label: 'View Forum Category', url: document.URL }, + ] + break + default: + presenceData.details = 'Browsing the forum' + } + break + case 'map.truckersmp.com': + presenceData.details = 'Viewing the TruckersMP Map' + if (document.location.pathname.includes('?follow=')) { + presenceData.details = 'TruckersMP Map' + presenceData.state = `Following ${ + document.querySelector('div.player-name')?.textContent + }` + } + break + } - if (!buttons) delete presenceData.buttons; - if (privacy) delete presenceData.state; - if (timestamp) presenceData.startTimestamp = browsingTimestamp; + if (!buttons) + delete presenceData.buttons + if (privacy) + delete presenceData.state + if (timestamp) + presenceData.startTimestamp = browsingTimestamp - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/TrueAchievements/metadata.json b/websites/T/TrueAchievements/metadata.json index 92f69f11c4d4..e59e9364046c 100644 --- a/websites/T/TrueAchievements/metadata.json +++ b/websites/T/TrueAchievements/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "TrueAchievements", - "description": { - "en": "TrueAchievements is the home of Xbox news, achievement lists and guides, reviews, interviews, leaderboards and more.", - "nl": "TrueAchievements is de plaats voor Xbox nieuws, prestatielijsten en gidsen, recensies, interviews, scoreborden en meer." - }, - "url": "www.trueachievements.com", - "version": "1.0.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrueAchievements/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrueAchievements/assets/thumbnail.png", - "color": "#c1f800", - "category": "other", - "tags": [ - "true", - "achievements", - "xbox" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "TrueAchievements", + "description": { + "en": "TrueAchievements is the home of Xbox news, achievement lists and guides, reviews, interviews, leaderboards and more.", + "nl": "TrueAchievements is de plaats voor Xbox nieuws, prestatielijsten en gidsen, recensies, interviews, scoreborden en meer." + }, + "url": "www.trueachievements.com", + "version": "1.0.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrueAchievements/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrueAchievements/assets/thumbnail.png", + "color": "#c1f800", + "category": "other", + "tags": [ + "true", + "achievements", + "xbox" + ] +} diff --git a/websites/T/TrueAchievements/presence.ts b/websites/T/TrueAchievements/presence.ts index c57d8e9ccce0..fc728df18f75 100644 --- a/websites/T/TrueAchievements/presence.ts +++ b/websites/T/TrueAchievements/presence.ts @@ -1,376 +1,408 @@ const presence = new Presence({ - clientId: "702467872315670529", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '702467872315670529', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TrueAchievements/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TrueAchievements/assets/logo.png', + } - presenceData.startTimestamp = browsingTimestamp; + presenceData.startTimestamp = browsingTimestamp - if (document.location.pathname.includes("/gamer/")) { - const user = document.querySelector(".tabs > ul > li").textContent; + if (document.location.pathname.includes('/gamer/')) { + const user = document.querySelector('.tabs > ul > li')?.textContent - if (document.location.pathname.includes("/gamecollection")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Game Collection"; - } else if (document.location.pathname.includes("/achievements")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Achievements"; - } else if (document.location.pathname.includes("/goals")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Goals"; - } else if (document.location.pathname.includes("/blog")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Blog"; - } else if (document.location.pathname.includes("/stats")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Statistics"; - } else { - presenceData.details = "Viewing profile of:"; - presenceData.state = user; - } - } else if (document.location.pathname.includes("/game/")) { - if (document.location.pathname.includes("/achievements")) { - presenceData.details = "Viewing Achievements of game:"; - presenceData.state = document.querySelector( - "div.panel-header.w > h3 > a" - ).textContent; - } else if (document.location.pathname.includes("/forum")) { - presenceData.details = "Viewing Forums of game:"; - presenceData.state = document.title.replace(" Forum", ""); - } else if (document.location.pathname.includes("/walkthrough")) { - presenceData.details = "Viewing Walkthrough of game:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace(" Walkthrough", ""); - } else if (document.location.pathname.includes("/reviews")) { - presenceData.details = "Viewing Reviews of game:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace(" Reviews", ""); - } else if (document.location.pathname.includes("/scores")) { - presenceData.details = "Viewing Top Scores of game:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace("Top Scores For ", ""); - } else if (document.location.pathname.includes("/gamers")) { - presenceData.details = "Viewing Gamers of game:"; - presenceData.state = document.querySelector( - "div.panel-header.w > h3 > a" - ).textContent; - } else { - presenceData.details = "Viewing game:"; - presenceData.state = document.querySelector(".info").textContent.trim(); - } - } else if ( - document.querySelector(".pagetitle") && - document.querySelector(".pagetitle").textContent === "Achievement Details" - ) { - presenceData.details = "Viewing acheievement:"; - presenceData.state = document.querySelector(".title").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = `Game: ${ - document.querySelector("div.panel-header.w > h3 > a").textContent - }`; - } else { - switch (document.location.pathname) { - case "/news": - case "/news.aspx": { - presenceData.details = "Viewing the latest news"; - break; - } - case "/xbox-one/news": { - presenceData.details = "Viewing the latest Xbox One news"; - break; - } - case "/xbox-one/games": { - presenceData.details = "Viewing the latest Xbox One games"; - break; - } - case "/xbox-one/prices": { - presenceData.details = "Viewing the latest Xbox One prices"; - break; - } - case "/xbox-360/news": { - presenceData.details = "Viewing the latest Xbox 360 news"; - break; - } - case "/xbox-360/games": { - presenceData.details = "Viewing the latest Xbox 360 games"; - break; - } - case "/xbox-360/prices": { - presenceData.details = "Viewing the latest Xbox 360 prices"; - break; - } - case "/windows/news": { - presenceData.details = "Viewing the latest Windows news"; - break; - } - case "/windows/games": { - presenceData.details = "Viewing the latest Windows games"; - break; - } - case "/windows/prices": { - presenceData.details = "Viewing the latest Windows prices"; - break; - } - case "/id-at-xbox/news": { - presenceData.details = "Viewing the latest ID@Xbox news"; - break; - } - case "/id-at-xbox/games": { - presenceData.details = "Viewing the latest ID@Xbox games"; - break; - } - case "/xbox-series-x/news": { - presenceData.details = "Viewing the latest Xbox Series X news"; - break; - } - case "/xbox-series-x/games": { - presenceData.details = "Viewing the latest Xbox Series X games"; - break; - } - case "/xbox-game-pass/news": { - presenceData.details = "Viewing the latest Xbox Game Pass news"; - break; - } - case "/xbox-game-pass/games": { - presenceData.details = "Viewing the latest Xbox Game Pass games"; - break; - } - case "/xbox-quests": { - presenceData.details = "Viewing the latest Xbox Game Pass quests"; - break; - } - case "/ea-access/news": { - presenceData.details = "Viewing the latest EA Access news"; - break; - } - case "/ea-access/games": { - presenceData.details = "Viewing the latest EA Access games"; - break; - } - case "/xbox-game-pass-pc/news": { - presenceData.details = "Viewing the latest Xbox Game Pass for PC news"; - break; - } - case "/xbox-game-pass-pc/games": { - presenceData.details = "Viewing the latest Xbox Game Pass for PC games"; - break; - } - case "/videos": { - presenceData.details = "Viewing the latest videos"; - break; - } - default: - if (document.querySelector(".newsitem > header > h1")) { - presenceData.details = "Reading article:"; - presenceData.state = document.querySelector( - ".newsitem > header > h1" - ).textContent; - presenceData.smallImageKey = Assets.Reading; - } else { - switch (document.location.pathname) { - case "/suggestnews.aspx": { - presenceData.details = "Suggesting new news"; - presenceData.smallImageKey = Assets.Writing; + if (document.location.pathname.includes('/gamecollection')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Game Collection' + } + else if (document.location.pathname.includes('/achievements')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Achievements' + } + else if (document.location.pathname.includes('/goals')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Goals' + } + else if (document.location.pathname.includes('/blog')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Blog' + } + else if (document.location.pathname.includes('/stats')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Statistics' + } + else { + presenceData.details = 'Viewing profile of:' + presenceData.state = user + } + } + else if (document.location.pathname.includes('/game/')) { + if (document.location.pathname.includes('/achievements')) { + presenceData.details = 'Viewing Achievements of game:' + presenceData.state = document.querySelector( + 'div.panel-header.w > h3 > a', + )?.textContent + } + else if (document.location.pathname.includes('/forum')) { + presenceData.details = 'Viewing Forums of game:' + presenceData.state = document.title.replace(' Forum', '') + } + else if (document.location.pathname.includes('/walkthrough')) { + presenceData.details = 'Viewing Walkthrough of game:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace(' Walkthrough', '') + } + else if (document.location.pathname.includes('/reviews')) { + presenceData.details = 'Viewing Reviews of game:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace(' Reviews', '') + } + else if (document.location.pathname.includes('/scores')) { + presenceData.details = 'Viewing Top Scores of game:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace('Top Scores For ', '') + } + else if (document.location.pathname.includes('/gamers')) { + presenceData.details = 'Viewing Gamers of game:' + presenceData.state = document.querySelector( + 'div.panel-header.w > h3 > a', + )?.textContent + } + else { + presenceData.details = 'Viewing game:' + presenceData.state = document.querySelector('.info')?.textContent?.trim() + } + } + else if ( + document.querySelector('.pagetitle') + && document.querySelector('.pagetitle')?.textContent === 'Achievement Details' + ) { + presenceData.details = 'Viewing acheievement:' + presenceData.state = document.querySelector('.title')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = `Game: ${ + document.querySelector('div.panel-header.w > h3 > a')?.textContent + }` + } + else { + switch (document.location.pathname) { + case '/news': + case '/news.aspx': { + presenceData.details = 'Viewing the latest news' + break + } + case '/xbox-one/news': { + presenceData.details = 'Viewing the latest Xbox One news' + break + } + case '/xbox-one/games': { + presenceData.details = 'Viewing the latest Xbox One games' + break + } + case '/xbox-one/prices': { + presenceData.details = 'Viewing the latest Xbox One prices' + break + } + case '/xbox-360/news': { + presenceData.details = 'Viewing the latest Xbox 360 news' + break + } + case '/xbox-360/games': { + presenceData.details = 'Viewing the latest Xbox 360 games' + break + } + case '/xbox-360/prices': { + presenceData.details = 'Viewing the latest Xbox 360 prices' + break + } + case '/windows/news': { + presenceData.details = 'Viewing the latest Windows news' + break + } + case '/windows/games': { + presenceData.details = 'Viewing the latest Windows games' + break + } + case '/windows/prices': { + presenceData.details = 'Viewing the latest Windows prices' + break + } + case '/id-at-xbox/news': { + presenceData.details = 'Viewing the latest ID@Xbox news' + break + } + case '/id-at-xbox/games': { + presenceData.details = 'Viewing the latest ID@Xbox games' + break + } + case '/xbox-series-x/news': { + presenceData.details = 'Viewing the latest Xbox Series X news' + break + } + case '/xbox-series-x/games': { + presenceData.details = 'Viewing the latest Xbox Series X games' + break + } + case '/xbox-game-pass/news': { + presenceData.details = 'Viewing the latest Xbox Game Pass news' + break + } + case '/xbox-game-pass/games': { + presenceData.details = 'Viewing the latest Xbox Game Pass games' + break + } + case '/xbox-quests': { + presenceData.details = 'Viewing the latest Xbox Game Pass quests' + break + } + case '/ea-access/news': { + presenceData.details = 'Viewing the latest EA Access news' + break + } + case '/ea-access/games': { + presenceData.details = 'Viewing the latest EA Access games' + break + } + case '/xbox-game-pass-pc/news': { + presenceData.details = 'Viewing the latest Xbox Game Pass for PC news' + break + } + case '/xbox-game-pass-pc/games': { + presenceData.details = 'Viewing the latest Xbox Game Pass for PC games' + break + } + case '/videos': { + presenceData.details = 'Viewing the latest videos' + break + } + default: + if (document.querySelector('.newsitem > header > h1')) { + presenceData.details = 'Reading article:' + presenceData.state = document.querySelector( + '.newsitem > header > h1', + )?.textContent + presenceData.smallImageKey = Assets.Reading + } + else { + switch (document.location.pathname) { + case '/suggestnews.aspx': { + presenceData.details = 'Suggesting new news' + presenceData.smallImageKey = Assets.Writing - break; - } - case "/news/community": { - presenceData.details = "Viewing the latest community news"; - break; - } - case "/news/tags/podcast": { - presenceData.details = "Viewing the latest podcasts"; - break; - } - case "/siteupdates": { - presenceData.details = "Viewing the latest site updates"; - break; - } - case "/games.aspx": { - presenceData.details = "Viewing all games"; - break; - } - case "/xbox-achievements.aspx": { - presenceData.details = "Viewing all achievements"; - break; - } - case "/solutions-required.aspx": { - presenceData.details = "Viewing all achievements"; - presenceData.state = "that require guides"; + break + } + case '/news/community': { + presenceData.details = 'Viewing the latest community news' + break + } + case '/news/tags/podcast': { + presenceData.details = 'Viewing the latest podcasts' + break + } + case '/siteupdates': { + presenceData.details = 'Viewing the latest site updates' + break + } + case '/games.aspx': { + presenceData.details = 'Viewing all games' + break + } + case '/xbox-achievements.aspx': { + presenceData.details = 'Viewing all achievements' + break + } + case '/solutions-required.aspx': { + presenceData.details = 'Viewing all achievements' + presenceData.state = 'that require guides' - break; - } - case "/sitereviews.aspx": { - presenceData.details = "Viewing site reviews"; - break; - } - case "/solutions": { - presenceData.details = "Viewing achievement solutions"; - break; - } - case "/xbox-live.aspx": { - presenceData.details = "Viewing Xbox Live status"; - break; - } - case "/challenges.aspx": { - presenceData.details = "Viewing the Challanges Hub"; - break; - } - case "/gamingsessions.aspx": { - presenceData.details = "Viewing the Gaming Sessions"; - break; - } - default: - if ( - document.location.pathname.includes("/viewcomment.aspx") && - document.querySelector(".pagetitle") && - document.querySelector(".pagetitle").textContent === - "View Solution" - ) { - presenceData.details = "Viewing solution for achievement:"; - presenceData.state = - document.querySelector(".title").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = `Game: ${ - document.querySelector("div.panel-header.w > h3 > a") - .textContent - }`; - } else { - switch (document.location.pathname) { - case "/serieslist.aspx": { - presenceData.details = "Viewing Game Series"; - break; - } - case "/popularachievements.aspx": { - presenceData.details = "Viewing popular achievements"; - break; - } - case "/walkthroughs.aspx": { - presenceData.details = - "Viewing Xbox Walkthroughs and Guides"; - break; - } - case "/reviews.aspx": { - presenceData.details = "Viewing user reviews"; - break; - } - case "/gamereleases.aspx": { - presenceData.details = "Viewing upcoming releases"; - break; - } - case "/searchresults.aspx": { - presenceData.details = "Searching for:"; - presenceData.state = - document.querySelector( - "#txtSearchFor" - ).value; - presenceData.smallImageKey = Assets.Search; + break + } + case '/sitereviews.aspx': { + presenceData.details = 'Viewing site reviews' + break + } + case '/solutions': { + presenceData.details = 'Viewing achievement solutions' + break + } + case '/xbox-live.aspx': { + presenceData.details = 'Viewing Xbox Live status' + break + } + case '/challenges.aspx': { + presenceData.details = 'Viewing the Challanges Hub' + break + } + case '/gamingsessions.aspx': { + presenceData.details = 'Viewing the Gaming Sessions' + break + } + default: + if ( + document.location.pathname.includes('/viewcomment.aspx') + && document.querySelector('.pagetitle') + && document.querySelector('.pagetitle')?.textContent + === 'View Solution' + ) { + presenceData.details = 'Viewing solution for achievement:' + presenceData.state = document.querySelector('.title')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = `Game: ${ + document.querySelector('div.panel-header.w > h3 > a') + ?.textContent + }` + } + else { + switch (document.location.pathname) { + case '/serieslist.aspx': { + presenceData.details = 'Viewing Game Series' + break + } + case '/popularachievements.aspx': { + presenceData.details = 'Viewing popular achievements' + break + } + case '/walkthroughs.aspx': { + presenceData.details = 'Viewing Xbox Walkthroughs and Guides' + break + } + case '/reviews.aspx': { + presenceData.details = 'Viewing user reviews' + break + } + case '/gamereleases.aspx': { + presenceData.details = 'Viewing upcoming releases' + break + } + case '/searchresults.aspx': { + presenceData.details = 'Searching for:' + presenceData.state = document.querySelector( + '#txtSearchFor', + )?.value + presenceData.smallImageKey = Assets.Search - break; - } - default: - if (document.location.pathname.includes("/products")) { - if (document.location.pathname.includes("/latest")) - presenceData.details = "Viewing the latest products"; - else if ( - document.location.pathname.includes("/xbox-sales") - ) - presenceData.details = "Viewing Xbox sales"; - else if (document.querySelector(".pagetitle")) { - presenceData.details = "Viewing prices for:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace("Best price for ", "") - .trim(); - } - } else if (document.location.pathname.includes("/forum/")) { - presenceData.smallImageKey = Assets.Reading; - if ( - document.location.pathname.includes("/viewthreads.aspx") - ) { - presenceData.details = - "Forums - Viewing their recent threads"; - } else if ( - document.location.pathname.includes("/forums.aspx") - ) - presenceData.details = "Browsing the forums..."; - else if ( - document.location.pathname.includes("/viewboard.aspx") - ) { - presenceData.details = "Forums - Viewing board:"; - presenceData.state = - document.querySelector(".pagetitle").textContent; - } else if ( - document.location.pathname.includes("/newthreads.aspx") - ) - presenceData.details = "Forums - Viewing new threads"; - else if ( - document.location.pathname.includes("/viewthread.aspx") - ) { - presenceData.details = "Forums - Reading thread:"; - presenceData.state = document.querySelector( - "#oMessageThread > div:nth-child(2) > h1" - ).textContent; - } else if ( - document.location.pathname.includes("/search.aspx") - ) { - presenceData.details = "Forums - Searching for:"; - presenceData.state = - document.querySelector( - "#txtSearchFor" - ).value; - presenceData.smallImageKey = Assets.Search; - } - } else if ( - document.location.pathname.includes("/leaderboard") - ) - presenceData.details = "Viewing the leaderboards"; - else if ( - document.location.pathname.includes( - "/userleaderboards.aspx" - ) - ) { - presenceData.details = - "Viewing user created leaderboards"; - } else if ( - document.location.pathname.includes("/TAPlaylist") - ) { - if (document.location.pathname.includes("/forum")) { - presenceData.details = - "Viewing TA Playlist forum posts"; - } else if (document.location.pathname.includes("/stats")) - presenceData.details = "Viewing TA Playlist statistics"; - else if (document.location.pathname.includes("/clips")) - presenceData.details = "Viewing TA Playlist clips"; - else if (document.location.pathname.includes("/history")) - presenceData.details = "Viewing TA Playlist history"; - else if ( - document.querySelector( - ".community-playlist > div.header > div > h1" - ) !== null - ) { - presenceData.details = "Viewing:"; - presenceData.state = document.querySelector( - ".community-playlist > div.header > div > h1" - ).textContent; - } else presenceData.details = "TA Playlist - Browsing..."; - } else if (document.location.pathname === "/") - presenceData.details = "Browsing..."; - } - } - } - } - } - } + break + } + default: + if (document.location.pathname.includes('/products')) { + if (document.location.pathname.includes('/latest')) { + presenceData.details = 'Viewing the latest products' + } + else if ( + document.location.pathname.includes('/xbox-sales') + ) { + presenceData.details = 'Viewing Xbox sales' + } + else if (document.querySelector('.pagetitle')) { + presenceData.details = 'Viewing prices for:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace('Best price for ', '') + .trim() + } + } + else if (document.location.pathname.includes('/forum/')) { + presenceData.smallImageKey = Assets.Reading + if ( + document.location.pathname.includes('/viewthreads.aspx') + ) { + presenceData.details = 'Forums - Viewing their recent threads' + } + else if ( + document.location.pathname.includes('/forums.aspx') + ) { + presenceData.details = 'Browsing the forums...' + } + else if ( + document.location.pathname.includes('/viewboard.aspx') + ) { + presenceData.details = 'Forums - Viewing board:' + presenceData.state = document.querySelector('.pagetitle')?.textContent + } + else if ( + document.location.pathname.includes('/newthreads.aspx') + ) { + presenceData.details = 'Forums - Viewing new threads' + } + else if ( + document.location.pathname.includes('/viewthread.aspx') + ) { + presenceData.details = 'Forums - Reading thread:' + presenceData.state = document.querySelector( + '#oMessageThread > div:nth-child(2) > h1', + )?.textContent + } + else if ( + document.location.pathname.includes('/search.aspx') + ) { + presenceData.details = 'Forums - Searching for:' + presenceData.state = document.querySelector( + '#txtSearchFor', + )?.value + presenceData.smallImageKey = Assets.Search + } + } + else if ( + document.location.pathname.includes('/leaderboard') + ) { + presenceData.details = 'Viewing the leaderboards' + } + else if ( + document.location.pathname.includes( + '/userleaderboards.aspx', + ) + ) { + presenceData.details = 'Viewing user created leaderboards' + } + else if ( + document.location.pathname.includes('/TAPlaylist') + ) { + if (document.location.pathname.includes('/forum')) { + presenceData.details = 'Viewing TA Playlist forum posts' + } + else if (document.location.pathname.includes('/stats')) { + presenceData.details = 'Viewing TA Playlist statistics' + } + else if (document.location.pathname.includes('/clips')) { + presenceData.details = 'Viewing TA Playlist clips' + } + else if (document.location.pathname.includes('/history')) { + presenceData.details = 'Viewing TA Playlist history' + } + else if ( + document.querySelector( + '.community-playlist > div.header > div > h1', + ) !== null + ) { + presenceData.details = 'Viewing:' + presenceData.state = document.querySelector( + '.community-playlist > div.header > div > h1', + )?.textContent + } + else { + presenceData.details = 'TA Playlist - Browsing...' + } + } + else if (document.location.pathname === '/') { + presenceData.details = 'Browsing...' + } + } + } + } + } + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TrueID/metadata.json b/websites/T/TrueID/metadata.json index 4214de657f0c..0218f6dded0c 100644 --- a/websites/T/TrueID/metadata.json +++ b/websites/T/TrueID/metadata.json @@ -1,49 +1,49 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Faelayis", - "id": "328731868096888833" - }, - "service": "TrueID", - "description": { - "en": "True ID experience a new entertainment center more than and better privileges For every lifestyle, easy to use, complete in one place.", - "th": "ทรูไอดี สัมผัสประสบการณ์ใหม่ของศูนย์รวมความบันเทิงที่สุดกว่า และสิทธิพิเศษที่ดีกว่า เพื่อทุกไลฟ์สไตล์ ใช้งานง่าย จบครบในที่เดียว." - }, - "url": [ - "home.trueid.net", - "movie.trueid.net", - "tv.trueid.net" - ], - "version": "1.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrueID/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrueID/assets/thumbnail.jpg", - "color": "#e0081a", - "category": "videos", - "tags": [ - "tv", - "thai", - "video", - "media" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "timestamps", - "title": "Show timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Faelayis", + "id": "328731868096888833" + }, + "service": "TrueID", + "description": { + "en": "True ID experience a new entertainment center more than and better privileges For every lifestyle, easy to use, complete in one place.", + "th": "ทรูไอดี สัมผัสประสบการณ์ใหม่ของศูนย์รวมความบันเทิงที่สุดกว่า และสิทธิพิเศษที่ดีกว่า เพื่อทุกไลฟ์สไตล์ ใช้งานง่าย จบครบในที่เดียว." + }, + "url": [ + "home.trueid.net", + "movie.trueid.net", + "tv.trueid.net" + ], + "version": "1.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrueID/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrueID/assets/thumbnail.jpg", + "color": "#e0081a", + "category": "videos", + "tags": [ + "tv", + "thai", + "video", + "media" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "timestamps", + "title": "Show timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/T/TrueID/presence.ts b/websites/T/TrueID/presence.ts index 9644b9ecd63c..2c6b5f854964 100644 --- a/websites/T/TrueID/presence.ts +++ b/websites/T/TrueID/presence.ts @@ -1,178 +1,174 @@ const presence = new Presence({ - clientId: "912784051801301053", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '912784051801301053', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const time = await presence.getSetting("timestamps"), - privacy = await presence.getSetting("privacy"), - buttons = await presence.getSetting("buttons"), - path = document.location, - lang = path.pathname.substring(1, 6), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TrueID/assets/logo.jpg", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const time = await presence.getSetting('timestamps') + const privacy = await presence.getSetting('privacy') + const buttons = await presence.getSetting('buttons') + const path = document.location + const lang = path.pathname.substring(1, 6) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TrueID/assets/logo.jpg', + startTimestamp: browsingTimestamp, + } - switch (path.hostname) { - case "home.trueid.net": { - presenceData.details = lang === "th-th" ? "หน้าแรก" : "Home page"; - break; - } - case "movie.trueid.net": { - let ep, - result, - result_ = [], - title = - document.querySelector( - "#__next > div > div.wrapper.-spacing > div > div.banner > div.box_desc > header > h1" - )?.textContent ?? null; - title === null - ? (title = - document.querySelector( - "#__next > div > div.wrapper.-spacing > div.player-wrap.contentbox > div.player-meta > div > header > div > h1" - )?.textContent ?? `${lang === "th-th" ? "ไม่พบ" : "not found"}`) - : null; - const selector = - document.querySelector( - "#section-category > div > div.col-12.col-sm-12.col-md-3.col-lg-2 > div > ul > li.active" - )?.textContent ?? `${lang === "th-th" ? "ไม่พบ" : "not found"}`; - switch (true) { - case path.pathname.includes("animation-genre"): - presenceData.details = `${ - lang === "th-th" ? "อนิเมชัน" : "Animation" - }`; - presenceData.state = `${ - lang === "th-th" ? "หมวดหมู่" : "Category" - } ${selector}`; - break; - case path.pathname.includes("movies-genre"): - presenceData.details = `${lang === "th-th" ? "หนัง" : "Movies"}`; - presenceData.state = `${ - lang === "th-th" ? "หมวดหมู่" : "Category" - } ${selector}`; - break; - case path.pathname.includes("series-genre"): - presenceData.details = `${lang === "th-th" ? "ซีรีส์" : "Series"}`; - presenceData.state = `${ - lang === "th-th" ? "หมวดหมู่" : "Category" - } ${selector}`; - break; - case path.pathname.includes("tvshow-genre"): - presenceData.details = `${ - lang === "th-th" ? "รวมฮิตวาไรตี้" : "Variety Hits" - }`; - presenceData.state = `${ - lang === "th-th" ? "หมวดหมู่" : "Category" - } ${selector}`; - break; - case path.pathname.includes("documentary-genre"): - presenceData.details = `${ - lang === "th-th" ? "ความรู้ และ สารคดี" : "Knowledge & Documentary" - }`; - presenceData.state = `${ - lang === "th-th" ? "หมวดหมู่" : "Category" - } ${selector}`; - break; - case path.pathname.includes("series"): - ep = title.match(/\d+/g); - result = title.replace(`EP.${ep} | `, ""); - result_ = result.split("| "); - presenceData.details = `${lang === "th-th" ? "ซีรีส์" : "Series"} ${ - ep - ? `${ - privacy - ? "" - : lang === "th-th" - ? `ตอนที่ ${ep[0]}` - : `Ep ${ep[0]}` - }` - : "" - }`; - presenceData.state = `${result_[1] ?? result}`; - if (buttons) { - presenceData.buttons = [ - { - label: `${lang === "th-th" ? "ดูซีรีส์" : "Watch Series"}`, - url: document.location.href.replace(/#\d+/, ""), - }, - ]; - } - break; - case path.pathname.includes("movie"): - presenceData.details = `${lang === "th-th" ? "หนัง" : "Movie"}`; - presenceData.state = `${title}`; - if (buttons) { - presenceData.buttons = [ - { - label: `${lang === "th-th" ? "ดูหนัง" : "Watch Movies"}`, - url: document.location.href.replace(/#\d+/, ""), - }, - ]; - } - break; - default: - presenceData.details = "Movie"; - presenceData.state = lang === "th-th" ? "หน้าแรก" : "Home page"; - break; - } + switch (path.hostname) { + case 'home.trueid.net': { + presenceData.details = lang === 'th-th' ? 'หน้าแรก' : 'Home page' + break + } + case 'movie.trueid.net': { + let ep + let result + let result_ = [] + let title = document.querySelector( + '#__next > div > div.wrapper.-spacing > div > div.banner > div.box_desc > header > h1', + )?.textContent ?? null + if (title === null) { + title = document.querySelector( + '#__next > div > div.wrapper.-spacing > div.player-wrap.contentbox > div.player-meta > div > header > div > h1', + )?.textContent ?? `${lang === 'th-th' ? 'ไม่พบ' : 'not found'}` + } + const selector = document.querySelector( + '#section-category > div > div.col-12.col-sm-12.col-md-3.col-lg-2 > div > ul > li.active', + )?.textContent ?? `${lang === 'th-th' ? 'ไม่พบ' : 'not found'}` + switch (true) { + case path.pathname.includes('animation-genre'): + presenceData.details = `${ + lang === 'th-th' ? 'อนิเมชัน' : 'Animation' + }` + presenceData.state = `${ + lang === 'th-th' ? 'หมวดหมู่' : 'Category' + } ${selector}` + break + case path.pathname.includes('movies-genre'): + presenceData.details = `${lang === 'th-th' ? 'หนัง' : 'Movies'}` + presenceData.state = `${ + lang === 'th-th' ? 'หมวดหมู่' : 'Category' + } ${selector}` + break + case path.pathname.includes('series-genre'): + presenceData.details = `${lang === 'th-th' ? 'ซีรีส์' : 'Series'}` + presenceData.state = `${ + lang === 'th-th' ? 'หมวดหมู่' : 'Category' + } ${selector}` + break + case path.pathname.includes('tvshow-genre'): + presenceData.details = `${ + lang === 'th-th' ? 'รวมฮิตวาไรตี้' : 'Variety Hits' + }` + presenceData.state = `${ + lang === 'th-th' ? 'หมวดหมู่' : 'Category' + } ${selector}` + break + case path.pathname.includes('documentary-genre'): + presenceData.details = `${ + lang === 'th-th' ? 'ความรู้ และ สารคดี' : 'Knowledge & Documentary' + }` + presenceData.state = `${ + lang === 'th-th' ? 'หมวดหมู่' : 'Category' + } ${selector}` + break + case path.pathname.includes('series'): + ep = title.match(/\d+/g) + result = title.replace(`EP.${ep} | `, '') + result_ = result.split('| ') + presenceData.details = `${lang === 'th-th' ? 'ซีรีส์' : 'Series'} ${ + ep + ? `${ + privacy + ? '' + : lang === 'th-th' + ? `ตอนที่ ${ep[0]}` + : `Ep ${ep[0]}` + }` + : '' + }` + presenceData.state = `${result_[1] ?? result}` + if (buttons) { + presenceData.buttons = [ + { + label: `${lang === 'th-th' ? 'ดูซีรีส์' : 'Watch Series'}`, + url: document.location.href.replace(/#\d+/, ''), + }, + ] + } + break + case path.pathname.includes('movie'): + presenceData.details = `${lang === 'th-th' ? 'หนัง' : 'Movie'}` + presenceData.state = `${title}` + if (buttons) { + presenceData.buttons = [ + { + label: `${lang === 'th-th' ? 'ดูหนัง' : 'Watch Movies'}`, + url: document.location.href.replace(/#\d+/, ''), + }, + ] + } + break + default: + presenceData.details = 'Movie' + presenceData.state = lang === 'th-th' ? 'หน้าแรก' : 'Home page' + break + } - break; - } - case "tv.trueid.net": { - switch (true) { - case path.pathname.includes("live"): - presenceData.details = `${ - lang === "th-th" ? "ดูทีวีออนไลน์" : "TV Online" - }`; - presenceData.state = `${lang === "th-th" ? "ช่อง" : "Channel"} ${ - document.querySelector( - "#__next > div > div.wrapper.-spacing > div.player-block.d-flex > div > div.desc-nowrap.d-flex > div.desc-block.title-middle > div > h1" - )?.textContent ?? - "".replace("ดูช่อง ", "").replace("ออนไลน์", "").split("–")[0] - }`; - presenceData.smallImageKey = Assets.Live; - if (buttons) { - presenceData.buttons = [ - { - label: `${ - lang === "th-th" ? "ดูทีวีออนไลน์" : "Watch tv online" - }`, - url: document.location.href.replace(/#\d+/, ""), - }, - ]; - } - break; - case path.pathname.includes("tvguide"): - presenceData.details = "Tv Guide"; - presenceData.state = - lang === "th-th" - ? "ผังรายการทีวีช่องทีวีทั้งหมด" - : "Program schedule of all channels"; - presenceData.smallImageKey = Assets.Question; - break; - default: - presenceData.details = "Tv"; - presenceData.state = lang === "th-th" ? "หน้าแรก" : "Home page"; - break; - } + break + } + case 'tv.trueid.net': { + switch (true) { + case path.pathname.includes('live'): + presenceData.details = `${ + lang === 'th-th' ? 'ดูทีวีออนไลน์' : 'TV Online' + }` + presenceData.state = `${lang === 'th-th' ? 'ช่อง' : 'Channel'} ${ + document.querySelector( + '#__next > div > div.wrapper.-spacing > div.player-block.d-flex > div > div.desc-nowrap.d-flex > div.desc-block.title-middle > div > h1', + )?.textContent + ?? ''.replace('ดูช่อง ', '').replace('ออนไลน์', '').split('–')[0] + }` + presenceData.smallImageKey = Assets.Live + if (buttons) { + presenceData.buttons = [ + { + label: `${ + lang === 'th-th' ? 'ดูทีวีออนไลน์' : 'Watch tv online' + }`, + url: document.location.href.replace(/#\d+/, ''), + }, + ] + } + break + case path.pathname.includes('tvguide'): + presenceData.details = 'Tv Guide' + presenceData.state = lang === 'th-th' + ? 'ผังรายการทีวีช่องทีวีทั้งหมด' + : 'Program schedule of all channels' + presenceData.smallImageKey = Assets.Question + break + default: + presenceData.details = 'Tv' + presenceData.state = lang === 'th-th' ? 'หน้าแรก' : 'Home page' + break + } - break; - } - default: { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } - if (!time) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - if (privacy) { - delete presenceData.state; - delete presenceData.buttons; - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + break + } + default: { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + if (!time) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + if (privacy) { + delete presenceData.state + delete presenceData.buttons + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TrueSteamAchievements/metadata.json b/websites/T/TrueSteamAchievements/metadata.json index e87ebcabdc9e..031a926a440a 100644 --- a/websites/T/TrueSteamAchievements/metadata.json +++ b/websites/T/TrueSteamAchievements/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "TrueSteamAchievements", - "description": { - "en": "TrueSteamAchievements is the home of Steam news, achievement lists and guides, reviews, interviews, leaderboards and more.", - "nl": "TrueSteamAchievements is de plaats voor Steam nieuws, prestatielijsten en gidsen, recensies, interviews, scoreborden en meer." - }, - "url": "truesteamachievements.com", - "version": "1.0.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrueSteamAchievements/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrueSteamAchievements/assets/thumbnail.jpg", - "color": "#FFF", - "category": "other", - "tags": [ - "true", - "achievements", - "steam" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "TrueSteamAchievements", + "description": { + "en": "TrueSteamAchievements is the home of Steam news, achievement lists and guides, reviews, interviews, leaderboards and more.", + "nl": "TrueSteamAchievements is de plaats voor Steam nieuws, prestatielijsten en gidsen, recensies, interviews, scoreborden en meer." + }, + "url": "truesteamachievements.com", + "version": "1.0.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrueSteamAchievements/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrueSteamAchievements/assets/thumbnail.jpg", + "color": "#FFF", + "category": "other", + "tags": [ + "true", + "achievements", + "steam" + ] +} diff --git a/websites/T/TrueSteamAchievements/presence.ts b/websites/T/TrueSteamAchievements/presence.ts index b66848916a3a..f172b3ea0aca 100644 --- a/websites/T/TrueSteamAchievements/presence.ts +++ b/websites/T/TrueSteamAchievements/presence.ts @@ -1,230 +1,259 @@ const presence = new Presence({ - clientId: "701044403405324348", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '701044403405324348', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TrueSteamAchievements/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TrueSteamAchievements/assets/logo.png', + } - presenceData.startTimestamp = browsingTimestamp; + presenceData.startTimestamp = browsingTimestamp - if (document.location.pathname.includes("/gamer/")) { - const user = document.querySelector(".tabs > ul > li").textContent; + if (document.location.pathname.includes('/gamer/')) { + const user = document.querySelector('.tabs > ul > li')?.textContent - if (document.location.pathname.includes("/gamecollection")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Game Collection"; - } else if (document.location.pathname.includes("/achievements")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Achievements"; - } else if (document.location.pathname.includes("/goals")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Goals"; - } else if (document.location.pathname.includes("/blog")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Blog"; - } else if (document.location.pathname.includes("/stats")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Statistics"; - } else { - presenceData.details = "Viewing profile of:"; - presenceData.state = user; - } - } else if (document.location.pathname.includes("/game/")) { - if (document.location.pathname.includes("/achievements")) { - presenceData.details = "Viewing Achievements of game:"; - presenceData.state = document.querySelector( - "div.panel-header.w > h3 > a" - ).textContent; - } else if (document.location.pathname.includes("/forum")) { - presenceData.details = "Viewing Forums of game:"; - presenceData.state = document.title.replace(" Forum", ""); - } else if (document.location.pathname.includes("/walkthrough")) { - presenceData.details = "Viewing Walkthrough of game:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace(" Walkthrough", ""); - } else if (document.location.pathname.includes("/reviews")) { - presenceData.details = "Viewing Reviews of game:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace(" Reviews", ""); - } else if (document.location.pathname.includes("/scores")) { - presenceData.details = "Viewing Top Scores of game:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace("Top Scores For ", ""); - } else if (document.location.pathname.includes("/gamers")) { - presenceData.details = "Viewing Gamers of game:"; - presenceData.state = document.querySelector( - "div.panel-header.w > h3 > a" - ).textContent; - } else { - presenceData.details = "Viewing game:"; - presenceData.state = document.querySelector(".info").textContent.trim(); - } - } else if ( - document.querySelector(".pagetitle")?.textContent === "Achievement Details" - ) { - presenceData.details = "Viewing acheievement:"; - presenceData.state = document.querySelector(".title").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = `Game: ${ - document.querySelector("div.panel-header.w > h3 > a").textContent - }`; - } else if ( - document.location.pathname === "/news" || - document.location.pathname === "/news.aspx" - ) - presenceData.details = "Viewing the latest news"; - else if (document.querySelector(".newsitem > header > h1")) { - presenceData.details = "Reading article:"; - presenceData.state = document.querySelector( - ".newsitem > header > h1" - ).textContent; - presenceData.smallImageKey = Assets.Reading; - } else { - switch (document.location.pathname) { - case "/suggestnews.aspx": { - presenceData.details = "Suggesting new news"; - presenceData.smallImageKey = Assets.Writing; + if (document.location.pathname.includes('/gamecollection')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Game Collection' + } + else if (document.location.pathname.includes('/achievements')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Achievements' + } + else if (document.location.pathname.includes('/goals')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Goals' + } + else if (document.location.pathname.includes('/blog')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Blog' + } + else if (document.location.pathname.includes('/stats')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Statistics' + } + else { + presenceData.details = 'Viewing profile of:' + presenceData.state = user + } + } + else if (document.location.pathname.includes('/game/')) { + if (document.location.pathname.includes('/achievements')) { + presenceData.details = 'Viewing Achievements of game:' + presenceData.state = document.querySelector( + 'div.panel-header.w > h3 > a', + )?.textContent + } + else if (document.location.pathname.includes('/forum')) { + presenceData.details = 'Viewing Forums of game:' + presenceData.state = document.title.replace(' Forum', '') + } + else if (document.location.pathname.includes('/walkthrough')) { + presenceData.details = 'Viewing Walkthrough of game:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace(' Walkthrough', '') + } + else if (document.location.pathname.includes('/reviews')) { + presenceData.details = 'Viewing Reviews of game:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace(' Reviews', '') + } + else if (document.location.pathname.includes('/scores')) { + presenceData.details = 'Viewing Top Scores of game:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace('Top Scores For ', '') + } + else if (document.location.pathname.includes('/gamers')) { + presenceData.details = 'Viewing Gamers of game:' + presenceData.state = document.querySelector( + 'div.panel-header.w > h3 > a', + )?.textContent + } + else { + presenceData.details = 'Viewing game:' + presenceData.state = document.querySelector('.info')?.textContent?.trim() + } + } + else if ( + document.querySelector('.pagetitle')?.textContent === 'Achievement Details' + ) { + presenceData.details = 'Viewing acheievement:' + presenceData.state = document.querySelector('.title')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = `Game: ${ + document.querySelector('div.panel-header.w > h3 > a')?.textContent + }` + } + else if ( + document.location.pathname === '/news' + || document.location.pathname === '/news.aspx' + ) { + presenceData.details = 'Viewing the latest news' + } + else if (document.querySelector('.newsitem > header > h1')) { + presenceData.details = 'Reading article:' + presenceData.state = document.querySelector( + '.newsitem > header > h1', + )?.textContent + presenceData.smallImageKey = Assets.Reading + } + else { + switch (document.location.pathname) { + case '/suggestnews.aspx': { + presenceData.details = 'Suggesting new news' + presenceData.smallImageKey = Assets.Writing - break; - } - case "/news/community": { - presenceData.details = "Viewing the latest community news"; - break; - } - case "/siteupdates": { - presenceData.details = "Viewing the latest site updates"; - break; - } - case "/games.aspx": { - presenceData.details = "Viewing all games"; - break; - } - case "/steam-achievements.aspx": { - presenceData.details = "Viewing all achievements"; - break; - } - case "/solutions-required.aspx": { - presenceData.details = "Viewing all achievements"; - presenceData.state = "that require guides"; + break + } + case '/news/community': { + presenceData.details = 'Viewing the latest community news' + break + } + case '/siteupdates': { + presenceData.details = 'Viewing the latest site updates' + break + } + case '/games.aspx': { + presenceData.details = 'Viewing all games' + break + } + case '/steam-achievements.aspx': { + presenceData.details = 'Viewing all achievements' + break + } + case '/solutions-required.aspx': { + presenceData.details = 'Viewing all achievements' + presenceData.state = 'that require guides' - break; - } - case "/sitereviews.aspx": { - presenceData.details = "Viewing site reviews"; - break; - } - case "/solutions": { - presenceData.details = "Viewing achievement solutions"; - break; - } - default: - if ( - document.location.pathname.includes("/viewcomment.aspx") && - document.querySelector(".pagetitle")?.textContent === "View Solution" - ) { - presenceData.details = "Viewing solution for achievement:"; - presenceData.state = document.querySelector(".title").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = `Game: ${ - document.querySelector("div.panel-header.w > h3 > a").textContent - }`; - } else { - switch (document.location.pathname) { - case "/serieslist.aspx": { - presenceData.details = "Viewing Game Series"; - break; - } - case "/popularachievements.aspx": { - presenceData.details = "Viewing popular achievements"; - break; - } - case "/walkthroughs.aspx": { - presenceData.details = "Viewing Steam Walkthroughs and Guides"; - break; - } - case "/reviews.aspx": { - presenceData.details = "Viewing user reviews"; - break; - } - case "/gamereleases.aspx": { - presenceData.details = "Viewing upcoming releases"; - break; - } - case "/searchresults.aspx": { - presenceData.details = "Searching for:"; - presenceData.state = - document.querySelector("#txtSearchFor").value; - presenceData.smallImageKey = Assets.Search; + break + } + case '/sitereviews.aspx': { + presenceData.details = 'Viewing site reviews' + break + } + case '/solutions': { + presenceData.details = 'Viewing achievement solutions' + break + } + default: + if ( + document.location.pathname.includes('/viewcomment.aspx') + && document.querySelector('.pagetitle')?.textContent === 'View Solution' + ) { + presenceData.details = 'Viewing solution for achievement:' + presenceData.state = document.querySelector('.title')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = `Game: ${ + document.querySelector('div.panel-header.w > h3 > a')?.textContent + }` + } + else { + switch (document.location.pathname) { + case '/serieslist.aspx': { + presenceData.details = 'Viewing Game Series' + break + } + case '/popularachievements.aspx': { + presenceData.details = 'Viewing popular achievements' + break + } + case '/walkthroughs.aspx': { + presenceData.details = 'Viewing Steam Walkthroughs and Guides' + break + } + case '/reviews.aspx': { + presenceData.details = 'Viewing user reviews' + break + } + case '/gamereleases.aspx': { + presenceData.details = 'Viewing upcoming releases' + break + } + case '/searchresults.aspx': { + presenceData.details = 'Searching for:' + presenceData.state = document.querySelector('#txtSearchFor')?.value + presenceData.smallImageKey = Assets.Search - break; - } - default: - if (document.location.pathname.includes("/products")) { - if (document.location.pathname.includes("/latest")) - presenceData.details = "Viewing the latest products"; - else if (document.location.pathname.includes("/steam-sales")) - presenceData.details = "Viewing steam sales"; - else if (document.querySelector(".pagetitle")) { - presenceData.details = "Viewing prices for:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace("Best price for ", "") - .trim(); - } - } else if (document.location.pathname.includes("/forum/")) { - presenceData.smallImageKey = Assets.Reading; - if (document.location.pathname.includes("/viewthreads.aspx")) { - presenceData.details = - "Forums - Viewing their recent threads"; - } else if (document.location.pathname.includes("/forums.aspx")) - presenceData.details = "Browsing the forums..."; - else if ( - document.location.pathname.includes("/viewboard.aspx") - ) { - presenceData.details = "Forums - Viewing board:"; - presenceData.state = - document.querySelector(".pagetitle").textContent; - } else if ( - document.location.pathname.includes("/newthreads.aspx") - ) - presenceData.details = "Forums - Viewing new threads"; - else if ( - document.location.pathname.includes("/viewthread.aspx") - ) { - presenceData.details = "Forums - Reading thread:"; - presenceData.state = document.querySelector( - "#oMessageThread > div:nth-child(2) > h1" - ).textContent; - } else if ( - document.location.pathname.includes("/search.aspx") - ) { - presenceData.details = "Forums - Searching for:"; - presenceData.state = - document.querySelector( - "#txtSearchFor" - ).value; - presenceData.smallImageKey = Assets.Search; - } - } else if (document.location.pathname.includes("/leaderboard")) - presenceData.details = "Viewing the leaderboards"; - else if ( - document.location.pathname.includes("/userleaderboards.aspx") - ) - presenceData.details = "Viewing user created leaderboards"; - else if (document.location.pathname === "/") - presenceData.details = "Browsing..."; - } - } - } - } + break + } + default: + if (document.location.pathname.includes('/products')) { + if (document.location.pathname.includes('/latest')) { + presenceData.details = 'Viewing the latest products' + } + else if (document.location.pathname.includes('/steam-sales')) { + presenceData.details = 'Viewing steam sales' + } + else if (document.querySelector('.pagetitle')) { + presenceData.details = 'Viewing prices for:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace('Best price for ', '') + .trim() + } + } + else if (document.location.pathname.includes('/forum/')) { + presenceData.smallImageKey = Assets.Reading + if (document.location.pathname.includes('/viewthreads.aspx')) { + presenceData.details = 'Forums - Viewing their recent threads' + } + else if (document.location.pathname.includes('/forums.aspx')) { + presenceData.details = 'Browsing the forums...' + } + else if ( + document.location.pathname.includes('/viewboard.aspx') + ) { + presenceData.details = 'Forums - Viewing board:' + presenceData.state = document.querySelector('.pagetitle')?.textContent + } + else if ( + document.location.pathname.includes('/newthreads.aspx') + ) { + presenceData.details = 'Forums - Viewing new threads' + } + else if ( + document.location.pathname.includes('/viewthread.aspx') + ) { + presenceData.details = 'Forums - Reading thread:' + presenceData.state = document.querySelector( + '#oMessageThread > div:nth-child(2) > h1', + )?.textContent + } + else if ( + document.location.pathname.includes('/search.aspx') + ) { + presenceData.details = 'Forums - Searching for:' + presenceData.state = document.querySelector( + '#txtSearchFor', + )?.value + presenceData.smallImageKey = Assets.Search + } + } + else if (document.location.pathname.includes('/leaderboard')) { + presenceData.details = 'Viewing the leaderboards' + } + else if ( + document.location.pathname.includes('/userleaderboards.aspx') + ) { + presenceData.details = 'Viewing user created leaderboards' + } + else if (document.location.pathname === '/') { + presenceData.details = 'Browsing...' + } + } + } + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TrueTrophies/metadata.json b/websites/T/TrueTrophies/metadata.json index 00b26032da61..9fc7d1b4ecf8 100644 --- a/websites/T/TrueTrophies/metadata.json +++ b/websites/T/TrueTrophies/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "TrueTrophies", - "description": { - "en": "TrueTrophies is the home of Playstation news, achievement lists and guides, reviews, interviews, leaderboards and more.", - "nl": "TrueTrophies is de plaats voor Playstation nieuws, prestatielijsten en gidsen, recensies, interviews, scoreborden en meer." - }, - "url": "www.truetrophies.com", - "version": "1.0.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrueTrophies/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrueTrophies/assets/thumbnail.png", - "color": "#2e94d8", - "category": "other", - "tags": [ - "true", - "achievements", - "playstation", - "trophies" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "TrueTrophies", + "description": { + "en": "TrueTrophies is the home of Playstation news, achievement lists and guides, reviews, interviews, leaderboards and more.", + "nl": "TrueTrophies is de plaats voor Playstation nieuws, prestatielijsten en gidsen, recensies, interviews, scoreborden en meer." + }, + "url": "www.truetrophies.com", + "version": "1.0.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TrueTrophies/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TrueTrophies/assets/thumbnail.png", + "color": "#2e94d8", + "category": "other", + "tags": [ + "true", + "achievements", + "playstation", + "trophies" + ] +} diff --git a/websites/T/TrueTrophies/presence.ts b/websites/T/TrueTrophies/presence.ts index 6a5c12779b14..95be9656c807 100644 --- a/websites/T/TrueTrophies/presence.ts +++ b/websites/T/TrueTrophies/presence.ts @@ -1,305 +1,333 @@ const presence = new Presence({ - clientId: "702476721059790938", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '702476721059790938', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TrueTrophies/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TrueTrophies/assets/logo.png', + } - presenceData.startTimestamp = browsingTimestamp; + presenceData.startTimestamp = browsingTimestamp - if (document.location.pathname.includes("/gamer/")) { - const user = document.querySelector(".tabs > ul > li").textContent; + if (document.location.pathname.includes('/gamer/')) { + const user = document.querySelector('.tabs > ul > li')?.textContent - if (document.location.pathname.includes("/gamecollection")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Game Collection"; - } else if (document.location.pathname.includes("/trophies")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Trophies"; - } else if (document.location.pathname.includes("/goals")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Goals"; - } else if (document.location.pathname.includes("/blog")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Blog"; - } else if (document.location.pathname.includes("/stats")) { - presenceData.details = `Viewing ${user}'s`; - presenceData.state = "Statistics"; - } else { - presenceData.details = "Viewing profile of:"; - presenceData.state = user; - } - } else if (document.location.pathname.includes("/game/")) { - if (document.location.pathname.includes("/trophies")) { - presenceData.details = "Viewing Trophies of game:"; - presenceData.state = document.querySelector( - "div.panel-header.w > h3 > a" - ).textContent; - } else if (document.location.pathname.includes("/forum")) { - presenceData.details = "Viewing Forums of game:"; - presenceData.state = document.title.replace(" Forum", ""); - } else if (document.location.pathname.includes("/walkthrough")) { - presenceData.details = "Viewing Walkthrough of game:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace(" Walkthrough", ""); - } else if (document.location.pathname.includes("/reviews")) { - presenceData.details = "Viewing Reviews of game:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace(" Reviews", ""); - } else if (document.location.pathname.includes("/scores")) { - presenceData.details = "Viewing Top Scores of game:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace("Top Scores For ", ""); - } else if (document.location.pathname.includes("/gamers")) { - presenceData.details = "Viewing Gamers of game:"; - presenceData.state = document.querySelector( - "div.panel-header.w > h3 > a" - ).textContent; - } else { - presenceData.details = "Viewing game:"; - presenceData.state = document.querySelector(".info").textContent.trim(); - } - } else if ( - document.querySelector(".pagetitle")?.textContent === "Trophy Details" - ) { - presenceData.details = "Viewing trophy:"; - presenceData.state = document.querySelector(".title").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = `Game: ${ - document.querySelector("div.panel-header.w > h3 > a").textContent - }`; - } else if ( - document.location.pathname === "/news" || - document.location.pathname === "/news.aspx" - ) - presenceData.details = "Viewing the latest news"; - else if (document.querySelector(".newsitem > header > h1")) { - presenceData.details = "Reading article:"; - presenceData.state = document.querySelector( - ".newsitem > header > h1" - ).textContent; - presenceData.smallImageKey = Assets.Reading; - } else { - switch (document.location.pathname) { - case "/suggestnews.aspx": { - presenceData.details = "Suggesting new news"; - presenceData.smallImageKey = Assets.Writing; + if (document.location.pathname.includes('/gamecollection')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Game Collection' + } + else if (document.location.pathname.includes('/trophies')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Trophies' + } + else if (document.location.pathname.includes('/goals')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Goals' + } + else if (document.location.pathname.includes('/blog')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Blog' + } + else if (document.location.pathname.includes('/stats')) { + presenceData.details = `Viewing ${user}'s` + presenceData.state = 'Statistics' + } + else { + presenceData.details = 'Viewing profile of:' + presenceData.state = user + } + } + else if (document.location.pathname.includes('/game/')) { + if (document.location.pathname.includes('/trophies')) { + presenceData.details = 'Viewing Trophies of game:' + presenceData.state = document.querySelector( + 'div.panel-header.w > h3 > a', + )?.textContent + } + else if (document.location.pathname.includes('/forum')) { + presenceData.details = 'Viewing Forums of game:' + presenceData.state = document.title.replace(' Forum', '') + } + else if (document.location.pathname.includes('/walkthrough')) { + presenceData.details = 'Viewing Walkthrough of game:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace(' Walkthrough', '') + } + else if (document.location.pathname.includes('/reviews')) { + presenceData.details = 'Viewing Reviews of game:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace(' Reviews', '') + } + else if (document.location.pathname.includes('/scores')) { + presenceData.details = 'Viewing Top Scores of game:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace('Top Scores For ', '') + } + else if (document.location.pathname.includes('/gamers')) { + presenceData.details = 'Viewing Gamers of game:' + presenceData.state = document.querySelector( + 'div.panel-header.w > h3 > a', + )?.textContent + } + else { + presenceData.details = 'Viewing game:' + presenceData.state = document.querySelector('.info')?.textContent?.trim() + } + } + else if ( + document.querySelector('.pagetitle')?.textContent === 'Trophy Details' + ) { + presenceData.details = 'Viewing trophy:' + presenceData.state = document.querySelector('.title')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = `Game: ${ + document.querySelector('div.panel-header.w > h3 > a')?.textContent + }` + } + else if ( + document.location.pathname === '/news' + || document.location.pathname === '/news.aspx' + ) { + presenceData.details = 'Viewing the latest news' + } + else if (document.querySelector('.newsitem > header > h1')) { + presenceData.details = 'Reading article:' + presenceData.state = document.querySelector( + '.newsitem > header > h1', + )?.textContent + presenceData.smallImageKey = Assets.Reading + } + else { + switch (document.location.pathname) { + case '/suggestnews.aspx': { + presenceData.details = 'Suggesting new news' + presenceData.smallImageKey = Assets.Writing - break; - } - case "/news/community": { - presenceData.details = "Viewing the latest community news"; - break; - } - case "/news/playstation-vr": { - presenceData.details = "Viewing the latest PlayStation VR news"; - break; - } - case "/news/playstation-network": { - presenceData.details = "Viewing the latest PlayStation Network news"; - break; - } - case "/news/tags/podcast": { - presenceData.details = "Viewing the latest podcasts"; - break; - } - case "/siteupdates": { - presenceData.details = "Viewing the latest site updates"; - break; - } - case "/games.aspx": { - presenceData.details = "Viewing all games"; - break; - } - case "/playstationtrophies.aspx": { - presenceData.details = "Viewing all trophies"; - break; - } - case "/solutions-required.aspx": { - presenceData.details = "Viewing all trophies"; - presenceData.state = "that require guides"; + break + } + case '/news/community': { + presenceData.details = 'Viewing the latest community news' + break + } + case '/news/playstation-vr': { + presenceData.details = 'Viewing the latest PlayStation VR news' + break + } + case '/news/playstation-network': { + presenceData.details = 'Viewing the latest PlayStation Network news' + break + } + case '/news/tags/podcast': { + presenceData.details = 'Viewing the latest podcasts' + break + } + case '/siteupdates': { + presenceData.details = 'Viewing the latest site updates' + break + } + case '/games.aspx': { + presenceData.details = 'Viewing all games' + break + } + case '/playstationtrophies.aspx': { + presenceData.details = 'Viewing all trophies' + break + } + case '/solutions-required.aspx': { + presenceData.details = 'Viewing all trophies' + presenceData.state = 'that require guides' - break; - } - case "/sitereviews.aspx": { - presenceData.details = "Viewing site reviews"; - break; - } - case "/solutions": { - presenceData.details = "Viewing trophy solutions"; - break; - } - case "/psn.aspx": { - presenceData.details = "Viewing PlayStation Network status"; - break; - } - case "/ps4/news": { - presenceData.details = "Viewing the latest PS4 news"; - break; - } - case "/ps4/games": { - presenceData.details = "Viewing the latest PS4 games"; - break; - } - case "/ps4/prices": { - presenceData.details = "Viewing the latest PS4 prices"; - break; - } - case "/ps3/news": { - presenceData.details = "Viewing the latest PS3 news"; - break; - } - case "/ps3/games": { - presenceData.details = "Viewing the latest PS3 games"; - break; - } - case "/ps3/prices": { - presenceData.details = "Viewing the latest PS3 prices"; - break; - } - case "/vita/news": { - presenceData.details = "Viewing the latest VITA news"; - break; - } - case "/vita/games": { - presenceData.details = "Viewing the latest VITA games"; - break; - } - case "/vita/prices": { - presenceData.details = "Viewing the latest VITA prices"; - break; - } - case "/ps-now/news": { - presenceData.details = "Viewing the latest PlayStation Now news"; - break; - } - case "/ps-now/games": { - presenceData.details = "Viewing the latest PlayStation Now games"; - break; - } - case "/playstation-vr/news": { - presenceData.details = "Viewing the latest PlayStation VR news"; - break; - } - case "/playstation-vr/games": { - presenceData.details = "Viewing the latest PlayStation VR games"; - break; - } - default: - if ( - document.location.pathname.includes("/viewcomment.aspx") && - document.querySelector(".pagetitle")?.textContent === "View Solution" - ) { - presenceData.details = "Viewing solution for trophy:"; - presenceData.state = document.querySelector(".title").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = `Game: ${ - document.querySelector("div.panel-header.w > h3 > a").textContent - }`; - } else { - switch (document.location.pathname) { - case "/serieslist.aspx": { - presenceData.details = "Viewing Game Series"; - break; - } - case "/populartrophies.aspx": { - presenceData.details = "Viewing popular trophies"; - break; - } - case "/walkthroughs.aspx": { - presenceData.details = - "Viewing PlayStation Walkthroughs and Guides"; - break; - } - case "/reviews.aspx": { - presenceData.details = "Viewing user reviews"; - break; - } - case "/gamereleases.aspx": { - presenceData.details = "Viewing upcoming releases"; - break; - } - case "/gamingsessions.aspx": { - presenceData.details = "Viewing the Gaming Sessions"; - break; - } - case "/searchresults.aspx": { - presenceData.details = "Searching for:"; - presenceData.state = - document.querySelector("#txtSearchFor").value; - presenceData.smallImageKey = Assets.Search; + break + } + case '/sitereviews.aspx': { + presenceData.details = 'Viewing site reviews' + break + } + case '/solutions': { + presenceData.details = 'Viewing trophy solutions' + break + } + case '/psn.aspx': { + presenceData.details = 'Viewing PlayStation Network status' + break + } + case '/ps4/news': { + presenceData.details = 'Viewing the latest PS4 news' + break + } + case '/ps4/games': { + presenceData.details = 'Viewing the latest PS4 games' + break + } + case '/ps4/prices': { + presenceData.details = 'Viewing the latest PS4 prices' + break + } + case '/ps3/news': { + presenceData.details = 'Viewing the latest PS3 news' + break + } + case '/ps3/games': { + presenceData.details = 'Viewing the latest PS3 games' + break + } + case '/ps3/prices': { + presenceData.details = 'Viewing the latest PS3 prices' + break + } + case '/vita/news': { + presenceData.details = 'Viewing the latest VITA news' + break + } + case '/vita/games': { + presenceData.details = 'Viewing the latest VITA games' + break + } + case '/vita/prices': { + presenceData.details = 'Viewing the latest VITA prices' + break + } + case '/ps-now/news': { + presenceData.details = 'Viewing the latest PlayStation Now news' + break + } + case '/ps-now/games': { + presenceData.details = 'Viewing the latest PlayStation Now games' + break + } + case '/playstation-vr/news': { + presenceData.details = 'Viewing the latest PlayStation VR news' + break + } + case '/playstation-vr/games': { + presenceData.details = 'Viewing the latest PlayStation VR games' + break + } + default: + if ( + document.location.pathname.includes('/viewcomment.aspx') + && document.querySelector('.pagetitle')?.textContent === 'View Solution' + ) { + presenceData.details = 'Viewing solution for trophy:' + presenceData.state = document.querySelector('.title')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = `Game: ${ + document.querySelector('div.panel-header.w > h3 > a')?.textContent + }` + } + else { + switch (document.location.pathname) { + case '/serieslist.aspx': { + presenceData.details = 'Viewing Game Series' + break + } + case '/populartrophies.aspx': { + presenceData.details = 'Viewing popular trophies' + break + } + case '/walkthroughs.aspx': { + presenceData.details = 'Viewing PlayStation Walkthroughs and Guides' + break + } + case '/reviews.aspx': { + presenceData.details = 'Viewing user reviews' + break + } + case '/gamereleases.aspx': { + presenceData.details = 'Viewing upcoming releases' + break + } + case '/gamingsessions.aspx': { + presenceData.details = 'Viewing the Gaming Sessions' + break + } + case '/searchresults.aspx': { + presenceData.details = 'Searching for:' + presenceData.state = document.querySelector('#txtSearchFor')?.value + presenceData.smallImageKey = Assets.Search - break; - } - default: - if (document.location.pathname.includes("/products")) { - if (document.location.pathname.includes("/latest")) - presenceData.details = "Viewing the latest products"; - else if ( - document.location.pathname.includes("/playstation-sales") - ) - presenceData.details = "Viewing PlayStation sales"; - else if (document.querySelector(".pagetitle")) { - presenceData.details = "Viewing prices for:"; - presenceData.state = document - .querySelector(".pagetitle") - .textContent.replace("Best price for ", "") - .trim(); - } - } else if (document.location.pathname.includes("/forum/")) { - presenceData.smallImageKey = Assets.Reading; - if (document.location.pathname.includes("/viewthreads.aspx")) { - presenceData.details = - "Forums - Viewing their recent threads"; - } else if (document.location.pathname.includes("/forums.aspx")) - presenceData.details = "Browsing the forums..."; - else if ( - document.location.pathname.includes("/viewboard.aspx") - ) { - presenceData.details = "Forums - Viewing board:"; - presenceData.state = - document.querySelector(".pagetitle").textContent; - } else if ( - document.location.pathname.includes("/newthreads.aspx") - ) - presenceData.details = "Forums - Viewing new threads"; - else if ( - document.location.pathname.includes("/viewthread.aspx") - ) { - presenceData.details = "Forums - Reading thread:"; - presenceData.state = document.querySelector( - "#oMessageThread > div:nth-child(2) > h1" - ).textContent; - } else if ( - document.location.pathname.includes("/search.aspx") - ) { - presenceData.details = "Forums - Searching for:"; - presenceData.state = - document.querySelector( - "#txtSearchFor" - ).value; - presenceData.smallImageKey = Assets.Search; - } - } else if (document.location.pathname.includes("/leaderboard")) - presenceData.details = "Viewing the leaderboards"; - else if ( - document.location.pathname.includes("/userleaderboards.aspx") - ) - presenceData.details = "Viewing user created leaderboards"; - else if (document.location.pathname === "/") - presenceData.details = "Browsing..."; - } - } - } - } + break + } + default: + if (document.location.pathname.includes('/products')) { + if (document.location.pathname.includes('/latest')) { + presenceData.details = 'Viewing the latest products' + } + else if ( + document.location.pathname.includes('/playstation-sales') + ) { + presenceData.details = 'Viewing PlayStation sales' + } + else if (document.querySelector('.pagetitle')) { + presenceData.details = 'Viewing prices for:' + presenceData.state = document + .querySelector('.pagetitle') + ?.textContent + ?.replace('Best price for ', '') + .trim() + } + } + else if (document.location.pathname.includes('/forum/')) { + presenceData.smallImageKey = Assets.Reading + if (document.location.pathname.includes('/viewthreads.aspx')) { + presenceData.details = 'Forums - Viewing their recent threads' + } + else if (document.location.pathname.includes('/forums.aspx')) { + presenceData.details = 'Browsing the forums...' + } + else if ( + document.location.pathname.includes('/viewboard.aspx') + ) { + presenceData.details = 'Forums - Viewing board:' + presenceData.state = document.querySelector('.pagetitle')?.textContent + } + else if ( + document.location.pathname.includes('/newthreads.aspx') + ) { + presenceData.details = 'Forums - Viewing new threads' + } + else if ( + document.location.pathname.includes('/viewthread.aspx') + ) { + presenceData.details = 'Forums - Reading thread:' + presenceData.state = document.querySelector( + '#oMessageThread > div:nth-child(2) > h1', + )?.textContent + } + else if ( + document.location.pathname.includes('/search.aspx') + ) { + presenceData.details = 'Forums - Searching for:' + presenceData.state = document.querySelector( + '#txtSearchFor', + )?.value + presenceData.smallImageKey = Assets.Search + } + } + else if (document.location.pathname.includes('/leaderboard')) { + presenceData.details = 'Viewing the leaderboards' + } + else if ( + document.location.pathname.includes('/userleaderboards.aspx') + ) { + presenceData.details = 'Viewing user created leaderboards' + } + else if (document.location.pathname === '/') { + presenceData.details = 'Browsing...' + } + } + } + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TryHackMe/metadata.json b/websites/T/TryHackMe/metadata.json index c617005b01ac..c12e35d87660 100644 --- a/websites/T/TryHackMe/metadata.json +++ b/websites/T/TryHackMe/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "SherlockSec", - "id": "231061378075590656" - }, - "service": "TryHackMe", - "description": { - "en": "TryHackMe takes the pain out of learning and teaching Cybersecurity.", - "nl": "TryHackMe haalt de pijn uit het leren en onderwijzen van cyberbeveiliging." - }, - "url": "tryhackme.com", - "version": "1.1.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TryHackMe/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TryHackMe/assets/thumbnail.png", - "color": "#343C42", - "category": "other", - "tags": [ - "security", - "games" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "SherlockSec", + "id": "231061378075590656" + }, + "service": "TryHackMe", + "description": { + "en": "TryHackMe takes the pain out of learning and teaching Cybersecurity.", + "nl": "TryHackMe haalt de pijn uit het leren en onderwijzen van cyberbeveiliging." + }, + "url": "tryhackme.com", + "version": "1.1.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TryHackMe/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TryHackMe/assets/thumbnail.png", + "color": "#343C42", + "category": "other", + "tags": [ + "security", + "games" + ] +} diff --git a/websites/T/TryHackMe/presence.ts b/websites/T/TryHackMe/presence.ts index 78e28cb41344..94b71ba294e7 100644 --- a/websites/T/TryHackMe/presence.ts +++ b/websites/T/TryHackMe/presence.ts @@ -1,50 +1,59 @@ const presence = new Presence({ - clientId: "656826806061498368", //The client ID of the Application created at https://discordapp.com/developers/applications - //Enable use and detection of media key presses - }), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TryHackMe/assets/logo.png", - }, - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '656826806061498368', // The client ID of the Application created at https://discordapp.com/developers/applications + // Enable use and detection of media key presses +}) +const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TryHackMe/assets/logo.png', +} +const browsingTimestamp = Math.floor(Date.now() / 1000) -let customData = false; +let customData = false -presence.on("UpdateData", async () => { - customData = false; - presenceData.startTimestamp = browsingTimestamp; +presence.on('UpdateData', async () => { + customData = false + presenceData.startTimestamp = browsingTimestamp - if (document.location.pathname === "/dashboard") - presenceData.details = "Viewing the Dashboard!"; - else if (document.location.pathname === "/profile") - presenceData.details = "Viewing their profile!"; - else if (document.location.pathname.startsWith("/room")) { - const title = document.querySelector("#title"); + if (document.location.pathname === '/dashboard') { + presenceData.details = 'Viewing the Dashboard!' + } + else if (document.location.pathname === '/profile') { + presenceData.details = 'Viewing their profile!' + } + else if (document.location.pathname.startsWith('/room')) { + const title = document.querySelector('#title') - if (title) { - customData = true; + if (title) { + customData = true - presence.setActivity({ - details: "Completing room:", - state: title.textContent, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TryHackMe/assets/logo.png", - startTimestamp: browsingTimestamp, - }); - } else presenceData.details = "Looking at rooms!"; - } else if ( - document.location.pathname === "/upload" || - document.location.pathname === "/manage-rooms" || - document.location.pathname.startsWith("/room/manage") || - document.location.pathname === "/assign-tasks" || - document.location.pathname === "/your-material" - ) { - presenceData.details = "Managing a room!"; - presenceData.state = `Page: ${document.location.pathname}`; - //presenceData.startTimestamp = browsingTimestamp; - } else if (document.location.pathname === "/leaderboards") - presenceData.details = "Checking the leaderboards!"; - else presenceData.details = "Breaking stuff!"; + presence.setActivity({ + details: 'Completing room:', + state: title.textContent, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TryHackMe/assets/logo.png', + startTimestamp: browsingTimestamp, + }) + } + else { + presenceData.details = 'Looking at rooms!' + } + } + else if ( + document.location.pathname === '/upload' + || document.location.pathname === '/manage-rooms' + || document.location.pathname.startsWith('/room/manage') + || document.location.pathname === '/assign-tasks' + || document.location.pathname === '/your-material' + ) { + presenceData.details = 'Managing a room!' + presenceData.state = `Page: ${document.location.pathname}` + // presenceData.startTimestamp = browsingTimestamp; + } + else if (document.location.pathname === '/leaderboards') { + presenceData.details = 'Checking the leaderboards!' + } + else { + presenceData.details = 'Breaking stuff!' + } - if (!customData) presence.setActivity(presenceData); -}); + if (!customData) + presence.setActivity(presenceData) +}) diff --git a/websites/T/TuMangaOnline/metadata.json b/websites/T/TuMangaOnline/metadata.json index 45e7162adc4c..ab9ba40e00be 100644 --- a/websites/T/TuMangaOnline/metadata.json +++ b/websites/T/TuMangaOnline/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "TuMangaOnline", - "description": { - "en": "Read manga online.", - "nl": "Lees manga online." - }, - "url": [ - "lectortmo.com", - "tmocommunity.com", - "visortmo.com", - "zonatmo.com" - ], - "version": "1.2.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TuMangaOnline/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TuMangaOnline/assets/thumbnail.png", - "color": "#3366cc", - "category": "anime", - "tags": [ - "anime", - "manga" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "TuMangaOnline", + "description": { + "en": "Read manga online.", + "nl": "Lees manga online." + }, + "url": [ + "lectortmo.com", + "tmocommunity.com", + "visortmo.com", + "zonatmo.com" + ], + "version": "1.2.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TuMangaOnline/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TuMangaOnline/assets/thumbnail.png", + "color": "#3366cc", + "category": "anime", + "tags": [ + "anime", + "manga" + ] +} diff --git a/websites/T/TuMangaOnline/presence.ts b/websites/T/TuMangaOnline/presence.ts index e684e5e21249..00d42da13287 100644 --- a/websites/T/TuMangaOnline/presence.ts +++ b/websites/T/TuMangaOnline/presence.ts @@ -1,61 +1,69 @@ const presence = new Presence({ - clientId: "640980262750126080", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '640980262750126080', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TuMangaOnline/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TuMangaOnline/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if ( - document.location.hostname === "lectortmo.com" || - document.location.hostname === "visortmo.com" - ) { - if (document.location.pathname === "/") - presenceData.details = "Browsing..."; - else if (document.location.pathname.includes("/library/manga/")) { - presenceData.details = "Viewing manga:"; - presenceData.state = document.querySelector( - "#app > section > header > section > div > div > div:nth-child(3) > h1" - ).textContent; - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/library")) - presenceData.details = "Viewing the library"; - else if (document.location.pathname.includes("/groups/")) { - presenceData.details = "Viewing group:"; - presenceData.state = document.querySelector( - "#app > section > header > section > div > div > div:nth-child(2) > h1" - ).textContent; - } else if (document.location.pathname.includes("/groups")) - presenceData.details = "Viewing groups"; - else if (document.location.pathname.includes("/lists/")) { - presenceData.details = "Viewing group:"; - presenceData.state = document.querySelector( - "#app > section > header > section > div > div > div:nth-child(2) > h1" - ).textContent; - } else if (document.location.pathname.includes("/lists")) - presenceData.details = "Viewing groups"; - else if (document.location.pathname.includes("/viewer/")) { - presenceData.details = "Reading manga:"; - presenceData.smallImageKey = Assets.Reading; - presenceData.state = document.querySelector( - "#app > section:nth-child(2) > div > div > h1" - ).textContent; - } - } else if (document.location.hostname === "tmocommunity.com") { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Browsing the forums..."; - if (document.location.pathname.includes("/d/")) { - presenceData.details = "Reading forum post:"; - presenceData.state = document.querySelector( - "#content > div > div > header > div > ul > li.item-title > h2" - ).textContent; - } - } + if ( + document.location.hostname === 'lectortmo.com' + || document.location.hostname === 'visortmo.com' + ) { + if (document.location.pathname === '/') { + presenceData.details = 'Browsing...' + } + else if (document.location.pathname.includes('/library/manga/')) { + presenceData.details = 'Viewing manga:' + presenceData.state = document.querySelector( + '#app > section > header > section > div > div > div:nth-child(3) > h1', + )?.textContent + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/library')) { + presenceData.details = 'Viewing the library' + } + else if (document.location.pathname.includes('/groups/')) { + presenceData.details = 'Viewing group:' + presenceData.state = document.querySelector( + '#app > section > header > section > div > div > div:nth-child(2) > h1', + )?.textContent + } + else if (document.location.pathname.includes('/groups')) { + presenceData.details = 'Viewing groups' + } + else if (document.location.pathname.includes('/lists/')) { + presenceData.details = 'Viewing group:' + presenceData.state = document.querySelector( + '#app > section > header > section > div > div > div:nth-child(2) > h1', + )?.textContent + } + else if (document.location.pathname.includes('/lists')) { + presenceData.details = 'Viewing groups' + } + else if (document.location.pathname.includes('/viewer/')) { + presenceData.details = 'Reading manga:' + presenceData.smallImageKey = Assets.Reading + presenceData.state = document.querySelector( + '#app > section:nth-child(2) > div > div > h1', + )?.textContent + } + } + else if (document.location.hostname === 'tmocommunity.com') { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Browsing the forums...' + if (document.location.pathname.includes('/d/')) { + presenceData.details = 'Reading forum post:' + presenceData.state = document.querySelector( + '#content > div > div > header > div > ul > li.item-title > h2', + )?.textContent + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Tubi/metadata.json b/websites/T/Tubi/metadata.json index 9d34f3bdd9d7..badd94b9aa94 100644 --- a/websites/T/Tubi/metadata.json +++ b/websites/T/Tubi/metadata.json @@ -1,60 +1,60 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dark_Ville", - "id": "638080361179512853" - }, - "contributors": [ - { - "name": "Alexx", - "id": "604182077088202784" - } - ], - "service": "Tubi", - "description": { - "en": "Tubi is an American streaming service based in San Francisco, California, United States, that launched in 2014. It is a free, ad-supported service, with advertisements shown during commercial breaks in between programming. It is the largest independently-owned video service in the United States.", - "nl": "Tubi is een Amerikaanse streamingdienst gevestigd in San Francisco, Californië, Verenigde Staten, die in 2014 werd gelanceerd. Het is een gratis, door advertenties ondersteunde dienst, met advertenties die worden getoond tijdens reclameblokken tussen het programmeren. Het is de grootste onafhankelijke videodienst in de Verenigde Staten." - }, - "url": "tubitv.com", - "version": "1.3.11", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tubi/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tubi/assets/thumbnail.png", - "color": "#F12C7B", - "category": "videos", - "tags": [ - "tubi", - "video", - "media" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fas fa-user-secret", - "value": false - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true, - "if": { - "privacy": false - } - }, - { - "id": "covers", - "title": "Show Cover", - "icon": "fad fa-images", - "value": true, - "if": { - "privacy": false - } - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dark_Ville", + "id": "638080361179512853" + }, + "contributors": [ + { + "name": "Alexx", + "id": "604182077088202784" + } + ], + "service": "Tubi", + "description": { + "en": "Tubi is an American streaming service based in San Francisco, California, United States, that launched in 2014. It is a free, ad-supported service, with advertisements shown during commercial breaks in between programming. It is the largest independently-owned video service in the United States.", + "nl": "Tubi is een Amerikaanse streamingdienst gevestigd in San Francisco, Californië, Verenigde Staten, die in 2014 werd gelanceerd. Het is een gratis, door advertenties ondersteunde dienst, met advertenties die worden getoond tijdens reclameblokken tussen het programmeren. Het is de grootste onafhankelijke videodienst in de Verenigde Staten." + }, + "url": "tubitv.com", + "version": "1.3.11", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tubi/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tubi/assets/thumbnail.png", + "color": "#F12C7B", + "category": "videos", + "tags": [ + "tubi", + "video", + "media" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fas fa-user-secret", + "value": false + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true, + "if": { + "privacy": false + } + }, + { + "id": "covers", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true, + "if": { + "privacy": false + } + } + ] +} diff --git a/websites/T/Tubi/presence.ts b/websites/T/Tubi/presence.ts index 310027b7b6ff..8164cce39b40 100644 --- a/websites/T/Tubi/presence.ts +++ b/websites/T/Tubi/presence.ts @@ -1,102 +1,110 @@ const presence = new Presence({ - clientId: "937290941285429311", - }), - browingTimestamp = Math.floor(Date.now() / 1000); + clientId: '937290941285429311', +}) +const browingTimestamp = Math.floor(Date.now() / 1000) async function getStrings() { - return presence.getStrings( - { - play: "general.playing", - paused: "general.paused", - browse: "general.browsing", - live: "general.live", - buttonWatchVideo: "general.buttonWatchVideo", - buttonWatchLive: "general.buttonWatchStream", - viewCategory: "general.viewCategory", - search: "general.searchFor", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + play: 'general.playing', + paused: 'general.paused', + browse: 'general.browsing', + live: 'general.live', + buttonWatchVideo: 'general.buttonWatchVideo', + buttonWatchLive: 'general.buttonWatchStream', + viewCategory: 'general.viewCategory', + search: 'general.searchFor', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Tubi/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Tubi/assets/logo.png', } -let strings: Awaited>, - oldLang: string = null; +let strings: Awaited> +let oldLang: string | null = null -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }, - video = document.querySelector("video"), - search = document.querySelector('[type="search"]'), - { href, pathname } = document.location, - [newLang, privacy, buttons, covers] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("privacy"), - presence.getSetting("buttons"), - presence.getSetting("covers"), - ]); - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } + const video = document.querySelector('video') + const search = document.querySelector('[type="search"]') + const { href, pathname } = document.location + const [newLang, privacy, buttons, covers] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('privacy'), + presence.getSetting('buttons'), + presence.getSetting('covers'), + ]) + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - if (privacy) { - presenceData.details = strings.browse; - return; - } - if (search?.value) { - presenceData.details = strings.search; - presenceData.state = search.value; - presenceData.smallImageKey = Assets.Search; - } else if (pathname.includes("/category/")) { - presenceData.details = strings.viewCategory; - presenceData.state = document.querySelector( - '[property="og:title"]' - ).content; - } else if (video && !isNaN(video.duration)) { - presenceData.largeImageKey = document.querySelector( - 'meta[property="og:image"]' - ).content; - presenceData.details = document.querySelector( - 'meta[property="og:title"]' - ).content; - if (!pathname.includes("live")) { - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? strings.paused - : strings.play; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ); - presenceData.buttons = [ - { - label: strings.buttonWatchVideo, - url: href, - }, - ]; - } else { - presenceData.buttons = [ - { - label: strings.buttonWatchLive, - url: href, - }, - ]; - presenceData.smallImageText = strings.live; - presenceData.smallImageKey = Assets.Live; - } - presenceData.startTimestamp = browingTimestamp; + if (privacy) { + presenceData.details = strings.browse + return + } + if (search?.value) { + presenceData.details = strings.search + presenceData.state = search.value + presenceData.smallImageKey = Assets.Search + } + else if (pathname.includes('/category/')) { + presenceData.details = strings.viewCategory + presenceData.state = document.querySelector( + '[property="og:title"]', + )?.content + } + else if (video && !Number.isNaN(video.duration)) { + presenceData.largeImageKey = document.querySelector( + 'meta[property="og:image"]', + )?.content + presenceData.details = document.querySelector( + 'meta[property="og:title"]', + )?.content + if (!pathname.includes('live')) { + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? strings.paused + : strings.play; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) + presenceData.buttons = [ + { + label: strings.buttonWatchVideo, + url: href, + }, + ] + } + else { + presenceData.buttons = [ + { + label: strings.buttonWatchLive, + url: href, + }, + ] + presenceData.smallImageText = strings.live + presenceData.smallImageKey = Assets.Live + } + presenceData.startTimestamp = browingTimestamp - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else presenceData.details = strings.browse; + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else { + presenceData.details = strings.browse + } - if (!buttons) delete presenceData.buttons; - if (!covers) presenceData.largeImageKey = Assets.Logo; - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (!buttons) + delete presenceData.buttons + if (!covers) + presenceData.largeImageKey = Assets.Logo + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TugaStrikes/metadata.json b/websites/T/TugaStrikes/metadata.json index 10d55fed974e..9fe2d88c5946 100644 --- a/websites/T/TugaStrikes/metadata.json +++ b/websites/T/TugaStrikes/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kewaii", - "id": "135112599460118528" - }, - "service": "TugaStrikes", - "description": { - "en": "TugaStrikes is a Gaming Community Founded in 2017 focusing on CS:GO", - "nl": "TugaStrikes is een gamingcommunity die is opgericht in 2017 en zich richt op CS:GO" - }, - "url": "tugastrikes.com", - "version": "1.2.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TugaStrikes/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TugaStrikes/assets/thumbnail.png", - "color": "#00ecec", - "category": "games", - "tags": [ - "community", - "csgo", - "gaming", - "tugastrikes" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Kewaii", + "id": "135112599460118528" + }, + "service": "TugaStrikes", + "description": { + "en": "TugaStrikes is a Gaming Community Founded in 2017 focusing on CS:GO", + "nl": "TugaStrikes is een gamingcommunity die is opgericht in 2017 en zich richt op CS:GO" + }, + "url": "tugastrikes.com", + "version": "1.2.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TugaStrikes/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TugaStrikes/assets/thumbnail.png", + "color": "#00ecec", + "category": "games", + "tags": [ + "community", + "csgo", + "gaming", + "tugastrikes" + ] +} diff --git a/websites/T/TugaStrikes/presence.ts b/websites/T/TugaStrikes/presence.ts index 2db83501a06d..1b78d314ed45 100644 --- a/websites/T/TugaStrikes/presence.ts +++ b/websites/T/TugaStrikes/presence.ts @@ -1,45 +1,45 @@ const presence = new Presence({ - clientId: "630098355145539595", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '630098355145539595', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TugaStrikes/assets/logo.png", - }, - [page, section] = window.location.href - .replace("https://tugastrikes.com/", "") - .split("/"); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TugaStrikes/assets/logo.png', + } + const [page, section] = window.location.href + .replace('https://tugastrikes.com/', '') + .split('/') - let state; - switch (section) { - case "skins": { - state = "Skins"; - break; - } - case "myskins": { - state = "My Skins"; - break; - } - case "buyskins": { - state = "Buy Skins"; - break; - } - case "sellskins": { - state = "Sell Skins"; - break; - } - default: - state = "Home Page"; - } + let state + switch (section) { + case 'skins': { + state = 'Skins' + break + } + case 'myskins': { + state = 'My Skins' + break + } + case 'buyskins': { + state = 'Buy Skins' + break + } + case 'sellskins': { + state = 'Sell Skins' + break + } + default: + state = 'Home Page' + } - if (page === "market") presenceData.details = "Market"; + if (page === 'market') + presenceData.details = 'Market' - presenceData.state = state; + presenceData.state = state - presenceData.startTimestamp = browsingTimestamp; - delete presenceData.smallImageKey; + presenceData.startTimestamp = browsingTimestamp + delete presenceData.smallImageKey - presence.setActivity(presenceData, true); -}); + presence.setActivity(presenceData, true) +}) diff --git a/websites/T/Tumblr/metadata.json b/websites/T/Tumblr/metadata.json index 72ddfa9afa56..5738404def69 100644 --- a/websites/T/Tumblr/metadata.json +++ b/websites/T/Tumblr/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "Tumblr", - "description": { - "en": "Tumblr is a place to express yourself, discover yourself, and bond over the stuff you love. It's where your interests connect you with your people.", - "nl": "Tumblr is een plek om jezelf te uiten, jezelf te ontdekken en een band op te bouwen over dingen waar je van houdt. Het is waar uw interesses u verbinden met uw mensen." - }, - "url": "www.tumblr.com", - "regExp": "([a-z0-9-]+[.])*tumblr[.]com[/]", - "version": "1.3.5", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tumblr/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tumblr/assets/thumbnail.png", - "color": "#395976", - "category": "other", - "tags": [ - "gifs", - "pics" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "Tumblr", + "description": { + "en": "Tumblr is a place to express yourself, discover yourself, and bond over the stuff you love. It's where your interests connect you with your people.", + "nl": "Tumblr is een plek om jezelf te uiten, jezelf te ontdekken en een band op te bouwen over dingen waar je van houdt. Het is waar uw interesses u verbinden met uw mensen." + }, + "url": "www.tumblr.com", + "regExp": "([a-z0-9-]+[.])*tumblr[.]com[/]", + "version": "1.3.5", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tumblr/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tumblr/assets/thumbnail.png", + "color": "#395976", + "category": "other", + "tags": [ + "gifs", + "pics" + ] +} diff --git a/websites/T/Tumblr/presence.ts b/websites/T/Tumblr/presence.ts index 7abdce4057d9..51f93a8651c6 100644 --- a/websites/T/Tumblr/presence.ts +++ b/websites/T/Tumblr/presence.ts @@ -1,193 +1,198 @@ const presence = new Presence({ - clientId: "640963335826833418", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '640963335826833418', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Tumblr/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { hostname, href, pathname } = document.location, - search = document.querySelector( - '[type="search"],#search_actions_search' - ); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Tumblr/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { hostname, href, pathname } = document.location + const search = document.querySelector( + '[type="search"],#search_actions_search', + ) - switch (hostname) { - case "www.tumblr.com": { - switch (true) { - case !!search?.value: { - presenceData.details = "Searching for"; - presenceData.state = search.value; - presenceData.smallImageKey = Assets.Search; - break; - } - case !!pathname.match(/[0-9]{18}/gm)?.[0]: { - const author = - document.querySelector('[rel="author"]'), - video = document.querySelector("video"); + switch (hostname) { + case 'www.tumblr.com': { + switch (true) { + case !!search?.value: { + presenceData.details = 'Searching for' + presenceData.state = search.value + presenceData.smallImageKey = Assets.Search + break + } + case !!pathname.match(/\d{18}/g)?.[0]: { + const author = document.querySelector('[rel="author"]') + const video = document.querySelector('video') - if (!isNaN(video?.duration)) { - delete presenceData.startTimestamp; - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Play; - presenceData.smallImageText = video.paused ? "Paused" : "Playing"; - if (!video.paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - } - presenceData.buttons = author - ? [ - { label: "Watch Video", url: href }, - { - label: "View Creator's Profile", - url: author.href, - }, - ] - : [{ label: "Watch Video", url: href }]; - } else { - presenceData.buttons = author - ? [ - { label: "View Post", url: href }, - { - label: "View Creator's Profile", - url: author.href, - }, - ] - : [{ label: "View Post", url: href }]; - } - presenceData.details = document.querySelector(".k31gt"); - presenceData.state = author?.textContent; + if (video && !Number.isNaN(video.duration)) { + delete presenceData.startTimestamp + presenceData.smallImageKey = video.paused + ? Assets.Pause + : Assets.Play + presenceData.smallImageText = video.paused ? 'Paused' : 'Playing' + if (!video.paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + } + presenceData.buttons = author + ? [ + { label: 'Watch Video', url: href }, + { + label: 'View Creator\'s Profile', + url: author.href, + }, + ] + : [{ label: 'Watch Video', url: href }] + } + else { + presenceData.buttons = author + ? [ + { label: 'View Post', url: href }, + { + label: 'View Creator\'s Profile', + url: author.href, + }, + ] + : [{ label: 'View Post', url: href }] + } + presenceData.details = document.querySelector('.k31gt') + presenceData.state = author?.textContent - break; - } - case pathname === "/": { - presenceData.details = "Viewing the home page"; - break; - } - case document.querySelector('[property="og:type"]') - ?.content === "profile": { - presenceData.details = `Viewing user: ${ - document.querySelector("header h1").textContent - }`; - presenceData.state = [ - ...document.querySelectorAll("header + div a"), - ].find(e => e.classList.length > 1)?.textContent; - presenceData.buttons = [{ label: "View Profile", url: href }]; - break; - } - case pathname.includes("/explore/answertime"): { - presenceData.details = "Exploring answer time content"; - break; - } - case pathname.includes("/explore/staff-picks"): { - presenceData.details = "Exploring staff picks"; - break; - } - case pathname.includes("/explore/trending"): { - presenceData.details = "Exploring trending content"; - break; - } - case pathname.includes("/explore/today"): { - presenceData.details = "Exploring daily content"; - break; - } - case pathname.includes("/dashboard"): { - presenceData.details = "Viewing their dashboard"; - break; - } - case pathname.includes("/new"): { - presenceData.details = "Making a new post..."; - presenceData.smallImageKey = Assets.Writing; - break; - } - case pathname.includes("/photos"): { - presenceData.details = "Viewing photos"; - break; - } - case pathname.includes("/gif"): { - presenceData.details = "Viewing GIFs"; - break; - } - case pathname.includes("/audio"): { - presenceData.details = "Viewing audio's"; - break; - } - case pathname.includes("/video"): { - presenceData.details = "Viewing videos"; - break; - } - case pathname.includes("/inbox"): { - presenceData.details = "Viewing their inbox"; - break; - } - case pathname.includes("/chats"): - case pathname.includes("/text"): { - presenceData.details = "Reading texts"; - presenceData.smallImageKey = Assets.Reading; - break; - } - case pathname.includes("/recommended-for-you"): { - presenceData.details = "Viewing recommendations"; - break; - } - case pathname.includes("/settings"): { - presenceData.details = "Viewing their settings"; - break; - } - case pathname.includes("/asks"): { - presenceData.details = "Reading questions"; - presenceData.smallImageKey = Assets.Reading; - break; - } - case pathname.includes("/quotes"): { - presenceData.details = "Reading quotes"; - presenceData.smallImageKey = Assets.Reading; - break; - } - } - break; - } - case "help.tumblr.com": { - const article = document.querySelector(".article-title"); - if (search?.value) { - presenceData.details = "Searching the help center for"; + break + } + case pathname === '/': { + presenceData.details = 'Viewing the home page' + break + } + case document.querySelector('[property="og:type"]') + ?.content === 'profile': { + presenceData.details = `Viewing user: ${ + document.querySelector('header h1')?.textContent + }` + presenceData.state = [ + ...document.querySelectorAll('header + div a'), + ].find(e => e.classList.length > 1)?.textContent + presenceData.buttons = [{ label: 'View Profile', url: href }] + break + } + case pathname.includes('/explore/answertime'): { + presenceData.details = 'Exploring answer time content' + break + } + case pathname.includes('/explore/staff-picks'): { + presenceData.details = 'Exploring staff picks' + break + } + case pathname.includes('/explore/trending'): { + presenceData.details = 'Exploring trending content' + break + } + case pathname.includes('/explore/today'): { + presenceData.details = 'Exploring daily content' + break + } + case pathname.includes('/dashboard'): { + presenceData.details = 'Viewing their dashboard' + break + } + case pathname.includes('/new'): { + presenceData.details = 'Making a new post...' + presenceData.smallImageKey = Assets.Writing + break + } + case pathname.includes('/photos'): { + presenceData.details = 'Viewing photos' + break + } + case pathname.includes('/gif'): { + presenceData.details = 'Viewing GIFs' + break + } + case pathname.includes('/audio'): { + presenceData.details = 'Viewing audio\'s' + break + } + case pathname.includes('/video'): { + presenceData.details = 'Viewing videos' + break + } + case pathname.includes('/inbox'): { + presenceData.details = 'Viewing their inbox' + break + } + case pathname.includes('/chats'): + case pathname.includes('/text'): { + presenceData.details = 'Reading texts' + presenceData.smallImageKey = Assets.Reading + break + } + case pathname.includes('/recommended-for-you'): { + presenceData.details = 'Viewing recommendations' + break + } + case pathname.includes('/settings'): { + presenceData.details = 'Viewing their settings' + break + } + case pathname.includes('/asks'): { + presenceData.details = 'Reading questions' + presenceData.smallImageKey = Assets.Reading + break + } + case pathname.includes('/quotes'): { + presenceData.details = 'Reading quotes' + presenceData.smallImageKey = Assets.Reading + break + } + } + break + } + case 'help.tumblr.com': { + const article = document.querySelector('.article-title') + if (search?.value) { + presenceData.details = 'Searching the help center for' - presenceData.state = search.value; - presenceData.smallImageKey = Assets.Search; - } else if ( - pathname.endsWith( - `/${document - .querySelector("html") - .getAttribute("lang") - ?.toLowerCase()}` - ) - ) { - presenceData.details = "Help center"; - presenceData.state = "Viewing the homepage"; - } else if (article) { - presenceData.details = "Help center - reading an article"; - presenceData.state = article.textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.buttons = [{ label: "Read Article", url: href }]; - } else presenceData.details = "Browsing through the help center"; + presenceData.state = search.value + presenceData.smallImageKey = Assets.Search + } + else if ( + pathname.endsWith( + `/${document + .querySelector('html') + ?.getAttribute('lang') + ?.toLowerCase()}`, + ) + ) { + presenceData.details = 'Help center' + presenceData.state = 'Viewing the homepage' + } + else if (article) { + presenceData.details = 'Help center - reading an article' + presenceData.state = article.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.buttons = [{ label: 'Read Article', url: href }] + } + else { + presenceData.details = 'Browsing through the help center' + } - break; - } - default: { - if ( - document.querySelector('[property="og:type"]') - ?.content !== "profile" - ) - return; - const username = document.querySelector("header h1")?.textContent; - presenceData.details = `Viewing user${username ? `: ${username}` : ""}`; - break; - } - } + break + } + default: { + if ( + document.querySelector('[property="og:type"]') + ?.content !== 'profile' + ) { + return + } + const username = document.querySelector('header h1')?.textContent + presenceData.details = `Viewing user${username ? `: ${username}` : ''}` + break + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TuneIn/metadata.json b/websites/T/TuneIn/metadata.json index 64c074f3d55b..502422db4cb5 100644 --- a/websites/T/TuneIn/metadata.json +++ b/websites/T/TuneIn/metadata.json @@ -1,60 +1,60 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kaduzzo", - "id": "198657088031817748" - }, - "contributors": [ - { - "name": "Alexx", - "id": "604182077088202784" - }, - { - "name": "Dark_Ville", - "id": "638080361179512853" - } - ], - "service": "TuneIn", - "description": { - "en": "TuneIn Inc. is an American audio streaming service delivering live news, radio, sports, music, and podcasts to over 60 million monthly active users. As of 2019, TuneIn has more than 75 million monthly active users. TuneIn is operated by company TuneIn Inc which is based in San Francisco, California.", - "nl": "TuneIn Inc. is een Amerikaanse audiostreamingservice die live nieuws, radio, sport, muziek en podcasts levert aan meer dan 60 miljoen maandelijkse actieve gebruikers. Vanaf 2019 heeft TuneIn meer dan 75 miljoen maandelijkse actieve gebruikers. TuneIn wordt beheerd door het bedrijf TuneIn Inc, gevestigd in San Francisco, Californië.", - "pt_BR": "TuneIn Inc. é um serviço de streaming de áudio que oferece notícias ao vivo, rádio, esportes, música e podcasts para mais de setecentos milhões de usuários ativos mensais. TuneIn conta com mais de setecentos e cinco milhões de usuários ativos mensais desde 2019. Sua sede fica localizada em São Francisco, Califórnia." - }, - "url": "tunein.com", - "version": "2.2.2", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TuneIn/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TuneIn/assets/thumbnail.png", - "color": "#33B6A8", - "category": "music", - "tags": [ - "tunein", - "music", - "radio", - "media" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-shield-alt", - "value": false - }, - { - "id": "timestamps", - "title": "Show timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "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": "Kaduzzo", + "id": "198657088031817748" + }, + "contributors": [ + { + "name": "Alexx", + "id": "604182077088202784" + }, + { + "name": "Dark_Ville", + "id": "638080361179512853" + } + ], + "service": "TuneIn", + "description": { + "en": "TuneIn Inc. is an American audio streaming service delivering live news, radio, sports, music, and podcasts to over 60 million monthly active users. As of 2019, TuneIn has more than 75 million monthly active users. TuneIn is operated by company TuneIn Inc which is based in San Francisco, California.", + "nl": "TuneIn Inc. is een Amerikaanse audiostreamingservice die live nieuws, radio, sport, muziek en podcasts levert aan meer dan 60 miljoen maandelijkse actieve gebruikers. Vanaf 2019 heeft TuneIn meer dan 75 miljoen maandelijkse actieve gebruikers. TuneIn wordt beheerd door het bedrijf TuneIn Inc, gevestigd in San Francisco, Californië.", + "pt_BR": "TuneIn Inc. é um serviço de streaming de áudio que oferece notícias ao vivo, rádio, esportes, música e podcasts para mais de setecentos milhões de usuários ativos mensais. TuneIn conta com mais de setecentos e cinco milhões de usuários ativos mensais desde 2019. Sua sede fica localizada em São Francisco, Califórnia." + }, + "url": "tunein.com", + "version": "2.2.2", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TuneIn/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TuneIn/assets/thumbnail.png", + "color": "#33B6A8", + "category": "music", + "tags": [ + "tunein", + "music", + "radio", + "media" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-shield-alt", + "value": false + }, + { + "id": "timestamps", + "title": "Show timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "cover", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true + } + ] +} diff --git a/websites/T/TuneIn/presence.ts b/websites/T/TuneIn/presence.ts index e93608ce5778..139f334bd1a5 100644 --- a/websites/T/TuneIn/presence.ts +++ b/websites/T/TuneIn/presence.ts @@ -1,72 +1,78 @@ const presence = new Presence({ - clientId: "844108776793178122", - }), - startTimestamp = Math.floor(Date.now() / 1000); + clientId: '844108776793178122', +}) +const startTimestamp = Math.floor(Date.now() / 1000) async function getStrings() { - return presence.getStrings({ - play: "general.playing", - pause: "general.paused", - browse: "general.browsing", - live: "general.live", - listening: "general.listeningMusic", - }); + return presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', + browse: 'general.browsing', + live: 'general.live', + listening: 'general.listeningMusic', + }) } -let strings: Awaited>, - oldLang: string = null; +let strings: Awaited> +let oldLang: string | null = null -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TuneIn/assets/logo.png", - type: ActivityType.Listening, - startTimestamp, - }, - [newLang, timestamps, cover, privacy] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("timestamps"), - presence.getSetting("cover"), - presence.getSetting("privacy"), - ]), - isLive = document.querySelector("[data-icon='stop']"), - isPlaying = document.querySelector("[data-testid='player-status-playing']"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TuneIn/assets/logo.png', + type: ActivityType.Listening, + startTimestamp, + } + const [newLang, timestamps, cover, privacy] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('timestamps'), + presence.getSetting('cover'), + presence.getSetting('privacy'), + ]) + const isLive = document.querySelector('[data-icon=\'stop\']') + const isPlaying = document.querySelector('[data-testid=\'player-status-playing\']') - if (oldLang !== newLang) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang) { + oldLang = newLang + strings = await getStrings() + } - if (isLive || isPlaying) { - if (privacy) presenceData.details = strings.listening; - else { - const title = document.querySelector("#playerTitle").textContent, - author = document.querySelector("#playerSubtitle").textContent, - artwork = document.querySelector( - "#directoryStationArtwork,#playerArtwork" - )?.src; + if (isLive || isPlaying) { + if (privacy) { + presenceData.details = strings.listening + } + else { + const title = document.querySelector('#playerTitle')?.textContent + const author = document.querySelector('#playerSubtitle')?.textContent + const artwork = document.querySelector( + '#directoryStationArtwork,#playerArtwork', + )?.src - if (title) presenceData.details = title; - if (author) presenceData.state = author; - if (artwork && cover) presenceData.largeImageKey = artwork; - } + if (title) + presenceData.details = title + if (author) + presenceData.state = author + if (artwork && cover) + presenceData.largeImageKey = artwork + } - presenceData.smallImageKey = isLive ? Assets.Live : Assets.Play; - presenceData.smallImageText = isLive ? strings.live : strings.play; + presenceData.smallImageKey = isLive ? Assets.Live : Assets.Play + presenceData.smallImageText = isLive ? strings.live : strings.play - if (!privacy && timestamps && !isLive && isPlaying) { - const elapsed = document.querySelector("#scrubberElapsed").textContent, - duration = document.querySelector("#scrubberDuration").textContent; + if (!privacy && timestamps && !isLive && isPlaying) { + const elapsed = document.querySelector('#scrubberElapsed')?.textContent + const duration = document.querySelector('#scrubberDuration')?.textContent - if (elapsed !== "00:00" || duration !== "") { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - presence.timestampFromFormat(elapsed), - presence.timestampFromFormat(duration) - ); - } - } - } else presenceData.details = strings.browse; + if (elapsed !== '00:00' || duration !== '') { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + presence.timestampFromFormat(elapsed ?? ''), + presence.timestampFromFormat(duration ?? ''), + ) + } + } + } + else { + presenceData.details = strings.browse + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/Tweakers/metadata.json b/websites/T/Tweakers/metadata.json index d333b76c96a7..ff2e3233713b 100644 --- a/websites/T/Tweakers/metadata.json +++ b/websites/T/Tweakers/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "bakzkndd", - "id": "343103632453009408" - }, - "service": "Tweakers", - "description": { - "nl": "Tweakers is de grootste elektronica- en technologiewebsite van Nederland en België.", - "en": "Tweakers is the biggest electronics and technology website in the Netherlands and Belgium." - }, - "url": "tweakers.net", - "regExp": "([a-z0-9-]+[.])*tweakers[.]net[/]", - "version": "1.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tweakers/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tweakers/assets/thumbnail.png", - "color": "#a11a3a", - "category": "other", - "tags": [ - "tweakers", - "technology", - "electronics", - "reviews", - "hardware", - "software", - "dutch" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "bakzkndd", + "id": "343103632453009408" + }, + "service": "Tweakers", + "description": { + "nl": "Tweakers is de grootste elektronica- en technologiewebsite van Nederland en België.", + "en": "Tweakers is the biggest electronics and technology website in the Netherlands and Belgium." + }, + "url": "tweakers.net", + "regExp": "([a-z0-9-]+[.])*tweakers[.]net[/]", + "version": "1.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Tweakers/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Tweakers/assets/thumbnail.png", + "color": "#a11a3a", + "category": "other", + "tags": [ + "tweakers", + "technology", + "electronics", + "reviews", + "hardware", + "software", + "dutch" + ] +} diff --git a/websites/T/Tweakers/presence.ts b/websites/T/Tweakers/presence.ts index 7154b7e87716..7b328046d10a 100644 --- a/websites/T/Tweakers/presence.ts +++ b/websites/T/Tweakers/presence.ts @@ -1,107 +1,152 @@ const presence = new Presence({ - clientId: "889467818020597790", -}); + clientId: '889467818020597790', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Tweakers/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Tweakers/assets/logo.png', + } - if (document.location.href.includes("nieuws/")) { - if (document.location.href.endsWith(".html")) { - presenceData.details = "Leest een artikel..."; - presenceData.state = `Artikel: '${document.location.pathname - .split("/")[3] - .replace(".html", "")}'`; - } else presenceData.details = "Scrollt nieuws artikelen..."; - } else if (document.location.href.includes("reviews/")) { - if (document.location.href.endsWith(".html")) { - presenceData.details = "Leest een review..."; - presenceData.state = `Review: '${document.location.pathname - .split("/")[3] - .replace(".html", "")}'`; - } else if ( - document.location.pathname.split("/")[2] && - document.location.pathname.split("/")[2] === "reviews" - ) { - presenceData.details = "Scrollt reviews..."; - presenceData.state = `Categorie: '${ - document.location.pathname.split("/")[1] - }'`; - } else presenceData.details = "Scrollt reviews..."; - } else if (document.location.href.includes("pricewatch/")) { - if (document.location.pathname.split("/")[3]) { - presenceData.details = "Bekijkt een product..."; - presenceData.state = `Product: '${document.location.pathname - .split("/")[3] - .replace(".html", "")}'`; - } else presenceData.details = "Scrollt pricewatch..."; - } else if (document.location.href.includes("aanbod/")) { - if (document.location.pathname.split("/")[3]) { - presenceData.details = "Bekijkt een aanbod..."; - presenceData.state = `Aanbod: '${document.location.pathname - .split("/")[3] - .replace(".html", "")}'`; - } else presenceData.details = "Scrollt Vraag en Aanbod..."; - } else if (document.location.href.includes("gathering.")) - presenceData.details = "Bekijkt het forum..."; - else if (document.location.href.includes("carriere/")) { - if (document.location.pathname.split("/")[4]) { - presenceData.details = "Bekijkt een baan..."; - presenceData.state = `Baan: '${document.location.pathname - .split("/")[4] - .replace(".html", "")}'`; - } else presenceData.details = "Zoekt een baan via tweakers..."; - } else if (document.location.href.includes("video/")) { - if (document.location.href.endsWith(".html")) { - presenceData.details = "Bekijkt een video..."; - presenceData.state = `Video: '${document.location.pathname - .split("/")[3] - .replace(".html", "")}'`; - } else presenceData.details = "Scrollt video's..."; - } else if (document.location.href.includes("podcast/")) - presenceData.details = "Luistert naar de podcast..."; - else if (document.location.href.includes("downloads/")) { - if (document.location.href.endsWith(".html")) { - presenceData.details = "Download een bestand..."; - presenceData.state = `Download: '${document.location.pathname - .split("/")[3] - .replace(".html", "")}'`; - } else presenceData.details = "Scrollt downloads..."; - } else if (document.location.href.includes("it-pro/")) - presenceData.details = "Scrollt IT Pro specials..."; - else if (document.location.href.includes("gallery")) { - if (document.location.pathname.split("/")[2]) - presenceData.details = "Bekijkt een profiel..."; - else presenceData.details = "Scrollt profielen..."; - } else if (document.location.href.includes("acties-en-evenementen/")) - presenceData.details = "Bekijkt acties en evenementen..."; - else if (document.location.href.includes("plan/")) { - if (document.location.href.endsWith(".html")) { - presenceData.details = "Bekijkt een plan..."; - presenceData.state = `Plan: '${document.location.pathname - .split("/")[3] - .replace(".html", "")}'`; - } else presenceData.details = "Scrollt plannen..."; - } else if (document.location.href.includes("abbonementen")) - presenceData.details = "Bekijkt abbonementen..."; - else if (document.location.href.includes("over-tweakers")) - presenceData.details = "Bekijkt informatie over tweakers..."; - else if (document.location.href.includes("karmastore")) - presenceData.details = "Bekijkt zijn/haar karma..."; - else if (document.location.href.includes("instellingen")) - presenceData.details = "Bekijkt instellingen..."; - else if ( - document.location.pathname && - document.location.pathname.length > 2 - ) { - presenceData.details = "Bladert..."; - presenceData.state = `Op pagina '${ - document.location.pathname.split("/")[1] - }'`; - } else presenceData.details = "Bezoekt de tweakers pagina..."; + if (document.location.href.includes('nieuws/')) { + if (document.location.href.endsWith('.html')) { + presenceData.details = 'Leest een artikel...' + presenceData.state = `Artikel: '${document.location.pathname + .split('/')[3] + .replace('.html', '')}'` + } + else { + presenceData.details = 'Scrollt nieuws artikelen...' + } + } + else if (document.location.href.includes('reviews/')) { + if (document.location.href.endsWith('.html')) { + presenceData.details = 'Leest een review...' + presenceData.state = `Review: '${document.location.pathname + .split('/')[3] + .replace('.html', '')}'` + } + else if ( + document.location.pathname.split('/')[2] + && document.location.pathname.split('/')[2] === 'reviews' + ) { + presenceData.details = 'Scrollt reviews...' + presenceData.state = `Categorie: '${ + document.location.pathname.split('/')[1] + }'` + } + else { + presenceData.details = 'Scrollt reviews...' + } + } + else if (document.location.href.includes('pricewatch/')) { + if (document.location.pathname.split('/')[3]) { + presenceData.details = 'Bekijkt een product...' + presenceData.state = `Product: '${document.location.pathname + .split('/')[3] + .replace('.html', '')}'` + } + else { + presenceData.details = 'Scrollt pricewatch...' + } + } + else if (document.location.href.includes('aanbod/')) { + if (document.location.pathname.split('/')[3]) { + presenceData.details = 'Bekijkt een aanbod...' + presenceData.state = `Aanbod: '${document.location.pathname + .split('/')[3] + .replace('.html', '')}'` + } + else { + presenceData.details = 'Scrollt Vraag en Aanbod...' + } + } + else if (document.location.href.includes('gathering.')) { + presenceData.details = 'Bekijkt het forum...' + } + else if (document.location.href.includes('carriere/')) { + if (document.location.pathname.split('/')[4]) { + presenceData.details = 'Bekijkt een baan...' + presenceData.state = `Baan: '${document.location.pathname + .split('/')[4] + .replace('.html', '')}'` + } + else { + presenceData.details = 'Zoekt een baan via tweakers...' + } + } + else if (document.location.href.includes('video/')) { + if (document.location.href.endsWith('.html')) { + presenceData.details = 'Bekijkt een video...' + presenceData.state = `Video: '${document.location.pathname + .split('/')[3] + .replace('.html', '')}'` + } + else { + presenceData.details = 'Scrollt video\'s...' + } + } + else if (document.location.href.includes('podcast/')) { + presenceData.details = 'Luistert naar de podcast...' + } + else if (document.location.href.includes('downloads/')) { + if (document.location.href.endsWith('.html')) { + presenceData.details = 'Download een bestand...' + presenceData.state = `Download: '${document.location.pathname + .split('/')[3] + .replace('.html', '')}'` + } + else { + presenceData.details = 'Scrollt downloads...' + } + } + else if (document.location.href.includes('it-pro/')) { + presenceData.details = 'Scrollt IT Pro specials...' + } + else if (document.location.href.includes('gallery')) { + if (document.location.pathname.split('/')[2]) + presenceData.details = 'Bekijkt een profiel...' + else presenceData.details = 'Scrollt profielen...' + } + else if (document.location.href.includes('acties-en-evenementen/')) { + presenceData.details = 'Bekijkt acties en evenementen...' + } + else if (document.location.href.includes('plan/')) { + if (document.location.href.endsWith('.html')) { + presenceData.details = 'Bekijkt een plan...' + presenceData.state = `Plan: '${document.location.pathname + .split('/')[3] + .replace('.html', '')}'` + } + else { + presenceData.details = 'Scrollt plannen...' + } + } + else if (document.location.href.includes('abbonementen')) { + presenceData.details = 'Bekijkt abbonementen...' + } + else if (document.location.href.includes('over-tweakers')) { + presenceData.details = 'Bekijkt informatie over tweakers...' + } + else if (document.location.href.includes('karmastore')) { + presenceData.details = 'Bekijkt zijn/haar karma...' + } + else if (document.location.href.includes('instellingen')) { + presenceData.details = 'Bekijkt instellingen...' + } + else if ( + document.location.pathname + && document.location.pathname.length > 2 + ) { + presenceData.details = 'Bladert...' + presenceData.state = `Op pagina '${ + document.location.pathname.split('/')[1] + }'` + } + else { + presenceData.details = 'Bezoekt de tweakers pagina...' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/TwitCasting/TwitCasting.json b/websites/T/TwitCasting/TwitCasting.json index 99b24dcf4f6f..233d341ab0e4 100644 --- a/websites/T/TwitCasting/TwitCasting.json +++ b/websites/T/TwitCasting/TwitCasting.json @@ -23,4 +23,4 @@ "description": "Second part of previous string", "message": "of channel:" } -} \ No newline at end of file +} diff --git a/websites/T/TwitCasting/metadata.json b/websites/T/TwitCasting/metadata.json index 0a13aa514ba2..0750ddd0ad07 100644 --- a/websites/T/TwitCasting/metadata.json +++ b/websites/T/TwitCasting/metadata.json @@ -1,98 +1,98 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kyrie", - "id": "368399721494216706" - }, - "service": "TwitCasting", - "description": { - "en": "TwitCasting is a live streaming community on App and PC. Join us and share what you love, what you are playing, your moment. Or watch what other people are doing in the instance. You can also stream the entire screen of your mobile phone so viewers can see what you are playing.", - "ja_JP": "モイ!ツイキャスはライブ配信を通して世界中の人とコミュニケーションする場を提供しています。 雑談、ラジオ配信、ゲーム配信、アニメ、ガールズ、ボーイズ、ミュージックなど色々なカテゴリのライブが配信中!スマホやPCから誰でも簡単に配信が始められます。" - }, - "url": "twitcasting.tv", - "regExp": "([a-z0-9]+[.])?twitcasting[.]tv", - "version": "1.0.17", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TwitCasting/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TwitCasting/assets/thumbnail.png", - "color": "#0280FC", - "category": "socials", - "tags": [ - "video", - "streaming", - "entertainment" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "streamDetail", - "if": { - "privacy": false - }, - "title": "Stream Details row1", - "icon": "fas fa-comment-alt-edit", - "value": "%title%", - "placeholder": "Use %title% or %streamer% or %game%" - }, - { - "id": "streamState", - "if": { - "privacy": false - }, - "title": "Stream Details row2", - "icon": "fas fa-comment-alt-edit", - "value": "%streamer%", - "placeholder": "Use %title% or %streamer% or %game%" - }, - { - "id": "vidDetail", - "if": { - "privacy": false - }, - "title": "Video Details row1", - "icon": "fas fa-comment-alt-edit", - "value": "%title%", - "placeholder": "Use %title% or %uploader% or %game%" - }, - { - "id": "vidState", - "if": { - "privacy": false - }, - "title": "Video Details row2", - "icon": "fas fa-comment-alt-edit", - "value": "%uploader%", - "placeholder": "Use %title% or %uploader% or %game%" - }, - { - "id": "timestamp", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "profilePic", - "title": "Show Streamer's Picture", - "icon": "fad fa-images", - "value": false - }, - { - "id": "buttons", - "if": { - "privacy": false - }, - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Kyrie", + "id": "368399721494216706" + }, + "service": "TwitCasting", + "description": { + "en": "TwitCasting is a live streaming community on App and PC. Join us and share what you love, what you are playing, your moment. Or watch what other people are doing in the instance. You can also stream the entire screen of your mobile phone so viewers can see what you are playing.", + "ja_JP": "モイ!ツイキャスはライブ配信を通して世界中の人とコミュニケーションする場を提供しています。 雑談、ラジオ配信、ゲーム配信、アニメ、ガールズ、ボーイズ、ミュージックなど色々なカテゴリのライブが配信中!スマホやPCから誰でも簡単に配信が始められます。" + }, + "url": "twitcasting.tv", + "regExp": "([a-z0-9]+[.])?twitcasting[.]tv", + "version": "1.0.17", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TwitCasting/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TwitCasting/assets/thumbnail.png", + "color": "#0280FC", + "category": "socials", + "tags": [ + "video", + "streaming", + "entertainment" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "streamDetail", + "if": { + "privacy": false + }, + "title": "Stream Details row1", + "icon": "fas fa-comment-alt-edit", + "value": "%title%", + "placeholder": "Use %title% or %streamer% or %game%" + }, + { + "id": "streamState", + "if": { + "privacy": false + }, + "title": "Stream Details row2", + "icon": "fas fa-comment-alt-edit", + "value": "%streamer%", + "placeholder": "Use %title% or %streamer% or %game%" + }, + { + "id": "vidDetail", + "if": { + "privacy": false + }, + "title": "Video Details row1", + "icon": "fas fa-comment-alt-edit", + "value": "%title%", + "placeholder": "Use %title% or %uploader% or %game%" + }, + { + "id": "vidState", + "if": { + "privacy": false + }, + "title": "Video Details row2", + "icon": "fas fa-comment-alt-edit", + "value": "%uploader%", + "placeholder": "Use %title% or %uploader% or %game%" + }, + { + "id": "timestamp", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "profilePic", + "title": "Show Streamer's Picture", + "icon": "fad fa-images", + "value": false + }, + { + "id": "buttons", + "if": { + "privacy": false + }, + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/T/TwitCasting/presence.ts b/websites/T/TwitCasting/presence.ts index 66c297a39ab6..2d45058e8089 100644 --- a/websites/T/TwitCasting/presence.ts +++ b/websites/T/TwitCasting/presence.ts @@ -1,205 +1,225 @@ -let elapsed = Math.floor(Date.now() / 1000), - oldLang = "en", - prevUrl = document.location.href; +let elapsed = Math.floor(Date.now() / 1000) +let oldLang = 'en' +let prevUrl = document.location.href const presence = new Presence({ - clientId: "951488835718635600", - }), - getStrings = async () => { - return presence.getStrings( - { - playing: "general.playing", - paused: "general.paused", - live: "general.live", - viewHome: "general.viewHome", - viewProfile: "general.viewProfile", - buttonViewProfile: "general.buttonViewProfile", - browsing: "general.browsing", - watchingLive: "general.watchingLive", - watchingVid: "general.watchingVid", - viewCategory: "general.viewCategory", - viewTheir: "twitcasting.viewTheir", - followList: "twitcasting.followList", - dashboardManage: "twitcasting.dashboardManage", - subs: "twitcasting.subs", - browsingVideos: "twitcasting.browsingVideos", - ofChannel: "twitcasting.ofChannel", - searchFor: "general.searchFor", - searchSomething: "general.searchSomething", - search: "general.search", - buttonWatchStream: "general.buttonWatchStream", - buttonWatchVideo: "general.buttonWatchVideo", - }, - oldLang - ); - }; + clientId: '951488835718635600', +}) +async function getStrings() { + return presence.getStrings( + { + playing: 'general.playing', + paused: 'general.paused', + live: 'general.live', + viewHome: 'general.viewHome', + viewProfile: 'general.viewProfile', + buttonViewProfile: 'general.buttonViewProfile', + browsing: 'general.browsing', + watchingLive: 'general.watchingLive', + watchingVid: 'general.watchingVid', + viewCategory: 'general.viewCategory', + viewTheir: 'twitcasting.viewTheir', + followList: 'twitcasting.followList', + dashboardManage: 'twitcasting.dashboardManage', + subs: 'twitcasting.subs', + browsingVideos: 'twitcasting.browsingVideos', + ofChannel: 'twitcasting.ofChannel', + searchFor: 'general.searchFor', + searchSomething: 'general.searchSomething', + search: 'general.search', + buttonWatchStream: 'general.buttonWatchStream', + buttonWatchVideo: 'general.buttonWatchVideo', + }, + oldLang, + ) +} -let strings: Awaited>; +let strings: Awaited> -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TwitCasting/assets/logo.png", - startTimestamp: elapsed, - }, - [ - showTimestamps, - newLang, - privacy, - vidDetail, - vidState, - streamDetail, - streamState, - profilePic, - buttons, - ] = await Promise.all([ - presence.getSetting("timestamp"), - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("privacy"), - presence.getSetting("vidDetail"), - presence.getSetting("vidState"), - presence.getSetting("streamDetail"), - presence.getSetting("streamState"), - presence.getSetting("profilePic"), - presence.getSetting("buttons"), - ]), - { pathname, search, href } = document.location, - title = document - .querySelector( - ":is(#movie_title_content, .tw-player-page-title-title)" - ) - ?.innerText.split("\n")[0], - channelName = - document.querySelector(".tw-user-nav-name")?.textContent, - game = - document.querySelector(".category-label")?.textContent; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TwitCasting/assets/logo.png', + startTimestamp: elapsed, + } as PresenceData + const [ + showTimestamps, + newLang, + privacy, + vidDetail, + vidState, + streamDetail, + streamState, + profilePic, + buttons, + ] = await Promise.all([ + presence.getSetting('timestamp'), + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('privacy'), + presence.getSetting('vidDetail'), + presence.getSetting('vidState'), + presence.getSetting('streamDetail'), + presence.getSetting('streamState'), + presence.getSetting('profilePic'), + presence.getSetting('buttons'), + ]) + const { pathname, search, href } = document.location + const title = document + .querySelector( + ':is(#movie_title_content, .tw-player-page-title-title)', + ) + ?.textContent + ?.split('\n')[0] + const channelName = document.querySelector('.tw-user-nav-name')?.textContent + const game = document.querySelector('.category-label')?.textContent - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - if (href !== prevUrl) { - prevUrl = href; - elapsed = Math.floor(Date.now() / 1000); - } + if (href !== prevUrl) { + prevUrl = href + elapsed = Math.floor(Date.now() / 1000) + } - if (new URLSearchParams(search).has("genre")) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browsing; - presenceData.details = strings.viewCategory; - if (!privacy) { - presenceData.state = document.querySelector( - "[aria-selected='true']" - ).textContent; - } - } else if (pathname === "/") presenceData.details = strings.viewHome; - else if (pathname.includes("/search")) { - if (privacy) presenceData.details = strings.searchSomething; - else { - presenceData.details = strings.searchFor; - presenceData.state = document - .querySelector("h2") - .textContent.split(":")[1] - .trim(); - } - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = strings.search; - } else if (pathname.includes("/broadcaster")) - presenceData.details = strings.dashboardManage; - else if (document.querySelector(".tw-user-nav-user")) { - if (profilePic) { - presenceData.largeImageKey = document - .querySelector(".tw-user-nav-icon > img") - .src.replace("_bigger", ""); - } - if ( - pathname.split("/").length === 2 && - !document.querySelector("[data-status='offline']") - ) { - if (privacy) presenceData.details = strings.watchingLive; - else { - presenceData.details = streamDetail - .replace("%title%", title) - .replace("%streamer%", channelName) - .replace("%game%", game); - presenceData.state = streamState - .replace("%title%", title) - .replace("%streamer%", channelName) - .replace("%game%", game); - presenceData.buttons = [ - { label: strings.buttonWatchStream, url: document.URL }, - ]; - } - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = strings.live; - } else if (pathname.includes("/movie")) { - if (privacy) presenceData.details = strings.watchingVid; - else { - presenceData.details = vidDetail - .replace("%title%", title) - .replace("%uploader%", channelName) - .replace("%game%", game); - presenceData.state = vidState - .replace("%title%", title) - .replace("%uploader%", channelName) - .replace("%game%", game); - const { duration, currentTime, paused } = - document.querySelector("video"); + if (new URLSearchParams(search).has('genre')) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browsing + presenceData.details = strings.viewCategory + if (!privacy) { + presenceData.state = document.querySelector( + '[aria-selected=\'true\']', + )?.textContent + } + } + else if (pathname === '/') { + presenceData.details = strings.viewHome + } + else if (pathname.includes('/search')) { + if (privacy) { + presenceData.details = strings.searchSomething + } + else { + presenceData.details = strings.searchFor + presenceData.state = document + .querySelector('h2') + ?.textContent + ?.split(':')[1] + .trim() + } + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = strings.search + } + else if (pathname.includes('/broadcaster')) { + presenceData.details = strings.dashboardManage + } + else if (document.querySelector('.tw-user-nav-user')) { + if (profilePic) { + presenceData.largeImageKey = document + .querySelector('.tw-user-nav-icon > img') + ?.src + .replace('_bigger', '') + } + if ( + pathname.split('/').length === 2 + && !document.querySelector('[data-status=\'offline\']') + ) { + if (privacy) { + presenceData.details = strings.watchingLive + } + else { + presenceData.details = streamDetail + .replace('%title%', title ?? '') + .replace('%streamer%', channelName ?? '') + .replace('%game%', game ?? '') + presenceData.state = streamState + .replace('%title%', title ?? '') + .replace('%streamer%', channelName ?? '') + .replace('%game%', game ?? '') + presenceData.buttons = [ + { label: strings.buttonWatchStream, url: document.URL }, + ] + } + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = strings.live + } + else if (pathname.includes('/movie')) { + if (privacy) { + presenceData.details = strings.watchingVid + } + else { + presenceData.details = vidDetail + .replace('%title%', title ?? '') + .replace('%uploader%', channelName ?? '') + .replace('%game%', game ?? '') + presenceData.state = vidState + .replace('%title%', title ?? '') + .replace('%uploader%', channelName ?? '') + .replace('%game%', game ?? '') + const { duration, currentTime, paused } = document.querySelector('video')! - delete presenceData.startTimestamp; + delete presenceData.startTimestamp - if (!paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(currentTime, duration); - } + if (!paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(currentTime, duration) + } - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = paused ? strings.paused : strings.playing; - presenceData.buttons = [ - { label: strings.buttonWatchVideo, url: document.URL }, - ]; - } - } else if (pathname.includes("/show") && !privacy) { - presenceData.details = strings.browsingVideos; - presenceData.state = `${strings.ofChannel} ${channelName}`; - presenceData.buttons = [ - { label: strings.buttonViewProfile, url: document.URL }, - ]; - } else if (!privacy) { - presenceData.details = strings.viewProfile; - presenceData.state = channelName; - presenceData.buttons = [ - { label: strings.buttonViewProfile, url: document.URL }, - ]; - } - } else if (pathname.includes("/notifyindex" || "/membership")) - presenceData.details = strings.subs; - else if (pathname.includes("/mybacks")) { - presenceData.details = strings.viewTheir; - presenceData.state = strings.followList; - } else if (document.querySelector("video[src]")) { - presenceData.details = strings.watchingLive; - presenceData.state = `${document - .querySelector(".tw-player-page-title-title h2") - .textContent.trim()} - ${ - document.querySelector("span.tw-live-author__info-username-inner") - .textContent - }`; - presenceData.type = ActivityType.Watching; - } else if (document.querySelector(".tw-user-nav2")) { - presenceData.details = strings.viewProfile; - presenceData.state = `${document - .querySelector(".tw-user-nav2-name") - .textContent.trim()} (${document - .querySelector(".tw-user-nav2-screen-id") - .textContent.trim()})`; - } - if (!showTimestamps) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - if (!buttons) delete presenceData.buttons; + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = paused ? strings.paused : strings.playing + presenceData.buttons = [ + { label: strings.buttonWatchVideo, url: document.URL }, + ] + } + } + else if (pathname.includes('/show') && !privacy) { + presenceData.details = strings.browsingVideos + presenceData.state = `${strings.ofChannel} ${channelName}` + presenceData.buttons = [ + { label: strings.buttonViewProfile, url: document.URL }, + ] + } + else if (!privacy) { + presenceData.details = strings.viewProfile + presenceData.state = channelName + presenceData.buttons = [ + { label: strings.buttonViewProfile, url: document.URL }, + ] + } + } + else if (pathname.includes('/notifyindex') || pathname.includes('/membership')) { + presenceData.details = strings.subs + } + else if (pathname.includes('/mybacks')) { + presenceData.details = strings.viewTheir + presenceData.state = strings.followList + } + else if (document.querySelector('video[src]')) { + presenceData.details = strings.watchingLive + presenceData.state = `${document + .querySelector('.tw-player-page-title-title h2') + ?.textContent + ?.trim()} - ${ + document.querySelector('span.tw-live-author__info-username-inner') + ?.textContent + }` + presenceData.type = ActivityType.Watching + } + else if (document.querySelector('.tw-user-nav2')) { + presenceData.details = strings.viewProfile + presenceData.state = `${document + .querySelector('.tw-user-nav2-name') + ?.textContent + ?.trim()} (${document + .querySelector('.tw-user-nav2-screen-id') + ?.textContent + ?.trim()})` + } + if (!showTimestamps) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + if (!buttons) + delete presenceData.buttons - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/TwitLonger/metadata.json b/websites/T/TwitLonger/metadata.json index 3d2f344a3a34..7f97e463bccf 100644 --- a/websites/T/TwitLonger/metadata.json +++ b/websites/T/TwitLonger/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "fror", - "id": "515668127829458945" - }, - "service": "TwitLonger", - "description": { - "en": "When you talk too much for Twitter.", - "nl": "Als je teveel praat voor Twitter." - }, - "url": "www.twitlonger.com", - "version": "1.0.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TwitLonger/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TwitLonger/assets/thumbnail.png", - "color": "#428BCA", - "category": "other", - "tags": [ - "twitter", - "micro-blogging" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "fror", + "id": "515668127829458945" + }, + "service": "TwitLonger", + "description": { + "en": "When you talk too much for Twitter.", + "nl": "Als je teveel praat voor Twitter." + }, + "url": "www.twitlonger.com", + "version": "1.0.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/TwitLonger/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/TwitLonger/assets/thumbnail.png", + "color": "#428BCA", + "category": "other", + "tags": [ + "twitter", + "micro-blogging" + ] +} diff --git a/websites/T/TwitLonger/presence.ts b/websites/T/TwitLonger/presence.ts index a6d3100f5326..b75bce346eee 100644 --- a/websites/T/TwitLonger/presence.ts +++ b/websites/T/TwitLonger/presence.ts @@ -1,46 +1,51 @@ const presence = new Presence({ - clientId: "719119956486258749", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '719119956486258749', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/TwitLonger/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/TwitLonger/assets/logo.png', + } - if (document.location.pathname === "/") { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Home"; - } else if (document.location.pathname.includes("/show/")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Reading an post"; - presenceData.state = `${ - document.querySelector("#postcontent > h3").textContent - } by ${ - document.querySelector( - "#user-info > div > h4 > a:nth-child(1)" - ).textContent - } (${ - document.querySelector( - "#user-info > div > h4 > a:nth-child(2)" - ).textContent - })`; - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/about")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "About"; - } else if (document.location.pathname.includes("/privacy")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Privacy"; - } else if (document.location.pathname.includes("/ad-free")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Ad-free"; - } else if (document.location.pathname.includes("/post")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Writing an Post"; - } + if (document.location.pathname === '/') { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Home' + } + else if (document.location.pathname.includes('/show/')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Reading an post' + presenceData.state = `${ + document.querySelector('#postcontent > h3')?.textContent + } by ${ + document.querySelector( + '#user-info > div > h4 > a:nth-child(1)', + )?.textContent + } (${ + document.querySelector( + '#user-info > div > h4 > a:nth-child(2)', + )?.textContent + })` + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/about')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'About' + } + else if (document.location.pathname.includes('/privacy')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Privacy' + } + else if (document.location.pathname.includes('/ad-free')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Ad-free' + } + else if (document.location.pathname.includes('/post')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Writing an Post' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Twitch/metadata.json b/websites/T/Twitch/metadata.json index 8787be141899..f27d5956a295 100644 --- a/websites/T/Twitch/metadata.json +++ b/websites/T/Twitch/metadata.json @@ -1,174 +1,174 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "contributors": [ - { - "name": "RisingSunLight", - "id": "240521747852558347" - }, - { - "name": "Hikki", - "id": "533014724569333770" - } - ], - "service": "Twitch", - "altnames": [ - "تويتش", - "توییچ", - "ٹویچ ڈاٹ ٹی وی", - "트위치" - ], - "description": { - "en": "Twitch is the world's leading live streaming platform for gamers and the things we love. Watch and chat now with millions of other fans from around the world.", - "tr": "Twitch, oyuncular ve sevdiğimiz şeyler için dünyanın önde gelen canlı yayın platformudur.", - "ro": "Twitch este cea mai mare platformă de live streaming pentru gameri și chestii pe care le iubim. Vizionează și vorbește cu milioane de alți fani din alte țări.", - "pt_BR": "Twitch é a plataforma líder mundial em streaming para gamers e coisas que amamos. Assista e converse agora com milhões de outros fãs ao redor do mundo.", - "fr": "Twitch est la plateforme leader mondial en streaming pour gamers e choses que nous aimons. Regardez et discutez maintenant avec des millions d'autres fans du monde entier.", - "uk_UA": "Twitch - це провідна в світі платформа прямого ефіру для геймерів та речей, які ми любимо. Дивіться та спілкуйтеся зараз із мільйонами інших шанувальників з усього світу.", - "nl": "Twitch is 's werelds grootste livestreaming-platform voor gamers en de dingen waar we van houden. Kijk en chat nu met miljoenen andere fans van over de hele wereld.", - "zh_CN": "Twitch是面向游戏玩家和各种事物的全球领先的直播平台。快来与来自世界各地的数百万粉丝一起观看和聊天。", - "zh_TW": "Twitch是面向遊戲玩家和各種事物的全球領先的實時串流平台。快來與來自世界各地的數百萬粉絲一起觀看和聊天。", - "vi_VN": "Twitch là nền tảng phát trực tuyến dẫn đầu thế giới dành cho các gamer và các thứ ta yêu thích. Hãy theo dõi ngay và trò truyện với hàng triệu người hâm mộ từ khắp thế giới." - }, - "url": [ - "www.twitch.tv", - "dashboard.twitch.tv", - "brand.twitch.tv", - "blog.twitch.tv", - "help.twitch.tv", - "affiliate.twitch.tv", - "dev.twitch.tv", - "discuss.dev.twitch.tv", - "devstatus.twitch.tv", - "status.twitch.tv" - ], - "version": "3.2.26", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/thumbnail.png", - "color": "#9146FF", - "category": "videos", - "tags": [ - "video", - "streaming", - "entertainment" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "browse", - "title": "Show Browsing Status", - "icon": "fad fa-book-reader", - "value": true - }, - { - "id": "live", - "title": "Show Livestreams", - "icon": "fad fa-podcast", - "value": true - }, - { - "id": "streamDetail", - "if": { - "privacy": false - }, - "title": "Stream Details row1", - "icon": "fas fa-comment-alt-edit", - "value": "%title%", - "placeholder": "Use %title% or %streamer% or %game%" - }, - { - "id": "streamState", - "if": { - "privacy": false - }, - "title": "Stream Details row2", - "icon": "fas fa-comment-alt-edit", - "value": "%streamer%", - "placeholder": "Use %title% or %streamer% or %game%" - }, - { - "id": "video", - "title": "Show Videos and Clips", - "icon": "fas fa-video", - "value": true - }, - { - "id": "vidDetail", - "if": { - "privacy": false - }, - "title": "Video Details row1", - "icon": "fas fa-comment-alt-edit", - "value": "%title%", - "placeholder": "Use %title% or %uploader% or %game%" - }, - { - "id": "vidState", - "if": { - "privacy": false - }, - "title": "Video Details row2", - "icon": "fas fa-comment-alt-edit", - "value": "%uploader%", - "placeholder": "Use %title% or %uploader% or %game%" - }, - { - "id": "timestamp", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "profilePic", - "title": "Show Streamer's Picture", - "icon": "fad fa-images", - "value": false - }, - { - "id": "logo", - "title": "Twitch Icon", - "icon": "fab fa-twitch", - "value": 0, - "values": [ - "Normal", - "Black Ops", - "White", - "Purple", - "Pride" - ] - }, - { - "id": "devLogo", - "title": "Twitch Developers Icon", - "icon": "fab fa-twitch", - "value": 0, - "values": [ - "Normal", - "White", - "Purple" - ] - }, - { - "id": "buttons", - "if": { - "privacy": false - }, - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "contributors": [ + { + "name": "RisingSunLight", + "id": "240521747852558347" + }, + { + "name": "Hikki", + "id": "533014724569333770" + } + ], + "service": "Twitch", + "altnames": [ + "تويتش", + "توییچ", + "ٹویچ ڈاٹ ٹی وی", + "트위치" + ], + "description": { + "en": "Twitch is the world's leading live streaming platform for gamers and the things we love. Watch and chat now with millions of other fans from around the world.", + "tr": "Twitch, oyuncular ve sevdiğimiz şeyler için dünyanın önde gelen canlı yayın platformudur.", + "ro": "Twitch este cea mai mare platformă de live streaming pentru gameri și chestii pe care le iubim. Vizionează și vorbește cu milioane de alți fani din alte țări.", + "pt_BR": "Twitch é a plataforma líder mundial em streaming para gamers e coisas que amamos. Assista e converse agora com milhões de outros fãs ao redor do mundo.", + "fr": "Twitch est la plateforme leader mondial en streaming pour gamers e choses que nous aimons. Regardez et discutez maintenant avec des millions d'autres fans du monde entier.", + "uk_UA": "Twitch - це провідна в світі платформа прямого ефіру для геймерів та речей, які ми любимо. Дивіться та спілкуйтеся зараз із мільйонами інших шанувальників з усього світу.", + "nl": "Twitch is 's werelds grootste livestreaming-platform voor gamers en de dingen waar we van houden. Kijk en chat nu met miljoenen andere fans van over de hele wereld.", + "zh_CN": "Twitch是面向游戏玩家和各种事物的全球领先的直播平台。快来与来自世界各地的数百万粉丝一起观看和聊天。", + "zh_TW": "Twitch是面向遊戲玩家和各種事物的全球領先的實時串流平台。快來與來自世界各地的數百萬粉絲一起觀看和聊天。", + "vi_VN": "Twitch là nền tảng phát trực tuyến dẫn đầu thế giới dành cho các gamer và các thứ ta yêu thích. Hãy theo dõi ngay và trò truyện với hàng triệu người hâm mộ từ khắp thế giới." + }, + "url": [ + "www.twitch.tv", + "dashboard.twitch.tv", + "brand.twitch.tv", + "blog.twitch.tv", + "help.twitch.tv", + "affiliate.twitch.tv", + "dev.twitch.tv", + "discuss.dev.twitch.tv", + "devstatus.twitch.tv", + "status.twitch.tv" + ], + "version": "3.2.26", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/thumbnail.png", + "color": "#9146FF", + "category": "videos", + "tags": [ + "video", + "streaming", + "entertainment" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "browse", + "title": "Show Browsing Status", + "icon": "fad fa-book-reader", + "value": true + }, + { + "id": "live", + "title": "Show Livestreams", + "icon": "fad fa-podcast", + "value": true + }, + { + "id": "streamDetail", + "if": { + "privacy": false + }, + "title": "Stream Details row1", + "icon": "fas fa-comment-alt-edit", + "value": "%title%", + "placeholder": "Use %title% or %streamer% or %game%" + }, + { + "id": "streamState", + "if": { + "privacy": false + }, + "title": "Stream Details row2", + "icon": "fas fa-comment-alt-edit", + "value": "%streamer%", + "placeholder": "Use %title% or %streamer% or %game%" + }, + { + "id": "video", + "title": "Show Videos and Clips", + "icon": "fas fa-video", + "value": true + }, + { + "id": "vidDetail", + "if": { + "privacy": false + }, + "title": "Video Details row1", + "icon": "fas fa-comment-alt-edit", + "value": "%title%", + "placeholder": "Use %title% or %uploader% or %game%" + }, + { + "id": "vidState", + "if": { + "privacy": false + }, + "title": "Video Details row2", + "icon": "fas fa-comment-alt-edit", + "value": "%uploader%", + "placeholder": "Use %title% or %uploader% or %game%" + }, + { + "id": "timestamp", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "profilePic", + "title": "Show Streamer's Picture", + "icon": "fad fa-images", + "value": false + }, + { + "id": "logo", + "title": "Twitch Icon", + "icon": "fab fa-twitch", + "value": 0, + "values": [ + "Normal", + "Black Ops", + "White", + "Purple", + "Pride" + ] + }, + { + "id": "devLogo", + "title": "Twitch Developers Icon", + "icon": "fab fa-twitch", + "value": 0, + "values": [ + "Normal", + "White", + "Purple" + ] + }, + { + "id": "buttons", + "if": { + "privacy": false + }, + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/T/Twitch/presence.ts b/websites/T/Twitch/presence.ts index 46dc5c4719d5..5728f250be1e 100644 --- a/websites/T/Twitch/presence.ts +++ b/websites/T/Twitch/presence.ts @@ -1,938 +1,948 @@ -let elapsed = Math.floor(Date.now() / 1000), - prevUrl = document.location.href, - oldLang = "en"; +let elapsed = Math.floor(Date.now() / 1000) +let prevUrl = document.location.href +let oldLang = 'en' const enum Assets { - BlackOps = "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/0.png", - DevMain = "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/1.png", - Purple = "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/2.png", - White = "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/3.png", - Pride = "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/4.png", - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/5.png", - DevWhite = "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/6.png", - DevPurple = "https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/7.png", + BlackOps = 'https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/0.png', + DevMain = 'https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/1.png', + Purple = 'https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/2.png', + White = 'https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/3.png', + Pride = 'https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/4.png', + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/5.png', + DevWhite = 'https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/6.png', + DevPurple = 'https://cdn.rcd.gg/PreMiD/websites/T/Twitch/assets/7.png', } const presence = new Presence({ - clientId: "802958789555781663", - }), - getElement = (query: string): string | undefined => { - return document.querySelector(query)?.textContent; - }, - getStrings = async () => { - return presence.getStrings( - { - play: "general.playing", - pause: "general.paused", - live: "general.live", - browse: "general.browsing", - viewPage: "general.viewPage", - home: "twitch.home", - download: "twitch.downloads", - jobs: "twitch.jobs", - turbo: "twitch.turbo", - partners: "twitch.partners", - press: "twitch.press", - security: "twitch.security", - access: "twitch.access", - ads: "twitch.ads", - guidelines: "twitch.guidelines", - terms: "general.terms", - privacy: "general.privacy", - cookie: "general.cookie", - watchingLive: "general.watchingLive", - watchingVid: "general.watchingVid", - viewProfile: "general.viewProfile", - viewCategory: "general.viewCategory", - viewWallet: "twitch.wallet", - viewEsports: "twitch.esports", - viewFollow: "twitch.viewFollow", - viewTeam: "twitch.viewTeam", - viewDropsInv: "twitch.viewDropsInv", - viewDropsComp: "twitch.viewDropsComp", - viewing: "general.viewing", - searchingFor: "general.searchFor", - searchingSomething: "general.searchSomething", - viewSettings: "twitch.viewSettings", - viewFriends: "twitch.viewFriends", - subs: "twitch.subs", - squad: "twitch.squad", - modStreamer: "twitch.modStreamer", - readingAbout: "general.readingAbout", - redeem: "twitch.redeem", - camp: "twitch.camp", - campBasic: "twitch.campBasic", - campSetup: "twitch.campSetup", - campLevel: "twitch.campLevel", - campConnect: "twitch.campConnect", - campReward: "twitch.campReward", - campMusic: "twitch.campMusic", - campLive: "twitch.campLive", - dashboard: "twitch.dashboard", - dashboardManage: "twitch.dashboardManage", - manageRoles: "twitch.manageRoles", - produce: "twitch.produce", - viewTheir: "twitch.viewTheir", - channelAnaly: "twitch.channelAnaly", - streamSum: "twitch.streamSum", - achievements: "twitch.achievements", - activity: "twitch.activity", - followList: "twitch.followList", - colls: "twitch.colls", - clips: "twitch.clips", - channelSettings: "twitch.channelSettings", - moderationSettings: "twitch.moderationSettings", - dropsSettings: "twitch.dropsSettings", - tools: "twitch.tools", - extensions: "twitch.extensions", - brand: "twitch.brand", - brandReal: "twitch.brandReal", - brandMadness: "twitch.brandMadness", - brandExpression: "twitch.brandExpression", - brandTogether: "twitch.brandTogether", - brandWatch: "twitch.brandWatch", - blogArchive: "twitch.blogArchive", - readingArticle: "general.readingArticle", - blogBrowse: "twitch.blogBrowse", - blogs: "twitch.blogs", - help: "twitch.help", - helpTopic: "twitch.helpTopic", - helpTopicCatalog: "twitch.helpTopicCatalog", - affiliate: "twitch.affiliate", - dev: "twitch.dev", - devProduct: "twitch.devProduct", - devShowcase: "twitch.devShowcase", - devSupport: "twitch.devSupport", - devDocs: "twitch.devDocs", - incident: "general.incidentHistory", - uptime: "general.uptimeHistory", - forums: "general.forums", - thread: "general.readingThread", - user: "general.viewUser", - watchStream: "general.buttonWatchStream", - watchVideo: "general.buttonWatchVideo", - }, - oldLang - ); - }, - devLogoArr = [Assets.DevMain, Assets.DevWhite, Assets.DevPurple], - logoArr = [ - Assets.Logo, - Assets.BlackOps, - Assets.White, - Assets.Purple, - Assets.Pride, - ]; - -let strings: Awaited>; - -presence.on("UpdateData", async () => { - const path = location.pathname.replace(/\/?$/, "/"), - [ - showBrowsing, - showLive, - showVideo, - showTimestamps, - newLang, - privacy, - vidDetail, - vidState, - streamDetail, - streamState, - pfp, - logo, - devLogo, - buttons, - ] = await Promise.all([ - presence.getSetting("browse"), - presence.getSetting("live"), - presence.getSetting("video"), - presence.getSetting("timestamp"), - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("privacy"), - presence.getSetting("vidDetail"), - presence.getSetting("vidState"), - presence.getSetting("streamDetail"), - presence.getSetting("streamState"), - presence.getSetting("profilePic"), - presence.getSetting("logo"), - presence.getSetting("devLogo"), - presence.getSetting("buttons"), - ]); - - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } - - let presenceData: PresenceData = { - type: ActivityType.Watching, - largeImageKey: logoArr[logo] || Assets.Logo, - startTimestamp: elapsed, - }; - - if (document.location.href !== prevUrl) { - prevUrl = document.location.href; - elapsed = Math.floor(Date.now() / 1000); - } - - switch (document.location.hostname) { - case "www.twitch.tv": { - //* Main website - const statics = { - "/downloads/": { - details: strings.viewPage, - state: strings.download, - }, - "/jobs/": { - details: strings.viewPage, - state: strings.jobs, - }, - "/turbo/": { - details: strings.viewPage, - state: strings.turbo, - }, - "/broadcast/studio/": { - details: strings.readingAbout, - state: "Twitch Studio", - }, - "/redeem/": { - details: strings.redeem, - }, - "/p/partners/": { - details: strings.viewPage, - state: strings.partners, - }, - "/p/press-center/": { - details: strings.viewPage, - state: strings.press, - }, - "/p/security/": { - details: strings.viewPage, - state: strings.security, - }, - "/p/legal/accessibility/": { - details: strings.viewPage, - state: strings.access, - }, - "/p/legal/ad-choices/": { - details: strings.viewPage, - state: strings.ads, - }, - "/p/legal/community-guidelines/": { - details: strings.viewPage, - state: strings.guidelines, - }, - "/p/legal/cookie-policy/": { - details: strings.viewPage, - state: strings.cookie, - }, - "/p/legal/privacy-notice/": { - details: strings.viewPage, - state: strings.privacy, - }, - "/p/legal/terms-of-serice/": { - details: strings.viewPage, - state: strings.terms, - }, - "/p/(\\w*|\\w*-\\w*)/about/": { - details: strings.readingAbout, - state: "Twitch", - }, - "/p/(\\w*|\\w*-\\w*)/stream/": { - details: strings.readingAbout, - state: "How to stream", - }, - "/p/(\\w*|\\w*-\\w*)/watch/": { - details: strings.readingAbout, - state: "How to watch", - }, - "/p/(\\w*|\\w*-\\w*)/company/": { - details: strings.readingAbout, - state: "The Company", - }, - "/p/(\\w*|\\w*-\\w*)/giftcard/": { - details: strings.readingAbout, - state: "Giftcards", - }, - "/p/(\\w*|\\w*-\\w*)/artists/": { - details: strings.readingAbout, - state: "Artists", - }, - "/creatorcamp/(\\w*|\\w*-\\w*)/learn-the-basics/": { - details: `${strings.camp} | ${strings.viewPage}`, - state: strings.campBasic, - }, - "/creatorcamp/(\\w*|\\w*-\\w*)/setting-up-your-stream/": { - details: `${strings.camp} | ${strings.viewPage}`, - state: strings.campSetup, - }, - "/creatorcamp/(\\w*|\\w*-\\w*)/level-up/": { - details: `${strings.camp} | ${strings.viewPage}`, - state: strings.campLevel, - }, - "/creatorcamp/(\\w*|\\w*-\\w*)/connect-and-engage/": { - details: `${strings.camp} | ${strings.viewPage}`, - state: strings.campConnect, - }, - "/creatorcamp/(\\w*|\\w*-\\w*)/get-rewarded/": { - details: `${strings.camp} | ${strings.viewPage}`, - state: strings.campReward, - }, - "/creatorcamp/(\\w*|\\w*-\\w*)/twitch-music-getting-started/": { - details: `${strings.camp} | ${strings.viewPage}`, - state: strings.campMusic, - }, - "/creatorcamp/(\\w*|\\w*-\\w*)/live/": { - details: `${strings.camp} | ${strings.viewPage}`, - state: strings.campLive, - }, - "/creatorcamp/(\\w*|\\w*-\\w*)/": { - details: `${strings.camp} | ${strings.viewPage}`, - state: strings.home, - }, - }; - - if (showBrowsing) { - for (const [k, v] of Object.entries(statics)) { - if (path.match(k)) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - presenceData = { ...presenceData, ...v }; - } - } - - if (path === "/") { - presenceData.details = strings.browse; - presenceData.state = strings.home; - } - - let user = getElement(".home-header-sticky .tw-title"); - if (user) { - const tab = getElement('a[aria-selected="true"] > div > div > p'), - profilePic = - ( - document.querySelector( - ".tw-halo > .tw-aspect > .tw-avatar > .tw-image-avatar" - ) ?? - document - .querySelector(".channel-root__info") - .querySelector('img[class*="image-avatar"]') - )?.src?.replace(/-[0-9]{1,2}x[0-9]{1,2}/, "-600x600") ?? - (logoArr[logo] || Assets.Logo); - user += tab ? ` (${tab})` : ""; - - presenceData.details = strings.viewProfile; - presenceData.state = user; - if (pfp) presenceData.largeImageKey = profilePic; - } - - if (path.includes("/team/")) { - presenceData.details = strings.viewTeam; - presenceData.state = document.location.pathname - .split("/") - .pop() - .split("_") - .map(word => word.charAt(0).toUpperCase() + word.slice(1)) - .join(" "); - } - - if (path.includes("/settings/")) { - presenceData.details = strings.viewSettings; - presenceData.state = getElement('a[aria-selected="true"]'); - } - - let searching = false; - if (path.includes("/search/")) { - searching = true; - - presenceData.details = strings.searchingFor; - presenceData.state = - document.querySelector("input").value; - presenceData.smallImageKey = Assets.Search; - } - - if (path.includes("/drops/inventory/")) - presenceData.details = strings.viewDropsInv; - - if (path.includes("/drops/campaigns/")) { - presenceData.details = strings.viewDropsComp; - - let activeDrop = null; - - for (const drop of document.querySelector( - ".drops-root__content > div:nth-child(4)" - ).children) { - if (drop.children[0].children[0].ariaExpanded === "true") - activeDrop = `${drop.firstElementChild.firstElementChild.firstElementChild.children[1].firstElementChild.children[0].textContent} (${drop.firstElementChild.firstElementChild.firstElementChild.children[1].firstElementChild.children[1].textContent})`; - } - - if (activeDrop) presenceData.state = activeDrop; - } - - if (path.includes("/subscriptions/")) { - const tab = getElement( - 'li:not([data-a-target="paid"]) > button[aria-selected="true"]' - ); - - presenceData.details = strings.subs; - if (tab) - presenceData.state = tab.replace(/(Subscriptions|Abonnements)/, ""); - } - - if (path.includes("/wallet/")) { - const tab = getElement( - 'li:not([data-index="0"]) > button[aria-selected="true"] > div > div > p' - ); - - presenceData.details = strings.viewWallet; - if (tab) presenceData.state = tab; - } - - const pathSplit = path.split("/"); - if (path.includes("/directory/following/")) { - const tab = getElement( - 'li:not([data-index="0"]) > a[aria-selected="true"] > div > div > p' - ); - - presenceData.details = strings.viewFollow; - if (tab) presenceData.state = tab; - } else if (path.includes("/directory/esports/")) { - presenceData.details = strings.viewEsports; - if (pathSplit.length > 4) { - presenceData.state = getElement( - `label[for="game_selector_${pathSplit[5]}"] > div > div > div.jnFWYC > p` - ); - } - } else if ( - ["gaming", "irl", "music", "creative"].includes(pathSplit[2]) - ) { - presenceData.details = strings.viewCategory; - presenceData.state = getElement("h1.tw-title"); - } else if (path.includes("/directory/")) { - presenceData.details = strings.browse; - presenceData.state = getElement( - 'a[aria-selected="true"] > div > div > p' - ); - } - - if (privacy && searching) { - presenceData.details = strings.searchingSomething; - delete presenceData.state; - } else if (privacy) { - presenceData.details = strings.browse; - delete presenceData.state; - delete presenceData.smallImageKey; - } - } - - if (path.includes("/squad/")) { - const squad = document.querySelectorAll(".squad-stream-channel-card a"), - squadNames: string[] = []; - - for (const squadUser of squad) squadNames.push(squadUser.textContent); - - presenceData.details = strings.squad; - presenceData.state = squadNames.join(", "); - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = strings.live; - } - - if (path.includes("/moderator/")) { - presenceData.details = strings.modStreamer; - presenceData.state = getElement(".stream-info-card p > a"); - - if (getElement(".modview-dock-widget p") !== "Offline") { - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = strings.live; - } - } - - const video = document.querySelector("video"); - if ( - !document.querySelector(".home-carousel-info") && - document.querySelector(".channel-root") && - video - ) { - const live = video.duration >= 1073741824; - - if (showLive && live) { - //* Live - const title = getElement("p[data-a-target='stream-title']"), - streamer = - document.querySelector(".channel-info-content h1")?.textContent ?? - document - .querySelector('[class*="metadata-layout__support"]') - ?.querySelector("a")?.textContent, - game = - getElement("a[data-a-target='stream-game-link']") || - "Just Chatting", - profilePic = - document - .querySelector( - "[class*=channel-info-content] [class*=tw-image]" - ) - ?.src?.replace(/-[0-9]{1,2}x[0-9]{1,2}/, "-600x600") ?? - (logoArr[logo] || Assets.Logo); - presenceData.details = streamDetail - .replace("%title%", title ?? "") - .replace("%streamer%", streamer ?? "") - .replace("%game%", game); - - presenceData.state = streamState - .replace("%title%", title ?? "") - .replace("%streamer%", streamer ?? "") - .replace("%game%", game); - - if (!presenceData.details) - presenceData.details = strings.watchingLive; - - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = strings.live; - if (pfp) presenceData.largeImageKey = profilePic; - - presenceData.buttons = [ - { - label: strings.watchStream, - url: document.URL.split("?")[0], - }, - ]; - } - - if (showVideo && !live) { - //* Video or Clips - const title = getElement(".channel-info-content h2") - .split("•") - .shift(), - uploader = - document.querySelector(".channel-info-content h1")?.textContent ?? - document - .querySelector('[class*="metadata-layout__support"]') - ?.querySelector("a")?.textContent, - game = - getElement("a[data-a-target='stream-game-link']") || - "Just Chatting", - profilePic = - document - .querySelector( - ".tw-halo > .tw-aspect > .tw-avatar > .tw-image-avatar" - ) - ?.src?.replace(/-[0-9]{1,2}x[0-9]{1,2}/, "-600x600") ?? - (logoArr[logo] || Assets.Logo); - presenceData.details = vidDetail - .replace("%title%", title ?? "") - .replace("%uploader%", uploader ?? "") - .replace("%game%", game); - presenceData.state = vidState - .replace("%title%", title ?? "") - .replace("%uploader%", uploader ?? "") - .replace("%game%", game); - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = strings.play; - if (pfp) presenceData.largeImageKey = profilePic; - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - - presenceData.buttons = [ - { - label: strings.watchVideo, - url: document.URL.split("?")[0], - }, - ]; - } - - if (((showLive && live) || (showVideo && !live)) && video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = strings.pause; - } - - //* Privacy mode enabled. - if (privacy && showLive && live) { - presenceData.details = strings.watchingLive; - delete presenceData.state; - } else if (privacy && showVideo && !live) { - presenceData.details = strings.watchingVid; - delete presenceData.state; - } else if (showBrowsing && (!showVideo || !showLive)) { - presenceData.details = strings.browse; - delete presenceData.state; - } - } - - break; - } - case "dashboard.twitch.tv": { - //* Creator Dashboard - if (showBrowsing) { - const statics = { - "/home/": { - details: `${strings.dashboard} | ${strings.viewPage}`, - state: strings.home, - }, - "/stream-manager/": { - details: strings.dashboard, - state: strings.dashboardManage, - }, - "/channel-analytics/": { - details: `${strings.dashboard} | ${strings.viewTheir}`, - state: strings.channelAnaly, - }, - "/stream-summary/": { - details: `${strings.dashboard} | ${strings.viewTheir}`, - state: strings.streamSum, - }, - "/achievements/": { - details: `${strings.dashboard} | ${strings.viewTheir}`, - state: strings.achievements, - }, - "/community/roles/": { - details: strings.dashboard, - state: strings.manageRoles, - }, - "/community/activity/": { - details: `${strings.dashboard} | ${strings.viewTheir}`, - state: strings.activity, - }, - "/community/followers-list/": { - details: `${strings.dashboard} | ${strings.viewTheir}`, - state: strings.followList, - }, - "/content/video-producer/": { - details: strings.dashboard, - state: strings.produce, - }, - "/content/collections/": { - details: `${strings.dashboard} | ${strings.viewTheir}`, - state: strings.colls, - }, - "/content/clips/": { - details: `${strings.dashboard} | ${strings.viewTheir}`, - state: strings.clips, - }, - "/settings/channel/": { - details: `${strings.dashboard} | ${strings.viewTheir}`, - state: strings.channelSettings, - }, - "/settings/moderation/": { - details: `${strings.dashboard} | ${strings.viewTheir}`, - state: strings.moderationSettings, - }, - "/drops/": { - details: `${strings.dashboard} | ${strings.viewTheir}`, - state: strings.dropsSettings, - }, - "/broadcast/": { - details: strings.dashboard, - state: strings.tools, - }, - "/extensions/": { - details: strings.dashboard, - state: strings.extensions, - }, - }; - - for (const [k, v] of Object.entries(statics)) { - if (path.match(k)) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - presenceData = { ...presenceData, ...v }; - } - } - - if (privacy) { - presenceData.details = strings.browse; - delete presenceData.state; - delete presenceData.smallImageKey; - } - } - - break; - } - case "brand.twitch.tv": { - //* Brand website - if (showBrowsing) { - const statics = { - "/brand/": { - details: strings.brand, - state: strings.brandReal, - }, - "/madness/": { - details: strings.brand, - state: strings.brandMadness, - }, - "/expression/": { - details: strings.brand, - state: strings.brandExpression, - }, - "/together/": { - details: strings.brand, - state: strings.brandTogether, - }, - }; - - for (const [k, v] of Object.entries(statics)) { - if (path.match(k)) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - presenceData = { ...presenceData, ...v }; - } - } - - if ( - path === "/" && - document.querySelector(".plyr").className.includes("plyr--playing") - ) { - presenceData.details = strings.brandWatch; - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = strings.play; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - presence.timestampFromFormat( - document.querySelector(".c-controls__time.plyr__time--current") - .textContent - ), - presence.timestampFromFormat("01:30") - ); - } else if (path === "/") presenceData.details = strings.brand; - - if (privacy) { - presenceData.details = strings.browse; - delete presenceData.state; - delete presenceData.smallImageKey; - } - } - - break; - } - case "blog.twitch.tv": { - //* Blog website - if (showBrowsing) { - const statics = { - "/": { - details: strings.blogBrowse, - }, - "/(\\w*|\\w*-\\w*)/archive/": { - details: strings.blogArchive.replace( - "{0}", - location.pathname.replace(/\/?$/, "/").split("/")[3] - ), - }, - "/(\\w*|\\w*-\\w*)/(\\d*)/(\\d*)/(\\d*)/((\\w*|\\w*-\\w*)*)/": { - details: `${strings.blogs} | ${strings.readingArticle}`, - state: document.querySelector(".c-page-heading__text")?.textContent, - }, - }; - - for (const [k, v] of Object.entries(statics)) { - if (path.match(k)) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - presenceData = { ...presenceData, ...v }; - } - } - - if (privacy) { - presenceData.details = strings.browse; - delete presenceData.state; - delete presenceData.smallImageKey; - } - } - - break; - } - case "help.twitch.tv": { - //* Help website - if (showBrowsing) { - const statics = { - "/s/": { - details: `${strings.help} | ${strings.browse}`, - }, - "/s/topiccatalog/": { - details: strings.helpTopicCatalog, - }, - "/s/topic/": { - details: strings.helpTopic, - state: document.querySelector(".headlineTitle")?.textContent, - }, - "/s/article/": { - details: `${strings.help} | ${strings.readingArticle}`, - state: document.querySelector(".articleTitle")?.textContent, - }, - }; - - for (const [k, v] of Object.entries(statics)) { - if (path.match(k)) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - presenceData = { ...presenceData, ...v }; - } - } - - if (privacy) { - presenceData.details = strings.browse; - delete presenceData.state; - delete presenceData.smallImageKey; - } - } - - break; - } - case "affiliate.twitch.tv": { - //* Help website - if (showBrowsing) { - presenceData.details = strings.readingAbout; - presenceData.state = strings.affiliate; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - - if (privacy) { - presenceData.details = strings.browse; - delete presenceData.state; - delete presenceData.smallImageKey; - } - } - - break; - } - case "dev.twitch.tv": { - //* Dev docs - presenceData.largeImageKey = devLogoArr[devLogo] || Assets.DevMain; - if (showBrowsing) { - const statics = { - "/": { - details: `${strings.dev} | ${strings.browse}`, - }, - "/products/": { - details: `${strings.dev} | ${strings.viewing}`, - state: strings.devProduct, - }, - "/showcase/": { - details: `${strings.dev} | ${strings.viewing}`, - state: strings.devShowcase, - }, - "/support/": { - details: `${strings.dev} | ${strings.viewing}`, - state: strings.devSupport, - }, - "/docs/": { - details: strings.devDocs, - state: strings.browse, - }, - "/docs/(\\w*|\\w*-\\w*)/": { - details: `${strings.devDocs} | ${strings.readingAbout}`, - state: document.querySelector(".text-content > h1")?.textContent, - }, - }; - - for (const [k, v] of Object.entries(statics)) { - if (path.match(k)) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - presenceData = { ...presenceData, ...v }; - } - } - - if (privacy) { - presenceData.details = strings.browse; - delete presenceData.state; - delete presenceData.smallImageKey; - } - } - - break; - } - case "discuss.dev.twitch.tv": { - //! Development forums - presenceData.largeImageKey = devLogoArr[devLogo] || Assets.DevMain; - if (showBrowsing) { - const statics = { - "/": { - details: `${strings.dev} (${strings.forums}) | ${strings.browse}`, - }, - "/c/": { - details: `${strings.dev} (${strings.forums}) | ${strings.viewCategory}`, - state: document.querySelector(".category-name")?.textContent, - }, - "/t/": { - details: `${strings.dev} (${strings.forums}) | ${strings.thread}`, - state: document.querySelector(".fancy-title")?.textContent, - }, - "/u/": { - details: `${strings.dev} (${strings.forums}) | ${strings.user}`, - state: document.querySelector(".username")?.textContent, - }, - }; - - for (const [k, v] of Object.entries(statics)) { - if (path.match(k)) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - presenceData = { ...presenceData, ...v }; - } - } - - if (privacy) { - presenceData.details = strings.browse; - delete presenceData.state; - delete presenceData.smallImageKey; - } - } - - break; - } - case "devstatus.twitch.tv": - case "status.twitch.tv": { - //* Status pages - if (document.location.hostname === "devstatus.twitch.tv") - presenceData.largeImageKey = devLogoArr[devLogo] || Assets.DevMain; - if (showBrowsing) { - const statics = { - "/": { - details: `Status page | ${strings.browse}`, - }, - "/incidents/": { - details: `Status page | ${strings.viewing}`, - state: document.querySelector(".page-title > div")?.textContent, - }, - "/history/": { - details: `Status page | ${strings.viewing}`, - state: strings.incident, - }, - "/uptime/": { - details: `Status page | ${strings.viewing}`, - state: strings.uptime, - }, - }; - - for (const [k, v] of Object.entries(statics)) { - if (path.match(k)) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - presenceData = { ...presenceData, ...v }; - } - } - - if (privacy) { - presenceData.details = strings.browse; - delete presenceData.state; - delete presenceData.smallImageKey; - } - } - - break; - } - // No default - } - - if (!showTimestamps) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - if (privacy || !buttons) delete presenceData.buttons; - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + clientId: '802958789555781663', +}) +function getElement(query: string): string | undefined { + return document.querySelector(query)?.textContent ?? undefined +} +async function getStrings() { + return presence.getStrings( + { + play: 'general.playing', + pause: 'general.paused', + live: 'general.live', + browse: 'general.browsing', + viewPage: 'general.viewPage', + home: 'twitch.home', + download: 'twitch.downloads', + jobs: 'twitch.jobs', + turbo: 'twitch.turbo', + partners: 'twitch.partners', + press: 'twitch.press', + security: 'twitch.security', + access: 'twitch.access', + ads: 'twitch.ads', + guidelines: 'twitch.guidelines', + terms: 'general.terms', + privacy: 'general.privacy', + cookie: 'general.cookie', + watchingLive: 'general.watchingLive', + watchingVid: 'general.watchingVid', + viewProfile: 'general.viewProfile', + viewCategory: 'general.viewCategory', + viewWallet: 'twitch.wallet', + viewEsports: 'twitch.esports', + viewFollow: 'twitch.viewFollow', + viewTeam: 'twitch.viewTeam', + viewDropsInv: 'twitch.viewDropsInv', + viewDropsComp: 'twitch.viewDropsComp', + viewing: 'general.viewing', + searchingFor: 'general.searchFor', + searchingSomething: 'general.searchSomething', + viewSettings: 'twitch.viewSettings', + viewFriends: 'twitch.viewFriends', + subs: 'twitch.subs', + squad: 'twitch.squad', + modStreamer: 'twitch.modStreamer', + readingAbout: 'general.readingAbout', + redeem: 'twitch.redeem', + camp: 'twitch.camp', + campBasic: 'twitch.campBasic', + campSetup: 'twitch.campSetup', + campLevel: 'twitch.campLevel', + campConnect: 'twitch.campConnect', + campReward: 'twitch.campReward', + campMusic: 'twitch.campMusic', + campLive: 'twitch.campLive', + dashboard: 'twitch.dashboard', + dashboardManage: 'twitch.dashboardManage', + manageRoles: 'twitch.manageRoles', + produce: 'twitch.produce', + viewTheir: 'twitch.viewTheir', + channelAnaly: 'twitch.channelAnaly', + streamSum: 'twitch.streamSum', + achievements: 'twitch.achievements', + activity: 'twitch.activity', + followList: 'twitch.followList', + colls: 'twitch.colls', + clips: 'twitch.clips', + channelSettings: 'twitch.channelSettings', + moderationSettings: 'twitch.moderationSettings', + dropsSettings: 'twitch.dropsSettings', + tools: 'twitch.tools', + extensions: 'twitch.extensions', + brand: 'twitch.brand', + brandReal: 'twitch.brandReal', + brandMadness: 'twitch.brandMadness', + brandExpression: 'twitch.brandExpression', + brandTogether: 'twitch.brandTogether', + brandWatch: 'twitch.brandWatch', + blogArchive: 'twitch.blogArchive', + readingArticle: 'general.readingArticle', + blogBrowse: 'twitch.blogBrowse', + blogs: 'twitch.blogs', + help: 'twitch.help', + helpTopic: 'twitch.helpTopic', + helpTopicCatalog: 'twitch.helpTopicCatalog', + affiliate: 'twitch.affiliate', + dev: 'twitch.dev', + devProduct: 'twitch.devProduct', + devShowcase: 'twitch.devShowcase', + devSupport: 'twitch.devSupport', + devDocs: 'twitch.devDocs', + incident: 'general.incidentHistory', + uptime: 'general.uptimeHistory', + forums: 'general.forums', + thread: 'general.readingThread', + user: 'general.viewUser', + watchStream: 'general.buttonWatchStream', + watchVideo: 'general.buttonWatchVideo', + }, + oldLang, + ) +} +const devLogoArr = [Assets.DevMain, Assets.DevWhite, Assets.DevPurple] +const logoArr = [ + Assets.Logo, + Assets.BlackOps, + Assets.White, + Assets.Purple, + Assets.Pride, +] + +let strings: Awaited> + +presence.on('UpdateData', async () => { + const path = location.pathname.replace(/\/?$/, '/') + const [ + showBrowsing, + showLive, + showVideo, + showTimestamps, + newLang, + privacy, + vidDetail, + vidState, + streamDetail, + streamState, + pfp, + logo, + devLogo, + buttons, + ] = await Promise.all([ + presence.getSetting('browse'), + presence.getSetting('live'), + presence.getSetting('video'), + presence.getSetting('timestamp'), + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('privacy'), + presence.getSetting('vidDetail'), + presence.getSetting('vidState'), + presence.getSetting('streamDetail'), + presence.getSetting('streamState'), + presence.getSetting('profilePic'), + presence.getSetting('logo'), + presence.getSetting('devLogo'), + presence.getSetting('buttons'), + ]) + + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } + + let presenceData: PresenceData = { + type: ActivityType.Watching, + largeImageKey: logoArr[logo] || Assets.Logo, + startTimestamp: elapsed, + } + + if (document.location.href !== prevUrl) { + prevUrl = document.location.href + elapsed = Math.floor(Date.now() / 1000) + } + + switch (document.location.hostname) { + case 'www.twitch.tv': { + //* Main website + const statics = { + '/downloads/': { + details: strings.viewPage, + state: strings.download, + }, + '/jobs/': { + details: strings.viewPage, + state: strings.jobs, + }, + '/turbo/': { + details: strings.viewPage, + state: strings.turbo, + }, + '/broadcast/studio/': { + details: strings.readingAbout, + state: 'Twitch Studio', + }, + '/redeem/': { + details: strings.redeem, + }, + '/p/partners/': { + details: strings.viewPage, + state: strings.partners, + }, + '/p/press-center/': { + details: strings.viewPage, + state: strings.press, + }, + '/p/security/': { + details: strings.viewPage, + state: strings.security, + }, + '/p/legal/accessibility/': { + details: strings.viewPage, + state: strings.access, + }, + '/p/legal/ad-choices/': { + details: strings.viewPage, + state: strings.ads, + }, + '/p/legal/community-guidelines/': { + details: strings.viewPage, + state: strings.guidelines, + }, + '/p/legal/cookie-policy/': { + details: strings.viewPage, + state: strings.cookie, + }, + '/p/legal/privacy-notice/': { + details: strings.viewPage, + state: strings.privacy, + }, + '/p/legal/terms-of-serice/': { + details: strings.viewPage, + state: strings.terms, + }, + '/p/(\\w*|\\w*-\\w*)/about/': { + details: strings.readingAbout, + state: 'Twitch', + }, + '/p/(\\w*|\\w*-\\w*)/stream/': { + details: strings.readingAbout, + state: 'How to stream', + }, + '/p/(\\w*|\\w*-\\w*)/watch/': { + details: strings.readingAbout, + state: 'How to watch', + }, + '/p/(\\w*|\\w*-\\w*)/company/': { + details: strings.readingAbout, + state: 'The Company', + }, + '/p/(\\w*|\\w*-\\w*)/giftcard/': { + details: strings.readingAbout, + state: 'Giftcards', + }, + '/p/(\\w*|\\w*-\\w*)/artists/': { + details: strings.readingAbout, + state: 'Artists', + }, + '/creatorcamp/(\\w*|\\w*-\\w*)/learn-the-basics/': { + details: `${strings.camp} | ${strings.viewPage}`, + state: strings.campBasic, + }, + '/creatorcamp/(\\w*|\\w*-\\w*)/setting-up-your-stream/': { + details: `${strings.camp} | ${strings.viewPage}`, + state: strings.campSetup, + }, + '/creatorcamp/(\\w*|\\w*-\\w*)/level-up/': { + details: `${strings.camp} | ${strings.viewPage}`, + state: strings.campLevel, + }, + '/creatorcamp/(\\w*|\\w*-\\w*)/connect-and-engage/': { + details: `${strings.camp} | ${strings.viewPage}`, + state: strings.campConnect, + }, + '/creatorcamp/(\\w*|\\w*-\\w*)/get-rewarded/': { + details: `${strings.camp} | ${strings.viewPage}`, + state: strings.campReward, + }, + '/creatorcamp/(\\w*|\\w*-\\w*)/twitch-music-getting-started/': { + details: `${strings.camp} | ${strings.viewPage}`, + state: strings.campMusic, + }, + '/creatorcamp/(\\w*|\\w*-\\w*)/live/': { + details: `${strings.camp} | ${strings.viewPage}`, + state: strings.campLive, + }, + '/creatorcamp/(\\w*|\\w*-\\w*)/': { + details: `${strings.camp} | ${strings.viewPage}`, + state: strings.home, + }, + } + + if (showBrowsing) { + for (const [k, v] of Object.entries(statics)) { + if (path.match(k)) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + presenceData = { ...presenceData, ...v } + } + } + + if (path === '/') { + presenceData.details = strings.browse + presenceData.state = strings.home + } + + let user = getElement('.home-header-sticky .tw-title') + if (user) { + const tab = getElement('a[aria-selected="true"] > div > div > p') + const profilePic = ( + document.querySelector( + '.tw-halo > .tw-aspect > .tw-avatar > .tw-image-avatar', + ) + ?? document + .querySelector('.channel-root__info') + ?.querySelector('img[class*="image-avatar"]') + )?.src?.replace(/-\d{1,2}x\d{1,2}/, '-600x600') + ?? (logoArr[logo] || Assets.Logo) + user += tab ? ` (${tab})` : '' + + presenceData.details = strings.viewProfile + presenceData.state = user + if (pfp) + presenceData.largeImageKey = profilePic + } + + if (path.includes('/team/')) { + presenceData.details = strings.viewTeam + presenceData.state = document.location.pathname + .split('/') + .pop() + ?.split('_') + .map(word => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' ') + } + + if (path.includes('/settings/')) { + presenceData.details = strings.viewSettings + presenceData.state = getElement('a[aria-selected="true"]') + } + + let searching = false + if (path.includes('/search/')) { + searching = true + + presenceData.details = strings.searchingFor + presenceData.state = document.querySelector('input')?.value + presenceData.smallImageKey = Assets.Search + } + + if (path.includes('/drops/inventory/')) + presenceData.details = strings.viewDropsInv + + if (path.includes('/drops/campaigns/')) { + presenceData.details = strings.viewDropsComp + + let activeDrop = null + + for (const drop of document.querySelector( + '.drops-root__content > div:nth-child(4)', + )?.children ?? []) { + if (drop.children[0].children[0].ariaExpanded === 'true') + activeDrop = `${drop.firstElementChild?.firstElementChild?.firstElementChild?.children[1].firstElementChild?.children[0].textContent} (${drop.firstElementChild?.firstElementChild?.firstElementChild?.children[1].firstElementChild?.children[1].textContent})` + } + + if (activeDrop) + presenceData.state = activeDrop + } + + if (path.includes('/subscriptions/')) { + const tab = getElement( + 'li:not([data-a-target="paid"]) > button[aria-selected="true"]', + ) + + presenceData.details = strings.subs + if (tab) + presenceData.state = tab.replace(/(Subscriptions|Abonnements)/, '') + } + + if (path.includes('/wallet/')) { + const tab = getElement( + 'li:not([data-index="0"]) > button[aria-selected="true"] > div > div > p', + ) + + presenceData.details = strings.viewWallet + if (tab) + presenceData.state = tab + } + + const pathSplit = path.split('/') + if (path.includes('/directory/following/')) { + const tab = getElement( + 'li:not([data-index="0"]) > a[aria-selected="true"] > div > div > p', + ) + + presenceData.details = strings.viewFollow + if (tab) + presenceData.state = tab + } + else if (path.includes('/directory/esports/')) { + presenceData.details = strings.viewEsports + if (pathSplit.length > 4) { + presenceData.state = getElement( + `label[for="game_selector_${pathSplit[5]}"] > div > div > div.jnFWYC > p`, + ) + } + } + else if ( + ['gaming', 'irl', 'music', 'creative'].includes(pathSplit[2]) + ) { + presenceData.details = strings.viewCategory + presenceData.state = getElement('h1.tw-title') + } + else if (path.includes('/directory/')) { + presenceData.details = strings.browse + presenceData.state = getElement( + 'a[aria-selected="true"] > div > div > p', + ) + } + + if (privacy && searching) { + presenceData.details = strings.searchingSomething + delete presenceData.state + } + else if (privacy) { + presenceData.details = strings.browse + delete presenceData.state + delete presenceData.smallImageKey + } + } + + if (path.includes('/squad/')) { + const squad = document.querySelectorAll('.squad-stream-channel-card a') + const squadNames: string[] = [] + + for (const squadUser of squad) squadNames.push(squadUser.textContent!) + + presenceData.details = strings.squad + presenceData.state = squadNames.join(', ') + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = strings.live + } + + if (path.includes('/moderator/')) { + presenceData.details = strings.modStreamer + presenceData.state = getElement('.stream-info-card p > a') + + if (getElement('.modview-dock-widget p') !== 'Offline') { + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = strings.live + } + } + + const video = document.querySelector('video') + if ( + !document.querySelector('.home-carousel-info') + && document.querySelector('.channel-root') + && video + ) { + const live = video.duration >= 1073741824 + + if (showLive && live) { + //* Live + const title = getElement('p[data-a-target=\'stream-title\']') + const streamer = document.querySelector('.channel-info-content h1')?.textContent + ?? document + .querySelector('[class*="metadata-layout__support"]') + ?.querySelector('a') + ?.textContent + const game = getElement('a[data-a-target=\'stream-game-link\']') + || 'Just Chatting' + const profilePic = document + .querySelector( + '[class*=channel-info-content] [class*=tw-image]', + ) + ?.src + ?.replace(/-\d{1,2}x\d{1,2}/, '-600x600') + ?? (logoArr[logo] || Assets.Logo) + presenceData.details = streamDetail + .replace('%title%', title ?? '') + .replace('%streamer%', streamer ?? '') + .replace('%game%', game) + + presenceData.state = streamState + .replace('%title%', title ?? '') + .replace('%streamer%', streamer ?? '') + .replace('%game%', game) + + if (!presenceData.details) + presenceData.details = strings.watchingLive + + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = strings.live + if (pfp) + presenceData.largeImageKey = profilePic + + presenceData.buttons = [ + { + label: strings.watchStream, + url: document.URL.split('?')[0], + }, + ] + } + + if (showVideo && !live) { + //* Video or Clips + const title = getElement('.channel-info-content h2') + ?.split('•') + .shift() + const uploader = document.querySelector('.channel-info-content h1')?.textContent + ?? document + .querySelector('[class*="metadata-layout__support"]') + ?.querySelector('a') + ?.textContent + const game = getElement('a[data-a-target=\'stream-game-link\']') + || 'Just Chatting' + const profilePic = document + .querySelector( + '.tw-halo > .tw-aspect > .tw-avatar > .tw-image-avatar', + ) + ?.src + ?.replace(/-\d{1,2}x\d{1,2}/, '-600x600') + ?? (logoArr[logo] || Assets.Logo) + presenceData.details = vidDetail + .replace('%title%', title ?? '') + .replace('%uploader%', uploader ?? '') + .replace('%game%', game) + presenceData.state = vidState + .replace('%title%', title ?? '') + .replace('%uploader%', uploader ?? '') + .replace('%game%', game) + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = strings.play + if (pfp) + presenceData.largeImageKey = profilePic; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + + presenceData.buttons = [ + { + label: strings.watchVideo, + url: document.URL.split('?')[0], + }, + ] + } + + if (((showLive && live) || (showVideo && !live)) && video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = strings.pause + } + + //* Privacy mode enabled. + if (privacy && showLive && live) { + presenceData.details = strings.watchingLive + delete presenceData.state + } + else if (privacy && showVideo && !live) { + presenceData.details = strings.watchingVid + delete presenceData.state + } + else if (showBrowsing && (!showVideo || !showLive)) { + presenceData.details = strings.browse + delete presenceData.state + } + } + + break + } + case 'dashboard.twitch.tv': { + //* Creator Dashboard + if (showBrowsing) { + const statics = { + '/home/': { + details: `${strings.dashboard} | ${strings.viewPage}`, + state: strings.home, + }, + '/stream-manager/': { + details: strings.dashboard, + state: strings.dashboardManage, + }, + '/channel-analytics/': { + details: `${strings.dashboard} | ${strings.viewTheir}`, + state: strings.channelAnaly, + }, + '/stream-summary/': { + details: `${strings.dashboard} | ${strings.viewTheir}`, + state: strings.streamSum, + }, + '/achievements/': { + details: `${strings.dashboard} | ${strings.viewTheir}`, + state: strings.achievements, + }, + '/community/roles/': { + details: strings.dashboard, + state: strings.manageRoles, + }, + '/community/activity/': { + details: `${strings.dashboard} | ${strings.viewTheir}`, + state: strings.activity, + }, + '/community/followers-list/': { + details: `${strings.dashboard} | ${strings.viewTheir}`, + state: strings.followList, + }, + '/content/video-producer/': { + details: strings.dashboard, + state: strings.produce, + }, + '/content/collections/': { + details: `${strings.dashboard} | ${strings.viewTheir}`, + state: strings.colls, + }, + '/content/clips/': { + details: `${strings.dashboard} | ${strings.viewTheir}`, + state: strings.clips, + }, + '/settings/channel/': { + details: `${strings.dashboard} | ${strings.viewTheir}`, + state: strings.channelSettings, + }, + '/settings/moderation/': { + details: `${strings.dashboard} | ${strings.viewTheir}`, + state: strings.moderationSettings, + }, + '/drops/': { + details: `${strings.dashboard} | ${strings.viewTheir}`, + state: strings.dropsSettings, + }, + '/broadcast/': { + details: strings.dashboard, + state: strings.tools, + }, + '/extensions/': { + details: strings.dashboard, + state: strings.extensions, + }, + } + + for (const [k, v] of Object.entries(statics)) { + if (path.match(k)) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + presenceData = { ...presenceData, ...v } + } + } + + if (privacy) { + presenceData.details = strings.browse + delete presenceData.state + delete presenceData.smallImageKey + } + } + + break + } + case 'brand.twitch.tv': { + //* Brand website + if (showBrowsing) { + const statics = { + '/brand/': { + details: strings.brand, + state: strings.brandReal, + }, + '/madness/': { + details: strings.brand, + state: strings.brandMadness, + }, + '/expression/': { + details: strings.brand, + state: strings.brandExpression, + }, + '/together/': { + details: strings.brand, + state: strings.brandTogether, + }, + } + + for (const [k, v] of Object.entries(statics)) { + if (path.match(k)) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + presenceData = { ...presenceData, ...v } + } + } + + if ( + path === '/' + && document.querySelector('.plyr')?.className.includes('plyr--playing') + ) { + presenceData.details = strings.brandWatch + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = strings.play; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + presence.timestampFromFormat( + document.querySelector('.c-controls__time.plyr__time--current') + ?.textContent ?? '', + ), + presence.timestampFromFormat('01:30'), + ) + } + else if (path === '/') { + presenceData.details = strings.brand + } + + if (privacy) { + presenceData.details = strings.browse + delete presenceData.state + delete presenceData.smallImageKey + } + } + + break + } + case 'blog.twitch.tv': { + //* Blog website + if (showBrowsing) { + const statics = { + '/': { + details: strings.blogBrowse, + }, + '/(\\w*|\\w*-\\w*)/archive/': { + details: strings.blogArchive.replace( + '{0}', + location.pathname.replace(/\/?$/, '/').split('/')[3], + ), + }, + '/(\\w*|\\w*-\\w*)/(\\d*)/(\\d*)/(\\d*)/((\\w*|\\w*-\\w*)*)/': { + details: `${strings.blogs} | ${strings.readingArticle}`, + state: document.querySelector('.c-page-heading__text')?.textContent, + }, + } + + for (const [k, v] of Object.entries(statics)) { + if (path.match(k)) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + presenceData = { ...presenceData, ...v } + } + } + + if (privacy) { + presenceData.details = strings.browse + delete presenceData.state + delete presenceData.smallImageKey + } + } + + break + } + case 'help.twitch.tv': { + //* Help website + if (showBrowsing) { + const statics = { + '/s/': { + details: `${strings.help} | ${strings.browse}`, + }, + '/s/topiccatalog/': { + details: strings.helpTopicCatalog, + }, + '/s/topic/': { + details: strings.helpTopic, + state: document.querySelector('.headlineTitle')?.textContent, + }, + '/s/article/': { + details: `${strings.help} | ${strings.readingArticle}`, + state: document.querySelector('.articleTitle')?.textContent, + }, + } + + for (const [k, v] of Object.entries(statics)) { + if (path.match(k)) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + presenceData = { ...presenceData, ...v } + } + } + + if (privacy) { + presenceData.details = strings.browse + delete presenceData.state + delete presenceData.smallImageKey + } + } + + break + } + case 'affiliate.twitch.tv': { + //* Help website + if (showBrowsing) { + presenceData.details = strings.readingAbout + presenceData.state = strings.affiliate + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + + if (privacy) { + presenceData.details = strings.browse + delete presenceData.state + delete presenceData.smallImageKey + } + } + + break + } + case 'dev.twitch.tv': { + //* Dev docs + presenceData.largeImageKey = devLogoArr[devLogo] || Assets.DevMain + if (showBrowsing) { + const statics = { + '/': { + details: `${strings.dev} | ${strings.browse}`, + }, + '/products/': { + details: `${strings.dev} | ${strings.viewing}`, + state: strings.devProduct, + }, + '/showcase/': { + details: `${strings.dev} | ${strings.viewing}`, + state: strings.devShowcase, + }, + '/support/': { + details: `${strings.dev} | ${strings.viewing}`, + state: strings.devSupport, + }, + '/docs/': { + details: strings.devDocs, + state: strings.browse, + }, + '/docs/(\\w*|\\w*-\\w*)/': { + details: `${strings.devDocs} | ${strings.readingAbout}`, + state: document.querySelector('.text-content > h1')?.textContent, + }, + } + + for (const [k, v] of Object.entries(statics)) { + if (path.match(k)) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + presenceData = { ...presenceData, ...v } + } + } + + if (privacy) { + presenceData.details = strings.browse + delete presenceData.state + delete presenceData.smallImageKey + } + } + + break + } + case 'discuss.dev.twitch.tv': { + // ! Development forums + presenceData.largeImageKey = devLogoArr[devLogo] || Assets.DevMain + if (showBrowsing) { + const statics = { + '/': { + details: `${strings.dev} (${strings.forums}) | ${strings.browse}`, + }, + '/c/': { + details: `${strings.dev} (${strings.forums}) | ${strings.viewCategory}`, + state: document.querySelector('.category-name')?.textContent, + }, + '/t/': { + details: `${strings.dev} (${strings.forums}) | ${strings.thread}`, + state: document.querySelector('.fancy-title')?.textContent, + }, + '/u/': { + details: `${strings.dev} (${strings.forums}) | ${strings.user}`, + state: document.querySelector('.username')?.textContent, + }, + } + + for (const [k, v] of Object.entries(statics)) { + if (path.match(k)) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + presenceData = { ...presenceData, ...v } + } + } + + if (privacy) { + presenceData.details = strings.browse + delete presenceData.state + delete presenceData.smallImageKey + } + } + + break + } + case 'devstatus.twitch.tv': + case 'status.twitch.tv': { + //* Status pages + if (document.location.hostname === 'devstatus.twitch.tv') + presenceData.largeImageKey = devLogoArr[devLogo] || Assets.DevMain + if (showBrowsing) { + const statics = { + '/': { + details: `Status page | ${strings.browse}`, + }, + '/incidents/': { + details: `Status page | ${strings.viewing}`, + state: document.querySelector('.page-title > div')?.textContent, + }, + '/history/': { + details: `Status page | ${strings.viewing}`, + state: strings.incident, + }, + '/uptime/': { + details: `Status page | ${strings.viewing}`, + state: strings.uptime, + }, + } + + for (const [k, v] of Object.entries(statics)) { + if (path.match(k)) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + presenceData = { ...presenceData, ...v } + } + } + + if (privacy) { + presenceData.details = strings.browse + delete presenceData.state + delete presenceData.smallImageKey + } + } + + break + } + } + + if (!showTimestamps) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + if (privacy || !buttons) + delete presenceData.buttons + + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/T/Typer.io/metadata.json b/websites/T/Typer.io/metadata.json index d5095c7c94fd..53effd613401 100644 --- a/websites/T/Typer.io/metadata.json +++ b/websites/T/Typer.io/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dzlandis", - "id": "259708781166985217" - }, - "service": "Typer.io", - "description": { - "en": "Online Multiplayer Typing Test - Improve your typing speed and race your friends. Practice on different texts and learn how to type faster." - }, - "url": "typer.io", - "version": "1.0.16", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Typer.io/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Typer.io/assets/thumbnail.png", - "color": "#4e6edd", - "category": "games", - "tags": [ - "typing", - "competition", - "typerio", - "race" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dzlandis", + "id": "259708781166985217" + }, + "service": "Typer.io", + "description": { + "en": "Online Multiplayer Typing Test - Improve your typing speed and race your friends. Practice on different texts and learn how to type faster." + }, + "url": "typer.io", + "version": "1.0.16", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Typer.io/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Typer.io/assets/thumbnail.png", + "color": "#4e6edd", + "category": "games", + "tags": [ + "typing", + "competition", + "typerio", + "race" + ] +} diff --git a/websites/T/Typer.io/presence.ts b/websites/T/Typer.io/presence.ts index 4453049681c6..cb60e6408fa5 100644 --- a/websites/T/Typer.io/presence.ts +++ b/websites/T/Typer.io/presence.ts @@ -1,213 +1,250 @@ const presence = new Presence({ - clientId: "854448403273351202", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); - -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Typer.io/assets/logo.png", - startTimestamp: browsingTimestamp, - }; - - // typer.io/play presence (aka quick play) - if (document.location.pathname.startsWith("/play")) { - const playingStatus = document - .querySelector( - "#__next > div.Play_root__16QtH > div.Play_container__392yl.false > div.Status_root__2iFRH > div > h3" - ) - .textContent.trim(); - - if (playingStatus) { - presenceData.details = "In a quick play race:"; - presenceData.state = playingStatus; - } - - try { - const quickplayWPM = `${document - .querySelector("#PreMiD-WPM") - .textContent.trim()} WPM`, - quickplayAccuracy = `${document - .querySelector("#PreMiD-ACC") - .textContent.trim()} acc`, - quickplayRaceStatus = document - .querySelector( - "#__next > div.Play_root__16QtH > div.Play_container__392yl.false > div.Status_root__2iFRH > div > h3" - ) - .textContent.trim(); - - if (quickplayRaceStatus === "GO!") { - presenceData.details = "In a quick play race:"; - presenceData.state = `${quickplayWPM}, ${quickplayAccuracy}`; - } - - const quickplayRacePlace = document - .querySelector("#PreMiD-RANK") - .textContent.trim(), - quickplayRaceTime = document - .querySelector("#PreMiD-TIME") - .textContent.trim(); - - if (quickplayRaceTime !== "--:--") { - presenceData.details = `Placed ${quickplayRacePlace} in a quick play race!`; - presenceData.state = `${quickplayWPM}, ${quickplayAccuracy}, ${quickplayRaceTime}`; - } - - if ( - quickplayRacePlace === "-" && - quickplayWPM !== "undefined" && - quickplayRaceStatus === "Game has Ended" - ) { - presenceData.details = "The game ended, did not finish."; - presenceData.state = `${quickplayWPM}, ${quickplayAccuracy}`; - } - } catch { - presenceData.details = "In a quick play race:"; - presenceData.state = "Connecting..."; - } - } else if (document.location.pathname.startsWith("/solo")) { - // typer.io/solo (when playing on the solo mode, aka solo play) - const soloRaceStatus = document - .querySelector( - "#__next > div.Play_root__16QtH > div.Play_container__392yl.Play_soloContainer__1IpE4 > div.Status_root__2iFRH > div > h3" - ) - .textContent.trim(); - - if (soloRaceStatus !== "Press 'Space' to begin...") { - presenceData.details = "In a solo race:"; - presenceData.state = soloRaceStatus; - } else if (soloRaceStatus === "Press 'Space' to begin...") { - presenceData.details = "In a solo race:"; - presenceData.state = "Waiting for user to start the race."; - } - - try { - const soloWPM = `${document - .querySelector("#PreMiD-WPM") - .textContent.trim()} WPM`, - soloAccuracy = `${document - .querySelector("#PreMiD-ACC") - .textContent.trim()} acc`, - soloRaceTime = document - .querySelector("#PreMiD-TIME") - .textContent.trim(); - - if (soloRaceStatus === "GO!") { - presenceData.details = "In a solo race:"; - presenceData.state = `${soloWPM}, ${soloAccuracy}`; - } - - if (soloRaceStatus === "Game has Ended" && soloRaceTime !== "--:--") { - presenceData.details = "Completed a solo race:"; - presenceData.state = `${soloWPM}, ${soloAccuracy}, ${soloRaceTime}`; - } else if ( - soloRaceStatus === "Game has Ended" && - soloRaceTime === "--:--" - ) { - presenceData.details = "Did not complete solo race:"; - presenceData.state = `${soloWPM}, ${soloAccuracy}`; - } - } catch { - presenceData.details = "In a solo race:"; - presenceData.state = "Connecting..."; - } - } else if (document.location.pathname.startsWith("/lobby")) { - // typer.io/lobby (aka custom play or group play) - try { - presenceData.details = document - .querySelector( - "#__next > main > div > div.Lobby_container__1Y-Os > div.Banner_root__thCyZ > h3" - ) - .textContent.trim(); - } catch { - const playingStatus = document - .querySelector( - "#__next > div.Play_root__16QtH > div.Play_container__392yl.false > div.Status_root__2iFRH > div > h3" - ) - .textContent.trim(), - privateWPM = `${document - .querySelector("#PreMiD-WPM") - .textContent.trim()} WPM`, - privateRacePlace = document - .querySelector("#PreMiD-RANK") - .textContent.trim(), - privateAccuracy = `${document - .querySelector("#PreMiD-ACC") - .textContent.trim()} acc`; - - if (playingStatus === "Get Ready..." || playingStatus === "Get Set...") { - presenceData.details = "In a private lobby race:"; - presenceData.state = playingStatus; - } - - if (playingStatus === "GO!") { - presenceData.details = "In a private lobby race:"; - presenceData.state = `${privateWPM}, ${privateAccuracy}`; - } - - if (privateRacePlace !== "-" || playingStatus === "Game has Ended") { - presenceData.details = `Placed ${privateRacePlace} in a private race!`; - presenceData.state = `${privateWPM}, ${privateAccuracy}, ${document - .querySelector("#PreMiD-TIME") - .textContent.trim()}`; - } - - if (privateRacePlace === "-" && playingStatus === "Game has Ended") { - presenceData.details = "The game ended, did not finish."; - presenceData.state = `${privateWPM}, ${privateAccuracy}`; - } - } - } else if (document.location.pathname.startsWith("/forum/post/")) { - // typer.io/forum/posts (when viewing individual posts) - try { - presenceData.details = "Reading a post on the forum:"; - presenceData.state = document - .querySelector( - "#__next > div.Post_root__ivA4B > div > div.Post_postContainer__oful_ > div.Post_postContent__2KI4z > div.Post_header__19SiQ > h1" - ) - .textContent.trim(); - } catch { - presenceData.details = "Reading a post on the forum."; - } - } else if (document.location.pathname === "/forum") - presenceData.details = "Scrolling through forum posts."; - // typer.io/forum (when scroling through all the posts on the forum) - else if (document.location.pathname.startsWith("/hiscores")) - presenceData.details = "Viewing the hiscores."; - // typer.io/hiscores (when viewing the hiscores page) - else if (document.location.pathname === "/u/settings") - presenceData.details = "Editing account settings..."; - // typer.io/u/settings (when a user is editing their bio/settings) - else if (document.location.pathname.startsWith("/u/")) { - // typer.io/u/(username) (when viewing a users profile) - try { - presenceData.details = `Viewing ${document - .querySelector( - "#__next > div.Profile_root__2QIUs > div.Profile_headerContainer__IYvIA > div.Profile_profileContainer__k2Fu9 > div.Profile_wrapper__3Ghk7 > div.Profile_content__rWK4h > h3" - ) - .textContent.trim()}'s profile.`; - } catch { - presenceData.details = "Viewing a user profile."; - } - } else if (document.location.pathname.startsWith("/login")) - presenceData.details = "Logging in..."; - // typer.io/login (when logging into an account via the login page) - else if (document.location.pathname.startsWith("/signup")) - presenceData.details = "Creating an account..."; - // typer.io/singup (when creating account via the signup page) - else if (document.location.pathname === "/") - presenceData.details = "Viewing the home page."; - // When viewing the home page (typer.io, no ending on the url typer.io) - else { - // When viewing a 404 page - try { - presenceData.details = document - .querySelector("#__next > main > h1") - .textContent.trim(); - } catch { - // When viewing a page which does not have 404 text. - presenceData.details = "Viewing an unsupported page."; - } - } - presence.setActivity(presenceData); -}); + clientId: '854448403273351202', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) + +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Typer.io/assets/logo.png', + startTimestamp: browsingTimestamp, + } + + // typer.io/play presence (aka quick play) + if (document.location.pathname.startsWith('/play')) { + const playingStatus = document + .querySelector( + '#__next > div.Play_root__16QtH > div.Play_container__392yl.false > div.Status_root__2iFRH > div > h3', + ) + ?.textContent + ?.trim() + + if (playingStatus) { + presenceData.details = 'In a quick play race:' + presenceData.state = playingStatus + } + + try { + const quickplayWPM = `${document + .querySelector('#PreMiD-WPM') + ?.textContent + ?.trim()} WPM` + const quickplayAccuracy = `${document + .querySelector('#PreMiD-ACC') + ?.textContent + ?.trim()} acc` + const quickplayRaceStatus = document + .querySelector( + '#__next > div.Play_root__16QtH > div.Play_container__392yl.false > div.Status_root__2iFRH > div > h3', + ) + ?.textContent + ?.trim() + + if (quickplayRaceStatus === 'GO!') { + presenceData.details = 'In a quick play race:' + presenceData.state = `${quickplayWPM}, ${quickplayAccuracy}` + } + + const quickplayRacePlace = document + .querySelector('#PreMiD-RANK') + ?.textContent + ?.trim() + const quickplayRaceTime = document + .querySelector('#PreMiD-TIME') + ?.textContent + ?.trim() + + if (quickplayRaceTime !== '--:--') { + presenceData.details = `Placed ${quickplayRacePlace} in a quick play race!` + presenceData.state = `${quickplayWPM}, ${quickplayAccuracy}, ${quickplayRaceTime}` + } + + if ( + quickplayRacePlace === '-' + && quickplayWPM !== 'undefined' + && quickplayRaceStatus === 'Game has Ended' + ) { + presenceData.details = 'The game ended, did not finish.' + presenceData.state = `${quickplayWPM}, ${quickplayAccuracy}` + } + } + catch { + presenceData.details = 'In a quick play race:' + presenceData.state = 'Connecting...' + } + } + else if (document.location.pathname.startsWith('/solo')) { + // typer.io/solo (when playing on the solo mode, aka solo play) + const soloRaceStatus = document + .querySelector( + '#__next > div.Play_root__16QtH > div.Play_container__392yl.Play_soloContainer__1IpE4 > div.Status_root__2iFRH > div > h3', + ) + ?.textContent + ?.trim() + + if (soloRaceStatus !== 'Press \'Space\' to begin...') { + presenceData.details = 'In a solo race:' + presenceData.state = soloRaceStatus + } + else if (soloRaceStatus === 'Press \'Space\' to begin...') { + presenceData.details = 'In a solo race:' + presenceData.state = 'Waiting for user to start the race.' + } + + try { + const soloWPM = `${document + .querySelector('#PreMiD-WPM') + ?.textContent + ?.trim()} WPM` + const soloAccuracy = `${document + .querySelector('#PreMiD-ACC') + ?.textContent + ?.trim()} acc` + const soloRaceTime = document + .querySelector('#PreMiD-TIME') + ?.textContent + ?.trim() + + if (soloRaceStatus === 'GO!') { + presenceData.details = 'In a solo race:' + presenceData.state = `${soloWPM}, ${soloAccuracy}` + } + + if (soloRaceStatus === 'Game has Ended' && soloRaceTime !== '--:--') { + presenceData.details = 'Completed a solo race:' + presenceData.state = `${soloWPM}, ${soloAccuracy}, ${soloRaceTime}` + } + else if ( + soloRaceStatus === 'Game has Ended' + && soloRaceTime === '--:--' + ) { + presenceData.details = 'Did not complete solo race:' + presenceData.state = `${soloWPM}, ${soloAccuracy}` + } + } + catch { + presenceData.details = 'In a solo race:' + presenceData.state = 'Connecting...' + } + } + else if (document.location.pathname.startsWith('/lobby')) { + // typer.io/lobby (aka custom play or group play) + try { + presenceData.details = document + .querySelector( + '#__next > main > div > div.Lobby_container__1Y-Os > div.Banner_root__thCyZ > h3', + ) + ?.textContent + ?.trim() + } + catch { + const playingStatus = document + .querySelector( + '#__next > div.Play_root__16QtH > div.Play_container__392yl.false > div.Status_root__2iFRH > div > h3', + ) + ?.textContent + ?.trim() + const privateWPM = `${document + .querySelector('#PreMiD-WPM') + ?.textContent + ?.trim()} WPM` + const privateRacePlace = document + .querySelector('#PreMiD-RANK') + ?.textContent + ?.trim() + const privateAccuracy = `${document + .querySelector('#PreMiD-ACC') + ?.textContent + ?.trim()} acc` + + if (playingStatus === 'Get Ready...' || playingStatus === 'Get Set...') { + presenceData.details = 'In a private lobby race:' + presenceData.state = playingStatus + } + + if (playingStatus === 'GO!') { + presenceData.details = 'In a private lobby race:' + presenceData.state = `${privateWPM}, ${privateAccuracy}` + } + + if (privateRacePlace !== '-' || playingStatus === 'Game has Ended') { + presenceData.details = `Placed ${privateRacePlace} in a private race!` + presenceData.state = `${privateWPM}, ${privateAccuracy}, ${document + .querySelector('#PreMiD-TIME') + ?.textContent + ?.trim()}` + } + + if (privateRacePlace === '-' && playingStatus === 'Game has Ended') { + presenceData.details = 'The game ended, did not finish.' + presenceData.state = `${privateWPM}, ${privateAccuracy}` + } + } + } + else if (document.location.pathname.startsWith('/forum/post/')) { + // typer.io/forum/posts (when viewing individual posts) + try { + presenceData.details = 'Reading a post on the forum:' + presenceData.state = document + .querySelector( + '#__next > div.Post_root__ivA4B > div > div.Post_postContainer__oful_ > div.Post_postContent__2KI4z > div.Post_header__19SiQ > h1', + ) + ?.textContent + ?.trim() + } + catch { + presenceData.details = 'Reading a post on the forum.' + } + } + else if (document.location.pathname === '/forum') { + presenceData.details = 'Scrolling through forum posts.' + } + // typer.io/forum (when scroling through all the posts on the forum) + else if (document.location.pathname.startsWith('/hiscores')) { + presenceData.details = 'Viewing the hiscores.' + } + // typer.io/hiscores (when viewing the hiscores page) + else if (document.location.pathname === '/u/settings') { + presenceData.details = 'Editing account settings...' + } + // typer.io/u/settings (when a user is editing their bio/settings) + else if (document.location.pathname.startsWith('/u/')) { + // typer.io/u/(username) (when viewing a users profile) + try { + presenceData.details = `Viewing ${document + .querySelector( + '#__next > div.Profile_root__2QIUs > div.Profile_headerContainer__IYvIA > div.Profile_profileContainer__k2Fu9 > div.Profile_wrapper__3Ghk7 > div.Profile_content__rWK4h > h3', + ) + ?.textContent + ?.trim()}'s profile.` + } + catch { + presenceData.details = 'Viewing a user profile.' + } + } + else if (document.location.pathname.startsWith('/login')) { + presenceData.details = 'Logging in...' + } + // typer.io/login (when logging into an account via the login page) + else if (document.location.pathname.startsWith('/signup')) { + presenceData.details = 'Creating an account...' + } + // typer.io/singup (when creating account via the signup page) + else if (document.location.pathname === '/') { + presenceData.details = 'Viewing the home page.' + } + // When viewing the home page (typer.io, no ending on the url typer.io) + else { + // When viewing a 404 page + try { + presenceData.details = document + .querySelector('#__next > main > h1') + ?.textContent + ?.trim() + } + catch { + // When viewing a page which does not have 404 text. + presenceData.details = 'Viewing an unsupported page.' + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/T/Typeracer/metadata.json b/websites/T/Typeracer/metadata.json index 94ea497bfcc7..b900fd795557 100644 --- a/websites/T/Typeracer/metadata.json +++ b/websites/T/Typeracer/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Hans5958", - "id": "279855717203050496" - }, - "service": "Typeracer", - "description": { - "en": "The award-winning online typing competition, TypeRacer, allows people to race each-other by typing quotes from books, movies, and songs. It is the first multiplayer typing game on the web.", - "nl": "De bekroonde online typecompetitie, TypeRacer, stelt mensen in staat om tegen elkaar te racen door citaten uit boeken, films en liedjes te typen. Het is het eerste typspel voor meerdere spelers op internet." - }, - "url": [ - "play.typeracer.com", - "data.typeracer.com" - ], - "version": "1.1.28", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Typeracer/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Typeracer/assets/thumbnail.png", - "color": "#007ec5", - "category": "games", - "tags": [ - "typing", - "multiplayer", - "competition" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Hans5958", + "id": "279855717203050496" + }, + "service": "Typeracer", + "description": { + "en": "The award-winning online typing competition, TypeRacer, allows people to race each-other by typing quotes from books, movies, and songs. It is the first multiplayer typing game on the web.", + "nl": "De bekroonde online typecompetitie, TypeRacer, stelt mensen in staat om tegen elkaar te racen door citaten uit boeken, films en liedjes te typen. Het is het eerste typspel voor meerdere spelers op internet." + }, + "url": [ + "play.typeracer.com", + "data.typeracer.com" + ], + "version": "1.1.28", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/Typeracer/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/Typeracer/assets/thumbnail.png", + "color": "#007ec5", + "category": "games", + "tags": [ + "typing", + "multiplayer", + "competition" + ] +} diff --git a/websites/T/Typeracer/presence.ts b/websites/T/Typeracer/presence.ts index 1f31a561ca99..d20dd56db843 100644 --- a/websites/T/Typeracer/presence.ts +++ b/websites/T/Typeracer/presence.ts @@ -1,240 +1,238 @@ const presence = new Presence({ - clientId: "655247212728811530", -}); + clientId: '655247212728811530', +}) -let currentURL = new URL(document.location.href), - currentPath = currentURL.pathname.replace(/^\/|\/$/g, "").split("/"); -const browsingTimestamp = Math.floor(Date.now() / 1000); +let currentURL = new URL(document.location.href) +let currentPath = currentURL.pathname.replace(/^\/|\/$/g, '').split('/') +const browsingTimestamp = Math.floor(Date.now() / 1000) let presenceData: PresenceData = { - details: "Viewing an unsupported page", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Typeracer/assets/logo.png", - startTimestamp: browsingTimestamp, -}; + details: 'Viewing an unsupported page', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Typeracer/assets/logo.png', + startTimestamp: browsingTimestamp, +} const updateCallback = { - _function: null as () => void, - get function(): () => void { - return this._function; - }, - set function(parameter) { - this._function = parameter; - }, - get present(): boolean { - return this._function !== null; - }, - }, - resetData = ( - defaultData: PresenceData = { - details: "Viewing an unsupported page", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/Typeracer/assets/logo.png", - startTimestamp: browsingTimestamp, - } - ): void => { - currentURL = new URL(document.location.href); - currentPath = currentURL.pathname.replace(/^\/|\/$/g, "").split("/"); - presenceData = { ...defaultData }; - }; + _function: null as unknown as () => void, + get function(): () => void { + return this._function + }, + set function(parameter) { + this._function = parameter + }, + get present(): boolean { + return this._function !== null + }, +} +function resetData(defaultData: PresenceData = { + details: 'Viewing an unsupported page', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/Typeracer/assets/logo.png', + startTimestamp: browsingTimestamp, +}): void { + currentURL = new URL(document.location.href) + currentPath = currentURL.pathname.replace(/^\/|\/$/g, '').split('/') + presenceData = { ...defaultData } +} ((): void => { - let raceStamp: number = null; - - if (currentURL.hostname === "play.typeracer.com") { - updateCallback.function = (): void => { - if (document.querySelector(".gameView")) { - presenceData.details = "Playing a race"; - const gameStatusLabel = - document.querySelector(".gameStatusLabel").textContent; - - switch (gameStatusLabel) { - case "Waiting for more people...": { - presenceData.state = "Waiting for more people..."; - if (raceStamp === null) raceStamp = Math.floor(Date.now() / 1000); - presenceData.startTimestamp = raceStamp; - - break; - } - case "The race is about to start!": { - presenceData.state = "Counting down..."; - presenceData.endTimestamp = - Math.floor(Date.now() / 1000) + - Number( - document - .querySelector(".countdownPopup .time") - .textContent.slice(1) - ); - raceStamp = null; - - break; - } - case "The race is on! Type the text below:": - case "Go!": { - const textBox = document.querySelector( - "table.gameView > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td > div > div" - ); - let lettersTyped = 0; - for (const i in textBox.children) { - if ( - typeof textBox.children[i] !== "number" && - typeof textBox.children[i] !== "function" && - getComputedStyle(textBox.children[i]).color === - "rgb(153, 204, 0)" - ) - lettersTyped += textBox.children[i].textContent.length; - } - presenceData.state = `${ - Math.round((lettersTyped / textBox.textContent.length) * 10000) / - 100 - }%, ${document - .querySelector(".rankPanelWpm-self") - .textContent.toUpperCase()}`; - if (raceStamp === null) raceStamp = Math.floor(Date.now() / 1000); - presenceData.startTimestamp = raceStamp; - - break; - } - default: - if ( - gameStatusLabel === "The race has ended." || - gameStatusLabel.startsWith("You finished") - ) { - presenceData.details = "Just finished with a race"; - presenceData.state = `${document - .querySelector(".rankPanelWpm-self") - .textContent.toUpperCase()}, ${ - document.querySelector( - ".tblOwnStats > tbody:nth-child(2) > tr:nth-child(3) > td:nth-child(2)" - ).textContent - } acc., ${ - document.querySelector( - ".tblOwnStats > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(2)" - ).textContent - }`; - presenceData.startTimestamp = browsingTimestamp; - } - } - } else presenceData.details = "Viewing the home page"; - }; - } else if (currentURL.hostname === "data.typeracer.com") { - /* - - Part 2 - data.typeracer.com (pit stop and misc. pages) - - */ - - switch (currentPath[0]) { - case "pit": { - switch (currentPath[1]) { - case "profile": { - presenceData.details = "Viewing a racer profile"; - presenceData.state = - document.querySelector("#profileUsername").textContent || null; - - break; - } - case "text_info": { - presenceData.details = "Viewing a text"; - presenceData.state = currentURL.searchParams.get("id"); - - break; - } - case "result": { - presenceData.details = "Viewing a race result"; - presenceData.state = `Race ${ - currentURL.searchParams.get("id").split("|")[2] - } of ${currentURL.searchParams.get("id").split("|")[1].slice(3)}`; - - break; - } - case "race_history": { - presenceData.details = "Viewing someone's race history"; - presenceData.state = currentURL.searchParams.get("user") || null; - - break; - } - case "home": { - presenceData.details = "Viewing the pit stop"; - break; - } - case "competitions": { - presenceData.details = "Viewing the competition result"; - const strong = document - .querySelector("div.themeContent > div:nth-child(5) > strong") - .textContent.trim() - .slice(0, -1) - .split(" "); - switch ( - document.querySelector("option[selected]").textContent.trim() - ) { - case "day": { - presenceData.state = strong.join(" "); - break; - } - case "week": { - presenceData.state = `${strong[1]} ${strong[2]}, ${strong[4]}`; - break; - } - case "month": { - presenceData.state = `${strong[3]} ${strong[4]}`; - break; - } - case "year": - { - [, presenceData.state] = strong; - // No default - } - break; - } - - break; - } - case "login": { - presenceData.details = "Logging in"; - break; - } - default: { - // eslint-disable-next-line no-one-time-vars/no-one-time-vars - const pageNames: { [index: string]: string } = { - // eslint-disable-next-line camelcase - upgrade_account: "Upgrade your account", - tos: "Terms of Service", - // eslint-disable-next-line camelcase - privacy_poicy: "Privacy Policy", - }; - presenceData.details = "Viewing a page"; - presenceData.state = pageNames[currentPath[1]]; - } - } - break; - } - case "misc": { - if (currentPath[1] === "about") { - presenceData.details = "Viewing a page"; - presenceData.state = "About"; - } - - break; - } - case "admin": - { - presenceData.details = "Viewing school admin pages"; - // No default - } - break; - } - } -})(); + let raceStamp: number | null = null + + if (currentURL.hostname === 'play.typeracer.com') { + updateCallback.function = (): void => { + if (document.querySelector('.gameView')) { + presenceData.details = 'Playing a race' + const gameStatusLabel = document.querySelector('.gameStatusLabel')?.textContent + + switch (gameStatusLabel) { + case 'Waiting for more people...': { + presenceData.state = 'Waiting for more people...' + if (raceStamp === null) + raceStamp = Math.floor(Date.now() / 1000) + presenceData.startTimestamp = raceStamp + + break + } + case 'The race is about to start!': { + presenceData.state = 'Counting down...' + presenceData.endTimestamp = Math.floor(Date.now() / 1000) + + Number( + document + .querySelector('.countdownPopup .time') + ?.textContent + ?.slice(1) ?? 0, + ) + raceStamp = null + + break + } + case 'The race is on! Type the text below:': + case 'Go!': { + const textBox = document.querySelector( + 'table.gameView > tbody > tr:nth-child(2) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr:nth-child(1) > td > div > div', + ) + let lettersTyped = 0 + for (const i in textBox?.children ?? []) { + if ( + typeof textBox?.children[i] !== 'number' + && typeof textBox?.children[i] !== 'function' + && getComputedStyle(textBox!.children[i]!).color + === 'rgb(153, 204, 0)' + ) { + lettersTyped += textBox!.children[i]!.textContent!.length + } + } + presenceData.state = `${ + Math.round((lettersTyped / (textBox?.textContent?.length ?? 0)) * 10000) + / 100 + }%, ${document + .querySelector('.rankPanelWpm-self') + ?.textContent + ?.toUpperCase() ?? ''}` + if (raceStamp === null) + raceStamp = Math.floor(Date.now() / 1000) + presenceData.startTimestamp = raceStamp + + break + } + default: + if ( + gameStatusLabel === 'The race has ended.' + || gameStatusLabel?.startsWith('You finished') + ) { + presenceData.details = 'Just finished with a race' + presenceData.state = `${document + .querySelector('.rankPanelWpm-self') + ?.textContent + ?.toUpperCase()}, ${ + document.querySelector( + '.tblOwnStats > tbody:nth-child(2) > tr:nth-child(3) > td:nth-child(2)', + )?.textContent + } acc., ${ + document.querySelector( + '.tblOwnStats > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(2)', + )?.textContent + }` + presenceData.startTimestamp = browsingTimestamp + } + } + } + else { + presenceData.details = 'Viewing the home page' + } + } + } + else if (currentURL.hostname === 'data.typeracer.com') { + /* + + Part 2 + data.typeracer.com (pit stop and misc. pages) + + */ + + switch (currentPath[0]) { + case 'pit': { + switch (currentPath[1]) { + case 'profile': { + presenceData.details = 'Viewing a racer profile' + presenceData.state = document.querySelector('#profileUsername')?.textContent || null + + break + } + case 'text_info': { + presenceData.details = 'Viewing a text' + presenceData.state = currentURL.searchParams.get('id') + + break + } + case 'result': { + presenceData.details = 'Viewing a race result' + presenceData.state = `Race ${ + currentURL.searchParams.get('id')?.split('|')[2] + } of ${currentURL.searchParams.get('id')?.split('|')[1].slice(3)}` + + break + } + case 'race_history': { + presenceData.details = 'Viewing someone\'s race history' + presenceData.state = currentURL.searchParams.get('user') || null + + break + } + case 'home': { + presenceData.details = 'Viewing the pit stop' + break + } + case 'competitions': { + presenceData.details = 'Viewing the competition result' + const strong = document + .querySelector('div.themeContent > div:nth-child(5) > strong') + ?.textContent + ?.trim() + .slice(0, -1) + .split(' ') + switch ( + document.querySelector('option[selected]')?.textContent?.trim() + ) { + case 'day': { + presenceData.state = strong?.join(' ') + break + } + case 'week': { + presenceData.state = `${strong?.[1]} ${strong?.[2]}, ${strong?.[4]}` + break + } + case 'month': { + presenceData.state = `${strong?.[3]} ${strong?.[4]}` + break + } + case 'year': { + [, presenceData.state] = strong ?? [] + break + } + } + + break + } + case 'login': { + presenceData.details = 'Logging in' + break + } + default: { + const pageNames: { [index: string]: string } = { + upgrade_account: 'Upgrade your account', + tos: 'Terms of Service', + privacy_poicy: 'Privacy Policy', + } + presenceData.details = 'Viewing a page' + presenceData.state = pageNames[currentPath[1]] + } + } + break + } + case 'misc': { + if (currentPath[1] === 'about') { + presenceData.details = 'Viewing a page' + presenceData.state = 'About' + } + + break + } + case 'admin': { + presenceData.details = 'Viewing school admin pages' + break + } + } + } +})() if (updateCallback.present) { - const defaultData = { ...presenceData }; - presence.on("UpdateData", async () => { - resetData(defaultData); - updateCallback.function(); - presence.setActivity(presenceData); - }); -} else { - presence.on("UpdateData", async () => { - presence.setActivity(presenceData); - }); + const defaultData = { ...presenceData } + presence.on('UpdateData', async () => { + resetData(defaultData) + updateCallback.function() + presence.setActivity(presenceData) + }) +} +else { + presence.on('UpdateData', async () => { + presence.setActivity(presenceData) + }) } diff --git "a/websites/T/T\303\274rk Hack Team/metadata.json" "b/websites/T/T\303\274rk Hack Team/metadata.json" index fe367fc59bed..57af16154eb2 100644 --- "a/websites/T/T\303\274rk Hack Team/metadata.json" +++ "b/websites/T/T\303\274rk Hack Team/metadata.json" @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "AlbaySIMSEK", - "id": "432476132609228800" - }, - "service": "Türk Hack Team", - "description": { - "en": "Türk Hack Team Turkey is one of the popular webmaster forum.", - "tr": "Türk Hack Team, Türkiye'nin popüler yazılım geliştirme forumlarından birisidir.", - "nl": "Türk Hack Team Turkije is een van de populaire webmasterforums." - }, - "url": [ - "turkhackteam.org", - "www.turkhackteam.org" - ], - "version": "1.2.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrk%20Hack%20Team/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrk%20Hack%20Team/assets/thumbnail.png", - "color": "#1c1c1c", - "category": "other", - "tags": [ - "forum", - "turkish" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "AlbaySIMSEK", + "id": "432476132609228800" + }, + "service": "Türk Hack Team", + "description": { + "en": "Türk Hack Team Turkey is one of the popular webmaster forum.", + "tr": "Türk Hack Team, Türkiye'nin popüler yazılım geliştirme forumlarından birisidir.", + "nl": "Türk Hack Team Turkije is een van de populaire webmasterforums." + }, + "url": [ + "turkhackteam.org", + "www.turkhackteam.org" + ], + "version": "1.2.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrk%20Hack%20Team/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrk%20Hack%20Team/assets/thumbnail.png", + "color": "#1c1c1c", + "category": "other", + "tags": [ + "forum", + "turkish" + ] +} diff --git "a/websites/T/T\303\274rk Hack Team/presence.ts" "b/websites/T/T\303\274rk Hack Team/presence.ts" index 9f3126e7564e..90bf3f4460d8 100644 --- "a/websites/T/T\303\274rk Hack Team/presence.ts" +++ "b/websites/T/T\303\274rk Hack Team/presence.ts" @@ -1,62 +1,68 @@ -const presence = new Presence({ clientId: "653578846448123906" }), - pages: { [key: string]: string } = { - "/usercp.php": "Kullanıcı Profili", - "/ihbar/": "İhbar Portalı", - }; +const presence = new Presence({ clientId: '653578846448123906' }) +const pages: { [key: string]: string } = { + '/usercp.php': 'Kullanıcı Profili', + '/ihbar/': 'İhbar Portalı', +} -presence.on("UpdateData", async () => { - const page = document.location.pathname, - kategori = document.querySelector( - "#inlinemodform > table.tborder.respborder > tbody > tr > td.tcat" - ), - CevapButon = document.querySelector( - "body > div:nth-child(5) > div.showth-top-bor > div > div:nth-child(1) > a" - ), - login = document.querySelector( - "body > div:nth-child(3) > table.tborder > tbody > tr:nth-child(2) > td > div > div > form > fieldset > legend" - ), - register = document.querySelector( - "body > div:nth-child(3) > form > table > tbody > tr:nth-child(2) > td > div.panel > div > fieldset > legend" - ), - report = document.querySelector( - "body > div:nth-child(5) > form > table > tbody > tr:nth-child(1) > td" - ), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrk%20Hack%20Team/assets/logo.png", - startTimestamp: Math.floor(Date.now() / 1000), - }; +presence.on('UpdateData', async () => { + const page = document.location.pathname + const kategori = document.querySelector( + '#inlinemodform > table.tborder.respborder > tbody > tr > td.tcat', + ) + const CevapButon = document.querySelector( + 'body > div:nth-child(5) > div.showth-top-bor > div > div:nth-child(1) > a', + ) + const login = document.querySelector( + 'body > div:nth-child(3) > table.tborder > tbody > tr:nth-child(2) > td > div > div > form > fieldset > legend', + ) + const register = document.querySelector( + 'body > div:nth-child(3) > form > table > tbody > tr:nth-child(2) > td > div.panel > div > fieldset > legend', + ) + const report = document.querySelector( + 'body > div:nth-child(5) > form > table > tbody > tr:nth-child(1) > td', + ) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrk%20Hack%20Team/assets/logo.png', + startTimestamp: Math.floor(Date.now() / 1000), + } - if (kategori && kategori.textContent !== "") { - presenceData.details = "Bir kategoriyi inceliyor:"; - [, presenceData.state] = kategori.textContent.split(":"); - } else if (CevapButon && CevapButon.textContent !== "") { - presenceData.details = "Bir konuyu inceliyor:"; - presenceData.state = document.querySelector( - "body > div:nth-child(6) > h1" - ).textContent; - } else if (login && login.textContent === "Giriş") { - presenceData.details = "Kullanıcı Paneli"; - presenceData.state = "Giriş Yap"; - } else if ( - register && - register.textContent === "Lütfen Doğum tarihinizi verin" - ) { - presenceData.details = "Kullanıcı Paneli"; - presenceData.state = "Kayıt Ol"; - } else if ( - report.textContent.toLowerCase().includes("mesaji moderatöre bi̇ldi̇r") - ) { - presenceData.details = "Bir Mesajı Moderatöre Bildiriyor"; - presenceData.state = `Forum: ${report.textContent.split(":")[1]}`; - } else if (pages[page] || pages[page.slice(0, -1)]) { - presenceData.details = "Forumda geziniyor:"; - presenceData.state = pages[page] || pages[page.slice(0, -1)]; - } else { - presenceData.details = "Forumda geziniyor:"; - presenceData.state = "Ana Sayfa"; - } + if (kategori && kategori.textContent !== '') { + presenceData.details = 'Bir kategoriyi inceliyor:'; + [, presenceData.state] = kategori.textContent?.split(':') ?? [] + } + else if (CevapButon && CevapButon.textContent !== '') { + presenceData.details = 'Bir konuyu inceliyor:' + presenceData.state = document.querySelector( + 'body > div:nth-child(6) > h1', + )?.textContent + } + else if (login && login.textContent === 'Giriş') { + presenceData.details = 'Kullanıcı Paneli' + presenceData.state = 'Giriş Yap' + } + else if ( + register + && register.textContent === 'Lütfen Doğum tarihinizi verin' + ) { + presenceData.details = 'Kullanıcı Paneli' + presenceData.state = 'Kayıt Ol' + } + else if ( + report?.textContent?.toLowerCase().includes('mesaji moderatöre bi̇ldi̇r') + ) { + presenceData.details = 'Bir Mesajı Moderatöre Bildiriyor' + presenceData.state = `Forum: ${report.textContent.split(':')[1]}` + } + else if (pages[page] || pages[page.slice(0, -1)]) { + presenceData.details = 'Forumda geziniyor:' + presenceData.state = pages[page] || pages[page.slice(0, -1)] + } + else { + presenceData.details = 'Forumda geziniyor:' + presenceData.state = 'Ana Sayfa' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git "a/websites/T/T\303\274rkAnimeTV/iframe.ts" "b/websites/T/T\303\274rkAnimeTV/iframe.ts" index f19b8efc6a38..6a304d50b90a 100644 --- "a/websites/T/T\303\274rkAnimeTV/iframe.ts" +++ "b/websites/T/T\303\274rkAnimeTV/iframe.ts" @@ -1,13 +1,13 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", async () => { - const video: HTMLVideoElement = document.querySelector("video"); +iframe.on('UpdateData', async () => { + const video = document.querySelector('video') - if (video) { - iframe.send({ - paused: video.paused, - duration: video.duration, - currentTime: video.currentTime, - }); - } -}); + if (video) { + iframe.send({ + paused: video.paused, + duration: video.duration, + currentTime: video.currentTime, + }) + } +}) diff --git "a/websites/T/T\303\274rkAnimeTV/metadata.json" "b/websites/T/T\303\274rkAnimeTV/metadata.json" index c33a0a25f5b1..631e46acec4c 100644 --- "a/websites/T/T\303\274rkAnimeTV/metadata.json" +++ "b/websites/T/T\303\274rkAnimeTV/metadata.json" @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kabal", - "id": "269581360316940299" - }, - "service": "TürkAnimeTV", - "description": { - "tr": "TürkAnimeTV, türkçe altyazılı anime izleyebileceğiniz bir site.", - "en": "TürkAnimeTV is a site where you can watch anime with Turkish subtitles.", - "nl": "TürkAnimeTV is een site waar je anime kunt kijken met Turkse ondertitels." - }, - "url": "www.turkanime.co", - "version": "1.1.31", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrkAnimeTV/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrkAnimeTV/assets/thumbnail.png", - "color": "#3398b9", - "category": "videos", - "tags": [ - "türk", - "anime", - "video" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Kabal", + "id": "269581360316940299" + }, + "service": "TürkAnimeTV", + "description": { + "tr": "TürkAnimeTV, türkçe altyazılı anime izleyebileceğiniz bir site.", + "en": "TürkAnimeTV is a site where you can watch anime with Turkish subtitles.", + "nl": "TürkAnimeTV is een site waar je anime kunt kijken met Turkse ondertitels." + }, + "url": "www.turkanime.co", + "version": "1.1.31", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrkAnimeTV/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrkAnimeTV/assets/thumbnail.png", + "color": "#3398b9", + "category": "videos", + "tags": [ + "türk", + "anime", + "video" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git "a/websites/T/T\303\274rkAnimeTV/presence.ts" "b/websites/T/T\303\274rkAnimeTV/presence.ts" index a99ed00aac96..8fd0350b747c 100644 --- "a/websites/T/T\303\274rkAnimeTV/presence.ts" +++ "b/websites/T/T\303\274rkAnimeTV/presence.ts" @@ -1,104 +1,105 @@ interface Video { - paused: boolean; - duration: number; - currentTime: number; + paused: boolean + duration: number + currentTime: number } -const presence = new Presence({ clientId: "666074265233260555" }), - strings = presence.getStrings({ - playing: "general.playing", - paused: "general.paused", - browsing: "general.browsing", - viewAnime: "general.viewAnime", - watching: "general.watching", - episode: "general.episode", - watchEpisode: "general.buttonViewEpisode", - anime: "general.anime", - }); +const presence = new Presence({ clientId: '666074265233260555' }) +const strings = presence.getStrings({ + playing: 'general.playing', + paused: 'general.paused', + browsing: 'general.browsing', + viewAnime: 'general.viewAnime', + watching: 'general.watching', + episode: 'general.episode', + watchEpisode: 'general.buttonViewEpisode', + anime: 'general.anime', +}) -let video: Video; +let video: Video -presence.on("iFrameData", (msg: Video) => { - video = msg; -}); +presence.on('iFrameData', (msg: unknown) => { + video = msg as Video +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrkAnimeTV/assets/logo.png", - }, - title = - document - .querySelector( - "#arkaplan > div:nth-child(3) > div.col-xs-8 > div > div:nth-child(3) > div > div.panel-ust > ol > li:nth-child(1) > a" - ) - ?.textContent.trim() || null, - ep = document - .querySelector( - "#arkaplan > div:nth-child(3) > div.col-xs-8 > div > div:nth-child(3) > div > div.panel-ust > ol > li:nth-child(2) > a" - ) - ?.textContent.trim(), - animeTitle = document - .querySelector("#detayPaylas > div > div.panel-ust > div") - ?.textContent.trim(), - animePage = - document - .querySelector( - "#arkaplan > div:nth-child(3) > div.col-xs-8 > div > div:nth-child(3) > div > div.panel-ust > ol > li:nth-child(1) > a" - ) - ?.getAttribute("href") || document.URL; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/T%C3%BCrkAnimeTV/assets/logo.png', + } + const title = document + .querySelector( + '#arkaplan > div:nth-child(3) > div.col-xs-8 > div > div:nth-child(3) > div > div.panel-ust > ol > li:nth-child(1) > a', + ) + ?.textContent + ?.trim() || null + const ep = document + .querySelector( + '#arkaplan > div:nth-child(3) > div.col-xs-8 > div > div:nth-child(3) > div > div.panel-ust > ol > li:nth-child(2) > a', + ) + ?.textContent + ?.trim() + const animeTitle = document + .querySelector('#detayPaylas > div > div.panel-ust > div') + ?.textContent + ?.trim() + const animePage = document + .querySelector( + '#arkaplan > div:nth-child(3) > div.col-xs-8 > div > div:nth-child(3) > div > div.panel-ust > ol > li:nth-child(1) > a', + ) + ?.getAttribute('href') || document.URL - // Series & Movies - if (title && ep) { - const epNum = ep.match(/[0-9]+\. Bölüm/g); + // Series & Movies + if (title && ep) { + const epNum = ep.match(/\d+\. Bölüm/g) - presenceData.details = `${(await strings).watching} ${title}`; - if (epNum) { - presenceData.state = `${(await strings).episode} ${ - epNum[0].split(".")[0] - }`; - } + presenceData.details = `${(await strings).watching} ${title}` + if (epNum) { + presenceData.state = `${(await strings).episode} ${ + epNum[0].split('.')[0] + }` + } - presenceData.buttons = [ - { - label: (await strings).watchEpisode, - url: document.URL.split("&")[0], - }, - { - label: (await strings).anime, - url: `https://www.turkanime.net/${animePage}`, - }, - ]; - } else if (window.location.pathname.startsWith("/anime/") && animeTitle) { - // About Anime Page - presenceData.details = (await strings).viewAnime; - presenceData.state = animeTitle; - presenceData.buttons = [ - { - label: (await strings).anime, - url: animePage, - }, - ]; - } else { - // Browsing - presenceData.details = (await strings).browsing; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } + presenceData.buttons = [ + { + label: (await strings).watchEpisode, + url: document.URL.split('&')[0], + }, + { + label: (await strings).anime, + url: `https://www.turkanime.net/${animePage}`, + }, + ] + } + else if (window.location.pathname.startsWith('/anime/') && animeTitle) { + // About Anime Page + presenceData.details = (await strings).viewAnime + presenceData.state = animeTitle + presenceData.buttons = [ + { + label: (await strings).anime, + url: animePage, + }, + ] + } + else { + // Browsing + presenceData.details = (await strings).browsing + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } - if (video) { - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? (await strings).paused - : (await strings).playing; + if (video) { + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? (await strings).paused + : (await strings).playing - if (!video.paused && video.duration) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ); - } - } + if (!video.paused && video.duration) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/taiga Bot/metadata.json b/websites/T/taiga Bot/metadata.json index 0426524f1e4e..9576d7e76902 100644 --- a/websites/T/taiga Bot/metadata.json +++ b/websites/T/taiga Bot/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "CRUGG", - "id": "228965621478588416" - }, - "service": "taiga Bot", - "description": { - "en": "taiga is a Discord Bot with many features like Virtual Trading Cards, an economy system and in the future even a Plugin Marketplace", - "de": "taiga ist ein Discord Bot mit vielen Funktionen wie virtuellen Sammelkarten, ein Wirtschaftssystem und in der Zukunft ein Pluginmarktplatz", - "fr": "taiga est un Bot Discord avec plein de fonctionnalités comme des Cartes à Jouer Virtuelles, un système d'économie et même un Marché aux Plugin à venir", - "nl": "taiga is een Discord Bot met vele kenmerken zoals Virtuele Ruil Kaarten, een economie systeem en in de toekomst zelfs een Plugin Marketplace." - }, - "url": "taigabot.net", - "version": "3.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/taiga%20Bot/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/taiga%20Bot/assets/thumbnail.png", - "color": "#ff006d", - "category": "other", - "tags": [ - "discord", - "bot", - "taiga" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "CRUGG", + "id": "228965621478588416" + }, + "service": "taiga Bot", + "description": { + "en": "taiga is a Discord Bot with many features like Virtual Trading Cards, an economy system and in the future even a Plugin Marketplace", + "de": "taiga ist ein Discord Bot mit vielen Funktionen wie virtuellen Sammelkarten, ein Wirtschaftssystem und in der Zukunft ein Pluginmarktplatz", + "fr": "taiga est un Bot Discord avec plein de fonctionnalités comme des Cartes à Jouer Virtuelles, un système d'économie et même un Marché aux Plugin à venir", + "nl": "taiga is een Discord Bot met vele kenmerken zoals Virtuele Ruil Kaarten, een economie systeem en in de toekomst zelfs een Plugin Marketplace." + }, + "url": "taigabot.net", + "version": "3.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/taiga%20Bot/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/taiga%20Bot/assets/thumbnail.png", + "color": "#ff006d", + "category": "other", + "tags": [ + "discord", + "bot", + "taiga" + ] +} diff --git a/websites/T/taiga Bot/presence.ts b/websites/T/taiga Bot/presence.ts index b27a199af6de..2d6e47e64f7b 100644 --- a/websites/T/taiga Bot/presence.ts +++ b/websites/T/taiga Bot/presence.ts @@ -1,28 +1,28 @@ const presence = new Presence({ - clientId: "682593223948238849", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '682593223948238849', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) function getRow(row: number) { - const metas = document.querySelectorAll("meta"); - for (const meta of metas) { - if (meta.getAttribute("property") === `premid:row${row}`) - return meta.getAttribute("content"); - } - return; + const metas = document.querySelectorAll('meta') + for (const meta of metas) { + if (meta.getAttribute('property') === `premid:row${row}`) + return meta.getAttribute('content') + } } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/T/taiga%20Bot/assets/logo.png", - startTimestamp: browsingTimestamp, - }; - presenceData.details = getRow(1); - presenceData.state = getRow(2); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/T/taiga%20Bot/assets/logo.png', + startTimestamp: browsingTimestamp, + } + presenceData.details = getRow(1) + presenceData.state = getRow(2) - if (!presenceData.details) delete presenceData.details; - if (!presenceData.state) delete presenceData.state; + if (!presenceData.details) + delete presenceData.details + if (!presenceData.state) + delete presenceData.state - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/T/top.gg/metadata.json b/websites/T/top.gg/metadata.json index b28a8d97f4a3..afec0fb9b149 100644 --- a/websites/T/top.gg/metadata.json +++ b/websites/T/top.gg/metadata.json @@ -1,32 +1,32 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "marco_rennmaus", - "id": "321714991050784770" - }, - "contributors": [ - { - "name": "Eren", - "id": "478937019758673931" - } - ], - "service": "top.gg", - "description": { - "en": "Rich Presence for top.gg - The biggest Discord Bot List and more", - "tr": "top.gg, en büyük ve en gelişmiş Discord bot listesidir.", - "de": "Rich Presence für top.gg - Die größte Discord Bot Liste und mehr", - "nl": "Rich Presence voor top.gg - De grootste Discord Bot-lijst en meer" - }, - "url": "top.gg", - "version": "1.3.31", - "logo": "https://cdn.rcd.gg/PreMiD/websites/T/top.gg/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/top.gg/assets/thumbnail.png", - "color": "#7289DA", - "category": "other", - "tags": [ - "discord", - "bot", - "gaming" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "marco_rennmaus", + "id": "321714991050784770" + }, + "contributors": [ + { + "name": "Eren", + "id": "478937019758673931" + } + ], + "service": "top.gg", + "description": { + "en": "Rich Presence for top.gg - The biggest Discord Bot List and more", + "tr": "top.gg, en büyük ve en gelişmiş Discord bot listesidir.", + "de": "Rich Presence für top.gg - Die größte Discord Bot Liste und mehr", + "nl": "Rich Presence voor top.gg - De grootste Discord Bot-lijst en meer" + }, + "url": "top.gg", + "version": "1.3.31", + "logo": "https://cdn.rcd.gg/PreMiD/websites/T/top.gg/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/top.gg/assets/thumbnail.png", + "color": "#7289DA", + "category": "other", + "tags": [ + "discord", + "bot", + "gaming" + ] +} diff --git a/websites/T/top.gg/presence.ts b/websites/T/top.gg/presence.ts index f2f4bae6d0fc..1dbfcf783c02 100644 --- a/websites/T/top.gg/presence.ts +++ b/websites/T/top.gg/presence.ts @@ -1,143 +1,172 @@ const presence = new Presence({ - clientId: "629380028576301093", -}); + clientId: '629380028576301093', +}) const enum Assets { - Dblstaff = "https://cdn.rcd.gg/PreMiD/websites/T/top.gg/assets/0.png", - Dslregular = "https://cdn.rcd.gg/PreMiD/websites/T/top.gg/assets/1.png", - Logo = "https://cdn.rcd.gg/PreMiD/websites/T/top.gg/assets/logo.png", + Dblstaff = 'https://cdn.rcd.gg/PreMiD/websites/T/top.gg/assets/0.png', + Dslregular = 'https://cdn.rcd.gg/PreMiD/websites/T/top.gg/assets/1.png', + Logo = 'https://cdn.rcd.gg/PreMiD/websites/T/top.gg/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }; - presenceData.details = "Viewing Page:"; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } + presenceData.details = 'Viewing Page:' - //Discord Bot List - if (window.location.pathname.startsWith("/moderation")) { - presenceData.details = "Viewing DBL Staff section:"; - presenceData.largeImageKey = Assets.Dblstaff; + // Discord Bot List + if (window.location.pathname.startsWith('/moderation')) { + presenceData.details = 'Viewing DBL Staff section:' + presenceData.largeImageKey = Assets.Dblstaff - switch (window.location.pathname) { - case "/moderation": { - const personalquota = - document.querySelectorAll(".quotaindiv")[0].textContent; + switch (window.location.pathname) { + case '/moderation': { + const personalquota = document.querySelectorAll('.quotaindiv')[0].textContent - presenceData.state = `Reviewed ${personalquota.substring( - personalquota.indexOf("reviewed") + 9, - personalquota.indexOf("/") - )} bots this week`; + presenceData.state = `Reviewed ${personalquota?.substring( + personalquota.indexOf('reviewed') + 9, + personalquota.indexOf('/'), + )} bots this week` - break; - } - case "/moderation/approve": { - presenceData.state = "Verification Queue"; - break; - } - case "/moderation/certify": { - presenceData.state = "Certification Queue"; - break; - } - case "/moderation/reports": { - presenceData.state = "Reports Queue"; - break; - } - case "/moderation/reviews": { - presenceData.state = "Reviews Dashboard"; - break; - } - default: - if (window.location.pathname.startsWith("/moderation/decline")) { - presenceData.state = - document.querySelector("#botlistitle").textContent; - } - } - } else if (window.location.pathname.startsWith("/bot/")) { - if (window.location.pathname.endsWith("/edit")) { - presenceData.details = "Editing a Discord bot:"; - presenceData.state = document - .querySelector("#botlistitle") - .textContent.substring(8); - } else if (window.location.pathname.endsWith("/vote")) { - presenceData.details = "Voting for a Discord bot:"; - presenceData.state = document - .querySelector("#totalContent > div > p") - .textContent.trim(); - } else if (window.location.pathname.endsWith("/report")) { - //Might not be the smartest idea to expose someone reporting bots - presenceData.state = "Discord Bot List"; - } else if (window.location.pathname.endsWith("/new")) - presenceData.state = "Add a bot"; - else if (document.querySelector(".entity-queue-message__indicator")) { - presenceData.details = `Viewing a Discord bot: ${document - .querySelector(".entity-header__name") - .textContent.trim()}`; - presenceData.largeImageKey = Assets.Dblstaff; - presenceData.state = "Bot isn't approved yet"; - } else { - presenceData.details = "Viewing a Discord bot:"; - presenceData.state = document - .querySelector(".entity-header__name") - .textContent.trim(); - } - } else if (window.location.pathname.startsWith("/list/")) { - presenceData.details = "Viewing a list of Discord bots:"; - presenceData.state = document - .querySelector("#botlistitle") - .textContent.split("-")[0] - .trim(); - } else if (window.location.pathname.startsWith("/tag/")) { - presenceData.details = "Viewing Discord bots with tag:"; - presenceData.state = document - .querySelector("#botlistitle") - .textContent.split("-")[0] - .trim(); - } else if ( - window.location.pathname.startsWith("/user/") || - window.location.pathname === "/me" - ) { - presenceData.details = "Viewing a profile:"; - presenceData.state = document.querySelector(".header").textContent; - } else if (window.location.pathname.startsWith("/api/docs")) - presenceData.state = "Discord Bot List API Documentation"; - //Discord Server List - else if (window.location.pathname.startsWith("/servers")) { - presenceData.largeImageKey = Assets.Dslregular; - if ( - window.location.pathname.startsWith("/servers/list/") || - window.location.pathname.startsWith("/servers/tag/") - ) { - presenceData.details = "Viewing:"; - presenceData.state = document.querySelector("#botlistitle").textContent; - } else if (document.querySelector(".entity-header__name")) { - if (document.querySelectorAll(".entity-header__button").length < 2) { - presenceData.details = - "Viewing a Discord Server | Server isn't published yet."; - presenceData.state = document - .querySelector(".entity-header__name") - .textContent.trim(); - } else presenceData.details = "Viewing a Discord Server:"; - presenceData.state = document - .querySelector(".entity-header__name") - .textContent.trim(); - } else if (window.location.pathname.endsWith("/edit")) { - presenceData.details = "Editing a Discord Server:"; - presenceData.state = document - .querySelector("#botlistitle") - .textContent.substring(8); - } else if (window.location.pathname.startsWith("/servers/new")) - presenceData.details = "Adding a new Discord server..."; - else if (window.location.pathname.startsWith("/servers/me")) - presenceData.state = "My servers"; - else presenceData.state = "Discord Servers"; - } else if (document.querySelector("#botlistitle")) { - //If it doesn't fit to anything - presenceData.state = document.querySelector("#botlistitle").textContent; - } else { - //If it really finds nothing - presenceData.details = "Viewing something..."; - } + break + } + case '/moderation/approve': { + presenceData.state = 'Verification Queue' + break + } + case '/moderation/certify': { + presenceData.state = 'Certification Queue' + break + } + case '/moderation/reports': { + presenceData.state = 'Reports Queue' + break + } + case '/moderation/reviews': { + presenceData.state = 'Reviews Dashboard' + break + } + default: + if (window.location.pathname.startsWith('/moderation/decline')) { + presenceData.state = document.querySelector('#botlistitle')?.textContent + } + } + } + else if (window.location.pathname.startsWith('/bot/')) { + if (window.location.pathname.endsWith('/edit')) { + presenceData.details = 'Editing a Discord bot:' + presenceData.state = document + .querySelector('#botlistitle') + ?.textContent + ?.substring(8) + } + else if (window.location.pathname.endsWith('/vote')) { + presenceData.details = 'Voting for a Discord bot:' + presenceData.state = document + .querySelector('#totalContent > div > p') + ?.textContent + ?.trim() + } + else if (window.location.pathname.endsWith('/report')) { + // Might not be the smartest idea to expose someone reporting bots + presenceData.state = 'Discord Bot List' + } + else if (window.location.pathname.endsWith('/new')) { + presenceData.state = 'Add a bot' + } + else if (document.querySelector('.entity-queue-message__indicator')) { + presenceData.details = `Viewing a Discord bot: ${document + .querySelector('.entity-header__name') + ?.textContent + ?.trim()}` + presenceData.largeImageKey = Assets.Dblstaff + presenceData.state = 'Bot isn\'t approved yet' + } + else { + presenceData.details = 'Viewing a Discord bot:' + presenceData.state = document + .querySelector('.entity-header__name') + ?.textContent + ?.trim() + } + } + else if (window.location.pathname.startsWith('/list/')) { + presenceData.details = 'Viewing a list of Discord bots:' + presenceData.state = document + .querySelector('#botlistitle') + ?.textContent + ?.split('-')[0] + .trim() + } + else if (window.location.pathname.startsWith('/tag/')) { + presenceData.details = 'Viewing Discord bots with tag:' + presenceData.state = document + .querySelector('#botlistitle') + ?.textContent + ?.split('-')[0] + .trim() + } + else if ( + window.location.pathname.startsWith('/user/') + || window.location.pathname === '/me' + ) { + presenceData.details = 'Viewing a profile:' + presenceData.state = document.querySelector('.header')?.textContent + } + else if (window.location.pathname.startsWith('/api/docs')) { + presenceData.state = 'Discord Bot List API Documentation' + } + // Discord Server List + else if (window.location.pathname.startsWith('/servers')) { + presenceData.largeImageKey = Assets.Dslregular + if ( + window.location.pathname.startsWith('/servers/list/') + || window.location.pathname.startsWith('/servers/tag/') + ) { + presenceData.details = 'Viewing:' + presenceData.state = document.querySelector('#botlistitle')?.textContent + } + else if (document.querySelector('.entity-header__name')) { + if (document.querySelectorAll('.entity-header__button').length < 2) { + presenceData.details = 'Viewing a Discord Server | Server isn\'t published yet.' + presenceData.state = document + .querySelector('.entity-header__name') + ?.textContent + ?.trim() + } + else { + presenceData.details = 'Viewing a Discord Server:' + } + presenceData.state = document + .querySelector('.entity-header__name') + ?.textContent + ?.trim() + } + else if (window.location.pathname.endsWith('/edit')) { + presenceData.details = 'Editing a Discord Server:' + presenceData.state = document + .querySelector('#botlistitle') + ?.textContent + ?.substring(8) + } + else if (window.location.pathname.startsWith('/servers/new')) { + presenceData.details = 'Adding a new Discord server...' + } + else if (window.location.pathname.startsWith('/servers/me')) { + presenceData.state = 'My servers' + } + else { + presenceData.state = 'Discord Servers' + } + } + else if (document.querySelector('#botlistitle')) { + // If it doesn't fit to anything + presenceData.state = document.querySelector('#botlistitle')?.textContent + } + else { + // If it really finds nothing + presenceData.details = 'Viewing something...' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +})