diff --git a/websites/C/CDKeys/metadata.json b/websites/C/CDKeys/metadata.json index 5ce9b1ed9f71..e4d5bd90e86f 100644 --- a/websites/C/CDKeys/metadata.json +++ b/websites/C/CDKeys/metadata.json @@ -1,40 +1,40 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dark_Ville", - "id": "638080361179512853" - }, - "service": "CDKeys", - "description": { - "nl": "Hier bij CDKeys.com zijn we gespecialiseerd in het verstrekken van de beste digitale codes voor de populairste games. Je hoeft niet meer de volle prijs te betalen of te wachten op een spel. Wij combineren de laagste prijzen met een snelle digitale levering, zodat je snel kunt beginnen met het spelen van je favoriete games.", - "en": "Here at CDKeys.com, we specialise in providing you with the best digital codes for the hottest games. There’s no need to pay full price or wait for a game again. We combine the lowest prices with rapid digital delivery, so you can start playing your favourite games, fast." - }, - "url": "www.cdkeys.com", - "version": "1.1.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CDKeys/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CDKeys/assets/thumbnail.png", - "color": "#1F143D", - "category": "other", - "tags": [ - "cdkeys", - "games", - "key", - "buy", - "game-key" - ], - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - }, - { - "id": "cover", - "title": "Show Cover", - "icon": "fad fa-album", - "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": "CDKeys", + "description": { + "nl": "Hier bij CDKeys.com zijn we gespecialiseerd in het verstrekken van de beste digitale codes voor de populairste games. Je hoeft niet meer de volle prijs te betalen of te wachten op een spel. Wij combineren de laagste prijzen met een snelle digitale levering, zodat je snel kunt beginnen met het spelen van je favoriete games.", + "en": "Here at CDKeys.com, we specialise in providing you with the best digital codes for the hottest games. There’s no need to pay full price or wait for a game again. We combine the lowest prices with rapid digital delivery, so you can start playing your favourite games, fast." + }, + "url": "www.cdkeys.com", + "version": "1.1.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CDKeys/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CDKeys/assets/thumbnail.png", + "color": "#1F143D", + "category": "other", + "tags": [ + "cdkeys", + "games", + "key", + "buy", + "game-key" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + }, + { + "id": "cover", + "title": "Show Cover", + "icon": "fad fa-album", + "value": true + } + ] +} diff --git a/websites/C/CDKeys/presence.ts b/websites/C/CDKeys/presence.ts index 27c22e9154fd..7eb8849b7e3d 100644 --- a/websites/C/CDKeys/presence.ts +++ b/websites/C/CDKeys/presence.ts @@ -1,91 +1,101 @@ const presence = new Presence({ - clientId: "940892975502856232", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '940892975502856232', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CDKeys/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, href } = document.location, - [buttons, covers] = await Promise.all([ - presence.getSetting("buttons"), - presence.getSetting("cover"), - ]), - search = document.querySelector('[id="search"]'), - active = document.querySelector('[class="navigation__link current"]'), - series = document.querySelector( - "#maincontent > div.columns > div > div.wrap.cms-content" - ), - game = document.querySelector( - "#maincontent > div.pathname-title-wrapper > h1 > span" - ); - if (search?.value) { - presenceData.details = "Searching for"; - presenceData.state = search.value; - presenceData.smallImageKey = Assets.Search; - } else if (game) { - presenceData.buttons = [ - { - label: "View Game", - url: href, - }, - ]; - presenceData.largeImageKey = - document - .querySelector('[alt="main product photo"]') - ?.getAttribute("src") ?? "logo"; - presenceData.details = "Viewing product"; - presenceData.state = game.textContent; - } else if (document.querySelector("#product-addtocart-button")) { - presenceData.largeImageKey = - document - .querySelector('[alt="main product photo"]') - ?.getAttribute("src") ?? "logo"; - presenceData.buttons = [ - { - label: "View Product", - url: href, - }, - ]; - presenceData.details = "Viewing product"; - presenceData.state = document.querySelector( - "meta[property='og:title']" - ).content; - } else if (series) { - presenceData.buttons = [ - { - label: "View Product Series", - url: href, - }, - ]; - presenceData.details = "Viewing product series"; - presenceData.state = series.querySelector('[alt*=" "]').getAttribute("alt"); - } else if (active || pathname.includes("/coming-soon")) { - presenceData.buttons = [ - { - label: "View Category", - url: href, - }, - ]; - presenceData.details = "Viewing Category:"; - presenceData.state = active?.textContent ?? "Coming soon"; - } else if (pathname.includes("-sale")) { - presenceData.details = - document.querySelector('[name="title"]').content; - } else if (pathname.includes("order/history")) - presenceData.details = "Order History"; - else if (pathname.includes("/cart")) presenceData.details = "Cart"; - else if (pathname === "/") presenceData.details = "Home page"; - else if (pathname.includes("/wishlist")) presenceData.details = "Wishlist"; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CDKeys/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, href } = document.location + const [buttons, covers] = await Promise.all([ + presence.getSetting('buttons'), + presence.getSetting('cover'), + ]) + const search = document.querySelector('[id="search"]') + const active = document.querySelector('[class="navigation__link current"]') + const series = document.querySelector( + '#maincontent > div.columns > div > div.wrap.cms-content', + ) + const game = document.querySelector( + '#maincontent > div.pathname-title-wrapper > h1 > span', + ) + if (search?.value) { + presenceData.details = 'Searching for' + presenceData.state = search.value + presenceData.smallImageKey = Assets.Search + } + else if (game) { + presenceData.buttons = [ + { + label: 'View Game', + url: href, + }, + ] + presenceData.largeImageKey = document + .querySelector('[alt="main product photo"]') + ?.getAttribute('src') ?? 'logo' + presenceData.details = 'Viewing product' + presenceData.state = game.textContent + } + else if (document.querySelector('#product-addtocart-button')) { + presenceData.largeImageKey = document + .querySelector('[alt="main product photo"]') + ?.getAttribute('src') ?? 'logo' + presenceData.buttons = [ + { + label: 'View Product', + url: href, + }, + ] + presenceData.details = 'Viewing product' + presenceData.state = document.querySelector( + 'meta[property=\'og:title\']', + )?.content + } + else if (series) { + presenceData.buttons = [ + { + label: 'View Product Series', + url: href, + }, + ] + presenceData.details = 'Viewing product series' + presenceData.state = series.querySelector('[alt*=" "]')?.getAttribute('alt') + } + else if (active || pathname.includes('/coming-soon')) { + presenceData.buttons = [ + { + label: 'View Category', + url: href, + }, + ] + presenceData.details = 'Viewing Category:' + presenceData.state = active?.textContent ?? 'Coming soon' + } + else if (pathname.includes('-sale')) { + presenceData.details = document.querySelector('[name="title"]')?.content + } + else if (pathname.includes('order/history')) { + presenceData.details = 'Order History' + } + else if (pathname.includes('/cart')) { + presenceData.details = 'Cart' + } + else if (pathname === '/') { + presenceData.details = 'Home page' + } + else if (pathname.includes('/wishlist')) { + presenceData.details = 'Wishlist' + } - if (!buttons) delete presenceData.buttons; - if (!covers) { - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/C/CDKeys/assets/logo.png"; - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (!buttons) + delete presenceData.buttons + if (!covers) { + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/C/CDKeys/assets/logo.png' + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/CHIP Online/metadata.json b/websites/C/CHIP Online/metadata.json index e27224ed40aa..f7a516b7b9e8 100644 --- a/websites/C/CHIP Online/metadata.json +++ b/websites/C/CHIP Online/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Eren", - "id": "478937019758673931" - }, - "service": "CHIP Online", - "description": { - "tr": "Teknoloji/spor/gündem ve insanların blog oluşturduğu, Türkiye'de popüler bir site.", - "en": "CHIP Online is the independent web portal of the CHIP brand.", - "nl": "CHIP Online is het onafhankelijke webportaal van het merk CHIP.", - "vi_VN": "CHIP Online là cổng trang web độc lập của thương hiệu CHIP." - }, - "url": "www.chip.com.tr", - "version": "1.4.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CHIP%20Online/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CHIP%20Online/assets/thumbnail.png", - "color": "#F10C0C", - "category": "other", - "tags": [ - "news", - "turkish" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Eren", + "id": "478937019758673931" + }, + "service": "CHIP Online", + "description": { + "tr": "Teknoloji/spor/gündem ve insanların blog oluşturduğu, Türkiye'de popüler bir site.", + "en": "CHIP Online is the independent web portal of the CHIP brand.", + "nl": "CHIP Online is het onafhankelijke webportaal van het merk CHIP.", + "vi_VN": "CHIP Online là cổng trang web độc lập của thương hiệu CHIP." + }, + "url": "www.chip.com.tr", + "version": "1.4.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CHIP%20Online/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CHIP%20Online/assets/thumbnail.png", + "color": "#F10C0C", + "category": "other", + "tags": [ + "news", + "turkish" + ] +} diff --git a/websites/C/CHIP Online/presence.ts b/websites/C/CHIP Online/presence.ts index 8964286737df..38db8e48bc6e 100644 --- a/websites/C/CHIP Online/presence.ts +++ b/websites/C/CHIP Online/presence.ts @@ -1,46 +1,51 @@ const presence = new Presence({ - clientId: "651438286962688044", -}); + clientId: '651438286962688044', +}) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CHIP%20Online/assets/logo.png", - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CHIP%20Online/assets/logo.png', + } - if (window.location.pathname.startsWith("/haber/")) { - presenceData.details = "Bir haberi okuyor:"; - presenceData.state = document.querySelector( - "#colana > article > h1" - ).textContent; - } else if (window.location.pathname.endsWith("video/")) { - presenceData.details = "Bütün videolara göz atıyor."; - presenceData.state = "CHIP Online"; - } else if (window.location.pathname.endsWith("haber/")) { - presenceData.state = "Bütün haberlere göz atıyor."; - presenceData.details = "CHIP Online"; - } else if (window.location.pathname.endsWith("inceleme/")) { - presenceData.state = "Bütün incelemelere göz atıyor."; - presenceData.details = "CHIP Online"; - } else if (window.location.pathname.startsWith("/inceleme/")) { - presenceData.state = - document.querySelector("#anacontainer > h1").textContent; - presenceData.details = "Bir incelemeyi okuyor:"; - } else if (window.location.pathname.startsWith("/blog/")) { - presenceData.state = - document.querySelector("#article-body > h1").textContent; - presenceData.details = "Bir blog okuyor:"; - } else if (window.location.pathname.endsWith("forum/")) - presenceData.details = "Tüm forumlara göz atıyor."; - else if (window.location.pathname.endsWith("canli/")) { - presenceData.state = "CHIP Online"; - presenceData.details = "Tüm Tech-Talk arşivine göz atıyor."; - } else if (window.location.pathname.startsWith("/forum/")) { - presenceData.state = "Adlı konuyu/gönderiyi okuyor."; - presenceData.details = - document.querySelector("#forumwrap > h1").textContent; - } + if (window.location.pathname.startsWith('/haber/')) { + presenceData.details = 'Bir haberi okuyor:' + presenceData.state = document.querySelector( + '#colana > article > h1', + )?.textContent + } + else if (window.location.pathname.endsWith('video/')) { + presenceData.details = 'Bütün videolara göz atıyor.' + presenceData.state = 'CHIP Online' + } + else if (window.location.pathname.endsWith('haber/')) { + presenceData.state = 'Bütün haberlere göz atıyor.' + presenceData.details = 'CHIP Online' + } + else if (window.location.pathname.endsWith('inceleme/')) { + presenceData.state = 'Bütün incelemelere göz atıyor.' + presenceData.details = 'CHIP Online' + } + else if (window.location.pathname.startsWith('/inceleme/')) { + presenceData.state = document.querySelector('#anacontainer > h1')?.textContent + presenceData.details = 'Bir incelemeyi okuyor:' + } + else if (window.location.pathname.startsWith('/blog/')) { + presenceData.state = document.querySelector('#article-body > h1')?.textContent + presenceData.details = 'Bir blog okuyor:' + } + else if (window.location.pathname.endsWith('forum/')) { + presenceData.details = 'Tüm forumlara göz atıyor.' + } + else if (window.location.pathname.endsWith('canli/')) { + presenceData.state = 'CHIP Online' + presenceData.details = 'Tüm Tech-Talk arşivine göz atıyor.' + } + else if (window.location.pathname.startsWith('/forum/')) { + presenceData.state = 'Adlı konuyu/gönderiyi okuyor.' + presenceData.details = document.querySelector('#forumwrap > h1')?.textContent + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/CHZZK/metadata.json b/websites/C/CHZZK/metadata.json index bd3af1e9901a..8d1b6ea1ef9e 100644 --- a/websites/C/CHZZK/metadata.json +++ b/websites/C/CHZZK/metadata.json @@ -1,44 +1,44 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "374905512661221377", - "name": "Slowlife" - }, - "service": "CHZZK", - "altnames": [ - "치지직" - ], - "description": { - "en": "From the excitement of starting the broadcast until viewers and streamers meet and communicate. Every moment is enjoyable. Streaming begins in CHZZK." - }, - "url": "chzzk.naver.com", - "version": "1.0.5", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/thumbnail.png", - "color": "#00ffa3", - "category": "videos", - "tags": [ - "streaming", - "gaming", - "entertainment" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "logo", - "title": "Show Streamer Logo", - "icon": "fad fa-images", - "value": true - }, - { - "id": "time", - "title": "Show Stream Elapsed Time", - "icon": "fad fa-stopwatch", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "374905512661221377", + "name": "Slowlife" + }, + "service": "CHZZK", + "altnames": [ + "치지직" + ], + "description": { + "en": "From the excitement of starting the broadcast until viewers and streamers meet and communicate. Every moment is enjoyable. Streaming begins in CHZZK." + }, + "url": "chzzk.naver.com", + "version": "1.0.5", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/thumbnail.png", + "color": "#00ffa3", + "category": "videos", + "tags": [ + "streaming", + "gaming", + "entertainment" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "logo", + "title": "Show Streamer Logo", + "icon": "fad fa-images", + "value": true + }, + { + "id": "time", + "title": "Show Stream Elapsed Time", + "icon": "fad fa-stopwatch", + "value": false + } + ] +} diff --git a/websites/C/CHZZK/presence.ts b/websites/C/CHZZK/presence.ts index 66bc536e31ef..d2b1e2c4b167 100644 --- a/websites/C/CHZZK/presence.ts +++ b/websites/C/CHZZK/presence.ts @@ -1,115 +1,116 @@ const presence = new Presence({ - clientId: "1232944311415603281", - }), - getStrings = async () => { - return presence.getStrings( - { - play: "general.playing", - pause: "general.paused", - live: "general.live", - browse: "general.browsing", - ad: "youtube.ad", - watchingLive: "general.watchingLive", - watchingVid: "general.watchingVid", - watchStream: "general.buttonWatchStream", - watchVideo: "general.buttonWatchVideo", - }, - oldLang - ); - }, - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1232944311415603281', +}) +let oldLang: string = '' +async function getStrings() { + return presence.getStrings( + { + play: 'general.playing', + pause: 'general.paused', + live: 'general.live', + browse: 'general.browsing', + ad: 'youtube.ad', + watchingLive: 'general.watchingLive', + watchingVid: 'general.watchingVid', + watchStream: 'general.buttonWatchStream', + watchVideo: 'general.buttonWatchVideo', + }, + oldLang, + ) +} +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/0.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/0.png', } const enum ChzzkAssets { - Browse = "https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/1.png", - Live = "https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/2.png", - Play = "https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/3.png", - Pause = "https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/4.png", + Browse = 'https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/1.png', + Live = 'https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/2.png', + Play = 'https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/3.png', + Pause = 'https://cdn.rcd.gg/PreMiD/websites/C/CHZZK/assets/4.png', } -let oldLang: string, strings: Awaited>; +let strings: Awaited> -presence.on("UpdateData", async () => { - const [newLang, showStreamerLogo, showElapsedTime] = await Promise.all([ - presence.getSetting("lang"), - presence.getSetting("logo"), - presence.getSetting("time"), - ]); +presence.on('UpdateData', async () => { + const [newLang, showStreamerLogo, showElapsedTime] = await Promise.all([ + presence.getSetting('lang'), + presence.getSetting('logo'), + presence.getSetting('time'), + ]) - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - const presenceData: PresenceData = { - details: strings.browse, - largeImageKey: Assets.Logo, - smallImageKey: ChzzkAssets.Browse, - startTimestamp: browsingTimestamp, - type: ActivityType.Watching, - }, - { pathname, href } = document.location; + const presenceData: PresenceData = { + details: strings.browse, + largeImageKey: Assets.Logo, + smallImageKey: ChzzkAssets.Browse, + startTimestamp: browsingTimestamp, + type: ActivityType.Watching, + } + const { pathname, href } = document.location - switch (pathname.split("/")[1]) { - case "video": - case "live": - { - const video = document.querySelector("video"); - if ( - document.querySelector("div.ad_info_area")?.offsetParent - ) { - presenceData.details = strings.ad; - presenceData.smallImageKey = ChzzkAssets.Play; - presenceData.smallImageText = strings.play; - } else { - const streamerLogo = new URL( - document.querySelector( - "img[class^=video_information_image]" - ).src - ); - presenceData.details = document.querySelector( - "h2[class^=video_information_title]" - ).textContent; - presenceData.state = document.querySelector( - "div[class^=video_information_name]>span>span" - ).textContent; - presenceData.largeImageKey = showStreamerLogo - ? streamerLogo.href.replace(streamerLogo.search, "") - : Assets.Logo; + switch (pathname.split('/')[1]) { + case 'video': + case 'live': + { + const video = document.querySelector('video') + if ( + document.querySelector('div.ad_info_area')?.offsetParent + ) { + presenceData.details = strings.ad + presenceData.smallImageKey = ChzzkAssets.Play + presenceData.smallImageText = strings.play + } + else { + const streamerLogo = new URL( + document.querySelector( + 'img[class^=video_information_image]', + )!.src, + ) + presenceData.details = document.querySelector( + 'h2[class^=video_information_title]', + )?.textContent + presenceData.state = document.querySelector( + 'div[class^=video_information_name]>span>span', + )?.textContent + presenceData.largeImageKey = showStreamerLogo + ? streamerLogo.href.replace(streamerLogo.search, '') + : Assets.Logo - if (pathname.startsWith("/live")) { - presenceData.smallImageKey = ChzzkAssets.Live; - presenceData.smallImageText = strings.live; - if (showElapsedTime) { - presenceData.startTimestamp = - Math.floor(Date.now() / 1000) - - presence.timestampFromFormat( - document.querySelector("span[class^=video_information_count]") - .textContent - ); - } - presenceData.buttons = [{ url: href, label: strings.watchStream }]; - } else { - presenceData.smallImageKey = ChzzkAssets.Play; - presenceData.smallImageText = strings.play; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - presenceData.buttons = [{ url: href, label: strings.watchVideo }]; - } + if (pathname.startsWith('/live')) { + presenceData.smallImageKey = ChzzkAssets.Live + presenceData.smallImageText = strings.live + if (showElapsedTime) { + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + - presence.timestampFromFormat( + document.querySelector('span[class^=video_information_count]') + ?.textContent ?? '', + ) + } + presenceData.buttons = [{ url: href, label: strings.watchStream }] + } + else { + presenceData.smallImageKey = ChzzkAssets.Play + presenceData.smallImageText = strings.play; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video!) + presenceData.buttons = [{ url: href, label: strings.watchVideo }] + } - if (video.paused) { - presenceData.smallImageKey = ChzzkAssets.Pause; - presenceData.smallImageText = strings.pause; - delete presenceData.startTimestamp; - } + if (video!.paused) { + presenceData.smallImageKey = ChzzkAssets.Pause + presenceData.smallImageText = strings.pause + delete presenceData.startTimestamp + } - break; - } - } - break; - } - presence.setActivity(presenceData); -}); + break + } + } + break + } + presence.setActivity(presenceData) +}) diff --git a/websites/C/CNN/metadata.json b/websites/C/CNN/metadata.json index 590e9a58e681..ae57aed05b81 100644 --- a/websites/C/CNN/metadata.json +++ b/websites/C/CNN/metadata.json @@ -1,56 +1,56 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "N0chteil ^^", - "id": "495901098926669825" - }, - "service": "CNN", - "description": { - "en": "Cable News Network is a multinational news-based pay television channel headquartered in Atlanta. It is owned by CNN Worldwide, a unit of the WarnerMedia News & Sports division of AT&T's WarnerMedia.", - "nl": "Cable News Network is een multinationaal, op nieuws gebaseerd betaalt televisiekanaal met hoofdkantoor in Atlanta. Het is eigendom van CNN Worldwide, een onderdeel van de WarnerMedia News & Sports-divisie van AT&T's WarnerMedia.", - "vi_VN": "Cable News Network là kênh truyền hình cung cấp tin tức trả phí đa quốc gia trụ sở tại Atlanta. Nó được sở hữu bởi CNN Worldwide, một đơn vị của WarnerMedia News & Sports trong WarnerMedia thuộc AT&T." - }, - "url": [ - "edition.cnn.com", - "us.cnn.com" - ], - "version": "1.0.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CNN/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CNN/assets/thumbnail.png", - "color": "#CC1417", - "category": "other", - "tags": [ - "news" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "logo", - "title": "Icon", - "icon": "fad fa-icons", - "value": 0, - "values": [ - "Red", - "Transparent" - ] - }, - { - "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 - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "N0chteil ^^", + "id": "495901098926669825" + }, + "service": "CNN", + "description": { + "en": "Cable News Network is a multinational news-based pay television channel headquartered in Atlanta. It is owned by CNN Worldwide, a unit of the WarnerMedia News & Sports division of AT&T's WarnerMedia.", + "nl": "Cable News Network is een multinationaal, op nieuws gebaseerd betaalt televisiekanaal met hoofdkantoor in Atlanta. Het is eigendom van CNN Worldwide, een onderdeel van de WarnerMedia News & Sports-divisie van AT&T's WarnerMedia.", + "vi_VN": "Cable News Network là kênh truyền hình cung cấp tin tức trả phí đa quốc gia trụ sở tại Atlanta. Nó được sở hữu bởi CNN Worldwide, một đơn vị của WarnerMedia News & Sports trong WarnerMedia thuộc AT&T." + }, + "url": [ + "edition.cnn.com", + "us.cnn.com" + ], + "version": "1.0.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CNN/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CNN/assets/thumbnail.png", + "color": "#CC1417", + "category": "other", + "tags": [ + "news" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "logo", + "title": "Icon", + "icon": "fad fa-icons", + "value": 0, + "values": [ + "Red", + "Transparent" + ] + }, + { + "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 + } + ] +} diff --git a/websites/C/CNN/presence.ts b/websites/C/CNN/presence.ts index 7e952defb825..80609932b65b 100644 --- a/websites/C/CNN/presence.ts +++ b/websites/C/CNN/presence.ts @@ -1,189 +1,200 @@ const presence = new Presence({ - clientId: "839539095393796116", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '839539095393796116', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/CNN/assets/0.png", - LogoTransp = "https://cdn.rcd.gg/PreMiD/websites/C/CNN/assets/1.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/CNN/assets/0.png', + LogoTransp = 'https://cdn.rcd.gg/PreMiD/websites/C/CNN/assets/1.png', } -presence.on("UpdateData", async function () { - const setting = { - timeElapsed: await presence.getSetting("timeElapsed"), - showButtons: await presence.getSetting("showButtons"), - logo: await presence.getSetting<0 | 1>("logo"), - privacy: await presence.getSetting("privacy"), - }, - urlpath = window.location.pathname.split("/"), - presenceData: PresenceData = { - largeImageKey: - [Assets.Logo, Assets.LogoTransp][setting.logo] || Assets.Logo, - }; +presence.on('UpdateData', async () => { + const setting = { + timeElapsed: await presence.getSetting('timeElapsed'), + showButtons: await presence.getSetting('showButtons'), + logo: await presence.getSetting<0 | 1>('logo'), + privacy: await presence.getSetting('privacy'), + } + const urlpath = window.location.pathname.split('/') + const presenceData: PresenceData = { + largeImageKey: [Assets.Logo, Assets.LogoTransp][setting.logo] || Assets.Logo, + } - if (setting.timeElapsed && !setting.privacy) - presenceData.startTimestamp = browsingTimestamp; + if (setting.timeElapsed && !setting.privacy) + presenceData.startTimestamp = browsingTimestamp - if (!urlpath[1]) presenceData.details = "Home"; - else if ( - urlpath[1] === "world" || - urlpath[1] === "us" || - urlpath[1] === "politics" || - urlpath[1] === "business" || - urlpath[1] === "health" || - urlpath[1] === "entertainment" || - urlpath[1] === "style" || - urlpath[1] === "travel" || - urlpath[1] === "sport" || - (urlpath[1] === "sport" && - document.querySelector("a.sc-fjdhpX.sc-chPdSV.ewmEKt")) || - urlpath[1] === "videos" || - urlpath[1] === "africa" || - urlpath[1] === "americas" || - urlpath[1] === "asia" || - urlpath[1] === "australia" || - urlpath[1] === "china" || - urlpath[1] === "europe" || - urlpath[1] === "india" || - urlpath[1] === "middle-east" || - urlpath[1] === "uk" - ) { - presenceData.details = setting.privacy ? "Category" : "Category:"; - if (!setting.privacy) { - presenceData.state = - document.querySelector("h1.metadata-header__title")?.textContent || - document - .querySelector(".Text-sc-1amvtpj-0-span.jKFEoX") - ?.textContent.replace("Follow CNN ", "") || - "Not found"; - } + if (!urlpath[1]) { + presenceData.details = 'Home' + } + else if ( + urlpath[1] === 'world' + || urlpath[1] === 'us' + || urlpath[1] === 'politics' + || urlpath[1] === 'business' + || urlpath[1] === 'health' + || urlpath[1] === 'entertainment' + || urlpath[1] === 'style' + || urlpath[1] === 'travel' + || urlpath[1] === 'sport' + || (urlpath[1] === 'sport' + && document.querySelector('a.sc-fjdhpX.sc-chPdSV.ewmEKt')) + || urlpath[1] === 'videos' + || urlpath[1] === 'africa' + || urlpath[1] === 'americas' + || urlpath[1] === 'asia' + || urlpath[1] === 'australia' + || urlpath[1] === 'china' + || urlpath[1] === 'europe' + || urlpath[1] === 'india' + || urlpath[1] === 'middle-east' + || urlpath[1] === 'uk' + ) { + presenceData.details = setting.privacy ? 'Category' : 'Category:' + if (!setting.privacy) { + presenceData.state = document.querySelector('h1.metadata-header__title')?.textContent + || document + .querySelector('.Text-sc-1amvtpj-0-span.jKFEoX') + ?.textContent + ?.replace('Follow CNN ', '') + || 'Not found' + } - if (setting.showButtons && !setting.privacy) { - presenceData.buttons = [ - { - label: "View Category", - url: window.location.href, - }, - ]; - } - } else if ( - urlpath[1] >= "1900" && - parseInt(urlpath[1]) <= new Date().getFullYear() && - urlpath[2] >= "01" && - urlpath[2] <= "12" && - urlpath[3] >= "01" && - urlpath[3] <= "31" - ) { - presenceData.details = setting.privacy ? "Article" : "Article:"; - if (!setting.privacy) { - presenceData.state = - document.querySelector("h1.pg-headline")?.textContent || "Not found"; - } + if (setting.showButtons && !setting.privacy) { + presenceData.buttons = [ + { + label: 'View Category', + url: window.location.href, + }, + ] + } + } + else if ( + urlpath[1] >= '1900' + && Number.parseInt(urlpath[1]) <= new Date().getFullYear() + && urlpath[2] >= '01' + && urlpath[2] <= '12' + && urlpath[3] >= '01' + && urlpath[3] <= '31' + ) { + presenceData.details = setting.privacy ? 'Article' : 'Article:' + if (!setting.privacy) { + presenceData.state = document.querySelector('h1.pg-headline')?.textContent || 'Not found' + } - if (setting.showButtons && !setting.privacy) { - presenceData.buttons = [ - { - label: "View Article", - url: window.location.href, - }, - ]; - } - } else if (urlpath[1] === "profiles") { - presenceData.details = setting.privacy ? "Profile" : "Profile:"; - if (!setting.privacy) { - presenceData.state = - document.querySelector("div.cd__profile-name")?.textContent || - "Not found"; - } + if (setting.showButtons && !setting.privacy) { + presenceData.buttons = [ + { + label: 'View Article', + url: window.location.href, + }, + ] + } + } + else if (urlpath[1] === 'profiles') { + presenceData.details = setting.privacy ? 'Profile' : 'Profile:' + if (!setting.privacy) { + presenceData.state = document.querySelector('div.cd__profile-name')?.textContent + || 'Not found' + } - if (setting.showButtons && !setting.privacy) { - presenceData.buttons = [ - { - label: "View Profile", - url: window.location.href, - }, - ]; - } - } else if (urlpath[1] === "specials") { - if (urlpath[2]) { - if (urlpath[3] && urlpath[2] !== "us") { - presenceData.details = setting.privacy ? "Special" : "Special:"; - if (!setting.privacy) { - presenceData.state = - document.querySelector("h1.pg-headline")?.textContent || - document.querySelector("li>a.geyBat")?.textContent || - "Not found"; - } - } else { - presenceData.details = setting.privacy ? "Special" : "Special:"; - if (!setting.privacy) { - presenceData.state = - document.querySelector("a.sc-fjdhpX.sc-chPdSV.ewmEKt") - ?.textContent || "Not found"; - } - } + if (setting.showButtons && !setting.privacy) { + presenceData.buttons = [ + { + label: 'View Profile', + url: window.location.href, + }, + ] + } + } + else if (urlpath[1] === 'specials') { + if (urlpath[2]) { + if (urlpath[3] && urlpath[2] !== 'us') { + presenceData.details = setting.privacy ? 'Special' : 'Special:' + if (!setting.privacy) { + presenceData.state = document.querySelector('h1.pg-headline')?.textContent + || document.querySelector('li>a.geyBat')?.textContent + || 'Not found' + } + } + else { + presenceData.details = setting.privacy ? 'Special' : 'Special:' + if (!setting.privacy) { + presenceData.state = document.querySelector('a.sc-fjdhpX.sc-chPdSV.ewmEKt') + ?.textContent || 'Not found' + } + } - if (setting.showButtons && !setting.privacy) { - presenceData.buttons = [ - { - label: "View Special", - url: window.location.href, - }, - ]; - } - } else presenceData.details = "Specials"; - } else if (urlpath[1] === "election" && urlpath[2] >= "1900") { - presenceData.details = `Election ${urlpath[2]}`; + if (setting.showButtons && !setting.privacy) { + presenceData.buttons = [ + { + label: 'View Special', + url: window.location.href, + }, + ] + } + } + else { + presenceData.details = 'Specials' + } + } + else if (urlpath[1] === 'election' && urlpath[2] >= '1900') { + presenceData.details = `Election ${urlpath[2]}` - if (urlpath[4] === "president") { - const scoreStyle = document.querySelectorAll( - "div.bop-main-scorestyles__BOPCount-sc-17mbuqb-2" - ), - scoreStyle2 = document.querySelectorAll( - "div.bop-main-scorestyles__BOPName-sc-17mbuqb-3" - ); + if (urlpath[4] === 'president') { + const scoreStyle = document.querySelectorAll( + 'div.bop-main-scorestyles__BOPCount-sc-17mbuqb-2', + ) + const scoreStyle2 = document.querySelectorAll( + 'div.bop-main-scorestyles__BOPName-sc-17mbuqb-3', + ) - presenceData.state = `${scoreStyle2[1]?.textContent}: ${scoreStyle[1]?.textContent} - ${scoreStyle2[2]?.textContent}: ${scoreStyle[2]?.textContent}`; - } else if (urlpath[4] === "state") { - presenceData.state = document.querySelector( - "h1.pagestyles__DesktopH1-sc-7kqwl2-74" - )?.textContent; + presenceData.state = `${scoreStyle2[1]?.textContent}: ${scoreStyle[1]?.textContent} - ${scoreStyle2[2]?.textContent}: ${scoreStyle[2]?.textContent}` + } + else if (urlpath[4] === 'state') { + presenceData.state = document.querySelector( + 'h1.pagestyles__DesktopH1-sc-7kqwl2-74', + )?.textContent - if (setting.showButtons && !setting.privacy) { - presenceData.buttons = [ - { - label: "View Results", - url: window.location.href, - }, - ]; - } - } else presenceData.state = "Other"; - } else { - switch (urlpath[1]) { - case "interactive": { - presenceData.details = "Interactive Article"; - break; - } - case "account": { - presenceData.details = "Account"; - if (urlpath[2] === "register" && !setting.privacy) - presenceData.state = "Register"; - else if (urlpath[2] === "confirm" && !setting.privacy) - presenceData.state = "Confirming E-Mail"; - else if (urlpath[2] === "settings" && !setting.privacy) - presenceData.state = "Settings"; + if (setting.showButtons && !setting.privacy) { + presenceData.buttons = [ + { + label: 'View Results', + url: window.location.href, + }, + ] + } + } + else { + presenceData.state = 'Other' + } + } + else { + switch (urlpath[1]) { + case 'interactive': { + presenceData.details = 'Interactive Article' + break + } + case 'account': { + presenceData.details = 'Account' + if (urlpath[2] === 'register' && !setting.privacy) + presenceData.state = 'Register' + else if (urlpath[2] === 'confirm' && !setting.privacy) + presenceData.state = 'Confirming E-Mail' + else if (urlpath[2] === 'settings' && !setting.privacy) + presenceData.state = 'Settings' - break; - } - case "newsletters": { - presenceData.details = "Browsing Newsletters"; - break; - } - default: - presenceData.details = "Other"; - } - } + break + } + case 'newsletters': { + presenceData.details = 'Browsing Newsletters' + break + } + default: + presenceData.details = 'Other' + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/CS Money/metadata.json b/websites/C/CS Money/metadata.json index 297ba48eca36..e5b210c409d2 100644 --- a/websites/C/CS Money/metadata.json +++ b/websites/C/CS Money/metadata.json @@ -1,34 +1,34 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kyrie", - "id": "368399721494216706" - }, - "service": "CS Money", - "altnames": [ - "CS.Money" - ], - "description": { - "en": "A better way to trade CS:GO skins. Buy, sell, and trade skins easier and faster. All deals are secured with the highest level protection methods.", - "vi_VN": "Cách tốt hơn để trao đổi CS:GO skin. Mua, bán, và trao đổi skin nhanh hơn và dễ dàng hơn. Tất cả các giao dịch đều được bảo mật bằng phương thức cao nhất." - }, - "url": "cs.money", - "regExp": "([a-z0-9]+[.])?cs[.]money", - "version": "1.0.17", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CS%20Money/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CS%20Money/assets/thumbnail.png", - "color": "#4214AC", - "category": "games", - "tags": [ - "cs", - "go", - "csgo", - "dota", - "steam", - "money", - "trade", - "market", - "skins" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Kyrie", + "id": "368399721494216706" + }, + "service": "CS Money", + "altnames": [ + "CS.Money" + ], + "description": { + "en": "A better way to trade CS:GO skins. Buy, sell, and trade skins easier and faster. All deals are secured with the highest level protection methods.", + "vi_VN": "Cách tốt hơn để trao đổi CS:GO skin. Mua, bán, và trao đổi skin nhanh hơn và dễ dàng hơn. Tất cả các giao dịch đều được bảo mật bằng phương thức cao nhất." + }, + "url": "cs.money", + "regExp": "([a-z0-9]+[.])?cs[.]money", + "version": "1.0.17", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CS%20Money/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CS%20Money/assets/thumbnail.png", + "color": "#4214AC", + "category": "games", + "tags": [ + "cs", + "go", + "csgo", + "dota", + "steam", + "money", + "trade", + "market", + "skins" + ] +} diff --git a/websites/C/CS Money/presence.ts b/websites/C/CS Money/presence.ts index 5eccaff435bf..0db0a00b6556 100644 --- a/websites/C/CS Money/presence.ts +++ b/websites/C/CS Money/presence.ts @@ -1,75 +1,86 @@ const presence = new Presence({ - clientId: "922108073533898763", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '922108073533898763', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CS%20Money/assets/logo.png", - startTimestamp: browsingTimestamp, - }; - if ( - document.querySelector("#modal > div.styles_overlay__3KR4i") && - document.location.href.includes("csgo") - ) { - presenceData.details = `Inspecting skin: ${ - document.querySelector( - "#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_numerical__2-JYQ > div:nth-child(1) > div > div > div > div.ItemDetailsLayout_name__ZYPKv" - ).textContent - }`; - presenceData.state = document.querySelector( - "#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_numerical__2-JYQ > div:nth-child(5) > div.ItemDetailsLayout_price_block__37gpv > div.styles_price_wrap__7fZ5J > div.styles_information__TKFXx > div.styles_price_container__3Fc2t > span > span" - ).textContent; - presenceData.buttons = [ - { - label: "Inspect 3D", - url: document.querySelector( - "#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_visual__2lBPE > div:nth-child(3) > div > a:nth-child(3)" - ).href, - }, - { - label: "More details", - url: document.querySelector( - "#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_visual__2lBPE > div:nth-child(3) > div > a:nth-child(4)" - ).href, - }, - ]; - } else if ( - document.querySelector("#modal > div.styles_overlay__3KR4i") && - document.location.href.includes("dota") - ) { - presenceData.details = `Inspecting item: ${ - document.querySelector( - "#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_numerical__2-JYQ > div.MediaQueries_desktop__TwhBE > div > div > div > div" - ).textContent - }`; - presenceData.state = document.querySelector( - "#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_numerical__2-JYQ > div:nth-child(5) > div.ItemDetailsLayout_price_block__37gpv > div.styles_price_wrap__7fZ5J > div.styles_information__TKFXx > div.styles_price_container__3Fc2t > span > span" - ).textContent; - } else if (document.location.href.includes("trade")) - presenceData.details = "Making a trade offer"; - else if (document.location.href.includes("store")) - presenceData.details = "Browsing the store"; - else if (document.location.href.includes("sell")) - presenceData.details = "Selling items"; - else if (document.location.href.includes("auction")) - presenceData.details = "Joining an auction"; - else if (document.location.href.includes("personal-info")) - presenceData.details = "Viewing personal info"; - else if (document.location.href.includes("transactions")) - presenceData.details = "Viewing transactions"; - else if (document.location.hostname === "3d.cs.money") { - presenceData.details = "Inspecting 3D"; - presenceData.state = document.title.substring( - 0, - document.title.lastIndexOf("|") - 1 - ); - presenceData.buttons = [{ label: "Inspect 3D", url: document.URL }]; - } else if (document.location.hostname === "wiki.cs.money") { - presenceData.details = "Reading the wiki"; - [presenceData.state] = document.title.split(/—/); - presenceData.buttons = [{ label: "Read wiki", url: document.URL }]; - } else presenceData.details = "Browsing"; - presence.setActivity(presenceData); -}); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CS%20Money/assets/logo.png', + startTimestamp: browsingTimestamp, + } + if ( + document.querySelector('#modal > div.styles_overlay__3KR4i') + && document.location.href.includes('csgo') + ) { + presenceData.details = `Inspecting skin: ${ + document.querySelector( + '#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_numerical__2-JYQ > div:nth-child(1) > div > div > div > div.ItemDetailsLayout_name__ZYPKv', + )?.textContent + }` + presenceData.state = document.querySelector( + '#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_numerical__2-JYQ > div:nth-child(5) > div.ItemDetailsLayout_price_block__37gpv > div.styles_price_wrap__7fZ5J > div.styles_information__TKFXx > div.styles_price_container__3Fc2t > span > span', + )?.textContent + presenceData.buttons = [ + { + label: 'Inspect 3D', + url: document.querySelector( + '#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_visual__2lBPE > div:nth-child(3) > div > a:nth-child(3)', + )!.href, + }, + { + label: 'More details', + url: document.querySelector( + '#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_visual__2lBPE > div:nth-child(3) > div > a:nth-child(4)', + )!.href, + }, + ] + } + else if ( + document.querySelector('#modal > div.styles_overlay__3KR4i') + && document.location.href.includes('dota') + ) { + presenceData.details = `Inspecting item: ${ + document.querySelector( + '#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_numerical__2-JYQ > div.MediaQueries_desktop__TwhBE > div > div > div > div', + )?.textContent + }` + presenceData.state = document.querySelector( + '#modal > div > div.styles_wrapper__1pcux > div > div > div > div.ItemDetailsLayout_item_numerical__2-JYQ > div:nth-child(5) > div.ItemDetailsLayout_price_block__37gpv > div.styles_price_wrap__7fZ5J > div.styles_information__TKFXx > div.styles_price_container__3Fc2t > span > span', + )?.textContent + } + else if (document.location.href.includes('trade')) { + presenceData.details = 'Making a trade offer' + } + else if (document.location.href.includes('store')) { + presenceData.details = 'Browsing the store' + } + else if (document.location.href.includes('sell')) { + presenceData.details = 'Selling items' + } + else if (document.location.href.includes('auction')) { + presenceData.details = 'Joining an auction' + } + else if (document.location.href.includes('personal-info')) { + presenceData.details = 'Viewing personal info' + } + else if (document.location.href.includes('transactions')) { + presenceData.details = 'Viewing transactions' + } + else if (document.location.hostname === '3d.cs.money') { + presenceData.details = 'Inspecting 3D' + presenceData.state = document.title.substring( + 0, + document.title.lastIndexOf('|') - 1, + ) + presenceData.buttons = [{ label: 'Inspect 3D', url: document.URL }] + } + else if (document.location.hostname === 'wiki.cs.money') { + presenceData.details = 'Reading the wiki'; + [presenceData.state] = document.title.split(/—/) + presenceData.buttons = [{ label: 'Read wiki', url: document.URL }] + } + else { + presenceData.details = 'Browsing' + } + presence.setActivity(presenceData) +}) diff --git a/websites/C/CSGO Stash/metadata.json b/websites/C/CSGO Stash/metadata.json index f7a24ca83ce7..6bd83efbccf5 100644 --- a/websites/C/CSGO Stash/metadata.json +++ b/websites/C/CSGO Stash/metadata.json @@ -1,33 +1,33 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kyrie", - "id": "368399721494216706" - }, - "service": "CSGO Stash", - "altnames": [ - "CS:GO Stash" - ], - "description": { - "en": "Browse all CS:GO skins, knives, gloves, cases, collections, stickers, music kits, and more. Check prices, market stats, previews, and more for every CS:GO items", - "vi_VN": "Tìm tất cả các skin, găng tay, hòm, bộ sưu tập, hộp nhạc CS:GO và hơn nữa. Theo dõi giá, giá trị thị trường, xem trước và hơn nữa cho mọi vật phẩm CS:GO" - }, - "url": "csgostash.com", - "version": "1.2.14", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/thumbnail.png", - "color": "#13AFF0", - "category": "games", - "tags": [ - "cs", - "go", - "csgo", - "stash", - "steam", - "skins", - "market", - "marketplace", - "valve" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Kyrie", + "id": "368399721494216706" + }, + "service": "CSGO Stash", + "altnames": [ + "CS:GO Stash" + ], + "description": { + "en": "Browse all CS:GO skins, knives, gloves, cases, collections, stickers, music kits, and more. Check prices, market stats, previews, and more for every CS:GO items", + "vi_VN": "Tìm tất cả các skin, găng tay, hòm, bộ sưu tập, hộp nhạc CS:GO và hơn nữa. Theo dõi giá, giá trị thị trường, xem trước và hơn nữa cho mọi vật phẩm CS:GO" + }, + "url": "csgostash.com", + "version": "1.2.14", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/thumbnail.png", + "color": "#13AFF0", + "category": "games", + "tags": [ + "cs", + "go", + "csgo", + "stash", + "steam", + "skins", + "market", + "marketplace", + "valve" + ] +} diff --git a/websites/C/CSGO Stash/presence.ts b/websites/C/CSGO Stash/presence.ts index cc3ae944a806..7b645fa890de 100644 --- a/websites/C/CSGO Stash/presence.ts +++ b/websites/C/CSGO Stash/presence.ts @@ -1,174 +1,203 @@ const presence = new Presence({ - clientId: "918832169823125555", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '918832169823125555', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/logo.png", - Skins = "https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/0.png", - Case = "https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/1.png", - Sticker = "https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/2.png", - Glove = "https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/3.png", - Items = "https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/4.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/logo.png', + Skins = 'https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/0.png', + Case = 'https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/1.png', + Sticker = 'https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/2.png', + Glove = 'https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/3.png', + Items = 'https://cdn.rcd.gg/PreMiD/websites/C/CSGO%20Stash/assets/4.png', } -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - details: "Browsing...", - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - shortTitle = document.title.substring( - 0, - document.title.lastIndexOf("-") - 1 - ), - path = document.location.pathname, - priceLeft = document.querySelector( - "#prices > div:nth-child(2) > a > span.pull-left" - ), - priceRight = document.querySelector( - "#prices > div:nth-child(2) > a > span.pull-right" - ), - priceMiddle = document.querySelector( - "a.btn.btn-default.market-button-item" - ), - steamPrice = document.querySelector( - "div.col-md-6.col-md-6-collapse-top-margin > div:nth-child(2) > a > span.pull-right" - ), - middleImage = document.querySelector( - "div.col-md-8.col-widen > div > div:nth-child(2) > div:nth-child(1) > img" - ), - leftImage = document.querySelector( - "body > div.container.main-content > div:nth-child(3) > div > div:nth-child(1) > a > img" - ); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + details: 'Browsing...', + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const shortTitle = document.title.substring( + 0, + document.title.lastIndexOf('-') - 1, + ) + const path = document.location.pathname + const priceLeft = document.querySelector( + '#prices > div:nth-child(2) > a > span.pull-left', + ) + const priceRight = document.querySelector( + '#prices > div:nth-child(2) > a > span.pull-right', + ) + const priceMiddle = document.querySelector( + 'a.btn.btn-default.market-button-item', + ) + const steamPrice = document.querySelector( + 'div.col-md-6.col-md-6-collapse-top-margin > div:nth-child(2) > a > span.pull-right', + ) + const middleImage = document.querySelector( + 'div.col-md-8.col-widen > div > div:nth-child(2) > div:nth-child(1) > img', + ) + const leftImage = document.querySelector( + 'body > div.container.main-content > div:nth-child(3) > div > div:nth-child(1) > a > img', + ) - if (path.startsWith("/skin")) { - presenceData.details = `Viewing: ${shortTitle}`; - presenceData.state = `${priceLeft.textContent}: ${priceRight.textContent}`; - presenceData.largeImageKey = document.querySelector( - "a.image-popup-vertical-fit.misc-click > img" - ).src; - presenceData.buttons = [{ label: "View Skin", url: document.URL }]; - } else if (path.startsWith("/weapon")) { - presenceData.details = "Browsing weapon skins"; - presenceData.state = shortTitle; - presenceData.smallImageKey = Assets.Skins; - presenceData.smallImageText = "Viewing skins"; - } else if (path.startsWith("/skin-rarity")) { - presenceData.details = "Viewing a skin rarity catalog"; - presenceData.state = shortTitle; - presenceData.smallImageKey = Assets.Skins; - presenceData.smallImageText = "Viewing skins"; - } else if (path.startsWith("/case")) { - presenceData.details = `Viewing case: ${shortTitle}`; - presenceData.state = priceMiddle.textContent; - presenceData.largeImageKey = leftImage.src; - presenceData.buttons = [{ label: "View Case", url: document.URL }]; - } else if (path.startsWith("/containers")) { - presenceData.details = "Browsing containers"; - presenceData.state = shortTitle; - presenceData.smallImageKey = Assets.Case; - presenceData.smallImageText = "Viewing containers"; - } else if (path.startsWith("/collection")) { - presenceData.details = "Viewing a skin collection"; - presenceData.state = shortTitle; - } else if (path.startsWith("/sticker")) { - if (path.startsWith("/stickers/tournament")) { - presenceData.details = "Browsing tournament stickers"; - presenceData.state = shortTitle; - } else if (path.startsWith("/stickers/community")) { - presenceData.details = "Browsing community stickers"; - presenceData.state = shortTitle; - } else if (path.startsWith("/stickers/capsule")) { - delete presenceData.smallImageKey; - delete presenceData.smallImageText; - presenceData.details = `Viewing the ${shortTitle}`; - presenceData.state = priceMiddle.textContent; - presenceData.largeImageKey = leftImage.src; - presenceData.buttons = [{ label: "View Capsule", url: document.URL }]; - } else if (path.startsWith("/sticker/regular")) - presenceData.details = "Browsing stickers"; - else { - presenceData.details = `Viewing sticker: ${shortTitle}`; - presenceData.state = `Steam price: ${steamPrice.textContent}`; - presenceData.largeImageKey = middleImage.src; - presenceData.smallImageKey = Assets.Sticker; - presenceData.smallImageText = "Viewing stickers"; - presenceData.buttons = [{ label: "View Sticker", url: document.URL }]; - } - } else if (path.startsWith("/glove")) { - if (path === "/gloves") { - presenceData.details = "Browsing gloves"; - presenceData.smallImageKey = Assets.Glove; - presenceData.smallImageText = "Viewing gloves"; - } else { - presenceData.details = `Viewing glove: ${shortTitle}`; - presenceData.state = `${priceLeft.textContent}: ${priceRight.textContent}`; - presenceData.largeImageKey = document.querySelector( - "div.well.result-box.nomargin > img" - ).src; - presenceData.buttons = [{ label: "View Glove", url: document.URL }]; - } - } else if (path.startsWith("/agent")) { - if (path === "/agents") presenceData.details = "Browsing agents"; - else if (path.startsWith("/agents")) { - presenceData.details = "Browsing agents"; - presenceData.state = shortTitle; - } else { - presenceData.details = `Viewing agent: ${shortTitle}`; - presenceData.state = `Steam price: ${steamPrice.textContent}`; - presenceData.largeImageKey = middleImage.src; - presenceData.buttons = [{ label: "View Agent", url: document.URL }]; - } - } else if (path.startsWith("/patch")) { - if (path.startsWith("/patches")) { - presenceData.details = "Browsing patches"; - presenceData.state = shortTitle; - } else { - presenceData.details = `Viewing patch: ${shortTitle}`; - presenceData.state = `Steam price: ${steamPrice.textContent}`; - presenceData.largeImageKey = middleImage.src; - presenceData.buttons = [{ label: "View Patch", url: document.URL }]; - } - } else if (path.startsWith("/graffiti")) { - if (path === "/graffiti") presenceData.details = "Browsing graffitis"; - else if (path.startsWith("/graffiti/collection")) { - presenceData.details = "Browsing graffiti collection"; - presenceData.state = shortTitle; - } else if (path.startsWith("/graffiti/tournament")) { - presenceData.details = "Browsing tournament graffitis"; - presenceData.state = shortTitle; - } else if (path.startsWith("/graffiti/box")) { - presenceData.details = `Viewing graffiti box: ${shortTitle}`; - presenceData.state = `Steam price: ${priceMiddle.textContent}`; - presenceData.largeImageKey = leftImage.src; - presenceData.buttons = [ - { label: "View Graffiti Box", url: document.URL }, - ]; - } else { - presenceData.details = `Viewing graffiti: ${shortTitle}`; - presenceData.state = `Steam price: ${steamPrice.textContent}`; - presenceData.largeImageKey = middleImage.src; - presenceData.buttons = [{ label: "View Graffiti", url: document.URL }]; - } - } else if (path.startsWith("/item")) { - if (path === "/items") { - presenceData.details = "Browsing items"; - presenceData.smallImageKey = Assets.Items; - presenceData.smallImageText = "Viewing items"; - } else { - presenceData.details = `Viewing item: ${shortTitle}`; - presenceData.state = `Steam price: ${steamPrice.textContent}`; - presenceData.largeImageKey = middleImage.src; - presenceData.buttons = [{ label: "View Item", url: document.URL }]; - } - } else if (path.includes("google-search")) { - presenceData.details = "Searching for:"; - presenceData.state = document.querySelector( - "span.gcsc-find-more-on-google-query" - ).textContent; - } else if (document.location.href === "https://csgostash.com") - presenceData.details = "Home page"; + if (path.startsWith('/skin')) { + presenceData.details = `Viewing: ${shortTitle}` + presenceData.state = `${priceLeft?.textContent}: ${priceRight?.textContent}` + presenceData.largeImageKey = document.querySelector( + 'a.image-popup-vertical-fit.misc-click > img', + )?.src + presenceData.buttons = [{ label: 'View Skin', url: document.URL }] + } + else if (path.startsWith('/weapon')) { + presenceData.details = 'Browsing weapon skins' + presenceData.state = shortTitle + presenceData.smallImageKey = Assets.Skins + presenceData.smallImageText = 'Viewing skins' + } + else if (path.startsWith('/skin-rarity')) { + presenceData.details = 'Viewing a skin rarity catalog' + presenceData.state = shortTitle + presenceData.smallImageKey = Assets.Skins + presenceData.smallImageText = 'Viewing skins' + } + else if (path.startsWith('/case')) { + presenceData.details = `Viewing case: ${shortTitle}` + presenceData.state = priceMiddle?.textContent + presenceData.largeImageKey = leftImage?.src + presenceData.buttons = [{ label: 'View Case', url: document.URL }] + } + else if (path.startsWith('/containers')) { + presenceData.details = 'Browsing containers' + presenceData.state = shortTitle + presenceData.smallImageKey = Assets.Case + presenceData.smallImageText = 'Viewing containers' + } + else if (path.startsWith('/collection')) { + presenceData.details = 'Viewing a skin collection' + presenceData.state = shortTitle + } + else if (path.startsWith('/sticker')) { + if (path.startsWith('/stickers/tournament')) { + presenceData.details = 'Browsing tournament stickers' + presenceData.state = shortTitle + } + else if (path.startsWith('/stickers/community')) { + presenceData.details = 'Browsing community stickers' + presenceData.state = shortTitle + } + else if (path.startsWith('/stickers/capsule')) { + delete presenceData.smallImageKey + delete presenceData.smallImageText + presenceData.details = `Viewing the ${shortTitle}` + presenceData.state = priceMiddle?.textContent + presenceData.largeImageKey = leftImage?.src + presenceData.buttons = [{ label: 'View Capsule', url: document.URL }] + } + else if (path.startsWith('/sticker/regular')) { + presenceData.details = 'Browsing stickers' + } + else { + presenceData.details = `Viewing sticker: ${shortTitle}` + presenceData.state = `Steam price: ${steamPrice?.textContent}` + presenceData.largeImageKey = middleImage?.src + presenceData.smallImageKey = Assets.Sticker + presenceData.smallImageText = 'Viewing stickers' + presenceData.buttons = [{ label: 'View Sticker', url: document.URL }] + } + } + else if (path.startsWith('/glove')) { + if (path === '/gloves') { + presenceData.details = 'Browsing gloves' + presenceData.smallImageKey = Assets.Glove + presenceData.smallImageText = 'Viewing gloves' + } + else { + presenceData.details = `Viewing glove: ${shortTitle}` + presenceData.state = `${priceLeft?.textContent}: ${priceRight?.textContent}` + presenceData.largeImageKey = document.querySelector( + 'div.well.result-box.nomargin > img', + )?.src + presenceData.buttons = [{ label: 'View Glove', url: document.URL }] + } + } + else if (path.startsWith('/agent')) { + if (path === '/agents') { + presenceData.details = 'Browsing agents' + } + else if (path.startsWith('/agents')) { + presenceData.details = 'Browsing agents' + presenceData.state = shortTitle + } + else { + presenceData.details = `Viewing agent: ${shortTitle}` + presenceData.state = `Steam price: ${steamPrice?.textContent}` + presenceData.largeImageKey = middleImage?.src + presenceData.buttons = [{ label: 'View Agent', url: document.URL }] + } + } + else if (path.startsWith('/patch')) { + if (path.startsWith('/patches')) { + presenceData.details = 'Browsing patches' + presenceData.state = shortTitle + } + else { + presenceData.details = `Viewing patch: ${shortTitle}` + presenceData.state = `Steam price: ${steamPrice?.textContent}` + presenceData.largeImageKey = middleImage?.src + presenceData.buttons = [{ label: 'View Patch', url: document.URL }] + } + } + else if (path.startsWith('/graffiti')) { + if (path === '/graffiti') { + presenceData.details = 'Browsing graffitis' + } + else if (path.startsWith('/graffiti/collection')) { + presenceData.details = 'Browsing graffiti collection' + presenceData.state = shortTitle + } + else if (path.startsWith('/graffiti/tournament')) { + presenceData.details = 'Browsing tournament graffitis' + presenceData.state = shortTitle + } + else if (path.startsWith('/graffiti/box')) { + presenceData.details = `Viewing graffiti box: ${shortTitle}` + presenceData.state = `Steam price: ${priceMiddle?.textContent}` + presenceData.largeImageKey = leftImage?.src + presenceData.buttons = [ + { label: 'View Graffiti Box', url: document.URL }, + ] + } + else { + presenceData.details = `Viewing graffiti: ${shortTitle}` + presenceData.state = `Steam price: ${steamPrice?.textContent}` + presenceData.largeImageKey = middleImage?.src + presenceData.buttons = [{ label: 'View Graffiti', url: document.URL }] + } + } + else if (path.startsWith('/item')) { + if (path === '/items') { + presenceData.details = 'Browsing items' + presenceData.smallImageKey = Assets.Items + presenceData.smallImageText = 'Viewing items' + } + else { + presenceData.details = `Viewing item: ${shortTitle}` + presenceData.state = `Steam price: ${steamPrice?.textContent}` + presenceData.largeImageKey = middleImage?.src + presenceData.buttons = [{ label: 'View Item', url: document.URL }] + } + } + else if (path.includes('google-search')) { + presenceData.details = 'Searching for:' + presenceData.state = document.querySelector( + 'span.gcsc-find-more-on-google-query', + )?.textContent + } + else if (document.location.href === 'https://csgostash.com') { + presenceData.details = 'Home page' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/CTFtime/metadata.json b/websites/C/CTFtime/metadata.json index d9112dbde12a..3e31c1d43503 100644 --- a/websites/C/CTFtime/metadata.json +++ b/websites/C/CTFtime/metadata.json @@ -1,44 +1,44 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "605894319408283678", - "name": "eljooker" - }, - "service": "CTFtime", - "description": { - "en": "CTFtime is a website that tracks cybersecurity competitions known as Capture The Flag (CTF) events. These contests challenge participants to solve a variety of tasks, ranging from scavenger hunts on Wikipedia to basic programming exercises and even hacking into servers to steal data." - }, - "url": "ctftime.org", - "version": "1.0.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CTFtime/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CTFtime/assets/thumbnail.png", - "color": "#bf040d", - "category": "other", - "tags": [ - "cybersecurity", - "competetion", - "ctf", - "study" - ], - "settings": [ - { - "id": "timestamp", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "images", - "title": "Show Covers", - "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": { + "id": "605894319408283678", + "name": "eljooker" + }, + "service": "CTFtime", + "description": { + "en": "CTFtime is a website that tracks cybersecurity competitions known as Capture The Flag (CTF) events. These contests challenge participants to solve a variety of tasks, ranging from scavenger hunts on Wikipedia to basic programming exercises and even hacking into servers to steal data." + }, + "url": "ctftime.org", + "version": "1.0.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CTFtime/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CTFtime/assets/thumbnail.png", + "color": "#bf040d", + "category": "other", + "tags": [ + "cybersecurity", + "competetion", + "ctf", + "study" + ], + "settings": [ + { + "id": "timestamp", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "images", + "title": "Show Covers", + "icon": "fad fa-images", + "value": true + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/C/CTFtime/presence.ts b/websites/C/CTFtime/presence.ts index 71e01f5cf4c8..5c23b34f1db9 100644 --- a/websites/C/CTFtime/presence.ts +++ b/websites/C/CTFtime/presence.ts @@ -1,230 +1,235 @@ type Functionlize = { - [P in keyof T]: () => T[P]; -}; + [P in keyof T]: () => T[P]; +} -interface Route extends Functionlize> { - path: RegExp; +interface Route extends Functionlize> { + path: RegExp } const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/CTFtime/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/CTFtime/assets/logo.png', } enum Settings { - TIMESTAMP = "timestamp", - BUTTONS = "buttons", - COVERS = "images", + TIMESTAMP = 'timestamp', + BUTTONS = 'buttons', + COVERS = 'images', } -const { href, hostname } = document.location, - presence = new Presence({ - clientId: "1253040451624370300", - }), - imgElements = - document.querySelector(".span2 img")?.src ?? Assets.Logo, - startTimestamp: number = Math.floor(Date.now() / 1000), - router = ({ path }: { path: string; presenceData: PresenceData }): Route => { - const routes: Route[] = [ - { - path: /^\/$/, - details: () => "On Homepage", - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - }, +const { href, hostname } = document.location +const presence = new Presence({ + clientId: '1253040451624370300', +}) +const imgElements = document.querySelector('.span2 img')?.src ?? Assets.Logo +const startTimestamp: number = Math.floor(Date.now() / 1000) +function router({ path }: { path: string, presenceData: PresenceData }): Route { + const routes: Route[] = [ + { + path: /^\/$/, + details: () => 'On Homepage', + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + }, - { - path: /^\/ctfs$/, - details: () => "Looking for a CTF", - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - }, - { - path: /^\/event\/list\/.*upcoming.*$/, - details: () => "Browsing upcoming CTFs", - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - }, - { - path: /^\/event\/list\/.*now.*$/, - details: () => "Browsing running CTFs", - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - }, - { - path: /^\/event\/list\/.*archive.*$/, - details: () => "Browsing past CTFs", - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - }, - { - path: /^\/tasks.*$/, - details: () => "Searching write ups", - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - }, - { - path: /^\/calendar.*$/, - details: () => "Checking Calendar", - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - }, - { - path: /^\/profile.*$/, - details: () => "Editing their profile", - smallImageKey: () => Assets.Writing, - }, - { - path: /^\/writeups$/, - details: () => "Looking for Writeups", - smallImageKey: () => Assets.Reading, - }, - { - path: /^\/writeup.*$/, - details: () => "Reading a Challenge Writeup", - state: () => document.querySelector(".page-header h2").textContent, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Learning", - buttons: () => [ - { - label: "Read With Me", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/task.*$/, - details: () => "Viewng a Challenge Info", - state: () => document.querySelector(".page-header h2").textContent, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Learning", - buttons: () => [ - { - label: "Challenge Link", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/task.*\/writeup.*$/, - details: () => "Making a Challenge Write up", - state: () => document.querySelector(".page-header h2").textContent, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Learning", - buttons: () => [ - { - label: "Challenge Link", - url: (() => { - return href - .split("/") - .slice(0, 5) - .join("/") - .replace(/\/writeup$/, ""); - })(), - }, - ], - }, - { - path: /^\/event.*$/, - details: () => "Viewing a CTF", - state: () => document.querySelector(".page-header h2").textContent, - largeImageKey: () => imgElements, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - buttons: () => [ - { - label: "View CTF", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/user.*$/, - details: () => "Viewing user profile", - state: () => document.querySelector(".page-header h2").textContent, - largeImageKey: () => imgElements, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - buttons: () => [ - { - label: "Profile", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/team.*$/, - state: () => document.querySelector(".page-header h2").textContent, - details: () => "Viewing a Team", - largeImageKey: () => imgElements, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - buttons: () => [ - { - label: "View Team", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/stats.*$/, - state: () => { - const h3Elements = document.querySelectorAll("h3"); - if (h3Elements.length > 1) - return `Region: ${h3Elements[0].textContent}`; - else return "Global Ranking"; - }, - details: () => "Viewing Teams Ranking", - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - buttons: () => [ - { - label: "View Ranks", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/ctfprofile.*$/, - details: () => "Organizing CTF", - }, - { - path: /^\/+.*$/, - details: () => { - return href.split("/")[3].toUpperCase().split("-").join(" "); - }, - }, - ]; + { + path: /^\/ctfs$/, + details: () => 'Looking for a CTF', + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + }, + { + path: /^\/event\/list\/.*upcoming.*$/, + details: () => 'Browsing upcoming CTFs', + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + }, + { + path: /^\/event\/list\/.*now.*$/, + details: () => 'Browsing running CTFs', + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + }, + { + path: /^\/event\/list\/.*archive.*$/, + details: () => 'Browsing past CTFs', + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + }, + { + path: /^\/tasks.*$/, + details: () => 'Searching write ups', + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + }, + { + path: /^\/calendar.*$/, + details: () => 'Checking Calendar', + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + }, + { + path: /^\/profile.*$/, + details: () => 'Editing their profile', + smallImageKey: () => Assets.Writing, + }, + { + path: /^\/writeups$/, + details: () => 'Looking for Writeups', + smallImageKey: () => Assets.Reading, + }, + { + path: /^\/writeup.*$/, + details: () => 'Reading a Challenge Writeup', + state: () => document.querySelector('.page-header h2')?.textContent ?? undefined, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Learning', + buttons: () => [ + { + label: 'Read With Me', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/task.*$/, + details: () => 'Viewng a Challenge Info', + state: () => document.querySelector('.page-header h2')?.textContent ?? undefined, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Learning', + buttons: () => [ + { + label: 'Challenge Link', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/task.*\/writeup.*$/, + details: () => 'Making a Challenge Write up', + state: () => document.querySelector('.page-header h2')?.textContent ?? undefined, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Learning', + buttons: () => [ + { + label: 'Challenge Link', + url: (() => { + return href + .split('/') + .slice(0, 5) + .join('/') + .replace(/\/writeup$/, '') + })(), + }, + ], + }, + { + path: /^\/event.*$/, + details: () => 'Viewing a CTF', + state: () => document.querySelector('.page-header h2')?.textContent ?? undefined, + largeImageKey: () => imgElements, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + buttons: () => [ + { + label: 'View CTF', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/user.*$/, + details: () => 'Viewing user profile', + state: () => document.querySelector('.page-header h2')?.textContent ?? undefined, + largeImageKey: () => imgElements, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + buttons: () => [ + { + label: 'Profile', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/team.*$/, + state: () => document.querySelector('.page-header h2')?.textContent ?? undefined, + details: () => 'Viewing a Team', + largeImageKey: () => imgElements, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + buttons: () => [ + { + label: 'View Team', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/stats.*$/, + state: () => { + const h3Elements = document.querySelectorAll('h3') + if (h3Elements.length > 1) + return `Region: ${h3Elements[0].textContent}` + else return 'Global Ranking' + }, + details: () => 'Viewing Teams Ranking', + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + buttons: () => [ + { + label: 'View Ranks', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/ctfprofile.*$/, + details: () => 'Organizing CTF', + }, + { + path: /^\/.*$/, + details: () => { + return href.split('/')[3].toUpperCase().split('-').join(' ') + }, + }, + ] - return routes.find(route => route.path.test(path)); - }; + return routes.find(route => route.path.test(path))! +} -presence.on("UpdateData", async () => { - const [showTimestamp, showButtons, showCovers] = await Promise.all([ - presence.getSetting(Settings.TIMESTAMP), - presence.getSetting(Settings.BUTTONS), - presence.getSetting(Settings.COVERS), - ]), - presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }; +presence.on('UpdateData', async () => { + const [showTimestamp, showButtons, showCovers] = await Promise.all([ + presence.getSetting(Settings.TIMESTAMP), + presence.getSetting(Settings.BUTTONS), + presence.getSetting(Settings.COVERS), + ]) + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } - if (showTimestamp) presenceData.startTimestamp = startTimestamp; + if (showTimestamp) + presenceData.startTimestamp = startTimestamp - const route = router({ - presenceData, - path: href.replace(`https://${hostname}`, ""), - }); + const route = router({ + presenceData, + path: href.replace(`https://${hostname}`, ''), + }) - if (!route) return presence.setActivity(presenceData); - if (route.state) presenceData.state = route.state(); - if (route.details) presenceData.details = route.details(); - if (showButtons && route.buttons) presenceData.buttons = route.buttons(); - if (route.largeImageKey && showCovers) - presenceData.largeImageKey = route.largeImageKey(); - if (route.smallImageKey) presenceData.smallImageKey = route.smallImageKey(); - if (route.smallImageText) - presenceData.smallImageText = route.smallImageText(); - if (showTimestamp && route.endTimestamp) - presenceData.endTimestamp = route.endTimestamp(); + if (!route) + return presence.setActivity(presenceData) + if (route.state) + presenceData.state = route.state() + if (route.details) + presenceData.details = route.details() + if (showButtons && route.buttons) + presenceData.buttons = route.buttons() as [ButtonData] + if (route.largeImageKey && showCovers) + presenceData.largeImageKey = route.largeImageKey() + if (route.smallImageKey) + presenceData.smallImageKey = route.smallImageKey() + if (route.smallImageText) + presenceData.smallImageText = route.smallImageText() + if (showTimestamp && route.endTimestamp) + presenceData.endTimestamp = route.endTimestamp() - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/Caards/metadata.json b/websites/C/Caards/metadata.json index 74ae2e6f24c6..42f033a5bdee 100644 --- a/websites/C/Caards/metadata.json +++ b/websites/C/Caards/metadata.json @@ -1,41 +1,41 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Anaxes", - "id": "567885938160697377" - }, - "service": "Caards", - "description": { - "en": "Get people to know you. Now.", - "vi_VN": "Để mọi người biết đến bạn. Ngay bây giờ." - }, - "url": [ - "www.caards.me", - "help.caards.me", - "status.caards.me" - ], - "version": "1.0.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Caards/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Caards/assets/thumbnail.jpg", - "color": "#0F1225", - "category": "socials", - "tags": [ - "profiles", - "socials" - ], - "settings": [ - { - "id": "timestamp", - "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": "Anaxes", + "id": "567885938160697377" + }, + "service": "Caards", + "description": { + "en": "Get people to know you. Now.", + "vi_VN": "Để mọi người biết đến bạn. Ngay bây giờ." + }, + "url": [ + "www.caards.me", + "help.caards.me", + "status.caards.me" + ], + "version": "1.0.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Caards/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Caards/assets/thumbnail.jpg", + "color": "#0F1225", + "category": "socials", + "tags": [ + "profiles", + "socials" + ], + "settings": [ + { + "id": "timestamp", + "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/C/Caards/presence.ts b/websites/C/Caards/presence.ts index ffcc062322af..e25e3131edcd 100644 --- a/websites/C/Caards/presence.ts +++ b/websites/C/Caards/presence.ts @@ -1,113 +1,126 @@ const presence = new Presence({ - clientId: "887975742812590120", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '887975742812590120', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Caards/assets/logo.png", - details: "Viewing unsupported page", - }; - const { pathname, href, host } = document.location, - [showTimestamp, showButtons] = await Promise.all([ - presence.getSetting("timestamp"), - presence.getSetting("buttons"), - ]), - pages: Record = { - "/popular": { - details: "Viewing", - state: "Popular caards", - buttons: [{ label: "View Popular Caards", url: href }], - }, - "/feed": { details: "Viewing feed" }, - "/partners": { - details: "Viewing page", - state: "Partners", - buttons: [{ label: "View Partners", url: href }], - }, - "/privacy": { details: "Viewing", state: "Privacy Policy" }, - "/tos": { details: "Viewing", state: "Terms of Service" }, - "/signup": { details: "Signing up" }, - }; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Caards/assets/logo.png', + details: 'Viewing unsupported page', + } + const { pathname, href, host } = document.location + const [showTimestamp, showButtons] = await Promise.all([ + presence.getSetting('timestamp'), + presence.getSetting('buttons'), + ]) + const pages: Record = { + '/popular': { + details: 'Viewing', + state: 'Popular caards', + buttons: [{ label: 'View Popular Caards', url: href }], + }, + '/feed': { details: 'Viewing feed' }, + '/partners': { + details: 'Viewing page', + state: 'Partners', + buttons: [{ label: 'View Partners', url: href }], + }, + '/privacy': { details: 'Viewing', state: 'Privacy Policy' }, + '/tos': { details: 'Viewing', state: 'Terms of Service' }, + '/signup': { details: 'Signing up' }, + } - 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 + } - switch (host) { - case "www.caards.me": { - if (pathname === "/") presenceData.details = "Viewing home page"; - else if (pathname.includes("/u/")) { - presenceData.smallImageKey = Assets.Reading; - presenceData.details = "Viewing profile"; - presenceData.state = `${ - document.querySelector("span.Name.text-3xl")?.textContent ?? "Unknown" - }`; - presenceData.buttons = [ - { - label: "View Profile", - url: href, - }, - ]; - } else if (pathname === "/me/settings") { - presenceData.details = "Editing Profile"; - presenceData.state = `${ - "Tab:" + - ` ${document.querySelector("button.B01")?.textContent ?? "User"}` - }`; - } else if (pathname === "/themes") { - presenceData.details = "Viewing page"; - presenceData.state = "Themes"; - presenceData.buttons = [ - { - label: "View Themes", - url: href, - }, - ]; - } else if (pathname.includes("/t/")) { - const [, theme] = href.split("/t/"); - presenceData.details = "Viewing theme"; - presenceData.state = `${theme}`; - presenceData.buttons = [ - { - label: `View ${theme}`, - url: href, - }, - ]; - } else { - switch (pathname) { - case "/signin": { - const username = document.querySelector("input")?.value; - presenceData.details = "Signing In"; - username - ? (presenceData.state = `To ${username}`) - : (presenceData.state = "To Unknown"); + switch (host) { + case 'www.caards.me': { + if (pathname === '/') { + presenceData.details = 'Viewing home page' + } + else if (pathname.includes('/u/')) { + presenceData.smallImageKey = Assets.Reading + presenceData.details = 'Viewing profile' + presenceData.state = `${ + document.querySelector('span.Name.text-3xl')?.textContent ?? 'Unknown' + }` + presenceData.buttons = [ + { + label: 'View Profile', + url: href, + }, + ] + } + else if (pathname === '/me/settings') { + presenceData.details = 'Editing Profile' + presenceData.state = `${ + 'Tab:' + + ` ${document.querySelector('button.B01')?.textContent ?? 'User'}` + }` + } + else if (pathname === '/themes') { + presenceData.details = 'Viewing page' + presenceData.state = 'Themes' + presenceData.buttons = [ + { + label: 'View Themes', + url: href, + }, + ] + } + else if (pathname.includes('/t/')) { + const [, theme] = href.split('/t/') + presenceData.details = 'Viewing theme' + presenceData.state = `${theme}` + presenceData.buttons = [ + { + label: `View ${theme}`, + url: href, + }, + ] + } + else { + switch (pathname) { + case '/signin': { + const username = document.querySelector('input')?.value + presenceData.details = 'Signing In' + username + ? (presenceData.state = `To ${username}`) + : (presenceData.state = 'To Unknown') - break; - } - } - } - break; - } - case "help.caards.me": { - if (pathname === "/") presenceData.details = "Viewing help page"; - else if (pathname.includes("/widgets/")) { - presenceData.details = "Viewing help info..."; - presenceData.state = `Widget: ${href.split("/widgets/")[1]}`; - } + break + } + } + } + break + } + case 'help.caards.me': { + if (pathname === '/') { + presenceData.details = 'Viewing help page' + } + else if (pathname.includes('/widgets/')) { + presenceData.details = 'Viewing help info...' + presenceData.state = `Widget: ${href.split('/widgets/')[1]}` + } - break; - } - case "status.caards.me": { - if (pathname === "/") presenceData.details = "Viewing status page"; + break + } + case 'status.caards.me': { + if (pathname === '/') + presenceData.details = 'Viewing status page' - break; - } - } + break + } + } - if (!showButtons) delete presenceData.buttons; - if (showTimestamp) presenceData.startTimestamp = browsingTimestamp; + if (!showButtons) + delete presenceData.buttons + if (showTimestamp) + 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/C/CacaX/metadata.json b/websites/C/CacaX/metadata.json index 8751192b5e85..889990b10bc7 100644 --- a/websites/C/CacaX/metadata.json +++ b/websites/C/CacaX/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "418760799226429441", - "name": "doraf" - }, - "service": "CacaX", - "description": { - "en": "The social network of the future, 100% free of expression !" - }, - "url": [ - "www.cacax.fr", - "cacax.fr" - ], - "version": "1.0.6", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/thumbnail.jpg", - "color": "#78350F", - "category": "socials", - "tags": [ - "social", - "media" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "418760799226429441", + "name": "doraf" + }, + "service": "CacaX", + "description": { + "en": "The social network of the future, 100% free of expression !" + }, + "url": [ + "www.cacax.fr", + "cacax.fr" + ], + "version": "1.0.6", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/thumbnail.jpg", + "color": "#78350F", + "category": "socials", + "tags": [ + "social", + "media" + ] +} diff --git a/websites/C/CacaX/presence.ts b/websites/C/CacaX/presence.ts index 157a4b3bc474..78ccc69fe99c 100644 --- a/websites/C/CacaX/presence.ts +++ b/websites/C/CacaX/presence.ts @@ -1,122 +1,128 @@ const presence = new Presence({ - clientId: "1193287365620400128", - }), - capitalize = (text: string): string => { - return text - .replace(/[[{(_)}\]]/g, " ") - .split(" ") - .map(str => { - return str.charAt(0).toUpperCase() + str.slice(1); - }) - .join(" "); - }; + clientId: '1193287365620400128', +}) +function capitalize(text: string): string { + return text + .replace(/[[{(_)}\]]/g, ' ') + .split(' ') + .map((str) => { + return str.charAt(0).toUpperCase() + str.slice(1) + }) + .join(' ') +} -presence.on("UpdateData", async () => { - const { pathname, href } = document.location, - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/logo.png", - }, - images = document.querySelectorAll("img"); +presence.on('UpdateData', async () => { + const { pathname, href } = document.location + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/logo.png', + } + const images = document.querySelectorAll('img') - if (pathname.includes("/users/")) { - presenceData.details = `Profil de : ${ - document - .querySelector("p.text-md.text-neutral-500") - .childNodes[0].textContent.trim() + - document - .querySelector("p.text-md.text-neutral-500") - .childNodes[1].textContent.trim() - }`; - presenceData.state = `Regarde le profil de l'utilisateur ${ - document.querySelector("h1").textContent - }...`; - presenceData.buttons = [{ label: "Voir le Profil", url: href }]; - let imgUrl = ""; + if (pathname.includes('/users/')) { + presenceData.details = `Profil de : ${ + (document + .querySelector('p.text-md.text-neutral-500') + ?.childNodes[0] + ?.textContent + ?.trim() ?? '') + + (document + .querySelector('p.text-md.text-neutral-500') + ?.childNodes[1] + ?.textContent + ?.trim() ?? '') + }` + presenceData.state = `Regarde le profil de l'utilisateur ${ + document.querySelector('h1')?.textContent + }...` + presenceData.buttons = [{ label: 'Voir le Profil', url: href }] + let imgUrl = '' - for (const image of images) { - // Vérifie si la source (src) commence par "data:image/webp;base64", si alt est égal à "Avatar" et n'est pas à l'intérieur de l'élément exclu - if ( - !image.closest(".bg-neutral-800") && - image.src.startsWith("data:image/") && - image.alt === "Avatar" - ) { - imgUrl = image.src; - presenceData.smallImageKey = imgUrl; - break; - } - } + for (const image of images) { + // Vérifie si la source (src) commence par "data:image/webp;base64", si alt est égal à "Avatar" et n'est pas à l'intérieur de l'élément exclu + if ( + !image.closest('.bg-neutral-800') + && image.src.startsWith('data:image/') + && image.alt === 'Avatar' + ) { + imgUrl = image.src + presenceData.smallImageKey = imgUrl + break + } + } - // si rien trouvé - if (imgUrl === "") { - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/0.png"; - } else presenceData.largeImageKey = imgUrl; + // si rien trouvé + if (imgUrl === '') { + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/0.png' + } + else { + presenceData.largeImageKey = imgUrl + } - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/logo.png"; - } else if (pathname.includes("/posts/")) { - presenceData.details = "Posts"; - presenceData.state = `Regarde le post de ${ - document.querySelector("span").textContent - }...`; - presenceData.buttons = [{ label: "Voir le Post", url: href }]; + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/logo.png' + } + else if (pathname.includes('/posts/')) { + presenceData.details = 'Posts' + presenceData.state = `Regarde le post de ${ + document.querySelector('span')?.textContent + }...` + presenceData.buttons = [{ label: 'Voir le Post', url: href }] - let imgUrl = ""; + let imgUrl = '' - for (const image of images) { - // Vérifie si la source (src) commence par "data:image/webp;base64", si alt est égal à "Avatar" et n'est pas à l'intérieur de l'élément exclu - if ( - !image.closest(".bg-neutral-800") && - image.src.startsWith("data:image/") && - image.alt === "Avatar" - ) { - imgUrl = image.src; - presenceData.smallImageKey = imgUrl; - break; - } - } + for (const image of images) { + // Vérifie si la source (src) commence par "data:image/webp;base64", si alt est égal à "Avatar" et n'est pas à l'intérieur de l'élément exclu + if ( + !image.closest('.bg-neutral-800') + && image.src.startsWith('data:image/') + && image.alt === 'Avatar' + ) { + imgUrl = image.src + presenceData.smallImageKey = imgUrl + break + } + } - //si rien trouvé - if (imgUrl === "") { - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/0.png"; - } else presenceData.smallImageKey = imgUrl; + // si rien trouvé + if (imgUrl === '') { + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/0.png' + } + else { + presenceData.smallImageKey = imgUrl + } - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/logo.png"; - } else { - switch (pathname) { - case "/": - presenceData.details = "Accueil"; - presenceData.state = "Regarde les derniers posts..."; - break; - case "/notifications": - presenceData.details = "Notifications"; - presenceData.state = "Regarde ses notifications..."; - break; - case "/messages": - presenceData.details = "Messagerie"; - presenceData.state = "Regarde ses messages..."; - break; - case "/about": - presenceData.details = "À propos"; - presenceData.state = "Regarde la page à propos..."; - break; - case "/privacy": - presenceData.details = "Politique de confidentialité"; - presenceData.state = - "Regarde la politique de confidentialité (il veut voir si on respecte le RGPD)..."; - break; - case "/cacaxcoin": - presenceData.details = "CacaXCoin (CXC)"; - presenceData.state = "Regarde la page CacaXCoin..."; - break; - default: - presenceData.details = "Navigue"; - presenceData.state = capitalize(pathname.split("/")[1]); - } - } + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/C/CacaX/assets/logo.png' + } + else { + switch (pathname) { + case '/': + presenceData.details = 'Accueil' + presenceData.state = 'Regarde les derniers posts...' + break + case '/notifications': + presenceData.details = 'Notifications' + presenceData.state = 'Regarde ses notifications...' + break + case '/messages': + presenceData.details = 'Messagerie' + presenceData.state = 'Regarde ses messages...' + break + case '/about': + presenceData.details = 'À propos' + presenceData.state = 'Regarde la page à propos...' + break + case '/privacy': + presenceData.details = 'Politique de confidentialité' + presenceData.state = 'Regarde la politique de confidentialité (il veut voir si on respecte le RGPD)...' + break + case '/cacaxcoin': + presenceData.details = 'CacaXCoin (CXC)' + presenceData.state = 'Regarde la page CacaXCoin...' + break + default: + presenceData.details = 'Navigue' + presenceData.state = capitalize(pathname.split('/')[1]) + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/Canva/metadata.json b/websites/C/Canva/metadata.json index 1c45272568a6..b77bfb244466 100644 --- a/websites/C/Canva/metadata.json +++ b/websites/C/Canva/metadata.json @@ -1,37 +1,37 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Tellen", - "id": "535214819520020510" - }, - "contributors": [ - { - "name": "Bas950", - "id": "241278257335500811" - } - ], - "service": "Canva", - "description": { - "en": "Canva is a simplified graphic-design tool, founded in 2012. It uses a drag-and-drop format and provides access to photographs, vector images, graphics, and fonts.", - "it": "Canva è uno strumento di progettazione grafica semplificato , fondato nel 2012. Utilizza un formato drag-and-drop e consente di accedere a fotografie, immagini vettoriali, grafica e caratteri.", - "nl": "Canva is een vereenvoudigd grafisch ontwerpprogramma, opgericht in 2012. Het gebruikt een indeling voor slepen en neerzetten en biedt toegang tot foto's, vectorafbeeldingen, afbeeldingen en lettertypen.", - "vi_VN": "Canva là công cụ thiết kế đồ hoạ đơn giản, thành lập vào năm 2012. Nó sử dụng hình thức kéo-và-thả và cung cấp truy cập vào các tranh ảnh, véc tơ, đồ hoạ và phông." - }, - "url": [ - "canva.com", - "www.canva.com" - ], - "version": "1.2.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Canva/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Canva/assets/thumbnail.png", - "color": "#4075DB", - "category": "other", - "tags": [ - "canva", - "editor", - "graphic", - "design", - "graphic-design" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Tellen", + "id": "535214819520020510" + }, + "contributors": [ + { + "name": "Bas950", + "id": "241278257335500811" + } + ], + "service": "Canva", + "description": { + "en": "Canva is a simplified graphic-design tool, founded in 2012. It uses a drag-and-drop format and provides access to photographs, vector images, graphics, and fonts.", + "it": "Canva è uno strumento di progettazione grafica semplificato , fondato nel 2012. Utilizza un formato drag-and-drop e consente di accedere a fotografie, immagini vettoriali, grafica e caratteri.", + "nl": "Canva is een vereenvoudigd grafisch ontwerpprogramma, opgericht in 2012. Het gebruikt een indeling voor slepen en neerzetten en biedt toegang tot foto's, vectorafbeeldingen, afbeeldingen en lettertypen.", + "vi_VN": "Canva là công cụ thiết kế đồ hoạ đơn giản, thành lập vào năm 2012. Nó sử dụng hình thức kéo-và-thả và cung cấp truy cập vào các tranh ảnh, véc tơ, đồ hoạ và phông." + }, + "url": [ + "canva.com", + "www.canva.com" + ], + "version": "1.2.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Canva/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Canva/assets/thumbnail.png", + "color": "#4075DB", + "category": "other", + "tags": [ + "canva", + "editor", + "graphic", + "design", + "graphic-design" + ] +} diff --git a/websites/C/Canva/presence.ts b/websites/C/Canva/presence.ts index ba386691b1ea..6bda62970de0 100644 --- a/websites/C/Canva/presence.ts +++ b/websites/C/Canva/presence.ts @@ -1,102 +1,143 @@ const presence = new Presence({ - clientId: "670612134878773297", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '670612134878773297', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/C/Canva/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Canva/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (document.location.pathname === "/") - presenceData.details = "In the Homepage"; - else if (document.location.pathname.startsWith("/folder")) { - if (document.location.pathname.startsWith("/folder/all-designs")) - presenceData.details = "Browsing his designs"; - else if (document.location.pathname.startsWith("/folder/uploads")) { - presenceData.details = "Browsing the photos he"; - presenceData.state = "uploaded"; - } else if (document.location.pathname.startsWith("/folder/purchased")) { - presenceData.details = "Browsing the photos he"; - presenceData.state = "purchased"; - } else if (document.location.pathname.startsWith("/folder/likes")) { - presenceData.details = "Browsing the photos he"; - presenceData.state = "likes"; - } else if (document.location.pathname.startsWith("/folder/shared")) { - presenceData.details = "Browsing the designs and"; - presenceData.state = "photos shared with him"; - } else if (document.location.pathname.startsWith("/folder/trash")) - presenceData.details = "Browsing the trash"; - else if (document.location.pathname === "/folder/") - presenceData.details = "Browsing his folders"; - else if (document.location.pathname === "/folder") - presenceData.details = "Browsing the folders"; - else { - presenceData.details = "Browsing the folder: "; - presenceData.state = document - .querySelector("head > title") - .textContent.replace(" - Canva", ""); - } - } else if (document.location.pathname.startsWith("/templates/")) { - if (document.location.pathname.startsWith("/templates/search/")) - presenceData.details = "Searching templates"; - else presenceData.details = "Browsing the templates"; - } else if (document.location.pathname.startsWith("/photos/")) { - if (document.location.pathname.startsWith("/photos/search/")) { - presenceData.details = "Searching photos of:"; - [presenceData.state] = document - .querySelector("head > title") - .textContent.split(" - "); - } else presenceData.details = "Browsing the photos"; - } else if (document.location.pathname.startsWith("/brand")) - presenceData.details = "Editing his brand"; - else if (document.location.pathname.startsWith("/teams")) { - if (document.location.pathname.startsWith("/teams/designs")) - presenceData.details = "Browsing the team designs"; - else if (document.location.pathname.startsWith("/teams/folders")) - presenceData.details = "Browsing the team folders"; - else if (document.location.pathname.startsWith("/teams/members")) { - presenceData.details = "Viewing the team"; - presenceData.state = "members"; - } else if (document.location.pathname.startsWith("/teams/groups")) - presenceData.details = "Viewing the team groups"; - else if (document.location.pathname.startsWith("/teams/create")) - presenceData.details = "Creating a new group"; - else presenceData.details = "Browsing the team info"; - } else if (document.location.pathname.startsWith("/groups/")) { - if (document.location.pathname.endsWith("/designs")) { - presenceData.details = "Browsing the group"; - presenceData.state = "designs"; - } else if (document.location.pathname.endsWith("/folders")) - presenceData.details = "Browsing the group folders"; - else if (document.location.pathname.endsWith("/members")) { - presenceData.details = "Viewing the group"; - presenceData.state = "members"; - } else presenceData.details = "Browsing the group info"; - } else if (document.location.pathname.startsWith("/account")) { - if (document.location.pathname.startsWith("/account/information")) - presenceData.details = "In the account settings"; - else if (document.location.pathname.startsWith("/account/billing")) - presenceData.details = "In the billing settings"; - else if (document.location.pathname.startsWith("/account/print-orders")) - presenceData.details = "Viewing his Print Orders"; - else presenceData.details = "In the account settings"; - } else if (document.location.pathname.startsWith("/rewards")) - presenceData.details = "Inviting friends"; - else if (document.location.pathname.startsWith("/design/")) { - if (document.location.pathname.endsWith("/edit")) { - presenceData.details = "Editing the design:"; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/C/Canva/assets/0.png"; - presenceData.smallImageText = "Editing"; - presenceData.state = document.querySelector("head > title").textContent; - } else if (document.location.pathname.endsWith("/view")) { - presenceData.details = "Watching the design:"; - presenceData.state = document.querySelector("head > title").textContent; - } else presenceData.details = "Viewing a design"; - } else presenceData.details = "Browsing..."; + if (document.location.pathname === '/') { + presenceData.details = 'In the Homepage' + } + else if (document.location.pathname.startsWith('/folder')) { + if (document.location.pathname.startsWith('/folder/all-designs')) { + presenceData.details = 'Browsing his designs' + } + else if (document.location.pathname.startsWith('/folder/uploads')) { + presenceData.details = 'Browsing the photos he' + presenceData.state = 'uploaded' + } + else if (document.location.pathname.startsWith('/folder/purchased')) { + presenceData.details = 'Browsing the photos he' + presenceData.state = 'purchased' + } + else if (document.location.pathname.startsWith('/folder/likes')) { + presenceData.details = 'Browsing the photos he' + presenceData.state = 'likes' + } + else if (document.location.pathname.startsWith('/folder/shared')) { + presenceData.details = 'Browsing the designs and' + presenceData.state = 'photos shared with him' + } + else if (document.location.pathname.startsWith('/folder/trash')) { + presenceData.details = 'Browsing the trash' + } + else if (document.location.pathname === '/folder/') { + presenceData.details = 'Browsing his folders' + } + else if (document.location.pathname === '/folder') { + presenceData.details = 'Browsing the folders' + } + else { + presenceData.details = 'Browsing the folder: ' + presenceData.state = document + .querySelector('head > title') + ?.textContent + ?.replace(' - Canva', '') + } + } + else if (document.location.pathname.startsWith('/templates/')) { + if (document.location.pathname.startsWith('/templates/search/')) + presenceData.details = 'Searching templates' + else presenceData.details = 'Browsing the templates' + } + else if (document.location.pathname.startsWith('/photos/')) { + if (document.location.pathname.startsWith('/photos/search/')) { + presenceData.details = 'Searching photos of:'; + [presenceData.state] = document + ?.querySelector('head > title') + ?.textContent + ?.split(' - ') ?? [] + } + else { + presenceData.details = 'Browsing the photos' + } + } + else if (document.location.pathname.startsWith('/brand')) { + presenceData.details = 'Editing his brand' + } + else if (document.location.pathname.startsWith('/teams')) { + if (document.location.pathname.startsWith('/teams/designs')) { + presenceData.details = 'Browsing the team designs' + } + else if (document.location.pathname.startsWith('/teams/folders')) { + presenceData.details = 'Browsing the team folders' + } + else if (document.location.pathname.startsWith('/teams/members')) { + presenceData.details = 'Viewing the team' + presenceData.state = 'members' + } + else if (document.location.pathname.startsWith('/teams/groups')) { + presenceData.details = 'Viewing the team groups' + } + else if (document.location.pathname.startsWith('/teams/create')) { + presenceData.details = 'Creating a new group' + } + else { + presenceData.details = 'Browsing the team info' + } + } + else if (document.location.pathname.startsWith('/groups/')) { + if (document.location.pathname.endsWith('/designs')) { + presenceData.details = 'Browsing the group' + presenceData.state = 'designs' + } + else if (document.location.pathname.endsWith('/folders')) { + presenceData.details = 'Browsing the group folders' + } + else if (document.location.pathname.endsWith('/members')) { + presenceData.details = 'Viewing the group' + presenceData.state = 'members' + } + else { + presenceData.details = 'Browsing the group info' + } + } + else if (document.location.pathname.startsWith('/account')) { + if (document.location.pathname.startsWith('/account/information')) + presenceData.details = 'In the account settings' + else if (document.location.pathname.startsWith('/account/billing')) + presenceData.details = 'In the billing settings' + else if (document.location.pathname.startsWith('/account/print-orders')) + presenceData.details = 'Viewing his Print Orders' + else presenceData.details = 'In the account settings' + } + else if (document.location.pathname.startsWith('/rewards')) { + presenceData.details = 'Inviting friends' + } + else if (document.location.pathname.startsWith('/design/')) { + if (document.location.pathname.endsWith('/edit')) { + presenceData.details = 'Editing the design:' + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/C/Canva/assets/0.png' + presenceData.smallImageText = 'Editing' + presenceData.state = document.querySelector('head > title')?.textContent + } + else if (document.location.pathname.endsWith('/view')) { + presenceData.details = 'Watching the design:' + presenceData.state = document.querySelector('head > title')?.textContent + } + else { + presenceData.details = 'Viewing a design' + } + } + else { + 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/C/Canvas/metadata.json b/websites/C/Canvas/metadata.json index b3023e0f5da6..5f2ecd3724a5 100644 --- a/websites/C/Canvas/metadata.json +++ b/websites/C/Canvas/metadata.json @@ -1,37 +1,37 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "Canvas", - "description": { - "en": "Canvas by Instructure is the world's #1 Learning Management System for schools, teachers and educators. Learn more about implementing the best LMS today." - }, - "url": [ - "learn.canvas.net", - "canvas.instructure.com", - "www.canvas.net" - ], - "regExp": "((learn|www)[.]canvas[.]net|canvas[.]\\w+?([.]\\w+)+)|(\\w+?[.]instructure[.]com)", - "version": "1.2.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Canvas/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Canvas/assets/thumbnail.png", - "color": "#e63d2f", - "category": "other", - "tags": [ - "education", - "homework", - "quizzes", - "grading" - ], - "settings": [ - { - "id": "privacyMode", - "icon": "fas fa-user-secret", - "title": "Privacy Mode", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "Canvas", + "description": { + "en": "Canvas by Instructure is the world's #1 Learning Management System for schools, teachers and educators. Learn more about implementing the best LMS today." + }, + "url": [ + "learn.canvas.net", + "canvas.instructure.com", + "www.canvas.net" + ], + "regExp": "((learn|www)[.]canvas[.]net|canvas[.]\\w+?([.]\\w+)+)|(\\w+?[.]instructure[.]com)", + "version": "1.2.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Canvas/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Canvas/assets/thumbnail.png", + "color": "#e63d2f", + "category": "other", + "tags": [ + "education", + "homework", + "quizzes", + "grading" + ], + "settings": [ + { + "id": "privacyMode", + "icon": "fas fa-user-secret", + "title": "Privacy Mode", + "value": false + } + ] +} diff --git a/websites/C/Canvas/presence.ts b/websites/C/Canvas/presence.ts index c772383a356a..ec962431b485 100644 --- a/websites/C/Canvas/presence.ts +++ b/websites/C/Canvas/presence.ts @@ -1,939 +1,971 @@ const presence = new Presence({ - clientId: "1023383174027415572", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - canvasDataFunctions = { - announcement: ( - presenceData: PresenceData, - category: string, - private: boolean - ) => { - return (presenceData.details = applyPrivacy( - "Viewing announcements", - category, - private - )); - }, - discussion: ( - presenceData: PresenceData, - category: string, - discussionPath: string[], - private: boolean - ) => { - switch (discussionPath[0] ?? "") { - case "": { - presenceData.details = applyPrivacy( - "Viewing discussions", - category, - private - ); - break; - } - case "new": { - presenceData.details = applyPrivacy( - `Creating a new ${ - getNavigationPath()[1] === "Announcements" - ? "announcement" - : "discussion" - }`, - category, - private - ); - if (!private) { - presenceData.state = - document.querySelector( - "#discussion-title" - ).value; - } - break; - } - default: { - if (discussionPath[1] === "edit") { - presenceData.details = applyPrivacy( - `Editing a ${ - getNavigationPath()[1] === "Announcements" - ? "announcement" - : "discussion" - }`, - category, - private - ); - if (!private) { - presenceData.state = - document.querySelector( - "#discussion-title" - ).value; - } - } else { - presenceData.details = applyPrivacy( - `Viewing a ${ - getNavigationPath()[1] === "Announcements" - ? "announcement" - : "discussion" - }`, - category, - private - ); - if (!private) { - presenceData.state = - document.querySelector( - ".discussion-title" - ).textContent; - } - } - } - } - }, - pages: ( - presenceData: PresenceData, - category: string, - pagesPath: string[], - private: boolean - ) => { - if (pagesPath[0]) { - if (pagesPath[1] === "edit") { - presenceData.details = applyPrivacy( - "Editing a page", - category, - private - ); - if (!private) { - presenceData.state = - document.querySelector("#title").value; - } - } else { - presenceData.details = applyPrivacy( - "Viewing a page", - category, - private - ); - if (!private) { - presenceData.state = - document.querySelector( - ".page-title" - ).textContent; - } - } - } else { - const titleInput = document.querySelector("#title"); - if (titleInput) { - presenceData.details = applyPrivacy( - "Creating a page", - category, - private - ); - if (!private) presenceData.state = titleInput.value; - } else { - presenceData.details = applyPrivacy( - "Viewing pages", - category, - private - ); - } - } - }, - files: ( - presenceData: PresenceData, - category: string = null, - private: boolean - ) => { - if (category) { - presenceData.details = applyPrivacy( - "Browsing files", - category, - private - ); - } else presenceData.details = "Browsing files"; - if (!private) { - presenceData.state = document.querySelector( - "#breadcrumbs>ul>li+li:last-of-type a" - ).textContent; - } - }, - collaborations: ( - presenceData: PresenceData, - category: string, - private: boolean - ) => { - if ( - document.querySelector("#new_collaboration").style - .display !== "none" - ) { - presenceData.details = applyPrivacy( - "Creating a collaboration", - category, - private - ); - if (!private) { - presenceData.state = document.querySelector( - "#collaboration_collaboration_type" - ).value; - } - } else if ( - document.querySelector(".edit_collaboration") - ) { - presenceData.details = applyPrivacy( - "Editing a collaboration", - category, - private - ); - if (!private) { - presenceData.state = document.querySelector( - "[name='collaboration[title]']" - ).value; - } - } else { - presenceData.details = applyPrivacy( - "Browsing collaborations", - category, - private - ); - } - }, - conferences: ( - presenceData: PresenceData, - category: string, - private: boolean - ) => { - const conferenceInput = document.querySelector( - "#web_conference_conference_type" - ); - if (conferenceInput) { - presenceData.details = applyPrivacy( - `${conferenceInput.disabled ? "Editing" : "Creating"} a conference`, - category, - private - ); - if (!private) { - presenceData.state = document.querySelector( - "#web_conference_title" - ).value; - } - } else { - presenceData.details = applyPrivacy( - "Browsing conferences", - category, - private - ); - } - }, - people: ( - presenceData: PresenceData, - category: string, - private: boolean - ) => { - presenceData.details = applyPrivacy( - "Browsing members", - category, - private - ); - }, - profile: (presenceData: PresenceData, private: boolean) => { - presenceData.details = "Viewing a user's profile"; - if (!private) { - presenceData.state = document - .querySelector("h2") - .textContent.trim(); - presenceData.smallImageKey = getComputedStyle( - document.querySelector(".avatar") - ).backgroundImage.match(/url\("(.+)"\)/)[1]; - } - }, - }; + clientId: '1023383174027415572', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const canvasDataFunctions = { + announcement: ( + presenceData: PresenceData, + category: string, + isPrivate: boolean, + ) => { + return (presenceData.details = applyPrivacy( + 'Viewing announcements', + category, + isPrivate, + )) + }, + discussion: ( + presenceData: PresenceData, + category: string, + discussionPath: string[], + isPrivate: boolean, + ) => { + switch (discussionPath[0] ?? '') { + case '': { + presenceData.details = applyPrivacy( + 'Viewing discussions', + category, + isPrivate, + ) + break + } + case 'new': { + presenceData.details = applyPrivacy( + `Creating a new ${ + getNavigationPath()[1] === 'Announcements' + ? 'announcement' + : 'discussion' + }`, + category, + isPrivate, + ) + if (!isPrivate) { + presenceData.state = document.querySelector( + '#discussion-title', + )?.value + } + break + } + default: { + if (discussionPath[1] === 'edit') { + presenceData.details = applyPrivacy( + `Editing a ${ + getNavigationPath()[1] === 'Announcements' + ? 'announcement' + : 'discussion' + }`, + category, + isPrivate, + ) + if (!isPrivate) { + presenceData.state = document.querySelector( + '#discussion-title', + )?.value + } + } + else { + presenceData.details = applyPrivacy( + `Viewing a ${ + getNavigationPath()[1] === 'Announcements' + ? 'announcement' + : 'discussion' + }`, + category, + isPrivate, + ) + if (!isPrivate) { + presenceData.state = document.querySelector( + '.discussion-title', + )?.textContent + } + } + } + } + }, + pages: ( + presenceData: PresenceData, + category: string, + pagesPath: string[], + isPrivate: boolean, + ) => { + if (pagesPath[0]) { + if (pagesPath[1] === 'edit') { + presenceData.details = applyPrivacy( + 'Editing a page', + category, + isPrivate, + ) + if (!isPrivate) { + presenceData.state = document.querySelector('#title')?.value + } + } + else { + presenceData.details = applyPrivacy( + 'Viewing a page', + category, + isPrivate, + ) + if (!isPrivate) { + presenceData.state = document.querySelector( + '.page-title', + )?.textContent + } + } + } + else { + const titleInput = document.querySelector('#title') + if (titleInput) { + presenceData.details = applyPrivacy( + 'Creating a page', + category, + isPrivate, + ) + if (!isPrivate) + presenceData.state = titleInput.value + } + else { + presenceData.details = applyPrivacy( + 'Viewing pages', + category, + isPrivate, + ) + } + } + }, + files: ( + presenceData: PresenceData, + category: string | null = null, + isPrivate: boolean, + ) => { + if (category) { + presenceData.details = applyPrivacy( + 'Browsing files', + category, + isPrivate, + ) + } + else { + presenceData.details = 'Browsing files' + } + if (!isPrivate) { + presenceData.state = document.querySelector( + '#breadcrumbs>ul>li+li:last-of-type a', + )?.textContent + } + }, + collaborations: ( + presenceData: PresenceData, + category: string, + isPrivate: boolean, + ) => { + if ( + document.querySelector('#new_collaboration')?.style.display !== 'none' + ) { + presenceData.details = applyPrivacy( + 'Creating a collaboration', + category, + isPrivate, + ) + if (!isPrivate) { + presenceData.state = document.querySelector( + '#collaboration_collaboration_type', + )?.value + } + } + else if ( + document.querySelector('.edit_collaboration') + ) { + presenceData.details = applyPrivacy( + 'Editing a collaboration', + category, + isPrivate, + ) + if (!isPrivate) { + presenceData.state = document.querySelector( + '[name=\'collaboration[title]\']', + )?.value + } + } + else { + presenceData.details = applyPrivacy( + 'Browsing collaborations', + category, + isPrivate, + ) + } + }, + conferences: ( + presenceData: PresenceData, + category: string, + isPrivate: boolean, + ) => { + const conferenceInput = document.querySelector( + '#web_conference_conference_type', + ) + if (conferenceInput) { + presenceData.details = applyPrivacy( + `${conferenceInput.disabled ? 'Editing' : 'Creating'} a conference`, + category, + isPrivate, + ) + if (!isPrivate) { + presenceData.state = document.querySelector( + '#web_conference_title', + )?.value + } + } + else { + presenceData.details = applyPrivacy( + 'Browsing conferences', + category, + isPrivate, + ) + } + }, + people: ( + presenceData: PresenceData, + category: string, + isPrivate: boolean, + ) => { + presenceData.details = applyPrivacy( + 'Browsing members', + category, + isPrivate, + ) + }, + profile: (presenceData: PresenceData, isPrivate: boolean) => { + presenceData.details = 'Viewing a user\'s profile' + if (!isPrivate) { + presenceData.state = document + .querySelector('h2') + ?.textContent + ?.trim() + presenceData.smallImageKey = getComputedStyle( + document.querySelector('.avatar')!, + )?.backgroundImage?.match(/url\("(.+)"\)/)?.[1] + } + }, +} -function applyPrivacy(input: string, detail: string, private: boolean) { - return private ? input : `${input} for ${detail}`; +function applyPrivacy(input: string, detail: string, isPrivate: boolean) { + return isPrivate ? input : `${input} for ${detail}` } function getNavigationPath(): string[] { - return [...(document.querySelector("#breadcrumbs > ul")?.children ?? [])] - .slice(1) - .map(li => { - return li.textContent; - }); + return [...(document.querySelector('#breadcrumbs > ul')?.children ?? [])] + .slice(1) + .map((li) => { + return li?.textContent ?? '' + }) } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Canvas/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, hostname, search } = document.location, - pathSplit = pathname.split("/").filter(val => val), - privacyMode = await presence.getSetting("privacyMode"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Canvas/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, hostname, search } = document.location + const pathSplit = pathname.split('/').filter(val => val) + const privacyMode = await presence.getSetting('privacyMode') - if (hostname === "www.canvas.net") { - switch (pathSplit[0] ?? "") { - case "": { - presenceData.details = "Browsing catalog"; - break; - } - case "browse": { - presenceData.details = "Browsing course details"; - presenceData.state = - document.querySelector(".h1").textContent; - break; - } - case "courses": { - presenceData.details = "Enrolling in a course"; - presenceData.state = - document.querySelector( - "h2 > span" - ).lastChild.textContent; - break; - } - case "dashboard": { - presenceData.details = "Viewing their dashboard"; - break; - } - case "order_items": { - presenceData.details = "Viewing their purchase history"; - break; - } - } - } else { - // All other canvas domains - const navigationPath = getNavigationPath(), - topPath = navigationPath[navigationPath.length - 1], - firstPath = navigationPath[0]; - switch (pathSplit[0] ?? "") { - case "": { - presenceData.details = "Viewing dashboard"; - break; - } - case "about": { - canvasDataFunctions.profile(presenceData, privacyMode); - break; - } - case "account_notifications": { - presenceData.details = "Viewing global notifications"; - break; - } - case "calendar": { - presenceData.details = "Viewing calendar"; - presenceData.state = document.querySelector( - ".navigation_title_text" - ).textContent; - break; - } - case "conversations": { - const conversationInput = document.querySelector( - "#compose-message-subject" - ); - if (conversationInput) { - presenceData.details = "Composing a message"; - presenceData.state = conversationInput.value; - } else presenceData.details = "Viewing messages"; - break; - } - case "courses": { - if (pathSplit[1]) { - switch (pathSplit[2] ?? "") { - case "": { - if (privacyMode) presenceData.details = "Viewing a course"; - else { - presenceData.details = "Viewing course"; - presenceData.state = firstPath; - } - break; - } - case "announcements": { - canvasDataFunctions.announcement( - presenceData, - `course: ${firstPath}`, - privacyMode - ); - break; - } - case "assignments": { - switch (pathSplit[3] ?? "") { - case "": { - presenceData.details = applyPrivacy( - "Viewing assignments", - `course: ${firstPath}`, - privacyMode - ); - break; - } - case "new": { - presenceData.details = applyPrivacy( - "Creating an assignment", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) { - presenceData.state = - document.querySelector( - "#assignment_name" - ).value; - } - break; - } - case "syllabus": { - if ( - document.querySelector( - "#course_syllabus_body_ifr" - ) - ) { - presenceData.details = applyPrivacy( - "Editing syllabus", - `course: ${firstPath}`, - privacyMode - ); - } else { - presenceData.details = applyPrivacy( - "Viewing syllabus", - `course: ${firstPath}`, - privacyMode - ); - } - break; - } - default: { - switch (pathSplit[4]) { - case "edit": { - presenceData.details = applyPrivacy( - "Editing an assignment", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) { - presenceData.state = - document.querySelector( - "#assignment_name" - ).value; - } - break; - } - case "submissions": { - presenceData.details = applyPrivacy( - "Viewing submissions for an assignment", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) presenceData.state = navigationPath[2]; - break; - } - case "peer_reviews": { - presenceData.details = applyPrivacy( - "Viewing peer reviews for an assignment", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) presenceData.state = topPath; - break; - } - default: { - presenceData.details = applyPrivacy( - "Viewing assignment", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) presenceData.state = topPath; - } - } - } - } - break; - } - case "collaborations": { - canvasDataFunctions.collaborations( - presenceData, - `course: ${firstPath}`, - privacyMode - ); - break; - } - case "conferences": { - canvasDataFunctions.conferences( - presenceData, - `course: ${firstPath}`, - privacyMode - ); - break; - } - case "discussion_topics": { - canvasDataFunctions.discussion( - presenceData, - `course: ${firstPath}`, - pathSplit.slice(3), - privacyMode - ); - break; - } - case "external_tools": { - if (privacyMode) - presenceData.details = "Viewing external tools for a course"; - else { - presenceData.details = `Viewing course: ${firstPath}`; - presenceData.state = topPath; - } - break; - } - case "files": { - canvasDataFunctions.files( - presenceData, - `course: ${firstPath}`, - privacyMode - ); - break; - } - case "gradebook": { - switch (pathSplit[3]) { - case "history": { - presenceData.details = applyPrivacy( - "Viewing grade history", - `course: ${firstPath}`, - privacyMode - ); - break; - } - case "speed_grader": { - presenceData.details = applyPrivacy( - "Grading an assignment", - `course: ${ - document.querySelector( - "#context_title" - ).textContent - }`, - privacyMode - ); - if (!privacyMode) { - presenceData.state = - document.querySelector( - ".assignmentDetails__Title" - ).textContent; - } - break; - } - default: { - presenceData.details = applyPrivacy( - "Viewing gradebook", - `course: ${firstPath}`, - privacyMode - ); - } - } - break; - } - case "grades": { - if (pathSplit[3]) { - presenceData.details = applyPrivacy( - "Viewing student grades", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) presenceData.state = topPath; - } else { - presenceData.details = applyPrivacy( - "Viewing grades", - `course: ${firstPath}`, - privacyMode - ); - } - break; - } - case "groups": { - presenceData.details = applyPrivacy( - "Viewing groups", - `course: ${firstPath}`, - privacyMode - ); - break; - } - case "modules": { - if (pathSplit[3] === "progressions") { - presenceData.details = applyPrivacy( - "Viewing module progression", - `course: ${firstPath}`, - privacyMode - ); - } else { - presenceData.details = applyPrivacy( - "Viewing modules", - `course: ${firstPath}`, - privacyMode - ); - } - break; - } - case "outcomes": { - const createOutcomeModal = - document.querySelector( - "[data-testid='createOutcomeModal']" - ), - editOutcomeInput = document.querySelector( - "[data-testid='name-input']" - ); - if (createOutcomeModal) { - presenceData.details = applyPrivacy( - "Creating an outcome", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) { - presenceData.state = - createOutcomeModal.querySelector( - "input" - ).value; - } - } else if (editOutcomeInput) { - presenceData.details = applyPrivacy( - "Editing an outcome", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) presenceData.state = editOutcomeInput.value; - } else { - presenceData.details = applyPrivacy( - "Viewing outcomes", - `course: ${firstPath}`, - privacyMode - ); - } - break; - } - case "pages": { - canvasDataFunctions.pages( - presenceData, - `course: ${firstPath}`, - pathSplit.slice(3), - privacyMode - ); - break; - } - case "quizzes": { - if (pathSplit[3]) { - switch (pathSplit[4] ?? "") { - case "": { - presenceData.details = applyPrivacy( - "Viewing a quiz", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) presenceData.state = topPath; - break; - } - case "edit": { - presenceData.details = applyPrivacy( - "Editing a quiz", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) presenceData.state = topPath; - break; - } - case "history": { - presenceData.details = applyPrivacy( - "Viewing an attempt for a quiz", - /* in */ `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) { - presenceData.state = `${navigationPath[2]} - Attempt ${ - document - .querySelector( - ".quiz_version.selected" - ) - .textContent.match(/(\d+):/)[1] - }`; - } - break; - } - case "moderate": { - presenceData.details = applyPrivacy( - "Moderating a quiz", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) presenceData.state = navigationPath[2]; - break; - } - case "statistics": { - presenceData.details = applyPrivacy( - "Viewing statistics for a quiz", - /* in */ `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) presenceData.state = navigationPath[2]; - break; - } - case "submissions": { - presenceData.details = applyPrivacy( - "Viewing quiz log", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) - presenceData.state = `${navigationPath[2]} - ${navigationPath[3]}`; - break; - } - case "take": { - presenceData.details = applyPrivacy( - "Taking a quiz", - `course: ${firstPath}`, - privacyMode - ); - const currentQuestion = document.querySelector( - ".current_question i" - ), - timeElapsedType = document - .querySelector(".time_header") - .textContent.match(/(Running|Elapsed)/i)[1], - [, years, months, days, hours, minutes, seconds] = - document - .querySelector(".time_running") - .textContent.match( - /(?:([\d,]+) Years?, )?(?:(\d+) Months?, )?(?:(\d+) Days?, )?(?:(\d+) Hours?, )?(?:(\d+) Minutes?, )?(\d+) Seconds?/ - ) - .map(x => (x ? +x.replaceAll(",", "") : 0)), - timeElapsed = new Date(), - daySeconds = - seconds + minutes * 60 + hours * 3600 + days * 86400; - if (timeElapsedType === "Running") { - timeElapsed.setFullYear( - timeElapsed.getFullYear() + years - ); - timeElapsed.setMonth( - (timeElapsed.getMonth() + 1 + months) % 12 - ); - if (timeElapsed.getMonth() + 1 + months > 12) - timeElapsed.setFullYear(timeElapsed.getFullYear() + 1); - timeElapsed.setTime( - timeElapsed.getTime() + daySeconds * 1000 - ); - presenceData.startTimestamp = Math.floor( - Date.now() / 1000 - ); - presenceData.endTimestamp = Math.floor( - timeElapsed.getTime() / 1000 - ); - } else { - timeElapsed.setFullYear( - timeElapsed.getFullYear() - years - ); - timeElapsed.setMonth( - 12 - ((timeElapsed.getMonth() + 1 - months) % 12) - ); - if (timeElapsed.getMonth() + 1 - months < 0) - timeElapsed.setFullYear(timeElapsed.getFullYear() - 1); - timeElapsed.setTime( - timeElapsed.getTime() - daySeconds * 1000 - ); - presenceData.startTimestamp = Math.floor( - timeElapsed.getTime() / 1000 - ); - } - if (!privacyMode) { - presenceData.state = currentQuestion - ? `${topPath} - ${currentQuestion.nextSibling.textContent}` - : topPath; - } - break; - } - } - } else { - presenceData.details = applyPrivacy( - "Viewing quizzes", - `course: ${firstPath}`, - privacyMode - ); - } - break; - } - case "rubrics": { - if (document.querySelector("#rubric_new")) { - presenceData.details = applyPrivacy( - `${pathSplit[3] ? "Editing" : "Creating"} a rubric`, - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) { - presenceData.state = - document.querySelector( - "#rubric-title" - ).value; - } - } else if (pathSplit[3]) { - presenceData.details = applyPrivacy( - "Viewing rubric", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) presenceData.state = topPath; - } else { - presenceData.details = applyPrivacy( - "Viewing rubrics", - `course: ${firstPath}`, - privacyMode - ); - } - break; - } - case "settings": { - presenceData.details = applyPrivacy( - "Managing settings", - `course: ${firstPath}`, - privacyMode - ); - if (!privacyMode) { - presenceData.state = - document.querySelector( - ".ui-tabs-active" - ).textContent; - } - break; - } - case "users": { - if (pathSplit[3]) - canvasDataFunctions.profile(presenceData, privacyMode); - else { - canvasDataFunctions.people( - presenceData, - `course: ${firstPath}`, - privacyMode - ); - } - break; - } - } - } else presenceData.details = "Browsing all courses"; - break; - } - case "files": { - canvasDataFunctions.files(presenceData, null, privacyMode); - break; - } - case "groups": { - if (pathSplit[1]) { - presenceData.details = "Viewing a group"; - switch (pathSplit[2] ?? "") { - case "": { - if (!privacyMode) presenceData.state = topPath; - break; - } - case "announcements": { - canvasDataFunctions.announcement( - presenceData, - `group: ${firstPath}`, - privacyMode - ); - break; - } - case "pages": { - canvasDataFunctions.pages( - presenceData, - `group: ${firstPath}`, - pathSplit.slice(3), - privacyMode - ); - break; - } - case "discussion_topics": { - canvasDataFunctions.discussion( - presenceData, - `group: ${firstPath}`, - pathSplit.slice(3), - privacyMode - ); - break; - } - case "files": { - canvasDataFunctions.files( - presenceData, - `group: ${firstPath}`, - privacyMode - ); - break; - } - case "collaborations": { - canvasDataFunctions.collaborations( - presenceData, - `group: ${firstPath}`, - privacyMode - ); - break; - } - case "conferences": { - canvasDataFunctions.conferences( - presenceData, - `group: ${firstPath}`, - privacyMode - ); - break; - } - case "users": { - if (pathSplit[3]) - canvasDataFunctions.profile(presenceData, privacyMode); - else { - canvasDataFunctions.people( - presenceData, - `group: ${firstPath}`, - privacyMode - ); - } - break; - } - } - } else presenceData.details = "Viewing groups"; - break; - } - case "profile": { - switch (pathSplit[1] ?? "") { - case "": { - const profileNameInput = - document.querySelector("#name_input"); - if (profileNameInput) { - presenceData.details = "Editing profile"; - if (!privacyMode) presenceData.state = profileNameInput.value; - } else canvasDataFunctions.profile(presenceData, privacyMode); - break; - } - case "communication": { - presenceData.details = "Managing notification settings"; - break; - } - case "content_shares": { - presenceData.details = "Viewing shared content"; - break; - } - case "settings": { - presenceData.details = "Editing profile settings"; - break; - } - case "qr_mobile_login": { - presenceData.details = "Viewing QR code"; - break; - } - } - break; - } - case "search": { - switch (pathSplit[1]) { - case "all_courses": { - presenceData.details = "Searching all courses"; - presenceData.state = new URLSearchParams(search).get("search"); - break; - } - case "rubrics": { - presenceData.details = "Searching rubrics"; - break; - } - } - break; - } - default: { - presenceData.details = "Browsing"; - if (!privacyMode) { - presenceData.state = - document.querySelector("h2")?.textContent ?? - document.title; - } - } - } - } + if (hostname === 'www.canvas.net') { + switch (pathSplit[0] ?? '') { + case '': { + presenceData.details = 'Browsing catalog' + break + } + case 'browse': { + presenceData.details = 'Browsing course details' + presenceData.state = document.querySelector('.h1')?.textContent + break + } + case 'courses': { + presenceData.details = 'Enrolling in a course' + presenceData.state = document.querySelector( + 'h2 > span', + )?.lastChild?.textContent + break + } + case 'dashboard': { + presenceData.details = 'Viewing their dashboard' + break + } + case 'order_items': { + presenceData.details = 'Viewing their purchase history' + break + } + } + } + else { + // All other canvas domains + const navigationPath = getNavigationPath() + const topPath = navigationPath[navigationPath.length - 1] + const firstPath = navigationPath[0] + switch (pathSplit[0] ?? '') { + case '': { + presenceData.details = 'Viewing dashboard' + break + } + case 'about': { + canvasDataFunctions.profile(presenceData, privacyMode) + break + } + case 'account_notifications': { + presenceData.details = 'Viewing global notifications' + break + } + case 'calendar': { + presenceData.details = 'Viewing calendar' + presenceData.state = document.querySelector( + '.navigation_title_text', + )?.textContent + break + } + case 'conversations': { + const conversationInput = document.querySelector( + '#compose-message-subject', + ) + if (conversationInput) { + presenceData.details = 'Composing a message' + presenceData.state = conversationInput.value + } + else { + presenceData.details = 'Viewing messages' + } + break + } + case 'courses': { + if (pathSplit[1]) { + switch (pathSplit[2] ?? '') { + case '': { + if (privacyMode) { + presenceData.details = 'Viewing a course' + } + else { + presenceData.details = 'Viewing course' + presenceData.state = firstPath + } + break + } + case 'announcements': { + canvasDataFunctions.announcement( + presenceData, + `course: ${firstPath}`, + privacyMode, + ) + break + } + case 'assignments': { + switch (pathSplit[3] ?? '') { + case '': { + presenceData.details = applyPrivacy( + 'Viewing assignments', + `course: ${firstPath}`, + privacyMode, + ) + break + } + case 'new': { + presenceData.details = applyPrivacy( + 'Creating an assignment', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) { + presenceData.state = document.querySelector( + '#assignment_name', + )?.value + } + break + } + case 'syllabus': { + if ( + document.querySelector( + '#course_syllabus_body_ifr', + ) + ) { + presenceData.details = applyPrivacy( + 'Editing syllabus', + `course: ${firstPath}`, + privacyMode, + ) + } + else { + presenceData.details = applyPrivacy( + 'Viewing syllabus', + `course: ${firstPath}`, + privacyMode, + ) + } + break + } + default: { + switch (pathSplit[4]) { + case 'edit': { + presenceData.details = applyPrivacy( + 'Editing an assignment', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) { + presenceData.state = document.querySelector( + '#assignment_name', + )?.value + } + break + } + case 'submissions': { + presenceData.details = applyPrivacy( + 'Viewing submissions for an assignment', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) + presenceData.state = navigationPath[2] + break + } + case 'peer_reviews': { + presenceData.details = applyPrivacy( + 'Viewing peer reviews for an assignment', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) + presenceData.state = topPath + break + } + default: { + presenceData.details = applyPrivacy( + 'Viewing assignment', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) + presenceData.state = topPath + } + } + } + } + break + } + case 'collaborations': { + canvasDataFunctions.collaborations( + presenceData, + `course: ${firstPath}`, + privacyMode, + ) + break + } + case 'conferences': { + canvasDataFunctions.conferences( + presenceData, + `course: ${firstPath}`, + privacyMode, + ) + break + } + case 'discussion_topics': { + canvasDataFunctions.discussion( + presenceData, + `course: ${firstPath}`, + pathSplit.slice(3), + privacyMode, + ) + break + } + case 'external_tools': { + if (privacyMode) { + presenceData.details = 'Viewing external tools for a course' + } + else { + presenceData.details = `Viewing course: ${firstPath}` + presenceData.state = topPath + } + break + } + case 'files': { + canvasDataFunctions.files( + presenceData, + `course: ${firstPath}`, + privacyMode, + ) + break + } + case 'gradebook': { + switch (pathSplit[3]) { + case 'history': { + presenceData.details = applyPrivacy( + 'Viewing grade history', + `course: ${firstPath}`, + privacyMode, + ) + break + } + case 'speed_grader': { + presenceData.details = applyPrivacy( + 'Grading an assignment', + `course: ${ + document.querySelector( + '#context_title', + )?.textContent + }`, + privacyMode, + ) + if (!privacyMode) { + presenceData.state = document.querySelector( + '.assignmentDetails__Title', + )?.textContent + } + break + } + default: { + presenceData.details = applyPrivacy( + 'Viewing gradebook', + `course: ${firstPath}`, + privacyMode, + ) + } + } + break + } + case 'grades': { + if (pathSplit[3]) { + presenceData.details = applyPrivacy( + 'Viewing student grades', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) + presenceData.state = topPath + } + else { + presenceData.details = applyPrivacy( + 'Viewing grades', + `course: ${firstPath}`, + privacyMode, + ) + } + break + } + case 'groups': { + presenceData.details = applyPrivacy( + 'Viewing groups', + `course: ${firstPath}`, + privacyMode, + ) + break + } + case 'modules': { + if (pathSplit[3] === 'progressions') { + presenceData.details = applyPrivacy( + 'Viewing module progression', + `course: ${firstPath}`, + privacyMode, + ) + } + else { + presenceData.details = applyPrivacy( + 'Viewing modules', + `course: ${firstPath}`, + privacyMode, + ) + } + break + } + case 'outcomes': { + const createOutcomeModal = document.querySelector( + '[data-testid=\'createOutcomeModal\']', + ) + const editOutcomeInput = document.querySelector( + '[data-testid=\'name-input\']', + ) + if (createOutcomeModal) { + presenceData.details = applyPrivacy( + 'Creating an outcome', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) { + presenceData.state = createOutcomeModal?.querySelector( + 'input', + )?.value + } + } + else if (editOutcomeInput) { + presenceData.details = applyPrivacy( + 'Editing an outcome', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) + presenceData.state = editOutcomeInput.value + } + else { + presenceData.details = applyPrivacy( + 'Viewing outcomes', + `course: ${firstPath}`, + privacyMode, + ) + } + break + } + case 'pages': { + canvasDataFunctions.pages( + presenceData, + `course: ${firstPath}`, + pathSplit.slice(3), + privacyMode, + ) + break + } + case 'quizzes': { + if (pathSplit[3]) { + switch (pathSplit[4] ?? '') { + case '': { + presenceData.details = applyPrivacy( + 'Viewing a quiz', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) + presenceData.state = topPath + break + } + case 'edit': { + presenceData.details = applyPrivacy( + 'Editing a quiz', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) + presenceData.state = topPath + break + } + case 'history': { + presenceData.details = applyPrivacy( + 'Viewing an attempt for a quiz', + /* in */ `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) { + presenceData.state = `${navigationPath[2]} - Attempt ${ + document + .querySelector( + '.quiz_version.selected', + ) + ?.textContent + ?.match(/(\d+):/)?.[1] + }` + } + break + } + case 'moderate': { + presenceData.details = applyPrivacy( + 'Moderating a quiz', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) + presenceData.state = navigationPath[2] + break + } + case 'statistics': { + presenceData.details = applyPrivacy( + 'Viewing statistics for a quiz', + /* in */ `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) + presenceData.state = navigationPath[2] + break + } + case 'submissions': { + presenceData.details = applyPrivacy( + 'Viewing quiz log', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) + presenceData.state = `${navigationPath[2]} - ${navigationPath[3]}` + break + } + case 'take': { + presenceData.details = applyPrivacy( + 'Taking a quiz', + `course: ${firstPath}`, + privacyMode, + ) + const currentQuestion = document.querySelector( + '.current_question i', + ) + const timeElapsedType = document + .querySelector('.time_header') + ?.textContent + ?.match(/(Running|Elapsed)/i)?.[1] + const [, years, months, days, hours, minutes, seconds] = document + .querySelector('.time_running')!.textContent!.match( + /(?:([\d,]+) Years?, )?(?:(\d+) Months?, )?(?:(\d+) Days?, )?(?:(\d+) Hours?, )?(?:(\d+) Minutes?, )?(\d+) Seconds?/, + )!.map(x => (x ? +x.replaceAll(',', '') : 0)) + const timeElapsed = new Date() + const daySeconds = seconds + minutes * 60 + hours * 3600 + days * 86400 + if (timeElapsedType === 'Running') { + timeElapsed.setFullYear( + timeElapsed.getFullYear() + years, + ) + timeElapsed.setMonth( + (timeElapsed.getMonth() + 1 + months) % 12, + ) + if (timeElapsed.getMonth() + 1 + months > 12) + timeElapsed.setFullYear(timeElapsed.getFullYear() + 1) + timeElapsed.setTime( + timeElapsed.getTime() + daySeconds * 1000, + ) + presenceData.startTimestamp = Math.floor( + Date.now() / 1000, + ) + presenceData.endTimestamp = Math.floor( + timeElapsed.getTime() / 1000, + ) + } + else { + timeElapsed.setFullYear( + timeElapsed.getFullYear() - years, + ) + timeElapsed.setMonth( + 12 - ((timeElapsed.getMonth() + 1 - months) % 12), + ) + if (timeElapsed.getMonth() + 1 - months < 0) + timeElapsed.setFullYear(timeElapsed.getFullYear() - 1) + timeElapsed.setTime( + timeElapsed.getTime() - daySeconds * 1000, + ) + presenceData.startTimestamp = Math.floor( + timeElapsed.getTime() / 1000, + ) + } + if (!privacyMode) { + presenceData.state = currentQuestion + ? `${topPath} - ${currentQuestion.nextSibling?.textContent}` + : topPath + } + break + } + } + } + else { + presenceData.details = applyPrivacy( + 'Viewing quizzes', + `course: ${firstPath}`, + privacyMode, + ) + } + break + } + case 'rubrics': { + if (document.querySelector('#rubric_new')) { + presenceData.details = applyPrivacy( + `${pathSplit[3] ? 'Editing' : 'Creating'} a rubric`, + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) { + presenceData.state = document.querySelector( + '#rubric-title', + )?.value + } + } + else if (pathSplit[3]) { + presenceData.details = applyPrivacy( + 'Viewing rubric', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) + presenceData.state = topPath + } + else { + presenceData.details = applyPrivacy( + 'Viewing rubrics', + `course: ${firstPath}`, + privacyMode, + ) + } + break + } + case 'settings': { + presenceData.details = applyPrivacy( + 'Managing settings', + `course: ${firstPath}`, + privacyMode, + ) + if (!privacyMode) { + presenceData.state = document.querySelector( + '.ui-tabs-active', + )?.textContent + } + break + } + case 'users': { + if (pathSplit[3]) { + canvasDataFunctions.profile(presenceData, privacyMode) + } + else { + canvasDataFunctions.people( + presenceData, + `course: ${firstPath}`, + privacyMode, + ) + } + break + } + } + } + else { + presenceData.details = 'Browsing all courses' + } + break + } + case 'files': { + canvasDataFunctions.files(presenceData, null, privacyMode) + break + } + case 'groups': { + if (pathSplit[1]) { + presenceData.details = 'Viewing a group' + switch (pathSplit[2] ?? '') { + case '': { + if (!privacyMode) + presenceData.state = topPath + break + } + case 'announcements': { + canvasDataFunctions.announcement( + presenceData, + `group: ${firstPath}`, + privacyMode, + ) + break + } + case 'pages': { + canvasDataFunctions.pages( + presenceData, + `group: ${firstPath}`, + pathSplit.slice(3), + privacyMode, + ) + break + } + case 'discussion_topics': { + canvasDataFunctions.discussion( + presenceData, + `group: ${firstPath}`, + pathSplit.slice(3), + privacyMode, + ) + break + } + case 'files': { + canvasDataFunctions.files( + presenceData, + `group: ${firstPath}`, + privacyMode, + ) + break + } + case 'collaborations': { + canvasDataFunctions.collaborations( + presenceData, + `group: ${firstPath}`, + privacyMode, + ) + break + } + case 'conferences': { + canvasDataFunctions.conferences( + presenceData, + `group: ${firstPath}`, + privacyMode, + ) + break + } + case 'users': { + if (pathSplit[3]) { + canvasDataFunctions.profile(presenceData, privacyMode) + } + else { + canvasDataFunctions.people( + presenceData, + `group: ${firstPath}`, + privacyMode, + ) + } + break + } + } + } + else { + presenceData.details = 'Viewing groups' + } + break + } + case 'profile': { + switch (pathSplit[1] ?? '') { + case '': { + const profileNameInput = document.querySelector('#name_input') + if (profileNameInput) { + presenceData.details = 'Editing profile' + if (!privacyMode) + presenceData.state = profileNameInput.value + } + else { + canvasDataFunctions.profile(presenceData, privacyMode) + } + break + } + case 'communication': { + presenceData.details = 'Managing notification settings' + break + } + case 'content_shares': { + presenceData.details = 'Viewing shared content' + break + } + case 'settings': { + presenceData.details = 'Editing profile settings' + break + } + case 'qr_mobile_login': { + presenceData.details = 'Viewing QR code' + break + } + } + break + } + case 'search': { + switch (pathSplit[1]) { + case 'all_courses': { + presenceData.details = 'Searching all courses' + presenceData.state = new URLSearchParams(search).get('search') + break + } + case 'rubrics': { + presenceData.details = 'Searching rubrics' + break + } + } + break + } + default: { + presenceData.details = 'Browsing' + if (!privacyMode) { + presenceData.state = document.querySelector('h2')?.textContent + ?? document.title + } + } + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/Carl-bot/metadata.json b/websites/C/Carl-bot/metadata.json index 922561a7d28b..4df1be7d3bd7 100644 --- a/websites/C/Carl-bot/metadata.json +++ b/websites/C/Carl-bot/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "NMW03", - "id": "534099893979971584" - }, - "service": "Carl-bot", - "description": { - "en": "A fully customizable and modular discord bot featuring reaction roles, automod, logging, custom commands and much more.", - "nl": "Een volledig aanpasbare en modulaire discord-bot met reactierollen, automod, logboekregistratie, aangepaste opdrachten en nog veel meer.", - "vi_VN": "Một Discord bot có thể tuỳ chỉnh cung cấp nhận thẻ vai trò qua việc tương tác, ghi chú, lệnh tuỳ chỉnh và hơn nữa." - }, - "url": [ - "carl.gg", - "docs.carl.gg" - ], - "version": "1.4.27", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Carl-bot/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Carl-bot/assets/thumbnail.png", - "color": "#757F3F", - "category": "other", - "tags": [ - "bot", - "discord" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "NMW03", + "id": "534099893979971584" + }, + "service": "Carl-bot", + "description": { + "en": "A fully customizable and modular discord bot featuring reaction roles, automod, logging, custom commands and much more.", + "nl": "Een volledig aanpasbare en modulaire discord-bot met reactierollen, automod, logboekregistratie, aangepaste opdrachten en nog veel meer.", + "vi_VN": "Một Discord bot có thể tuỳ chỉnh cung cấp nhận thẻ vai trò qua việc tương tác, ghi chú, lệnh tuỳ chỉnh và hơn nữa." + }, + "url": [ + "carl.gg", + "docs.carl.gg" + ], + "version": "1.4.27", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Carl-bot/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Carl-bot/assets/thumbnail.png", + "color": "#757F3F", + "category": "other", + "tags": [ + "bot", + "discord" + ] +} diff --git a/websites/C/Carl-bot/presence.ts b/websites/C/Carl-bot/presence.ts index 8b3c6478c784..c1e248af7ca8 100644 --- a/websites/C/Carl-bot/presence.ts +++ b/websites/C/Carl-bot/presence.ts @@ -1,39 +1,41 @@ const presence = new Presence({ - clientId: "653372675166568481", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '653372675166568481', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Carl-bot/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Carl-bot/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (document.location.hostname === "carl.gg") { - if (document.location.pathname.startsWith("/dashboard/")) { - presenceData.details = "Managing the settings of:"; - presenceData.state = document - .querySelector( - "body > div.app > header > ul.navbar-nav.ml-auto.d-none.d-sm-inline-block > div > div" - ) - .textContent.split("Jump to")[0] - .trim(); - } else if (document.location.pathname.startsWith("/servers")) { - presenceData.details = "Browsing through"; - presenceData.state = "servers"; - } else if (document.location.pathname.startsWith("/status")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Carl-bot Status"; - } - } + if (document.location.hostname === 'carl.gg') { + if (document.location.pathname.startsWith('/dashboard/')) { + presenceData.details = 'Managing the settings of:' + presenceData.state = document + .querySelector( + 'body > div.app > header > ul.navbar-nav.ml-auto.d-none.d-sm-inline-block > div > div', + ) + ?.textContent + ?.split('Jump to')[0] + .trim() + } + else if (document.location.pathname.startsWith('/servers')) { + presenceData.details = 'Browsing through' + presenceData.state = 'servers' + } + else if (document.location.pathname.startsWith('/status')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Carl-bot Status' + } + } - if (document.location.hostname === "docs.carl.gg") { - presenceData.smallImageKey = Assets.Reading; - presenceData.details = "Documentation"; + if (document.location.hostname === 'docs.carl.gg') { + presenceData.smallImageKey = Assets.Reading + presenceData.details = 'Documentation' - presenceData.state = document.querySelector("h1").textContent; - } + presenceData.state = document.querySelector('h1')?.textContent + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/CatchPlay/metadata.json b/websites/C/CatchPlay/metadata.json index 6b280c16ad73..7f5b462ee354 100644 --- a/websites/C/CatchPlay/metadata.json +++ b/websites/C/CatchPlay/metadata.json @@ -1,36 +1,36 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "fjar", - "id": "334358518570287104" - }, - "service": "CatchPlay", - "description": { - "en": "CatchPlay is a Taiwanese multimedia company founded in 2007, whose businesses include OTT VOD streaming service operation, linear television channel operation (CatchPlay Movie Channel) and theatrical film distribution.", - "nl": "CatchPlay is een Taiwanees multimediabedrijf opgericht in 2007, met activiteiten als OTT VOD-streamingdienst, beheer van lineaire televisiekanalen (CatchPlay Movie Channel) en bioscoopfilmdistributie.", - "vi_VN": "CatchPlay là công ty truyền thông Đài Loan được thành lập năm 2007, với mục đích thêm dịch vụ phát trực tuyeesng OTT VOD, truyền hình tuyến tính (CatchPlay Movie Channel) và phân phối phim kịch." - }, - "url": [ - "www.catchplay.com", - "catchplay.com" - ], - "version": "1.0.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CatchPlay/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CatchPlay/assets/thumbnail.png", - "color": "#F26F21", - "category": "videos", - "tags": [ - "catchplay", - "video", - "media" - ], - "settings": [ - { - "id": "buttons", - "title": "Show Presence Buttons", - "icon": "fas fa-th-large", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "fjar", + "id": "334358518570287104" + }, + "service": "CatchPlay", + "description": { + "en": "CatchPlay is a Taiwanese multimedia company founded in 2007, whose businesses include OTT VOD streaming service operation, linear television channel operation (CatchPlay Movie Channel) and theatrical film distribution.", + "nl": "CatchPlay is een Taiwanees multimediabedrijf opgericht in 2007, met activiteiten als OTT VOD-streamingdienst, beheer van lineaire televisiekanalen (CatchPlay Movie Channel) en bioscoopfilmdistributie.", + "vi_VN": "CatchPlay là công ty truyền thông Đài Loan được thành lập năm 2007, với mục đích thêm dịch vụ phát trực tuyeesng OTT VOD, truyền hình tuyến tính (CatchPlay Movie Channel) và phân phối phim kịch." + }, + "url": [ + "www.catchplay.com", + "catchplay.com" + ], + "version": "1.0.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CatchPlay/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CatchPlay/assets/thumbnail.png", + "color": "#F26F21", + "category": "videos", + "tags": [ + "catchplay", + "video", + "media" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Presence Buttons", + "icon": "fas fa-th-large", + "value": true + } + ] +} diff --git a/websites/C/CatchPlay/presence.ts b/websites/C/CatchPlay/presence.ts index 1b4cf9c46174..ccc37f2aa597 100644 --- a/websites/C/CatchPlay/presence.ts +++ b/websites/C/CatchPlay/presence.ts @@ -1,59 +1,62 @@ const presence = new Presence({ - clientId: "758234121574678588", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - browsing: "general.browsing", - }); + clientId: '758234121574678588', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', + browsing: 'general.browsing', +}) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/CatchPlay/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/CatchPlay/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }, - buttons = await presence.getSetting("buttons"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } + const buttons = await presence.getSetting('buttons') - if (document.location.pathname.includes("/watch")) { - const video: HTMLVideoElement = document.querySelector(".player-box video"); - if (buttons) { - presenceData.buttons = [ - { - label: "Watch", - url: document.URL, - }, - ]; - } - if (video && !isNaN(video.duration)) { - if (document.querySelector(".CPplayer-header-subtitle")) { - presenceData.state = ` ${ - document.querySelector(".CPplayer-header-subtitle").textContent - }`; - } else presenceData.state = "Movie"; + if (document.location.pathname.includes('/watch')) { + const video = document.querySelector('.player-box video') + if (buttons) { + presenceData.buttons = [ + { + label: 'Watch', + url: document.URL, + }, + ] + } + if (video && !Number.isNaN(video.duration)) { + if (document.querySelector('.CPplayer-header-subtitle')) { + presenceData.state = ` ${ + document.querySelector('.CPplayer-header-subtitle')?.textContent + }` + } + else { + presenceData.state = 'Movie' + } - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ); - presenceData.details = ` ${ - document.querySelector(".CPplayer-header-title span").textContent - }`; - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? (await strings).pause - : (await strings).play; - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - presence.setActivity(presenceData, !video.paused); - } - } else { - presenceData.details = (await strings).browsing; - presence.setActivity(presenceData); - } -}); + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) + presenceData.details = ` ${ + document.querySelector('.CPplayer-header-title span')?.textContent + }` + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? (await strings).pause + : (await strings).play + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + presence.setActivity(presenceData, !video.paused) + } + } + else { + presenceData.details = (await strings).browsing + presence.setActivity(presenceData) + } +}) diff --git a/websites/C/Championgg/metadata.json b/websites/C/Championgg/metadata.json index aa993aa559b1..3e97474e8827 100644 --- a/websites/C/Championgg/metadata.json +++ b/websites/C/Championgg/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Drull", - "id": "244953147154366464" - }, - "service": "Championgg", - "description": { - "en": "Champion.gg provides League of Legends champion statistics, guides, builds, runes, masteries, skill orders and counters by role - including Win Rate, Ban Rate...", - "pt_BR": "Champion.gg fornece estatísticas, guias, builds, runas, masteries, ordens de habilidade e counters de campeões em League of Legends por função - incluindo Win Rate, Ban Rate...", - "nl": "Champion.gg biedt League of Legends kampioenstatistieken, gidsen, builds, runen, meesterschap, vaardigheidsopdrachten en tellers per rol - inclusief winstpercentage, banpercentage ...", - "vi_VN": "Champion.gg cung cấp thông số tướng, hướng dẫn, cách lên đồ, bảng ngọc, thông thạo, thứ tự lên kỹ năng và khắc chế trong Liên Minh Huyền Thoại - kèm theo Tỉ Lệ Thắng, Tỉ Lệ Cấm Chọn..." - }, - "url": "champion.gg", - "version": "1.0.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Championgg/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Championgg/assets/thumbnail.jpg", - "color": "#02442F", - "category": "games", - "tags": [ - "champion", - "champion-gg", - "league-of-legends", - "league", - "lol" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Drull", + "id": "244953147154366464" + }, + "service": "Championgg", + "description": { + "en": "Champion.gg provides League of Legends champion statistics, guides, builds, runes, masteries, skill orders and counters by role - including Win Rate, Ban Rate...", + "pt_BR": "Champion.gg fornece estatísticas, guias, builds, runas, masteries, ordens de habilidade e counters de campeões em League of Legends por função - incluindo Win Rate, Ban Rate...", + "nl": "Champion.gg biedt League of Legends kampioenstatistieken, gidsen, builds, runen, meesterschap, vaardigheidsopdrachten en tellers per rol - inclusief winstpercentage, banpercentage ...", + "vi_VN": "Champion.gg cung cấp thông số tướng, hướng dẫn, cách lên đồ, bảng ngọc, thông thạo, thứ tự lên kỹ năng và khắc chế trong Liên Minh Huyền Thoại - kèm theo Tỉ Lệ Thắng, Tỉ Lệ Cấm Chọn..." + }, + "url": "champion.gg", + "version": "1.0.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Championgg/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Championgg/assets/thumbnail.jpg", + "color": "#02442F", + "category": "games", + "tags": [ + "champion", + "champion-gg", + "league-of-legends", + "league", + "lol" + ] +} diff --git a/websites/C/Championgg/presence.ts b/websites/C/Championgg/presence.ts index 46a887a2106e..16b15ce1a033 100644 --- a/websites/C/Championgg/presence.ts +++ b/websites/C/Championgg/presence.ts @@ -1,31 +1,34 @@ const presence = new Presence({ - clientId: "704756386860499089", - }), - time = Math.floor(Date.now() / 1000); + clientId: '704756386860499089', +}) +const time = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Championgg/assets/logo.png", - }, - path = document.location.pathname.toLowerCase(); - if (path === "/") { - presenceData.details = "Initial page"; - presenceData.state = "Viewing champions"; - presenceData.startTimestamp = time; - } else if (path === "/statistics/") { - presenceData.details = "Statistics"; - presenceData.state = "Viewing win rates"; - presenceData.startTimestamp = time; - } else if (path.startsWith("/matchup")) { - presenceData.details = "Analysing matchup"; - presenceData.state = "Preparing to fight"; - presenceData.startTimestamp = time; - } else if (path.startsWith("/champion")) { - presenceData.details = "Checking Runes"; - presenceData.state = path.replace("/champion/", ""); - presenceData.startTimestamp = time; - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Championgg/assets/logo.png', + } + const path = document.location.pathname.toLowerCase() + if (path === '/') { + presenceData.details = 'Initial page' + presenceData.state = 'Viewing champions' + presenceData.startTimestamp = time + } + else if (path === '/statistics/') { + presenceData.details = 'Statistics' + presenceData.state = 'Viewing win rates' + presenceData.startTimestamp = time + } + else if (path.startsWith('/matchup')) { + presenceData.details = 'Analysing matchup' + presenceData.state = 'Preparing to fight' + presenceData.startTimestamp = time + } + else if (path.startsWith('/champion')) { + presenceData.details = 'Checking Runes' + presenceData.state = path.replace('/champion/', '') + presenceData.startTimestamp = time + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/Change/metadata.json b/websites/C/Change/metadata.json index 659befdfa55c..2cdf9d3852dd 100644 --- a/websites/C/Change/metadata.json +++ b/websites/C/Change/metadata.json @@ -1,35 +1,35 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Striker", - "id": "215509157837537280" - }, - "contributors": [ - { - "name": "Encrypted", - "id": "564434085708038144" - }, - { - "name": "TheSlowly", - "id": "505071508851523599" - } - ], - "service": "Change", - "description": { - "en": "Change the world", - "de": "Verändere die Welt", - "nl": "Verander de wereld", - "pt_BR": "Mude o mundo", - "vi_VN": "Thay đổi thế giới" - }, - "url": "www.change.org", - "version": "1.2.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Change/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Change/assets/thumbnail.png", - "color": "#FF0000", - "category": "other", - "tags": [ - "votes" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Striker", + "id": "215509157837537280" + }, + "contributors": [ + { + "name": "Encrypted", + "id": "564434085708038144" + }, + { + "name": "TheSlowly", + "id": "505071508851523599" + } + ], + "service": "Change", + "description": { + "en": "Change the world", + "de": "Verändere die Welt", + "nl": "Verander de wereld", + "pt_BR": "Mude o mundo", + "vi_VN": "Thay đổi thế giới" + }, + "url": "www.change.org", + "version": "1.2.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Change/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Change/assets/thumbnail.png", + "color": "#FF0000", + "category": "other", + "tags": [ + "votes" + ] +} diff --git a/websites/C/Change/presence.ts b/websites/C/Change/presence.ts index 8ee1b22ee899..9b9ea70f99cd 100644 --- a/websites/C/Change/presence.ts +++ b/websites/C/Change/presence.ts @@ -1,35 +1,33 @@ const presence = new Presence({ - clientId: "612042450785271811", - }), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Change/assets/logo.jpg", - }; + clientId: '612042450785271811', +}) +const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Change/assets/logo.jpg', +} -presence.on("UpdateData", async () => { - const title = document.querySelector( - ".mtl.mbxxxl.xs-mts.xs-mbxs.petition-title" - ); - if (title) { - presenceData.details = title.textContent; - presenceData.state = ( - document.querySelector(".mbxs span strong") ?? - document.querySelector("p.type-weak") - ).textContent; - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/C/Change/assets/logo.jpg"; - presenceData.buttons = [ - { - label: "View Petition", - url: document.location.href, - }, - ]; - presence.setActivity(presenceData); - } else { - presence.setActivity({ - details: "Browsing..", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Change/assets/logo.jpg", - }); - } -}); +presence.on('UpdateData', async () => { + const title = document.querySelector( + '.mtl.mbxxxl.xs-mts.xs-mbxs.petition-title', + ) + if (title) { + presenceData.details = title.textContent + presenceData.state = ( + document.querySelector('.mbxs span strong') + ?? document.querySelector('p.type-weak') + )?.textContent + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/C/Change/assets/logo.jpg' + presenceData.buttons = [ + { + label: 'View Petition', + url: document.location.href, + }, + ] + presence.setActivity(presenceData) + } + else { + presence.setActivity({ + details: 'Browsing..', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Change/assets/logo.jpg', + }) + } +}) diff --git a/websites/C/Character.AI/metadata.json b/websites/C/Character.AI/metadata.json index cbdd07cd587d..470fd25c9485 100644 --- a/websites/C/Character.AI/metadata.json +++ b/websites/C/Character.AI/metadata.json @@ -1,40 +1,40 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "205984221859151873", - "name": "joerkig" - }, - "service": "Character.AI", - "description": { - "en": "character.ai is bringing to life the science-fiction dream of open-ended conversations and collaborations with computers." - }, - "url": [ - "beta.character.ai", - "character.ai" - ], - "version": "1.0.6", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Character.AI/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Character.AI/assets/thumbnail.png", - "color": "#242525", - "category": "other", - "tags": [ - "ai", - "chat", - "characterai" - ], - "settings": [ - { - "id": "time", - "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": { + "id": "205984221859151873", + "name": "joerkig" + }, + "service": "Character.AI", + "description": { + "en": "character.ai is bringing to life the science-fiction dream of open-ended conversations and collaborations with computers." + }, + "url": [ + "beta.character.ai", + "character.ai" + ], + "version": "1.0.6", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Character.AI/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Character.AI/assets/thumbnail.png", + "color": "#242525", + "category": "other", + "tags": [ + "ai", + "chat", + "characterai" + ], + "settings": [ + { + "id": "time", + "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/C/Character.AI/presence.ts b/websites/C/Character.AI/presence.ts index b8dcdeb90b69..628c126df0e2 100644 --- a/websites/C/Character.AI/presence.ts +++ b/websites/C/Character.AI/presence.ts @@ -1,93 +1,95 @@ const presence = new Presence({ - clientId: "939893082546114611", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '939893082546114611', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Character.AI/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Character.AI/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - [time, buttons] = await Promise.all([ - presence.getSetting("time"), - presence.getSetting("buttons"), - ]), - { pathname, href, origin } = document.location, - button = { - label: "View Page", - url: href, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const [time, buttons] = await Promise.all([ + presence.getSetting('time'), + presence.getSetting('buttons'), + ]) + const { pathname, href, origin } = document.location + const button = { + label: 'View Page', + url: href, + } - switch (pathname.split("/")[1]) { - case "": { - presenceData.details = "Browsing Homepage"; - break; - } - case "chat2": { - presenceData.details = "Chatting with"; - presenceData.state = document - .querySelector(".swiper-no-swiping") - .parentElement.firstChild.textContent.replace("c.ai", ""); - presenceData.buttons = [button]; - break; - } - case "chat": { - presenceData.details = "Chatting with"; - presenceData.state = - document.querySelector(".chattitle")?.childNodes[1]?.textContent || - document.title.split("|")[0].replace("Chat with", "").trim(); - presenceData.buttons = [button]; - break; - } - case "feed": { - presenceData.details = "Browsing feed"; - break; - } - case "post": { - presenceData.details = "Viewing post"; - presenceData.state = document.querySelector( - `a[href^='${href.replace(origin, "")}']` - ).textContent; - presenceData.buttons = [button]; - break; - } - case "public-profile": { - presenceData.details = "Viewing profile"; - presenceData.state = - document.querySelector("span").childNodes[1].textContent; - presenceData.buttons = [button]; - break; - } - case "chats": { - presenceData.details = "Browsing chats"; - break; - } - case "profile": { - const { pathname } = document.location; - presenceData.details = "Viewing profile"; - presenceData.state = `for ${pathname.split("/")[2]}`; - break; - } - case "character": { - presenceData.details = "Creating character"; - break; - } - case "editing": { - presenceData.details = "Editing character"; - break; - } - } + switch (pathname.split('/')[1]) { + case '': { + presenceData.details = 'Browsing Homepage' + break + } + case 'chat2': { + presenceData.details = 'Chatting with' + presenceData.state = document + .querySelector('.swiper-no-swiping') + ?.parentElement + ?.firstChild + ?.textContent + ?.replace('c.ai', '') + presenceData.buttons = [button] + break + } + case 'chat': { + presenceData.details = 'Chatting with' + presenceData.state = document.querySelector('.chattitle')?.childNodes[1]?.textContent + || document.title.split('|')[0].replace('Chat with', '').trim() + presenceData.buttons = [button] + break + } + case 'feed': { + presenceData.details = 'Browsing feed' + break + } + case 'post': { + presenceData.details = 'Viewing post' + presenceData.state = document.querySelector( + `a[href^='${href.replace(origin, '')}']`, + )?.textContent + presenceData.buttons = [button] + break + } + case 'public-profile': { + presenceData.details = 'Viewing profile' + presenceData.state = document.querySelector('span')?.childNodes[1].textContent + presenceData.buttons = [button] + break + } + case 'chats': { + presenceData.details = 'Browsing chats' + break + } + case 'profile': { + const { pathname } = document.location + presenceData.details = 'Viewing profile' + presenceData.state = `for ${pathname.split('/')[2]}` + break + } + case 'character': { + presenceData.details = 'Creating character' + break + } + case 'editing': { + presenceData.details = 'Editing character' + break + } + } - if (!time) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } + if (!time) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } - if (!buttons && presenceData.buttons) delete presenceData.buttons; + if (!buttons && presenceData.buttons) + delete presenceData.buttons - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/ChatGPT/metadata.json b/websites/C/ChatGPT/metadata.json index a009f7d20e4b..d9c4a5323f99 100644 --- a/websites/C/ChatGPT/metadata.json +++ b/websites/C/ChatGPT/metadata.json @@ -1,39 +1,39 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "135058085386387457", - "name": "Extiriority" - }, - "contributors": [ - { - "name": "Kaktuswerk", - "id": "1167417152664522764" - } - ], - "service": "ChatGPT", - "description": { - "en": "ChatGPT is a natural language processing tool driven by AI technology that allows you to have human-like conversations and much more with the chatbot. The language model can answer questions and assist you with tasks, such as composing emails, essays, and code." - }, - "url": "chatgpt.com", - "version": "1.1.2", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/ChatGPT/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/ChatGPT/assets/thumbnail.png", - "color": "#75AC9D", - "category": "other", - "tags": [ - "ai", - "language", - "human-like", - "conversations", - "multi-purpose" - ], - "settings": [ - { - "id": "showTitle", - "title": "Show chat title", - "icon": "fa-solid fa-message-quote", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "135058085386387457", + "name": "Extiriority" + }, + "contributors": [ + { + "name": "Kaktuswerk", + "id": "1167417152664522764" + } + ], + "service": "ChatGPT", + "description": { + "en": "ChatGPT is a natural language processing tool driven by AI technology that allows you to have human-like conversations and much more with the chatbot. The language model can answer questions and assist you with tasks, such as composing emails, essays, and code." + }, + "url": "chatgpt.com", + "version": "1.1.2", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/ChatGPT/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/ChatGPT/assets/thumbnail.png", + "color": "#75AC9D", + "category": "other", + "tags": [ + "ai", + "language", + "human-like", + "conversations", + "multi-purpose" + ], + "settings": [ + { + "id": "showTitle", + "title": "Show chat title", + "icon": "fa-solid fa-message-quote", + "value": true + } + ] +} diff --git a/websites/C/ChatGPT/presence.ts b/websites/C/ChatGPT/presence.ts index ac46502aefe3..ce9447fa92a6 100644 --- a/websites/C/ChatGPT/presence.ts +++ b/websites/C/ChatGPT/presence.ts @@ -1,53 +1,56 @@ -const presence = new Presence({ clientId: "1102935778570547282" }), - browsingTimestamp = Math.floor(Date.now() / 1000); +const presence = new Presence({ clientId: '1102935778570547282' }) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/ChatGPT/assets/logo.png", - Talking = "https://cdn.rcd.gg/PreMiD/websites/C/ChatGPT/assets/0.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/ChatGPT/assets/logo.png', + Talking = 'https://cdn.rcd.gg/PreMiD/websites/C/ChatGPT/assets/0.png', } -presence.on("UpdateData", async () => { - const { pathname } = document.location, - presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - showTitle = await presence.getSetting("showTitle"), - isTalking = document.querySelector( - '[class*="text-2xl"] > span:nth-child(3)' - ); +presence.on('UpdateData', async () => { + const { pathname } = document.location + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const showTitle = await presence.getSetting('showTitle') + const isTalking = document.querySelector( + '[class*="text-2xl"] > span:nth-child(3)', + ) - let wordCount = 0; - for (const element of document.querySelectorAll( - '[data-message-author-role="user"],[data-message-author-role="assistant"]' - )) { - const text = element.textContent - .replace(/(, )|(,\n)|(,)|([.] )|([.])/gm, " ") - .replace(/([0-9]*)|(\/)|(')|(,)|( )/gm, ""); - wordCount += text.split(" ").slice(2, text.split(" ").length).length; - } + let wordCount = 0 + for (const element of document.querySelectorAll( + '[data-message-author-role="user"],[data-message-author-role="assistant"]', + )) { + const text = element?.textContent + ?.replace(/(, )|(,\n)|(,)|(\. )|(\.)/g, ' ') + // eslint-disable-next-line regexp/no-dupe-disjunctions + .replace(/(\d*)|(\/)|(')|(,)|( )/g, '') + wordCount += text?.split(' ').slice(2, text?.split(' ').length).length ?? 0 + } - if (pathname.split("/")[1] === "c") { - // check if the document title is the default title. If so, get the chat title from the UI. Otherwise, get it from the document title - if (document.title === "ChatGPT" && showTitle) { - presenceData.details = document.querySelector( - `[href="/c/${pathname.split("/")[2]}"]` - )?.textContent; - } else { - presenceData.details = showTitle - ? document.title - : "Talking with AI about something"; - } - presenceData.state = isTalking - ? "AI is responding..." - : `asked (${Number( - document.querySelectorAll('[data-message-author-role="user"]').length - )}) times | (${wordCount}) words`; - presenceData.smallImageKey = isTalking ? Assets.Talking : null; - } else { - presenceData.details = "Start new conversation"; - presenceData.state = "Thinking of a new prompt..."; - } + if (pathname.split('/')[1] === 'c') { + // check if the document title is the default title. If so, get the chat title from the UI. Otherwise, get it from the document title + if (document.title === 'ChatGPT' && showTitle) { + presenceData.details = document.querySelector( + `[href="/c/${pathname.split('/')[2]}"]`, + )?.textContent + } + else { + presenceData.details = showTitle + ? document.title + : 'Talking with AI about something' + } + presenceData.state = isTalking + ? 'AI is responding...' + : `asked (${Number( + document.querySelectorAll('[data-message-author-role="user"]').length, + )}) times | (${wordCount}) words` + presenceData.smallImageKey = isTalking ? Assets.Talking : null + } + else { + presenceData.details = 'Start new conversation' + presenceData.state = 'Thinking of a new prompt...' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/Chess/metadata.json b/websites/C/Chess/metadata.json index 015f3ca3340b..ccc8b9a6d963 100644 --- a/websites/C/Chess/metadata.json +++ b/websites/C/Chess/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Funeoz", - "id": "256093420206948352" - }, - "service": "Chess", - "description": { - "en": "Chess.com is the main internet chess server. It is also an Internet forum and a social network dedicated to chess.", - "fr": "Chess.com est le principal serveur internet d'échecs. C'est également un forum internet et un réseau social consacré aux échecs.", - "es": "Chess.com es el principal servidor web para el ajedrez. Es también un foro web y un red social dedicado al ajedrez.", - "nl": "Chess.com is de belangrijkste schaakserver op internet. Het is ook een internetforum en een sociaal netwerk gewijd aan schaken.", - "vi_VN": "Chess.com là máy chủ cờ vua chính trên Internet. Nó cũng là một diễn đàn và mạng xã hội dành riêng cho bộ môn cờ vua." - }, - "url": "www.chess.com", - "version": "1.2.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/thumbnail.png", - "color": "#4d7737", - "category": "games", - "tags": [ - "chess", - "games" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Funeoz", + "id": "256093420206948352" + }, + "service": "Chess", + "description": { + "en": "Chess.com is the main internet chess server. It is also an Internet forum and a social network dedicated to chess.", + "fr": "Chess.com est le principal serveur internet d'échecs. C'est également un forum internet et un réseau social consacré aux échecs.", + "es": "Chess.com es el principal servidor web para el ajedrez. Es también un foro web y un red social dedicado al ajedrez.", + "nl": "Chess.com is de belangrijkste schaakserver op internet. Het is ook een internetforum en een sociaal netwerk gewijd aan schaken.", + "vi_VN": "Chess.com là máy chủ cờ vua chính trên Internet. Nó cũng là một diễn đàn và mạng xã hội dành riêng cho bộ môn cờ vua." + }, + "url": "www.chess.com", + "version": "1.2.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/thumbnail.png", + "color": "#4d7737", + "category": "games", + "tags": [ + "chess", + "games" + ] +} diff --git a/websites/C/Chess/presence.ts b/websites/C/Chess/presence.ts index 1bd461d1241a..214c10e206ce 100644 --- a/websites/C/Chess/presence.ts +++ b/websites/C/Chess/presence.ts @@ -1,368 +1,404 @@ const presence = new Presence({ - clientId: "699204548664885279", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '699204548664885279', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/logo.png", - Statistics = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/0.png", - GamesArchive = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/1.png", - Daily = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/2.png", - Computer = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/3.png", - FourPC = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/4.png", - Variants = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/5.png", - Fog = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/6.png", - Horde = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/7.png", - Koth = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/8.png", - Torpedo = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/9.png", - ThreeCheck = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/10.png", - Giveaway = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/11.png", - Sideways = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/12.png", - Chataranga = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/13.png", - Blindfold = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/14.png", - Nocastle = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/15.png", - Anything = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/16.png", - Atomic = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/17.png", - Automate = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/18.png", - Puzzle = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/19.png", - PuzzleRush = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/20.png", - PuzzleWar = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/21.png", - PuzzleOfDay = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/22.png", - SoloChess = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/23.png", - Drills = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/24.png", - Lessons = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/25.png", - Analysis = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/26.png", - Articles = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/27.png", - Vision = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/28.png", - Openings = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/29.png", - Explorer = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/30.png", - Forum = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/31.png", - Clubs = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/32.png", - Blog = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/33.png", - Members = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/34.png", - Coaches = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/35.png", - ChessToday = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/36.png", - News = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/37.png", - ChessTV = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/38.png", - MasterGames = "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/39.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/logo.png', + Statistics = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/0.png', + GamesArchive = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/1.png', + Daily = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/2.png', + Computer = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/3.png', + FourPC = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/4.png', + Variants = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/5.png', + Fog = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/6.png', + Horde = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/7.png', + Koth = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/8.png', + Torpedo = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/9.png', + ThreeCheck = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/10.png', + Giveaway = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/11.png', + Sideways = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/12.png', + Chataranga = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/13.png', + Blindfold = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/14.png', + Nocastle = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/15.png', + Anything = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/16.png', + Atomic = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/17.png', + Automate = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/18.png', + Puzzle = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/19.png', + PuzzleRush = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/20.png', + PuzzleWar = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/21.png', + PuzzleOfDay = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/22.png', + SoloChess = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/23.png', + Drills = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/24.png', + Lessons = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/25.png', + Analysis = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/26.png', + Articles = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/27.png', + Vision = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/28.png', + Openings = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/29.png', + Explorer = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/30.png', + Forum = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/31.png', + Clubs = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/32.png', + Blog = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/33.png', + Members = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/34.png', + Coaches = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/35.png', + ChessToday = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/36.png', + News = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/37.png', + ChessTV = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/38.png', + MasterGames = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/39.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } - if (document.location.pathname === "/home") - presenceData.details = "Viewing home page"; - else if (document.location.pathname.includes("/messages")) - presenceData.details = "Viewing messages"; - else if (document.location.pathname.includes("/stats")) { - presenceData.details = "Viewing statistics"; - presenceData.smallImageKey = Assets.Statistics; - presenceData.smallImageText = "Statistics"; - } else if (document.location.pathname.includes("/games/archive")) { - presenceData.details = "Viewing games archive"; - presenceData.smallImageKey = Assets.GamesArchive; - presenceData.smallImageText = "Games archive"; - } else if (document.location.pathname.includes("/live")) { - presenceData.details = "Playing Live Chess"; - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = "Live"; - } else if (document.location.pathname.indexOf("/daily/") === 0) { - presenceData.details = "Playing Daily Chess"; - presenceData.smallImageKey = Assets.Daily; - presenceData.smallImageText = "Daily"; - } else if (document.location.pathname === "/daily") { - presenceData.details = "Playing Daily Chess"; - presenceData.smallImageKey = Assets.Daily; - presenceData.smallImageText = "Daily"; - } else if (document.location.pathname.includes("/play/computer")) { - presenceData.details = "Playing against computer"; - presenceData.smallImageKey = Assets.Computer; - presenceData.smallImageText = "Computer"; - } else if (document.location.pathname.includes("/tournaments")) - presenceData.details = "Viewing tournaments"; - else if (document.location.pathname.includes("/4-player-chess")) { - presenceData.details = "Playing 4 Player Chess"; - presenceData.smallImageKey = Assets.FourPC; - presenceData.smallImageText = "4 Player Chess"; - } else if (document.location.pathname === "/variants") { - presenceData.details = "Browsing through Chess Variants"; - presenceData.smallImageKey = Assets.Variants; - presenceData.smallImageText = "Variants"; - } else { - switch (0) { - case document.location.pathname.indexOf("/variants/fog-of-war/game/"): { - presenceData.details = "Playing Fog of War"; - presenceData.smallImageKey = Assets.Fog; - presenceData.smallImageText = "Fog of War"; + if (document.location.pathname === '/home') { + presenceData.details = 'Viewing home page' + } + else if (document.location.pathname.includes('/messages')) { + presenceData.details = 'Viewing messages' + } + else if (document.location.pathname.includes('/stats')) { + presenceData.details = 'Viewing statistics' + presenceData.smallImageKey = Assets.Statistics + presenceData.smallImageText = 'Statistics' + } + else if (document.location.pathname.includes('/games/archive')) { + presenceData.details = 'Viewing games archive' + presenceData.smallImageKey = Assets.GamesArchive + presenceData.smallImageText = 'Games archive' + } + else if (document.location.pathname.includes('/live')) { + presenceData.details = 'Playing Live Chess' + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = 'Live' + } + else if (document.location.pathname.indexOf('/daily/') === 0) { + presenceData.details = 'Playing Daily Chess' + presenceData.smallImageKey = Assets.Daily + presenceData.smallImageText = 'Daily' + } + else if (document.location.pathname === '/daily') { + presenceData.details = 'Playing Daily Chess' + presenceData.smallImageKey = Assets.Daily + presenceData.smallImageText = 'Daily' + } + else if (document.location.pathname.includes('/play/computer')) { + presenceData.details = 'Playing against computer' + presenceData.smallImageKey = Assets.Computer + presenceData.smallImageText = 'Computer' + } + else if (document.location.pathname.includes('/tournaments')) { + presenceData.details = 'Viewing tournaments' + } + else if (document.location.pathname.includes('/4-player-chess')) { + presenceData.details = 'Playing 4 Player Chess' + presenceData.smallImageKey = Assets.FourPC + presenceData.smallImageText = '4 Player Chess' + } + else if (document.location.pathname === '/variants') { + presenceData.details = 'Browsing through Chess Variants' + presenceData.smallImageKey = Assets.Variants + presenceData.smallImageText = 'Variants' + } + else { + switch (0) { + case document.location.pathname.indexOf('/variants/fog-of-war/game/'): { + presenceData.details = 'Playing Fog of War' + presenceData.smallImageKey = Assets.Fog + presenceData.smallImageText = 'Fog of War' - break; - } - case document.location.pathname.indexOf("/variants/horde/game/"): { - presenceData.details = "Playing Horde"; - presenceData.smallImageKey = Assets.Horde; - presenceData.smallImageText = "Horde"; + break + } + case document.location.pathname.indexOf('/variants/horde/game/'): { + presenceData.details = 'Playing Horde' + presenceData.smallImageKey = Assets.Horde + presenceData.smallImageText = 'Horde' - break; - } - case document.location.pathname.indexOf( - "/variants/king-of-the-hill/game/" - ): { - presenceData.details = "Playing King of the Hill"; - presenceData.smallImageKey = Assets.Koth; - presenceData.smallImageText = "King of the Hill"; + break + } + case document.location.pathname.indexOf( + '/variants/king-of-the-hill/game/', + ): { + presenceData.details = 'Playing King of the Hill' + presenceData.smallImageKey = Assets.Koth + presenceData.smallImageText = 'King of the Hill' - break; - } - case document.location.pathname.indexOf("/variants/torpedo/game/"): { - presenceData.details = "Playing Torpedo"; - presenceData.smallImageKey = Assets.Torpedo; - presenceData.smallImageText = "Torpedo"; + break + } + case document.location.pathname.indexOf('/variants/torpedo/game/'): { + presenceData.details = 'Playing Torpedo' + presenceData.smallImageKey = Assets.Torpedo + presenceData.smallImageText = 'Torpedo' - break; - } - case document.location.pathname.indexOf("/variants/3-check/game/"): { - presenceData.details = "Playing 3 Check"; - presenceData.smallImageKey = Assets.ThreeCheck; - presenceData.smallImageText = "3 Check"; + break + } + case document.location.pathname.indexOf('/variants/3-check/game/'): { + presenceData.details = 'Playing 3 Check' + presenceData.smallImageKey = Assets.ThreeCheck + presenceData.smallImageText = '3 Check' - break; - } - case document.location.pathname.indexOf("/variants/giveaway/game/"): { - presenceData.details = "Playing Giveaway"; - presenceData.smallImageKey = Assets.Giveaway; - presenceData.smallImageText = "Giveaway"; + break + } + case document.location.pathname.indexOf('/variants/giveaway/game/'): { + presenceData.details = 'Playing Giveaway' + presenceData.smallImageKey = Assets.Giveaway + presenceData.smallImageText = 'Giveaway' - break; - } - case document.location.pathname.indexOf( - "/variants/sideway-pawns/game/" - ): { - presenceData.details = "Playing Sideway Pawns"; - presenceData.smallImageKey = Assets.Sideways; - presenceData.smallImageText = "Sideways Pawns"; + break + } + case document.location.pathname.indexOf( + '/variants/sideway-pawns/game/', + ): { + presenceData.details = 'Playing Sideway Pawns' + presenceData.smallImageKey = Assets.Sideways + presenceData.smallImageText = 'Sideways Pawns' - break; - } - case document.location.pathname.indexOf("/variants/chaturanga/game/"): { - presenceData.details = "Playing Chaturanga"; - presenceData.smallImageKey = Assets.Chataranga; - presenceData.smallImageText = "Chaturanga"; + break + } + case document.location.pathname.indexOf('/variants/chaturanga/game/'): { + presenceData.details = 'Playing Chaturanga' + presenceData.smallImageKey = Assets.Chataranga + presenceData.smallImageText = 'Chaturanga' - break; - } - case document.location.pathname.indexOf("/variants/blindfold/game/"): { - presenceData.details = "Playing Blindfold"; - presenceData.smallImageKey = Assets.Blindfold; - presenceData.smallImageText = "Blindfold"; + break + } + case document.location.pathname.indexOf('/variants/blindfold/game/'): { + presenceData.details = 'Playing Blindfold' + presenceData.smallImageKey = Assets.Blindfold + presenceData.smallImageText = 'Blindfold' - break; - } - case document.location.pathname.indexOf("/variants/no-castling/game/"): { - presenceData.details = "Playing No Castling"; - presenceData.smallImageKey = Assets.Nocastle; - presenceData.smallImageText = "No Castling"; + break + } + case document.location.pathname.indexOf('/variants/no-castling/game/'): { + presenceData.details = 'Playing No Castling' + presenceData.smallImageKey = Assets.Nocastle + presenceData.smallImageText = 'No Castling' - break; - } - case document.location.pathname.indexOf( - "/variants/capture-anything/game/" - ): { - presenceData.details = "Playing Capture Anything"; - presenceData.smallImageKey = Assets.Anything; - presenceData.smallImageText = "Capture Anything"; + break + } + case document.location.pathname.indexOf( + '/variants/capture-anything/game/', + ): { + presenceData.details = 'Playing Capture Anything' + presenceData.smallImageKey = Assets.Anything + presenceData.smallImageText = 'Capture Anything' - break; - } - case document.location.pathname.indexOf("/variants/atomic/game/"): { - presenceData.details = "Playing Atomic"; - presenceData.smallImageKey = Assets.Atomic; - presenceData.smallImageText = "Atomic"; + break + } + case document.location.pathname.indexOf('/variants/atomic/game/'): { + presenceData.details = 'Playing Atomic' + presenceData.smallImageKey = Assets.Atomic + presenceData.smallImageText = 'Atomic' - break; - } - default: - if (document.location.pathname.includes("/automate")) { - presenceData.details = "Playing Automate chess"; - presenceData.smallImageKey = Assets.Automate; - presenceData.smallImageText = "Automate"; - } else { - switch (document.location.pathname) { - case "/puzzles/rated": { - presenceData.details = "Solving puzzles"; - presenceData.smallImageKey = Assets.Puzzle; - presenceData.smallImageText = "Puzzles"; + break + } + default: + if (document.location.pathname.includes('/automate')) { + presenceData.details = 'Playing Automate chess' + presenceData.smallImageKey = Assets.Automate + presenceData.smallImageText = 'Automate' + } + else { + switch (document.location.pathname) { + case '/puzzles/rated': { + presenceData.details = 'Solving puzzles' + presenceData.smallImageKey = Assets.Puzzle + presenceData.smallImageText = 'Puzzles' - break; - } - case "/puzzles/rush": { - presenceData.details = "Playing Puzzle Rush"; - presenceData.smallImageKey = Assets.PuzzleRush; - presenceData.smallImageText = "Puzzle Rush"; + break + } + case '/puzzles/rush': { + presenceData.details = 'Playing Puzzle Rush' + presenceData.smallImageKey = Assets.PuzzleRush + presenceData.smallImageText = 'Puzzle Rush' - break; - } - case "/puzzles/battle": { - presenceData.details = "Playing Puzzle Battle"; - presenceData.smallImageKey = Assets.PuzzleWar; - presenceData.smallImageText = "Puzzle Battle"; + break + } + case '/puzzles/battle': { + presenceData.details = 'Playing Puzzle Battle' + presenceData.smallImageKey = Assets.PuzzleWar + presenceData.smallImageText = 'Puzzle Battle' - break; - } - default: - if ( - document.location.pathname.indexOf( - "/forum/view/daily-puzzles/" - ) === 0 - ) { - presenceData.details = "Solving Daily Puzzle"; - presenceData.smallImageKey = Assets.PuzzleOfDay; - presenceData.smallImageText = "Daily Puzzle"; - } else if (document.location.pathname.includes("/solo-chess")) { - presenceData.details = "Playing Solo Chess"; - presenceData.smallImageKey = Assets.SoloChess; - presenceData.smallImageText = "Solo Chess"; - } else if (document.location.pathname.includes("/drills")) { - presenceData.details = "Playing drills"; - presenceData.smallImageKey = Assets.Drills; - presenceData.smallImageText = "Drills"; - } else if (document.location.pathname.includes("/lessons")) { - presenceData.details = "Viewing lessons"; - presenceData.smallImageKey = Assets.Lessons; - presenceData.smallImageText = "Lessons"; - } else if (document.location.pathname.includes("/analysis")) { - presenceData.details = "Analyzing a game"; - presenceData.smallImageKey = Assets.Analysis; - presenceData.smallImageText = "Analysis"; - } else if ( - document.location.pathname.indexOf("/article/view") === 0 - ) { - presenceData.details = "Reading an article"; - presenceData.smallImageKey = Assets.Articles; - presenceData.smallImageText = "Article"; - presenceData.state = document.title; - } else if (document.location.pathname === "/articles") { - presenceData.details = "Browsing through articles"; - presenceData.smallImageKey = Assets.Articles; - presenceData.smallImageText = "Articles"; - } else if (document.location.pathname === "/videos") - presenceData.details = "Browsing through videos"; - else if (document.location.pathname.includes("/vision")) { - presenceData.details = "Training vision"; - presenceData.smallImageKey = Assets.Vision; - presenceData.smallImageText = "Vision"; - } else if (document.location.pathname.includes("/openings")) { - presenceData.details = "Viewing openings"; - presenceData.smallImageKey = Assets.Openings; - presenceData.smallImageText = "Openings"; - } else if (document.location.pathname.includes("/explorer")) { - presenceData.details = "Using games explorer"; - presenceData.smallImageKey = Assets.Explorer; - presenceData.smallImageText = "Games explorer"; - } else if (document.location.pathname.includes("/forum")) { - presenceData.details = "Browsing through forum"; - presenceData.smallImageKey = Assets.Forum; - presenceData.smallImageText = "Forum"; - } else if (document.location.pathname.includes("/clubs")) { - presenceData.details = "Browsing through clubs"; - presenceData.smallImageKey = Assets.Clubs; - presenceData.smallImageText = "Clubs"; - } else if (document.location.pathname === "/blogs") { - presenceData.details = "Browsing through blogs"; - presenceData.smallImageKey = Assets.Blog; - presenceData.smallImageText = "Blog"; - } else if (document.location.pathname.indexOf("/blog/") === 0) { - presenceData.details = "Reading a blog post"; - presenceData.smallImageKey = Assets.Blog; - presenceData.smallImageText = "Blog post"; - presenceData.state = document.title; - } else if (document.location.pathname.includes("/members")) { - presenceData.details = "Browsing through members"; - presenceData.smallImageKey = Assets.Members; - presenceData.smallImageText = "Members"; - } else if (document.location.pathname.includes("/coaches")) { - presenceData.details = "Browsing through coaches"; - presenceData.smallImageKey = Assets.Coaches; - presenceData.smallImageText = "Coaches"; - } else if (document.location.pathname.includes("/today")) { - presenceData.details = "Viewing Chess Today"; - presenceData.smallImageKey = Assets.ChessToday; - presenceData.smallImageText = "Chess Today"; - } else if ( - document.location.pathname.indexOf("/news/view/") === 0 - ) { - presenceData.details = "Reading news"; - presenceData.smallImageKey = Assets.News; - presenceData.smallImageText = "News"; - presenceData.state = document.title; - } else if (document.location.pathname === "/news") { - presenceData.details = "Browsing through news"; - presenceData.smallImageKey = Assets.News; - presenceData.smallImageText = "News"; - } else if (document.location.pathname.includes("/tv")) { - presenceData.details = "Viewing ChessTV"; - presenceData.smallImageKey = Assets.ChessTV; - presenceData.smallImageText = "ChessTV"; - } else if (document.location.pathname === "/games") { - presenceData.details = "Browsing through master games"; - presenceData.smallImageKey = Assets.MasterGames; - presenceData.smallImageText = "Master Games"; - } else if ( - document.location.pathname.indexOf("/games/view/") === 0 - ) { - presenceData.details = "Watching a master game"; - presenceData.smallImageKey = Assets.MasterGames; - presenceData.smallImageText = "Master Games"; - presenceData.state = document.title.substring( - 0, - document.title.indexOf(")") + 1 - ); - } else if ( - document.location.pathname.includes( - "/computer-chess-championship" - ) - ) { - presenceData.details = "Watching Computer Chess Championship"; - presenceData.state = document.title.substring( - 0, - document.title.indexOf("-") - ); - } else if ( - document.location.pathname.indexOf("/video/player/") === 0 - ) { - const video: HTMLVideoElement = document.querySelector("video"); + break + } + default: + if ( + document.location.pathname.indexOf( + '/forum/view/daily-puzzles/', + ) === 0 + ) { + presenceData.details = 'Solving Daily Puzzle' + presenceData.smallImageKey = Assets.PuzzleOfDay + presenceData.smallImageText = 'Daily Puzzle' + } + else if (document.location.pathname.includes('/solo-chess')) { + presenceData.details = 'Playing Solo Chess' + presenceData.smallImageKey = Assets.SoloChess + presenceData.smallImageText = 'Solo Chess' + } + else if (document.location.pathname.includes('/drills')) { + presenceData.details = 'Playing drills' + presenceData.smallImageKey = Assets.Drills + presenceData.smallImageText = 'Drills' + } + else if (document.location.pathname.includes('/lessons')) { + presenceData.details = 'Viewing lessons' + presenceData.smallImageKey = Assets.Lessons + presenceData.smallImageText = 'Lessons' + } + else if (document.location.pathname.includes('/analysis')) { + presenceData.details = 'Analyzing a game' + presenceData.smallImageKey = Assets.Analysis + presenceData.smallImageText = 'Analysis' + } + else if ( + document.location.pathname.indexOf('/article/view') === 0 + ) { + presenceData.details = 'Reading an article' + presenceData.smallImageKey = Assets.Articles + presenceData.smallImageText = 'Article' + presenceData.state = document.title + } + else if (document.location.pathname === '/articles') { + presenceData.details = 'Browsing through articles' + presenceData.smallImageKey = Assets.Articles + presenceData.smallImageText = 'Articles' + } + else if (document.location.pathname === '/videos') { + presenceData.details = 'Browsing through videos' + } + else if (document.location.pathname.includes('/vision')) { + presenceData.details = 'Training vision' + presenceData.smallImageKey = Assets.Vision + presenceData.smallImageText = 'Vision' + } + else if (document.location.pathname.includes('/openings')) { + presenceData.details = 'Viewing openings' + presenceData.smallImageKey = Assets.Openings + presenceData.smallImageText = 'Openings' + } + else if (document.location.pathname.includes('/explorer')) { + presenceData.details = 'Using games explorer' + presenceData.smallImageKey = Assets.Explorer + presenceData.smallImageText = 'Games explorer' + } + else if (document.location.pathname.includes('/forum')) { + presenceData.details = 'Browsing through forum' + presenceData.smallImageKey = Assets.Forum + presenceData.smallImageText = 'Forum' + } + else if (document.location.pathname.includes('/clubs')) { + presenceData.details = 'Browsing through clubs' + presenceData.smallImageKey = Assets.Clubs + presenceData.smallImageText = 'Clubs' + } + else if (document.location.pathname === '/blogs') { + presenceData.details = 'Browsing through blogs' + presenceData.smallImageKey = Assets.Blog + presenceData.smallImageText = 'Blog' + } + else if (document.location.pathname.indexOf('/blog/') === 0) { + presenceData.details = 'Reading a blog post' + presenceData.smallImageKey = Assets.Blog + presenceData.smallImageText = 'Blog post' + presenceData.state = document.title + } + else if (document.location.pathname.includes('/members')) { + presenceData.details = 'Browsing through members' + presenceData.smallImageKey = Assets.Members + presenceData.smallImageText = 'Members' + } + else if (document.location.pathname.includes('/coaches')) { + presenceData.details = 'Browsing through coaches' + presenceData.smallImageKey = Assets.Coaches + presenceData.smallImageText = 'Coaches' + } + else if (document.location.pathname.includes('/today')) { + presenceData.details = 'Viewing Chess Today' + presenceData.smallImageKey = Assets.ChessToday + presenceData.smallImageText = 'Chess Today' + } + else if ( + document.location.pathname.indexOf('/news/view/') === 0 + ) { + presenceData.details = 'Reading news' + presenceData.smallImageKey = Assets.News + presenceData.smallImageText = 'News' + presenceData.state = document.title + } + else if (document.location.pathname === '/news') { + presenceData.details = 'Browsing through news' + presenceData.smallImageKey = Assets.News + presenceData.smallImageText = 'News' + } + else if (document.location.pathname.includes('/tv')) { + presenceData.details = 'Viewing ChessTV' + presenceData.smallImageKey = Assets.ChessTV + presenceData.smallImageText = 'ChessTV' + } + else if (document.location.pathname === '/games') { + presenceData.details = 'Browsing through master games' + presenceData.smallImageKey = Assets.MasterGames + presenceData.smallImageText = 'Master Games' + } + else if ( + document.location.pathname.indexOf('/games/view/') === 0 + ) { + presenceData.details = 'Watching a master game' + presenceData.smallImageKey = Assets.MasterGames + presenceData.smallImageText = 'Master Games' + presenceData.state = document.title.substring( + 0, + document.title.indexOf(')') + 1, + ) + } + else if ( + document.location.pathname.includes( + '/computer-chess-championship', + ) + ) { + presenceData.details = 'Watching Computer Chess Championship' + presenceData.state = document.title.substring( + 0, + document.title.indexOf('-'), + ) + } + else if ( + document.location.pathname.indexOf('/video/player/') === 0 + ) { + const video = document.querySelector('video') - if (video && !isNaN(video.duration)) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ); - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/logo.png"; - presenceData.details = "Watching video"; - presenceData.state = document.title; - if (video.paused) { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = (await strings).pause; - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } else { - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = (await strings).play; - } - } - } - } - } - } - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (video && !Number.isNaN(video.duration)) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/C/Chess/assets/logo.png' + presenceData.details = 'Watching video' + presenceData.state = document.title + if (video.paused) { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = (await strings).pause + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + else { + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = (await strings).play + } + } + } + } + } + } + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/Chessly/metadata.json b/websites/C/Chessly/metadata.json index f2d672b581a5..53f8c17e6bfc 100644 --- a/websites/C/Chessly/metadata.json +++ b/websites/C/Chessly/metadata.json @@ -1,32 +1,32 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "Chessly", - "description": { - "en": "Chess learning made fun and easy." - }, - "url": [ - "chessly.com", - "feedback.chessly.com" - ], - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Chessly/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Chessly/assets/thumbnail.png", - "color": "#d1007e", - "category": "games", - "tags": [ - "chess", - "study", - "repertoire", - "video", - "theory", - "lesson", - "stockfish", - "quiz", - "course" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "Chessly", + "description": { + "en": "Chess learning made fun and easy." + }, + "url": [ + "chessly.com", + "feedback.chessly.com" + ], + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Chessly/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Chessly/assets/thumbnail.png", + "color": "#d1007e", + "category": "games", + "tags": [ + "chess", + "study", + "repertoire", + "video", + "theory", + "lesson", + "stockfish", + "quiz", + "course" + ] +} diff --git a/websites/C/Chessly/presence.ts b/websites/C/Chessly/presence.ts index d0432590760a..280746abf1c9 100644 --- a/websites/C/Chessly/presence.ts +++ b/websites/C/Chessly/presence.ts @@ -1,127 +1,133 @@ const presence = new Presence({ - clientId: "1078446138966954085", -}); + clientId: '1078446138966954085', +}) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Chessly/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Chessly/assets/logo.png', } -let browsingTimestamp = Math.floor(Date.now() / 1000), - oldPath: string = null; +let browsingTimestamp = Math.floor(Date.now() / 1000) +let oldPath: string | null = null -presence.on("UpdateData", async () => { - const { pathname, hostname, href } = document.location; - if (oldPath !== pathname) { - browsingTimestamp = Math.floor(Date.now() / 1000); - oldPath = pathname; - } - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - pathList = pathname.split("/").filter(path => path !== ""); +presence.on('UpdateData', async () => { + const { pathname, hostname, href } = document.location + if (oldPath !== pathname) { + browsingTimestamp = Math.floor(Date.now() / 1000) + oldPath = pathname + } + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const pathList = pathname.split('/').filter(path => path !== '') - if (hostname === "chessly.com") { - switch (true) { - case /\/courses(\/|$)/.test(pathname): { - const i = pathList.indexOf("courses"); - if (pathList[i + 1]) { - const courseImage = document.querySelector( - "[class*='_imageWrapper'] img" - ); - switch (pathList[i + 2]) { - case "gift-checkout": - case "checkout": { - presenceData.details = "Purchasing a course"; - presenceData.state = courseImage.alt; - presenceData.largeImageKey = courseImage.src; - break; - } - case "lessons": { - presenceData.details = "Doing a lesson"; - presenceData.state = `${[ - ...document.querySelectorAll( - "[class*='UserViewLessonHeader'] a[class*='UserViewLessonHeader_breadcrumbItem']" - ), - ] - .map(e => e.textContent) - .join(", ")} - ${ - document.querySelector( - "header > [class*='UserViewLessonHeader'] > [class*='UserViewLessonHeader']" - ).textContent - }`; - break; - } - default: { - presenceData.details = "Viewing a course"; - presenceData.state = document.querySelector("h1").textContent; - presenceData.largeImageKey = courseImage.src; - } - } - } else presenceData.details = "Browsing courses"; - break; - } - case /\/games\//.test(pathname): { - if ( - document.querySelector( - "[class*='PrimaryActionButton']" - )?.textContent === "Play" - ) { - presenceData.details = "Preparing to play a game"; - presenceData.state = document.querySelector("h1").textContent; - } else { - presenceData.details = "Playing a game"; - presenceData.state = document.querySelector("h1").textContent; - } - break; - } - case pathList[0] === "dashboard": { - switch (pathList[1]) { - case "analysis": { - presenceData.details = "Analyzing a game"; - break; - } - case "settings": { - presenceData.details = "Managing account settings"; - break; - } - default: { - presenceData.details = "Browsing the dashboard"; - } - } - break; - } - case pathList[0] === "faq": { - presenceData.details = "Reading the FAQ"; - break; - } - case pathList[0] === "login": { - presenceData.details = "Logging in"; - break; - } - default: { - presenceData.details = "Browsing"; - } - } - } else if (hostname === "feedback.chessly.com") { - switch (pathList[0] ?? "") { - case "": { - presenceData.details = "Browsing feedback and suggestions"; - break; - } - case "suggestions": { - if (pathList[1] === "add") { - presenceData.details = "Creating a suggestion"; - presenceData.state = - document.querySelector("#suggestionTitle").value; - } else { - presenceData.details = "Viewing a suggestion"; - presenceData.state = document.querySelector("h1").textContent; - presenceData.buttons = [{ label: "View Suggestion", url: href }]; - } - } - } - } + if (hostname === 'chessly.com') { + switch (true) { + case /\/courses(?:\/|$)/.test(pathname): { + const i = pathList.indexOf('courses') + if (pathList[i + 1]) { + const courseImage = document.querySelector( + '[class*=\'_imageWrapper\'] img', + ) + switch (pathList[i + 2]) { + case 'gift-checkout': + case 'checkout': { + presenceData.details = 'Purchasing a course' + presenceData.state = courseImage?.alt + presenceData.largeImageKey = courseImage?.src + break + } + case 'lessons': { + presenceData.details = 'Doing a lesson' + presenceData.state = `${[ + ...document.querySelectorAll( + '[class*=\'UserViewLessonHeader\'] a[class*=\'UserViewLessonHeader_breadcrumbItem\']', + ), + ] + .map(e => e.textContent) + .join(', ')} - ${ + document.querySelector( + 'header > [class*=\'UserViewLessonHeader\'] > [class*=\'UserViewLessonHeader\']', + )?.textContent + }` + break + } + default: { + presenceData.details = 'Viewing a course' + presenceData.state = document.querySelector('h1')?.textContent + presenceData.largeImageKey = courseImage?.src + } + } + } + else { + presenceData.details = 'Browsing courses' + } + break + } + case /\/games\//.test(pathname): { + if ( + document.querySelector( + '[class*=\'PrimaryActionButton\']', + )?.textContent === 'Play' + ) { + presenceData.details = 'Preparing to play a game' + presenceData.state = document.querySelector('h1')?.textContent + } + else { + presenceData.details = 'Playing a game' + presenceData.state = document.querySelector('h1')?.textContent + } + break + } + case pathList[0] === 'dashboard': { + switch (pathList[1]) { + case 'analysis': { + presenceData.details = 'Analyzing a game' + break + } + case 'settings': { + presenceData.details = 'Managing account settings' + break + } + default: { + presenceData.details = 'Browsing the dashboard' + } + } + break + } + case pathList[0] === 'faq': { + presenceData.details = 'Reading the FAQ' + break + } + case pathList[0] === 'login': { + presenceData.details = 'Logging in' + break + } + default: { + presenceData.details = 'Browsing' + } + } + } + else if (hostname === 'feedback.chessly.com') { + switch (pathList[0] ?? '') { + case '': { + presenceData.details = 'Browsing feedback and suggestions' + break + } + case 'suggestions': { + if (pathList[1] === 'add') { + presenceData.details = 'Creating a suggestion' + presenceData.state = document.querySelector('#suggestionTitle')?.value + } + else { + presenceData.details = 'Viewing a suggestion' + presenceData.state = document.querySelector('h1')?.textContent + presenceData.buttons = [{ label: 'View Suggestion', url: href }] + } + } + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git "a/websites/C/Chia S\341\272\273 Nh\341\272\241c/metadata.json" "b/websites/C/Chia S\341\272\273 Nh\341\272\241c/metadata.json" index 6028d96b680e..08e66fb90f0f 100644 --- "a/websites/C/Chia S\341\272\273 Nh\341\272\241c/metadata.json" +++ "b/websites/C/Chia S\341\272\273 Nh\341\272\241c/metadata.json" @@ -1,52 +1,52 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kyrie", - "id": "368399721494216706" - }, - "service": "Chia Sẻ Nhạc", - "altnames": [ - "Chiasenhac" - ], - "description": { - "en": "High-fidelity music sharing and ranking community", - "vi_VN": "Cộng đồng chia sẻ nhạc chất lượng cao và xếp hạng âm nhạc trực tuyến" - }, - "url": "chiasenhac.vn", - "regExp": "([a-z0-9]+[.])?chiasenhac[.]vn", - "version": "1.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Chia%20S%E1%BA%BB%20Nh%E1%BA%A1c/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Chia%20S%E1%BA%BB%20Nh%E1%BA%A1c/assets/thumbnail.png", - "color": "#FB5B49", - "category": "music", - "tags": [ - "chia", - "se", - "nhac", - "music", - "high", - "quality", - "fidelity" - ], - "settings": [ - { - "id": "timestamps", - "title": "Hiện thời gian", - "icon": "fas fa-stopwatch", - "value": true - }, - { - "id": "cover", - "title": "Hiện ảnh album", - "icon": "fad fa-images", - "value": true - }, - { - "id": "buttons", - "title": "Hiện nút", - "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": "Chia Sẻ Nhạc", + "altnames": [ + "Chiasenhac" + ], + "description": { + "en": "High-fidelity music sharing and ranking community", + "vi_VN": "Cộng đồng chia sẻ nhạc chất lượng cao và xếp hạng âm nhạc trực tuyến" + }, + "url": "chiasenhac.vn", + "regExp": "([a-z0-9]+[.])?chiasenhac[.]vn", + "version": "1.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Chia%20S%E1%BA%BB%20Nh%E1%BA%A1c/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Chia%20S%E1%BA%BB%20Nh%E1%BA%A1c/assets/thumbnail.png", + "color": "#FB5B49", + "category": "music", + "tags": [ + "chia", + "se", + "nhac", + "music", + "high", + "quality", + "fidelity" + ], + "settings": [ + { + "id": "timestamps", + "title": "Hiện thời gian", + "icon": "fas fa-stopwatch", + "value": true + }, + { + "id": "cover", + "title": "Hiện ảnh album", + "icon": "fad fa-images", + "value": true + }, + { + "id": "buttons", + "title": "Hiện nút", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git "a/websites/C/Chia S\341\272\273 Nh\341\272\241c/presence.ts" "b/websites/C/Chia S\341\272\273 Nh\341\272\241c/presence.ts" index 25a8af2474d6..db25c21a8b87 100644 --- "a/websites/C/Chia S\341\272\273 Nh\341\272\241c/presence.ts" +++ "b/websites/C/Chia S\341\272\273 Nh\341\272\241c/presence.ts" @@ -1,146 +1,170 @@ const presence = new Presence({ - clientId: "927785613309116476", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '927785613309116476', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Chia%20S%E1%BA%BB%20Nh%E1%BA%A1c/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, href } = document.location, - [buttons, timestamps, cover] = await Promise.all([ - presence.getSetting("buttons"), - presence.getSetting("timestamps"), - presence.getSetting("cover"), - ]); - if (pathname.startsWith("/hd")) { - if (pathname === "/hd/video.html") presenceData.details = "Đang tìm video"; - else if (pathname.endsWith("v-video.html")) - presenceData.details = "Đang tìm video Việt Nam"; - else if (pathname.endsWith("us-video.html")) - presenceData.details = "Đang tìm video Âu Mỹ"; - else if (pathname.endsWith("c-video.html")) - presenceData.details = "Đang tìm video Hoa"; - else if (pathname.endsWith("k-video.html")) - presenceData.details = "Đang tìm video Hàn"; - else if (pathname.endsWith("l-video.html")) - presenceData.details = "Đang tìm video Live"; - else if (pathname.endsWith("h-video.html")) - presenceData.details = "Đang tìm video hài"; - else if (pathname.endsWith("j-video.html")) - presenceData.details = "Đang tìm video Nhật"; - else if (pathname.endsWith("f-video.html")) - presenceData.details = "Đang tìm video Pháp"; - else if (pathname.endsWith("o-video.html")) - presenceData.details = "Đang tìm video nước khác"; - else { - const { paused, currentTime, duration } = - document.querySelector("video"); - presenceData.details = document.querySelector( - "body > section > div.container > div > div.col-md-9 > div:nth-child(4) > div.col-md-4 > div > div.card-body > h2" - ).textContent; - presenceData.state = document - .querySelector( - "body > section > div.container > div > div.col-md-9 > div:nth-child(4) > div.col-md-4 > div > div.card-body > ul > li:nth-child(1)" - ) - .textContent.slice(7); - if (cover) { - presenceData.largeImageKey = document.querySelector( - "#companion_cover > img" - ).src; - } - if (timestamps) { - delete presenceData.startTimestamp; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Chia%20S%E1%BA%BB%20Nh%E1%BA%A1c/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, href } = document.location + const [buttons, timestamps, cover] = await Promise.all([ + presence.getSetting('buttons'), + presence.getSetting('timestamps'), + presence.getSetting('cover'), + ]) + if (pathname.startsWith('/hd')) { + if (pathname === '/hd/video.html') { + presenceData.details = 'Đang tìm video' + } + else if (pathname.endsWith('v-video.html')) { + presenceData.details = 'Đang tìm video Việt Nam' + } + else if (pathname.endsWith('us-video.html')) { + presenceData.details = 'Đang tìm video Âu Mỹ' + } + else if (pathname.endsWith('c-video.html')) { + presenceData.details = 'Đang tìm video Hoa' + } + else if (pathname.endsWith('k-video.html')) { + presenceData.details = 'Đang tìm video Hàn' + } + else if (pathname.endsWith('l-video.html')) { + presenceData.details = 'Đang tìm video Live' + } + else if (pathname.endsWith('h-video.html')) { + presenceData.details = 'Đang tìm video hài' + } + else if (pathname.endsWith('j-video.html')) { + presenceData.details = 'Đang tìm video Nhật' + } + else if (pathname.endsWith('f-video.html')) { + presenceData.details = 'Đang tìm video Pháp' + } + else if (pathname.endsWith('o-video.html')) { + presenceData.details = 'Đang tìm video nước khác' + } + else { + const { paused, currentTime, duration } = document.querySelector('video')! + presenceData.details = document.querySelector( + 'body > section > div.container > div > div.col-md-9 > div:nth-child(4) > div.col-md-4 > div > div.card-body > h2', + )?.textContent + presenceData.state = document + .querySelector( + 'body > section > div.container > div > div.col-md-9 > div:nth-child(4) > div.col-md-4 > div > div.card-body > ul > li:nth-child(1)', + ) + ?.textContent + ?.slice(7) + if (cover) { + presenceData.largeImageKey = document.querySelector( + '#companion_cover > img', + )?.src + } + if (timestamps) { + delete presenceData.startTimestamp - if (!paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(duration, currentTime); - } - } - if (buttons) - presenceData.buttons = [{ label: "Xem video", url: document.URL }]; - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = paused ? "Đã dừng" : "Đang phát"; - } - } else if ( - pathname.startsWith("/mp3") || - pathname.startsWith("/nghe-album") || - document.querySelector("#csnplayer > div.jw-overlays.jw-reset") - ) { - if (pathname.startsWith("/mp3/vietnam")) - presenceData.details = "Đang tìm nhạc Việt Nam"; - else if (pathname.startsWith("/mp3/us-uk")) - presenceData.details = "Đang tìm nhạc Âu Mỹ"; - else if (pathname.startsWith("/mp3/chinese")) - presenceData.details = "Đang tìm nhạc Hoa"; - else if (pathname.startsWith("/mp3/korea")) - presenceData.details = "Đang tìm nhạc Hàn"; - else if (pathname.startsWith("/mp3/japan")) - presenceData.details = "Đang tìm nhạc Nhật"; - else if (pathname.startsWith("/mp3/france")) - presenceData.details = "Đang tìm nhạc Pháp"; - else if (pathname.startsWith("/mp3/other")) - presenceData.details = "Đang tìm nhạc nước khác"; - else if (pathname.startsWith("/mp3/beat-playback")) - presenceData.details = "Đang tìm beat/playback"; - else if (document.querySelector("#csnplayer > div.jw-overlays.jw-reset")) { - const { paused, currentTime, duration } = - document.querySelector("video"); - presenceData.details = document.querySelector( - "body > section > div.container > div > div.col-md-9 > div:nth-child(4) > div.col-md-4 > div > div.card-body > h2" - ).textContent; - presenceData.state = document - .querySelector( - "body > section > div.container > div > div.col-md-9 > div:nth-child(4) > div.col-md-4 > div > div.card-body > ul > li:nth-child(1)" - ) - .textContent.slice(7); - if (cover) { - presenceData.largeImageKey = document.querySelector( - "#companion_cover > img" - ).src; - } - if (timestamps) { - delete presenceData.startTimestamp; + if (!paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(duration, currentTime) + } + } + if (buttons) + presenceData.buttons = [{ label: 'Xem video', url: document.URL }] + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = paused ? 'Đã dừng' : 'Đang phát' + } + } + else if ( + pathname.startsWith('/mp3') + || pathname.startsWith('/nghe-album') + || document.querySelector('#csnplayer > div.jw-overlays.jw-reset') + ) { + if (pathname.startsWith('/mp3/vietnam')) { + presenceData.details = 'Đang tìm nhạc Việt Nam' + } + else if (pathname.startsWith('/mp3/us-uk')) { + presenceData.details = 'Đang tìm nhạc Âu Mỹ' + } + else if (pathname.startsWith('/mp3/chinese')) { + presenceData.details = 'Đang tìm nhạc Hoa' + } + else if (pathname.startsWith('/mp3/korea')) { + presenceData.details = 'Đang tìm nhạc Hàn' + } + else if (pathname.startsWith('/mp3/japan')) { + presenceData.details = 'Đang tìm nhạc Nhật' + } + else if (pathname.startsWith('/mp3/france')) { + presenceData.details = 'Đang tìm nhạc Pháp' + } + else if (pathname.startsWith('/mp3/other')) { + presenceData.details = 'Đang tìm nhạc nước khác' + } + else if (pathname.startsWith('/mp3/beat-playback')) { + presenceData.details = 'Đang tìm beat/playback' + } + else if (document.querySelector('#csnplayer > div.jw-overlays.jw-reset')) { + const { paused, currentTime, duration } = document.querySelector('video')! + presenceData.details = document.querySelector( + 'body > section > div.container > div > div.col-md-9 > div:nth-child(4) > div.col-md-4 > div > div.card-body > h2', + )?.textContent + presenceData.state = document + .querySelector( + 'body > section > div.container > div > div.col-md-9 > div:nth-child(4) > div.col-md-4 > div > div.card-body > ul > li:nth-child(1)', + ) + ?.textContent + ?.slice(7) + if (cover) { + presenceData.largeImageKey = document.querySelector( + '#companion_cover > img', + )?.src + } + if (timestamps) { + delete presenceData.startTimestamp - if (!paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(duration, currentTime); - } - } - if (buttons) - presenceData.buttons = [{ label: "Nghe bài hát", url: document.URL }]; - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = paused ? "Đã dừng" : "Đang phát"; - } - } else if ( - pathname.includes("/nhac-hot") || - pathname.startsWith("/bang-xep-hang") - ) - presenceData.details = "Đang xem bảng xếp hạng"; - else if (pathname.startsWith("/ca-si")) { - presenceData.details = "Đang xem hồ sơ ca sĩ:"; - presenceData.state = document.querySelector( - "body > section > div.box_profile > div > div > div.thumb-mask.media.align-items-stretch.d-flex.align-content-center.justify-content-center > div > div > h4" - ).textContent; - if (buttons) - presenceData.buttons = [{ label: "Xem ca sĩ", url: document.URL }]; - } else if (pathname.startsWith("/user")) { - presenceData.details = "Đang xem hồ sơ người dùng:"; - presenceData.state = document.querySelector( - "body > section > div.box_profile > div > div.box_detail_profile.media-body.align-self-center > h4" - ).textContent; - if (buttons) - presenceData.buttons = [{ label: "Xem người dùng", url: document.URL }]; - } else if (pathname.startsWith("/dang-tai")) - presenceData.details = "Đang đăng tải nhạc"; - else if (pathname.startsWith("/chu-de")) { - presenceData.details = "Đang tìm nhạc theo chủ đề:"; - presenceData.state = document.querySelector( - "body > section > div.container > div > div.col-md-9 > div > div.media.media-tab > div > h2" - ).textContent; - } else if (href === "https://chiasenhac.vn/") - presenceData.details = "Trang chủ"; - presence.setActivity(presenceData); -}); + if (!paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(duration, currentTime) + } + } + if (buttons) + presenceData.buttons = [{ label: 'Nghe bài hát', url: document.URL }] + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = paused ? 'Đã dừng' : 'Đang phát' + } + } + else if ( + pathname.includes('/nhac-hot') + || pathname.startsWith('/bang-xep-hang') + ) { + presenceData.details = 'Đang xem bảng xếp hạng' + } + else if (pathname.startsWith('/ca-si')) { + presenceData.details = 'Đang xem hồ sơ ca sĩ:' + presenceData.state = document.querySelector( + 'body > section > div.box_profile > div > div > div.thumb-mask.media.align-items-stretch.d-flex.align-content-center.justify-content-center > div > div > h4', + )?.textContent + if (buttons) + presenceData.buttons = [{ label: 'Xem ca sĩ', url: document.URL }] + } + else if (pathname.startsWith('/user')) { + presenceData.details = 'Đang xem hồ sơ người dùng:' + presenceData.state = document.querySelector( + 'body > section > div.box_profile > div > div.box_detail_profile.media-body.align-self-center > h4', + )?.textContent + if (buttons) + presenceData.buttons = [{ label: 'Xem người dùng', url: document.URL }] + } + else if (pathname.startsWith('/dang-tai')) { + presenceData.details = 'Đang đăng tải nhạc' + } + else if (pathname.startsWith('/chu-de')) { + presenceData.details = 'Đang tìm nhạc theo chủ đề:' + presenceData.state = document.querySelector( + 'body > section > div.container > div > div.col-md-9 > div > div.media.media-tab > div > h2', + )?.textContent + } + else if (href === 'https://chiasenhac.vn/') { + presenceData.details = 'Trang chủ' + } + presence.setActivity(presenceData) +}) diff --git a/websites/C/Chompu/metadata.json b/websites/C/Chompu/metadata.json index 72656fe3bed6..dc11e5e587c5 100644 --- a/websites/C/Chompu/metadata.json +++ b/websites/C/Chompu/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "919878532228841532", - "name": "somboytiger" - }, - "service": "Chompu", - "description": { - "en": "Chompu is Discord app equipped with a music streaming system that supports multiple platforms, including Joox, TikTok, BiliBili, BiliBiliTV, VKMusic, Facebook Watch, TIDALMusic, AmazonMusic, Deezer, Nico, AppleMusic, Spotify, Soundcloud, Clyp, PornHub, and many more!", - "th": "Chompu คือ แอปดิสคอร์ดที่มาพร้อมด้วยระบบสตรีมเล่นเพลงที่รองรับสตรีมเล่นเพลงหลายแพลตฟอร์ม Joox, TikTok, BiliBili, BiliBiliTV, VKMusic, Facebook Watch, TIDALMusic, AmazonMusic, Deezer, Nico, AppleMusic, Spotify, Soundcloud, Clyp, PornHub และอื่นๆอีกมากมาย!" - }, - "url": "chompubot.work", - "version": "1.0.5", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Chompu/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Chompu/assets/thumbnail.png", - "color": "#ffbcff", - "category": "music", - "tags": [ - "music", - "music-room", - "discord", - "dashboard" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "919878532228841532", + "name": "somboytiger" + }, + "service": "Chompu", + "description": { + "en": "Chompu is Discord app equipped with a music streaming system that supports multiple platforms, including Joox, TikTok, BiliBili, BiliBiliTV, VKMusic, Facebook Watch, TIDALMusic, AmazonMusic, Deezer, Nico, AppleMusic, Spotify, Soundcloud, Clyp, PornHub, and many more!", + "th": "Chompu คือ แอปดิสคอร์ดที่มาพร้อมด้วยระบบสตรีมเล่นเพลงที่รองรับสตรีมเล่นเพลงหลายแพลตฟอร์ม Joox, TikTok, BiliBili, BiliBiliTV, VKMusic, Facebook Watch, TIDALMusic, AmazonMusic, Deezer, Nico, AppleMusic, Spotify, Soundcloud, Clyp, PornHub และอื่นๆอีกมากมาย!" + }, + "url": "chompubot.work", + "version": "1.0.5", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Chompu/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Chompu/assets/thumbnail.png", + "color": "#ffbcff", + "category": "music", + "tags": [ + "music", + "music-room", + "discord", + "dashboard" + ] +} diff --git a/websites/C/Chompu/presence.ts b/websites/C/Chompu/presence.ts index e683231f3ada..f3e72f379f88 100644 --- a/websites/C/Chompu/presence.ts +++ b/websites/C/Chompu/presence.ts @@ -1,127 +1,133 @@ const presence = new Presence({ - clientId: "1219713910165209169", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1219713910165209169', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Chompu/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Chompu/assets/logo.png', } const enum Pages { - Home = "/", - Dashboard = "/dashboard", - Status = "/status", - Contact = "/contact", + Home = '/', + Dashboard = '/dashboard', + Status = '/status', + Contact = '/contact', } const presenceData: PresenceData = { - type: ActivityType.Listening, - largeImageKey: Assets.Logo, -}; + type: ActivityType.Listening, + largeImageKey: Assets.Logo, +} -presence.on("UpdateData", async () => { - const base = document.location.pathname; +presence.on('UpdateData', async () => { + const base = document.location.pathname - if (/\/dashboard\/guild\/(.*[0-9_].*)\/music-room/gi.test(base)) { - if ( - document.querySelector("div.hidden.-player-status") && - document.querySelector("div.hidden.-player-status") - .textContent === "true" - ) { - const author = document.querySelector( - "p.text-small.mt-1.text-foreground\\/80.-player-author" - ), - playing = document.querySelector( - "svg.-player-playing" - ), - timeEndPlayer = document.querySelector( - "p.text-small.text-foreground\\/50.-player-position-end" - ).textContent, - [startPlayer, durationPlayer] = [ - presence.timestampFromFormat( - document.querySelector( - "p.text-small.-player-position-start" - ).textContent - ), - presence.timestampFromFormat(timeEndPlayer), - ], - [startTimestamp, endTimestamp] = presence.getTimestamps( - startPlayer, - durationPlayer - ); + if (/\/dashboard\/guild\/[^\d\n\r_\u2028\u2029]*[\d_].*\/music-room/i.test(base)) { + if ( + document.querySelector('div.hidden.-player-status') + && document.querySelector('div.hidden.-player-status') + ?.textContent === 'true' + ) { + const author = document.querySelector( + 'p.text-small.mt-1.text-foreground\\/80.-player-author', + ) + const playing = document.querySelector( + 'svg.-player-playing', + ) + const timeEndPlayer = document.querySelector( + 'p.text-small.text-foreground\\/50.-player-position-end', + )?.textContent + const [startPlayer, durationPlayer] = [ + presence.timestampFromFormat( + document.querySelector( + 'p.text-small.-player-position-start', + )?.textContent ?? '', + ), + presence.timestampFromFormat(timeEndPlayer ?? ''), + ] + const [startTimestamp, endTimestamp] = presence.getTimestamps( + startPlayer, + durationPlayer, + ); - [presenceData.startTimestamp, presenceData.endTimestamp] = [ - startTimestamp, - endTimestamp, - ]; + [presenceData.startTimestamp, presenceData.endTimestamp] = [ + startTimestamp, + endTimestamp, + ] - presenceData.details = document.querySelector( - "h1.text-large.font-medium.-player-title" - ); - presenceData.state = author; - presenceData.largeImageKey = document.querySelector( - "[data-label='guild-logo']" - ).src; - presenceData.smallImageKey = playing ? Assets.Play : Assets.Pause; - presenceData.smallImageText = playing ? "Playing" : "Pause"; - presenceData.startTimestamp = startTimestamp; - presenceData.endTimestamp = endTimestamp; - presenceData.buttons = [ - { - label: `Join Player ${ - document.querySelector( - "[data-label='player-requester']" - ).textContent - }`, - url: document.location.href, - }, - ]; + presenceData.details = document.querySelector( + 'h1.text-large.font-medium.-player-title', + ) + presenceData.state = author + presenceData.largeImageKey = document.querySelector( + '[data-label=\'guild-logo\']', + )?.src + presenceData.smallImageKey = playing ? Assets.Play : Assets.Pause + presenceData.smallImageText = playing ? 'Playing' : 'Pause' + presenceData.startTimestamp = startTimestamp + presenceData.endTimestamp = endTimestamp + presenceData.buttons = [ + { + label: `Join Player ${ + document.querySelector( + '[data-label=\'player-requester\']', + )?.textContent + }`, + url: document.location.href, + }, + ] - if (!playing) delete presenceData.startTimestamp; - } else { - presenceData.details = "No song queue found"; - presenceData.state = "In the server..."; - presenceData.largeImageKey = document.querySelector( - "[data-label='guild-logo']" - ) - ? document.querySelector("[data-label='guild-logo']") - .src - : Assets.Logo; - presenceData.smallImageText = "Zzz"; - presenceData.startTimestamp = browsingTimestamp; - presenceData.buttons = [ - { - label: "Join Player", - url: document.location.href, - }, - ]; - if (presenceData.endTimestamp) delete presenceData.endTimestamp; - } - } else { - presenceData.details = "Idk"; - presenceData.state = "Browsing..."; - presenceData.largeImageKey = Assets.Logo; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Zzz"; - presenceData.startTimestamp = browsingTimestamp; - if (presenceData.buttons) delete presenceData.buttons; - if (presenceData.endTimestamp) delete presenceData.endTimestamp; + if (!playing) + delete presenceData.startTimestamp + } + else { + presenceData.details = 'No song queue found' + presenceData.state = 'In the server...' + presenceData.largeImageKey = document.querySelector( + '[data-label=\'guild-logo\']', + ) + ? document.querySelector('[data-label=\'guild-logo\']') + ?.src + : Assets.Logo + presenceData.smallImageText = 'Zzz' + presenceData.startTimestamp = browsingTimestamp + presenceData.buttons = [ + { + label: 'Join Player', + url: document.location.href, + }, + ] + if (presenceData.endTimestamp) + delete presenceData.endTimestamp + } + } + else { + presenceData.details = 'Idk' + presenceData.state = 'Browsing...' + presenceData.largeImageKey = Assets.Logo + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Zzz' + presenceData.startTimestamp = browsingTimestamp + if (presenceData.buttons) + delete presenceData.buttons + if (presenceData.endTimestamp) + delete presenceData.endTimestamp - switch (base) { - case Pages.Home: - presenceData.details = "Home"; - break; - case Pages.Dashboard: - presenceData.details = "Dashboard"; - break; - case Pages.Status: - presenceData.details = "Status"; - break; - case Pages.Contact: - presenceData.details = "Contact"; - break; - } - } + switch (base) { + case Pages.Home: + presenceData.details = 'Home' + break + case Pages.Dashboard: + presenceData.details = 'Dashboard' + break + case Pages.Status: + presenceData.details = 'Status' + break + case Pages.Contact: + presenceData.details = 'Contact' + break + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/Cineby/api.ts b/websites/C/Cineby/api.ts index 7fcd88d8e665..55b136a60057 100644 --- a/websites/C/Cineby/api.ts +++ b/websites/C/Cineby/api.ts @@ -1,111 +1,108 @@ -/* eslint-disable camelcase */ -// Hack to resolve Deepscan -const no_op = (a: number) => a + 1; -no_op(0); - export interface Details { - poster_path?: string; + poster_path?: string } export interface TvDetails extends Details { - name?: string; - season_poster?: string; - episode_title?: string; - episode_number?: number; - season_number?: number; + name?: string + season_poster?: string + episode_title?: string + episode_number?: number + season_number?: number } export interface EpisodeDetails { - name: string; - episode_number: number; - season_number: number; + name: string + episode_number: number + season_number: number } export interface MovieDetails extends Details { - title?: string; - release_date?: string; - runtime?: number; + title?: string + release_date?: string + runtime?: number } export interface AnimeDetails { - details: { - title: string; - thumbnail: string; - episodes: { - episode: number; - title: string; - }[]; - }; + details: { + title: string + thumbnail: string + episodes: { + episode: number + title: string + }[] + } } -const cache: Map = new Map(); +const cache: Map = new Map() export class CinebyApi { - private static readonly BASE_URL = "https://db.cineby.app/3"; - private static readonly API_KEY = "269890f657dddf4635473cf4cf456576"; - - private static readonly ANIME_URL = "https://api.cineby.app/hianime"; - - public static async getCurrent( - pathname: string - ): Promise { - if (cache.has(pathname)) return cache.get(pathname) as T; - - const [type, id] = pathname.split("/").slice(1), - response = await fetch( - `${this.BASE_URL}/${type}/${id}?language=en&api_key=${this.API_KEY}` - ); - - if (type === "tv") { - const json = await response.json(), - episode = await this.getCurrentEpisode(pathname), - returnData = { - ...json, - season_poster: json.seasons[episode.season_number - 1].poster_path, - episode_title: episode.name, - episode_number: episode.episode_number, - season_number: episode.season_number, - } as T; - - cache.set(pathname, returnData); - - return returnData; - } - - const json = await response.json(); - cache.set(pathname, json); - - return json; - } - - private static async getCurrentEpisode( - pathname: string - ): Promise { - const [id, season, episode] = pathname.split("/").slice(2), - response = await fetch( - `${this.BASE_URL}/tv/${id}/season/${season ?? 1}/episode/${ - episode ?? 1 - }?language=en&api_key=${this.API_KEY}` - ); - - return response.json(); - } - - public static async getCurrentAnime(pathname: string): Promise { - if (cache.has(pathname)) return cache.get(pathname) as AnimeDetails; - - const { search } = document.location, - id = pathname.split("/")[2], - response = await fetch( - `${ - this.ANIME_URL - }/sources-with-id?providerId=${id}&dub=${new URLSearchParams( - search - ).get("dub")}` - ); - - cache.set(pathname, await response.json()); - - return response.json(); - } + private static readonly BASE_URL = 'https://db.cineby.app/3' + private static readonly API_KEY = '269890f657dddf4635473cf4cf456576' + + private static readonly ANIME_URL = 'https://api.cineby.app/hianime' + + public static async getCurrent( + pathname: string, + ): Promise { + if (cache.has(pathname)) + return cache.get(pathname) as T + + const [type, id] = pathname.split('/').slice(1) + const response = await fetch( + `${this.BASE_URL}/${type}/${id}?language=en&api_key=${this.API_KEY}`, + ) + + if (type === 'tv') { + const json = await response.json() + const episode = await this.getCurrentEpisode(pathname) + const returnData = { + ...json, + season_poster: json.seasons[episode.season_number - 1].poster_path, + episode_title: episode.name, + episode_number: episode.episode_number, + season_number: episode.season_number, + } as T + + cache.set(pathname, returnData) + + return returnData + } + + const json = await response.json() + cache.set(pathname, json) + + return json + } + + private static async getCurrentEpisode( + pathname: string, + ): Promise { + const [id, season, episode] = pathname.split('/').slice(2) + const response = await fetch( + `${this.BASE_URL}/tv/${id}/season/${season ?? 1}/episode/${ + episode ?? 1 + }?language=en&api_key=${this.API_KEY}`, + ) + + return response.json() + } + + public static async getCurrentAnime(pathname: string): Promise { + if (cache.has(pathname)) + return cache.get(pathname) as AnimeDetails + + const { search } = document.location + const id = pathname.split('/')[2] + const response = await fetch( + `${ + this.ANIME_URL + }/sources-with-id?providerId=${id}&dub=${new URLSearchParams( + search, + ).get('dub')}`, + ) + + cache.set(pathname, await response.json()) + + return response.json() + } } diff --git a/websites/C/Cineby/metadata.json b/websites/C/Cineby/metadata.json index 4640326004ee..cf6b3837cf48 100644 --- a/websites/C/Cineby/metadata.json +++ b/websites/C/Cineby/metadata.json @@ -1,43 +1,43 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "374905512661221377", - "name": "slowlife." - }, - "service": "Cineby", - "description": { - "en": "Watch Free TV Shows Online, Watch Free Movies Online" - }, - "url": "www.cineby.app", - "version": "1.0.1", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cineby/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cineby/assets/thumbnail.png", - "color": "#fb0013", - "category": "videos", - "tags": [ - "series", - "movies", - "anime" - ], - "settings": [ - { - "id": "showBrowsing", - "title": "Show Browsing", - "icon": "fad fa-search", - "value": false - }, - { - "id": "useActivityName", - "title": "Show Title as Activity", - "icon": "fad fa-user-edit", - "value": true - }, - { - "id": "showCover", - "title": "Show Cover", - "icon": "fas fa-images", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "374905512661221377", + "name": "slowlife." + }, + "service": "Cineby", + "description": { + "en": "Watch Free TV Shows Online, Watch Free Movies Online" + }, + "url": "www.cineby.app", + "version": "1.0.1", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cineby/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cineby/assets/thumbnail.png", + "color": "#fb0013", + "category": "videos", + "tags": [ + "series", + "movies", + "anime" + ], + "settings": [ + { + "id": "showBrowsing", + "title": "Show Browsing", + "icon": "fad fa-search", + "value": false + }, + { + "id": "useActivityName", + "title": "Show Title as Activity", + "icon": "fad fa-user-edit", + "value": true + }, + { + "id": "showCover", + "title": "Show Cover", + "icon": "fas fa-images", + "value": true + } + ] +} diff --git a/websites/C/Cineby/presence.ts b/websites/C/Cineby/presence.ts index f5d4085a7d05..67cf72ad29d8 100644 --- a/websites/C/Cineby/presence.ts +++ b/websites/C/Cineby/presence.ts @@ -1,94 +1,101 @@ -import { CinebyApi, MovieDetails, TvDetails } from "./api"; +import type { MovieDetails, TvDetails } from './api' +import { CinebyApi } from './api' const presence = new Presence({ - clientId: "1325115346696273993", - }), - startTimestamp = Math.floor(Date.now() / 1000); + clientId: '1325115346696273993', +}) +const startTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Cineby/assets/logo.png", - details: "Browsing", - type: ActivityType.Watching, - startTimestamp, - }, - { pathname } = document.location, - [showBrowsing, useActivityName, showCover] = await Promise.all([ - presence.getSetting("showBrowsing"), - presence.getSetting("useActivityName"), - presence.getSetting("showCover"), - ]); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Cineby/assets/logo.png', + details: 'Browsing', + type: ActivityType.Watching, + startTimestamp, + } + const { pathname } = document.location + const [showBrowsing, useActivityName, showCover] = await Promise.all([ + presence.getSetting('showBrowsing'), + presence.getSetting('useActivityName'), + presence.getSetting('showCover'), + ]) - switch (pathname.split("/")[1]) { - case "movie": { - const { - title, - poster_path: posterPath, - release_date: releaseDate, - runtime, - } = await CinebyApi.getCurrent(pathname); + switch (pathname.split('/')[1]) { + case 'movie': { + const { + title, + poster_path: posterPath, + release_date: releaseDate, + runtime, + } = await CinebyApi.getCurrent(pathname) - if (useActivityName) presenceData.name = title; - presenceData.details = title; - presenceData.state = `${releaseDate - .split("-") - .shift()} • ${runtime} minutes`; + if (useActivityName) + presenceData.name = title + presenceData.details = title + presenceData.state = `${releaseDate + ?.split('-') + .shift()} • ${runtime} minutes` - if (showCover) - presenceData.largeImageKey = `https://image.tmdb.org/t/p/original${posterPath}`; - break; - } - case "tv": { - const { - name: title, - season_poster: seasonPoster, - episode_title: episodeTitle, - season_number: seasonNumber, - episode_number: episodeNumber, - } = await CinebyApi.getCurrent(pathname); + if (showCover) + presenceData.largeImageKey = `https://image.tmdb.org/t/p/original${posterPath}` + break + } + case 'tv': { + const { + name: title, + season_poster: seasonPoster, + episode_title: episodeTitle, + season_number: seasonNumber, + episode_number: episodeNumber, + } = await CinebyApi.getCurrent(pathname) - if (useActivityName) presenceData.name = title; + if (useActivityName) + presenceData.name = title - presenceData.details = useActivityName ? episodeTitle : title; - presenceData.state = useActivityName - ? `Season ${seasonNumber}, Episode ${episodeNumber}` - : `S${seasonNumber}:E${episodeNumber} ${episodeTitle}`; + presenceData.details = useActivityName ? episodeTitle : title + presenceData.state = useActivityName + ? `Season ${seasonNumber}, Episode ${episodeNumber}` + : `S${seasonNumber}:E${episodeNumber} ${episodeTitle}` - if (showCover) - presenceData.largeImageKey = `https://image.tmdb.org/t/p/original${seasonPoster}`; + if (showCover) + presenceData.largeImageKey = `https://image.tmdb.org/t/p/original${seasonPoster}` - break; - } - case "anime": { - const { details } = await CinebyApi.getCurrentAnime(pathname), - { title, thumbnail, episodes } = details, - { episode, title: episodeTitle } = episodes.find( - ({ episode }) => - episode === (parseInt(pathname.split("/").pop()) || 1) - ); + break + } + case 'anime': { + const { details } = await CinebyApi.getCurrentAnime(pathname) + const { title, thumbnail, episodes } = details + const { episode, title: episodeTitle } = episodes.find( + ({ episode }) => + episode === (Number.parseInt(pathname.split('/').pop() ?? '0') || 1), + )! - if (useActivityName) presenceData.name = title; + if (useActivityName) + presenceData.name = title - presenceData.details = useActivityName - ? episodeTitle.replace(/E[0-9]{1,}: /, "").trim() - : title; - presenceData.state = `Episode ${episode}`; + presenceData.details = useActivityName + ? episodeTitle.replace(/E\d+: /, '').trim() + : title + presenceData.state = `Episode ${episode}` - if (showCover) presenceData.largeImageKey = thumbnail; - break; - } - default: - if (!showBrowsing) return presence.clearActivity(); - } + if (showCover) + presenceData.largeImageKey = thumbnail + break + } + default: + if (!showBrowsing) + return presence.clearActivity() + } - const video = document.querySelector("video"); - if (video) { - if (!video.paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - } else presenceData.smallImageKey = Assets.Pause; - } + const video = document.querySelector('video') + if (video) { + if (!video.paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + } + else { + presenceData.smallImageKey = Assets.Pause + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/Cisco Networking Academy/metadata.json b/websites/C/Cisco Networking Academy/metadata.json index 041e6d1eb628..a06f4f9f0f88 100644 --- a/websites/C/Cisco Networking Academy/metadata.json +++ b/websites/C/Cisco Networking Academy/metadata.json @@ -1,35 +1,35 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "YJJcoolcool", - "id": "300929818231308288" - }, - "contributors": [ - { - "name": "Atom Skully", - "id": "671037171611729920" - } - ], - "service": "Cisco Networking Academy", - "description": { - "en": "Cisco Networking Academy is a global IT and cybersecurity education platform.", - "vi_VN": "Cisco Networking Academy là nền tảng giáo dục an ninh mạng và IT toàn cầu." - }, - "url": [ - "www.netacad.com", - "legacy.netacad.com" - ], - "version": "1.0.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cisco%20Networking%20Academy/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cisco%20Networking%20Academy/assets/thumbnail.png", - "color": "#005073", - "category": "other", - "tags": [ - "netacad", - "cisco-netacad", - "cisco", - "cisco-networking", - "cisco-networking-academy" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "YJJcoolcool", + "id": "300929818231308288" + }, + "contributors": [ + { + "name": "Atom Skully", + "id": "671037171611729920" + } + ], + "service": "Cisco Networking Academy", + "description": { + "en": "Cisco Networking Academy is a global IT and cybersecurity education platform.", + "vi_VN": "Cisco Networking Academy là nền tảng giáo dục an ninh mạng và IT toàn cầu." + }, + "url": [ + "www.netacad.com", + "legacy.netacad.com" + ], + "version": "1.0.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cisco%20Networking%20Academy/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cisco%20Networking%20Academy/assets/thumbnail.png", + "color": "#005073", + "category": "other", + "tags": [ + "netacad", + "cisco-netacad", + "cisco", + "cisco-networking", + "cisco-networking-academy" + ] +} diff --git a/websites/C/Cisco Networking Academy/presence.ts b/websites/C/Cisco Networking Academy/presence.ts index 5738d3b3bbbe..e0cf579b0e1a 100644 --- a/websites/C/Cisco Networking Academy/presence.ts +++ b/websites/C/Cisco Networking Academy/presence.ts @@ -1,57 +1,74 @@ const presence = new Presence({ - clientId: "858886158045806602", -}); + clientId: '858886158045806602', +}) -let prevURL = "", - timestamp = Date.now(), - details = "", - state = ""; -presence.on("UpdateData", async () => { - if (prevURL !== window.location.pathname) { - prevURL = window.location.pathname; - timestamp = Date.now(); - } - if (window.location.pathname === "/") details = "Browsing Home Page"; - else if (window.location.pathname === "/portal/learning") - details = "Netacad Portal"; - else if (window.location.pathname.startsWith("/course/")) { - details = "Viewing course"; - state = document.querySelectorAll("h3")[0].textContent; - } else if (window.location.pathname.startsWith("/grade/report/")) { - details = "Viewing grades"; - state = document.querySelectorAll("h3")[0].textContent; - } else if (window.location.pathname.startsWith("/local/mail/")) - details = "Viewing messages"; - else if (window.location.pathname.startsWith("/calendar/")) { - details = "Viewing calendar"; - state = document.querySelectorAll("h3")[0].textContent; - } else if (window.location.pathname.startsWith("/mod/")) { - if ( - document - .querySelectorAll("h2")[0] - .textContent.toUpperCase() - .includes("EXAM") - ) - details = "Viewing exam"; - else details = "Viewing course content"; +let prevURL = '' +let timestamp = Date.now() +let details = '' +let state: string | null = null +presence.on('UpdateData', async () => { + if (prevURL !== window.location.pathname) { + prevURL = window.location.pathname + timestamp = Date.now() + } + if (window.location.pathname === '/') { + details = 'Browsing Home Page' + } + else if (window.location.pathname === '/portal/learning') { + details = 'Netacad Portal' + } + else if (window.location.pathname.startsWith('/course/')) { + details = 'Viewing course' + state = document.querySelectorAll('h3')[0].textContent + } + else if (window.location.pathname.startsWith('/grade/report/')) { + details = 'Viewing grades' + state = document.querySelectorAll('h3')[0].textContent + } + else if (window.location.pathname.startsWith('/local/mail/')) { + details = 'Viewing messages' + } + else if (window.location.pathname.startsWith('/calendar/')) { + details = 'Viewing calendar' + state = document.querySelectorAll('h3')[0].textContent + } + else if (window.location.pathname.startsWith('/mod/')) { + if ( + document + .querySelectorAll('h2')[0] + ?.textContent + ?.toUpperCase() + .includes('EXAM') + ) { + details = 'Viewing exam' + } + else { + details = 'Viewing course content' + } - state = document.querySelectorAll("h3")[0].textContent; - } else if (window.location.pathname.startsWith("/srwe-dl/")) { - details = "Viewing course content"; - state = document.querySelectorAll("h1")[0].textContent; - } else if (window.location.pathname.includes("assessment_history")) - details = "Viewing Assesment History"; - else details = "Browsing"; + state = document.querySelectorAll('h3')[0].textContent + } + else if (window.location.pathname.startsWith('/srwe-dl/')) { + details = 'Viewing course content' + state = document.querySelectorAll('h1')[0].textContent + } + else if (window.location.pathname.includes('assessment_history')) { + details = 'Viewing Assesment History' + } + else { + details = 'Browsing' + } - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Cisco%20Networking%20Academy/assets/logo.png", - details, - state, - startTimestamp: timestamp, - }; - if (!state) delete presenceData.state; + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Cisco%20Networking%20Academy/assets/logo.png', + details, + state, + startTimestamp: timestamp, + } + if (!state) + delete presenceData.state - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/Claude/Claude.json b/websites/C/Claude/Claude.json index ac8959d74d43..5f0472a3bcb2 100644 --- a/websites/C/Claude/Claude.json +++ b/websites/C/Claude/Claude.json @@ -1,22 +1,22 @@ { - "claude.talkingWithAI": { - "description": "Displayed when the user is engaging in a conversation with the AI.", - "message": "Talking with AI about something" - }, - "claude.aiResponding": { - "description": "Displayed when the AI is generating a response.", - "message": "AI is responding..." - }, - "claude.conversationStats": { - "description": "Displayed to show the number of times the user asked a question and total words used, e.g., 'asked (3) times | (150) words'.", - "message": "asked ({0}) times | ({1}) words" - }, - "claude.startNewConversation": { - "description": "Button text to start a new conversation.", - "message": "Start new conversation" - }, - "claude.thinkingOfPrompt": { - "description": "Displayed when the AI is thinking of a new prompt.", - "message": "Thinking of a new prompt..." - } + "claude.talkingWithAI": { + "description": "Displayed when the user is engaging in a conversation with the AI.", + "message": "Talking with AI about something" + }, + "claude.aiResponding": { + "description": "Displayed when the AI is generating a response.", + "message": "AI is responding..." + }, + "claude.conversationStats": { + "description": "Displayed to show the number of times the user asked a question and total words used, e.g., 'asked (3) times | (150) words'.", + "message": "asked ({0}) times | ({1}) words" + }, + "claude.startNewConversation": { + "description": "Button text to start a new conversation.", + "message": "Start new conversation" + }, + "claude.thinkingOfPrompt": { + "description": "Displayed when the AI is thinking of a new prompt.", + "message": "Thinking of a new prompt..." + } } diff --git a/websites/C/Claude/metadata.json b/websites/C/Claude/metadata.json index 3f381c89118a..97e625a2b00a 100644 --- a/websites/C/Claude/metadata.json +++ b/websites/C/Claude/metadata.json @@ -1,39 +1,39 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "1180088441459978261", - "name": "KohnoseLami" - }, - "contributors": [], - "service": "Claude", - "description": { - "en": "Claude is a family of large language models developed by Anthropic. The first model was released in March 2023.\n\nThe Claude 3 family, released in March 2024, consists of three models: Haiku optimized for speed, Sonnet balancing capabilities and performance, and Opus designed for complex reasoning tasks. These models can process both text and images, with Claude 3 Opus demonstrating enhanced capabilities in areas like mathematics, programming, and logical reasoning compared to previous versions.", - "ja_JP": "Claude(クロード)とは、Anthropic社が開発した大規模言語モデルを用いた対話型生成AIである。2023年3月14日に一般公開され、以降複数のバージョンがリリースされている。\n\n2024年3月に公開されたClaude 3 OpusはメンサのIQテストでIQスコア101を記録した。「フレンドリーで熱心な同僚」をコンセプトの一つとしている。" - }, - "url": "claude.ai", - "version": "1.0.1", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/thumbnail.jpeg", - "color": "#DA7756", - "category": "other", - "tags": [ - "ai", - "language", - "human-like", - "conversations", - "multi-purpose" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "showTitle", - "title": "Show chat title", - "icon": "fa-solid fa-message-quote", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "1180088441459978261", + "name": "KohnoseLami" + }, + "contributors": [], + "service": "Claude", + "description": { + "en": "Claude is a family of large language models developed by Anthropic. The first model was released in March 2023.\n\nThe Claude 3 family, released in March 2024, consists of three models: Haiku optimized for speed, Sonnet balancing capabilities and performance, and Opus designed for complex reasoning tasks. These models can process both text and images, with Claude 3 Opus demonstrating enhanced capabilities in areas like mathematics, programming, and logical reasoning compared to previous versions.", + "ja_JP": "Claude(クロード)とは、Anthropic社が開発した大規模言語モデルを用いた対話型生成AIである。2023年3月14日に一般公開され、以降複数のバージョンがリリースされている。\n\n2024年3月に公開されたClaude 3 OpusはメンサのIQテストでIQスコア101を記録した。「フレンドリーで熱心な同僚」をコンセプトの一つとしている。" + }, + "url": "claude.ai", + "version": "1.0.1", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/thumbnail.jpeg", + "color": "#DA7756", + "category": "other", + "tags": [ + "ai", + "language", + "human-like", + "conversations", + "multi-purpose" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "showTitle", + "title": "Show chat title", + "icon": "fa-solid fa-message-quote", + "value": true + } + ] +} diff --git a/websites/C/Claude/presence.ts b/websites/C/Claude/presence.ts index 5a7e7c51aefa..922b9039ff27 100644 --- a/websites/C/Claude/presence.ts +++ b/websites/C/Claude/presence.ts @@ -1,90 +1,94 @@ -import { franc } from "franc-min"; +import { franc } from 'franc-min' const presence = new Presence({ - clientId: "1326893434073776181", - }), - getStrings = async () => { - return presence.getStrings( - { - talkingWithAI: "claude.talkingWithAI", - aiResponding: "claude.aiResponding", - conversationStats: "claude.conversationStats", - startNewConversation: "claude.startNewConversation", - thinkingOfPrompt: "claude.thinkingOfPrompt", - }, - await presence.getSetting("lang").catch(() => "en") - ); - }, - browsingTimestamp = Math.floor(Date.now() / 1000); -let oldLang: string = null, - strings: Awaited>; + clientId: '1326893434073776181', +}) +async function getStrings() { + return presence.getStrings( + { + talkingWithAI: 'claude.talkingWithAI', + aiResponding: 'claude.aiResponding', + conversationStats: 'claude.conversationStats', + startNewConversation: 'claude.startNewConversation', + thinkingOfPrompt: 'claude.thinkingOfPrompt', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) +} +const browsingTimestamp = Math.floor(Date.now() / 1000) +let oldLang: string | null = null +let strings: Awaited> const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/logo.png", - Talking = "https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/0.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/logo.png', + Talking = 'https://cdn.rcd.gg/PreMiD/websites/C/Claude/assets/0.png', } -presence.on("UpdateData", async () => { - const [lang, showTitle] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("showTitle"), - ]); +presence.on('UpdateData', async () => { + const [lang, showTitle] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('showTitle'), + ]) - if (oldLang !== lang) { - oldLang = lang; - strings = await getStrings(); - } + if (oldLang !== lang) { + oldLang = lang + strings = await getStrings() + } - const { pathname } = document.location, - presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - messageElements = Array.from( - document.querySelectorAll( - 'div[class*="font-user-message"],div[class*="font-claude-message"]' - ) - ), - isTalking = - messageElements - .at(-1) - ?.parentElement.getAttribute("data-is-streaming") === "true"; + const { pathname } = document.location + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const messageElements = Array.from( + document.querySelectorAll( + 'div[class*="font-user-message"],div[class*="font-claude-message"]', + ), + ) + const isTalking = messageElements + .at(-1) + ?.parentElement + ?.getAttribute('data-is-streaming') === 'true' - let wordCount = 0; - for (const element of messageElements) { - const text = element.textContent - .replace(/(, )|(,\n)|(,)|([.] )|([.])/gm, " ") - .replace(/([0-9]*)|(\/)|(')|(,)|( )/gm, ""); - wordCount += Array.from( - new Intl.Segmenter(franc(text), { granularity: "word" }).segment(text) - ).length; - } + let wordCount = 0 + for (const element of messageElements) { + const text = element.textContent + ?.replace(/(, )|(,\n)|(,)|(\. )|(\.)/g, ' ') + // eslint-disable-next-line regexp/no-dupe-disjunctions + ?.replace(/(\d*)|(\/)|(')|(,)|( )/g, '') + wordCount += Array.from( + new Intl.Segmenter(franc(text), { granularity: 'word' }).segment(text!), + ).length + } - if (pathname.split("/")[1] === "chat") { - // check if the document title is the default title. If so, get the chat title from the UI. Otherwise, get it from the document title - if (document.title === "Claude" && showTitle) { - presenceData.details = document.querySelector( - `a[href="/chat/${pathname.split("/")[2]}"]` - )?.textContent; - } else - presenceData.details = showTitle ? document.title : strings.talkingWithAI; - presenceData.state = isTalking - ? strings.aiResponding - : strings.conversationStats - .replace( - "{0}", - `${ - messageElements.filter(e => - e.classList.contains("font-user-message") - ).length - }` - ) - .replace("{1}", `${wordCount}`); - presenceData.smallImageKey = isTalking ? Assets.Talking : null; - } else { - presenceData.details = strings.startNewConversation; - presenceData.state = strings.thinkingOfPrompt; - } + if (pathname.split('/')[1] === 'chat') { + // check if the document title is the default title. If so, get the chat title from the UI. Otherwise, get it from the document title + if (document.title === 'Claude' && showTitle) { + presenceData.details = document.querySelector( + `a[href="/chat/${pathname.split('/')[2]}"]`, + )?.textContent + } + else { + presenceData.details = showTitle ? document.title : strings.talkingWithAI + } + presenceData.state = isTalking + ? strings.aiResponding + : strings.conversationStats + .replace( + '{0}', + `${ + messageElements.filter(e => + e.classList.contains('font-user-message'), + ).length + }`, + ) + .replace('{1}', `${wordCount}`) + presenceData.smallImageKey = isTalking ? Assets.Talking : null + } + else { + presenceData.details = strings.startNewConversation + presenceData.state = strings.thinkingOfPrompt + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/Click Jogos/metadata.json b/websites/C/Click Jogos/metadata.json index 6780db526a90..29d23aa3fdab 100644 --- a/websites/C/Click Jogos/metadata.json +++ b/websites/C/Click Jogos/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "fror", - "id": "515668127829458945" - }, - "service": "Click Jogos", - "description": { - "en": "Founded in 2004, Click Jogos is now the largest online gaming portal in Brazil. All titles are free and do not require registration. Our goal is to provide an incredible entertainment experience.", - "pt_BR": "Fundado em 2004, o Click Jogos é hoje o maior portal de jogos online do Brasil. Todos os títulos são gratuitos e não exigem cadastro. Nosso objetivo é proporcionar uma experiência incrível em entretenimento.", - "nl": "Click Jogos, opgericht in 2004, is nu het grootste online gamingportaal in Brazilië. Alle titels zijn gratis en vereisen geen registratie. Ons doel is om een ongelooflijke entertainmentervaring te bieden.", - "vi_VN": "Thành lập năm 2004, Click Jogos là cổng game lớn nhất Brazil. Tất cả các trò chơi đều miễn phí và không cần đăng nhập. Mục tiêu của chúng tôi là cung cấp trải nghiệm giải trí tuyệt vời." - }, - "url": "www.clickjogos.com.br", - "version": "1.1.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Click%20Jogos/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Click%20Jogos/assets/thumbnail.png", - "color": "#FF9902", - "category": "games", - "tags": [ - "games", - "flash", - "brazil", - "entertainment", - "fun" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "fror", + "id": "515668127829458945" + }, + "service": "Click Jogos", + "description": { + "en": "Founded in 2004, Click Jogos is now the largest online gaming portal in Brazil. All titles are free and do not require registration. Our goal is to provide an incredible entertainment experience.", + "pt_BR": "Fundado em 2004, o Click Jogos é hoje o maior portal de jogos online do Brasil. Todos os títulos são gratuitos e não exigem cadastro. Nosso objetivo é proporcionar uma experiência incrível em entretenimento.", + "nl": "Click Jogos, opgericht in 2004, is nu het grootste online gamingportaal in Brazilië. Alle titels zijn gratis en vereisen geen registratie. Ons doel is om een ongelooflijke entertainmentervaring te bieden.", + "vi_VN": "Thành lập năm 2004, Click Jogos là cổng game lớn nhất Brazil. Tất cả các trò chơi đều miễn phí và không cần đăng nhập. Mục tiêu của chúng tôi là cung cấp trải nghiệm giải trí tuyệt vời." + }, + "url": "www.clickjogos.com.br", + "version": "1.1.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Click%20Jogos/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Click%20Jogos/assets/thumbnail.png", + "color": "#FF9902", + "category": "games", + "tags": [ + "games", + "flash", + "brazil", + "entertainment", + "fun" + ] +} diff --git a/websites/C/Click Jogos/presence.ts b/websites/C/Click Jogos/presence.ts index 53653bd3279d..0c885435f6a7 100644 --- a/websites/C/Click Jogos/presence.ts +++ b/websites/C/Click Jogos/presence.ts @@ -1,46 +1,49 @@ const presence = new Presence({ - clientId: "692436770775760927", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - search: "general.searching", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '692436770775760927', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', + search: 'general.searching', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Click%20Jogos/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Click%20Jogos/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (document.location.pathname === "/") - presenceData.details = "Página Inicial"; - else if (document.location.pathname.includes("/categorias")) - presenceData.details = "Categorias"; - else if (document.location.pathname.includes("/busca/")) { - presenceData.details = "Pesquisando por:"; - presenceData.state = document.querySelector("input").value; - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = (await strings).search; - } else if (document.location.pathname.includes("/jogos/")) { - if ( - document.querySelector( - "#game_src > div.fullscreen-header > div:nth-child(1) > div > div > div:nth-child(2) > a > h1" - ) - ) { - presenceData.details = "Jogando:"; - presenceData.state = document.querySelector( - "#game_src > div.fullscreen-header > div:nth-child(1) > div > div > div:nth-child(2) > a > h1" - ).textContent; - } else { - presenceData.details = "Jogando:"; - presenceData.state = - document.querySelectorAll(".game-header-title")[0].textContent; - } - } + if (document.location.pathname === '/') { + presenceData.details = 'Página Inicial' + } + else if (document.location.pathname.includes('/categorias')) { + presenceData.details = 'Categorias' + } + else if (document.location.pathname.includes('/busca/')) { + presenceData.details = 'Pesquisando por:' + presenceData.state = document.querySelector('input')?.value + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = (await strings).search + } + else if (document.location.pathname.includes('/jogos/')) { + if ( + document.querySelector( + '#game_src > div.fullscreen-header > div:nth-child(1) > div > div > div:nth-child(2) > a > h1', + ) + ) { + presenceData.details = 'Jogando:' + presenceData.state = document.querySelector( + '#game_src > div.fullscreen-header > div:nth-child(1) > div > div > div:nth-child(2) > a > h1', + )?.textContent + } + else { + presenceData.details = 'Jogando:' + presenceData.state = document.querySelectorAll('.game-header-title')[0].textContent + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/CliffsNotes/metadata.json b/websites/C/CliffsNotes/metadata.json index 60cf4e32d239..d348bb25ae91 100644 --- a/websites/C/CliffsNotes/metadata.json +++ b/websites/C/CliffsNotes/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Gurrman375D", - "id": "446528923535278082" - }, - "service": "CliffsNotes", - "description": { - "en": "CliffsNotes study guides are written by real teachers and professors, so no matter what you're studying, CliffsNotes can ease your homework headaches and help you score high on exams.", - "nl": "CliffsNotes-studiegidsen zijn geschreven door echte leraren en professoren, dus wat je ook studeert, CliffsNotes kan je huiswerkhoofdpijn verlichten en je helpen hoog te scoren op examens.", - "vi_VN": "CliffsNotes cung cấp hướng dẫn được viết bởi các giáo viên và giáo sư thật, nên không kể bạn đang học gì, CliffsNotes có thể giúp bạn nhẹ đi các cơn đau đầu khi làm bài tập và giúp bạn đạt điểm cao trong các bài kiểm tra." - }, - "url": "www.cliffsnotes.com", - "version": "1.0.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CliffsNotes/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CliffsNotes/assets/thumbnail.png", - "color": "#FFE500", - "category": "other", - "tags": [ - "cliffsnotes", - "study", - "help" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Gurrman375D", + "id": "446528923535278082" + }, + "service": "CliffsNotes", + "description": { + "en": "CliffsNotes study guides are written by real teachers and professors, so no matter what you're studying, CliffsNotes can ease your homework headaches and help you score high on exams.", + "nl": "CliffsNotes-studiegidsen zijn geschreven door echte leraren en professoren, dus wat je ook studeert, CliffsNotes kan je huiswerkhoofdpijn verlichten en je helpen hoog te scoren op examens.", + "vi_VN": "CliffsNotes cung cấp hướng dẫn được viết bởi các giáo viên và giáo sư thật, nên không kể bạn đang học gì, CliffsNotes có thể giúp bạn nhẹ đi các cơn đau đầu khi làm bài tập và giúp bạn đạt điểm cao trong các bài kiểm tra." + }, + "url": "www.cliffsnotes.com", + "version": "1.0.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CliffsNotes/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CliffsNotes/assets/thumbnail.png", + "color": "#FFE500", + "category": "other", + "tags": [ + "cliffsnotes", + "study", + "help" + ] +} diff --git a/websites/C/CliffsNotes/presence.ts b/websites/C/CliffsNotes/presence.ts index 5718d8419553..b5013bc51e09 100644 --- a/websites/C/CliffsNotes/presence.ts +++ b/websites/C/CliffsNotes/presence.ts @@ -1,110 +1,137 @@ const presence = new Presence({ - clientId: "715667985267949649", -}); + clientId: '715667985267949649', +}) -let title, subTitle, chapter, quiz, search; -const browsingTimestamp = Math.floor(Date.now() / 1000), - path = document.location.pathname; -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CliffsNotes/assets/logo.png", - startTimestamp: browsingTimestamp, - }; - if (path === "/") presenceData.details = "Viewing Home"; - else if (path.includes("/literature/")) { - title = document.querySelector( - "#mainTag > section > div:nth-child(1) > div.small-12.medium-9.columns > div.title-wrapper > h1" - ) as HTMLTextAreaElement; - subTitle = document.querySelector( - "#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > article > h2 > span:nth-child(2)" - ) as HTMLTextAreaElement; - chapter = document.querySelector( - "#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > article > h2" - ) as HTMLTextAreaElement; - quiz = document.querySelector("#headerid"); - if (title && chapter) { - presenceData.details = title.textContent; - presenceData.state = chapter.textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - } else if (title && subTitle) { - presenceData.details = title.textContent; - presenceData.state = subTitle.textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - } else if (quiz) presenceData.details = "Taking a Quiz"; - else { - title = document.querySelector( - "#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > div > div > div > div.small-12.medium-12.columns.clear-padding > article > h2" - ) as HTMLTextAreaElement; - if (title) presenceData.details = title.textContent; - } - } else if (path.includes("/test-prep")) { - title = document.querySelector( - "#mainTag > section > div:nth-child(1) > div.small-12.medium-9.columns > div.title-wrapper > h1" - ) as HTMLTextAreaElement; - subTitle = document.querySelector( - "#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > article > h2 > span:nth-child(2)" - ) as HTMLTextAreaElement; - chapter = document.querySelector( - "#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > article > h2" - ) as HTMLTextAreaElement; - quiz = document.querySelector("#headerid"); - if (title && chapter) { - presenceData.details = title.textContent; - presenceData.state = chapter.textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - } else if (title && subTitle) { - presenceData.details = title.textContent; - presenceData.state = subTitle.textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - } else if (quiz) presenceData.details = "Taking a Quiz"; - else presenceData.details = "Viewing Test Prep"; - } else if (path.includes("/study-guides/")) { - title = document.querySelector( - "#phsubheader_0_headerTitle" - ) as HTMLTextAreaElement; - subTitle = document.querySelector( - "#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > div > div > h2" - ) as HTMLTextAreaElement; - chapter = document.querySelector( - "#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > article > h2" - ) as HTMLTextAreaElement; - quiz = document.querySelector("#headerid"); - if (title && chapter) { - presenceData.details = title.textContent; - presenceData.state = chapter.textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - } else if (title && subTitle) { - presenceData.details = title.textContent; - presenceData.state = subTitle.textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - } else if (quiz) presenceData.details = "Taking a Quiz"; - else presenceData.details = "Viewing Study Guides"; - } else if (path.includes("/search")) { - search = document.querySelector( - "#phsection1_1_phmiddlesection_0_searchResults > div > h3 > span" - ) as HTMLTextAreaElement; - if (search) { - presenceData.details = "Searching:"; - presenceData.state = search.textContent; - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Searching"; - } - } else if (path.includes("/discover-")) { - title = document.querySelector( - "#mainTag > section > div:nth-child(1) > div > div > h1" - ) as HTMLTextAreaElement; - presenceData.details = `Viewing ${title.textContent}`; - } else if (path === "/disclaimer") - presenceData.details = "Viewing Disclaimer"; - else presenceData.details = "Viewing a Special Page"; +let title, subTitle, chapter, quiz, search +const browsingTimestamp = Math.floor(Date.now() / 1000) +const path = document.location.pathname +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CliffsNotes/assets/logo.png', + startTimestamp: browsingTimestamp, + } + if (path === '/') { + presenceData.details = 'Viewing Home' + } + else if (path.includes('/literature/')) { + title = document.querySelector( + '#mainTag > section > div:nth-child(1) > div.small-12.medium-9.columns > div.title-wrapper > h1', + ) as HTMLTextAreaElement + subTitle = document.querySelector( + '#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > article > h2 > span:nth-child(2)', + ) as HTMLTextAreaElement + chapter = document.querySelector( + '#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > article > h2', + ) as HTMLTextAreaElement + quiz = document.querySelector('#headerid') + if (title && chapter) { + presenceData.details = title.textContent + presenceData.state = chapter.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + } + else if (title && subTitle) { + presenceData.details = title.textContent + presenceData.state = subTitle.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + } + else if (quiz) { + presenceData.details = 'Taking a Quiz' + } + else { + title = document.querySelector( + '#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > div > div > div > div.small-12.medium-12.columns.clear-padding > article > h2', + ) as HTMLTextAreaElement + if (title) + presenceData.details = title.textContent + } + } + else if (path.includes('/test-prep')) { + title = document.querySelector( + '#mainTag > section > div:nth-child(1) > div.small-12.medium-9.columns > div.title-wrapper > h1', + ) as HTMLTextAreaElement + subTitle = document.querySelector( + '#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > article > h2 > span:nth-child(2)', + ) as HTMLTextAreaElement + chapter = document.querySelector( + '#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > article > h2', + ) as HTMLTextAreaElement + quiz = document.querySelector('#headerid') + if (title && chapter) { + presenceData.details = title.textContent + presenceData.state = chapter.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + } + else if (title && subTitle) { + presenceData.details = title.textContent + presenceData.state = subTitle.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + } + else if (quiz) { + presenceData.details = 'Taking a Quiz' + } + else { + presenceData.details = 'Viewing Test Prep' + } + } + else if (path.includes('/study-guides/')) { + title = document.querySelector( + '#phsubheader_0_headerTitle', + ) as HTMLTextAreaElement + subTitle = document.querySelector( + '#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > div > div > h2', + ) as HTMLTextAreaElement + chapter = document.querySelector( + '#mainTag > div.row.background-white > div.small-12.medium-9.columns.left-rail-column.clear-padding-for-small-only > div > div.small-12.medium-9.columns > article > h2', + ) as HTMLTextAreaElement + quiz = document.querySelector('#headerid') + if (title && chapter) { + presenceData.details = title.textContent + presenceData.state = chapter.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + } + else if (title && subTitle) { + presenceData.details = title.textContent + presenceData.state = subTitle.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + } + else if (quiz) { + presenceData.details = 'Taking a Quiz' + } + else { + presenceData.details = 'Viewing Study Guides' + } + } + else if (path.includes('/search')) { + search = document.querySelector( + '#phsection1_1_phmiddlesection_0_searchResults > div > h3 > span', + ) as HTMLTextAreaElement + if (search) { + presenceData.details = 'Searching:' + presenceData.state = search.textContent + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Searching' + } + } + else if (path.includes('/discover-')) { + title = document.querySelector( + '#mainTag > section > div:nth-child(1) > div > div > h1', + ) as HTMLTextAreaElement + presenceData.details = `Viewing ${title.textContent}` + } + else if (path === '/disclaimer') { + presenceData.details = 'Viewing Disclaimer' + } + else { + presenceData.details = 'Viewing a Special Page' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/CloudConvert/metadata.json b/websites/C/CloudConvert/metadata.json index dd8f14dda89d..7080fefabbe5 100644 --- a/websites/C/CloudConvert/metadata.json +++ b/websites/C/CloudConvert/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "CloudConvert", - "description": { - "en": "CloudConvert is an online file converter. We support nearly all audio, video, document, ebook, archive, image, spreadsheet, and presentation formats. " - }, - "url": [ - "www.cloudconvert.com", - "cloudconvert.com" - ], - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CloudConvert/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CloudConvert/assets/thumbnail.png", - "color": "#b53836", - "category": "other", - "tags": [ - "convert", - "file", - "online" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "CloudConvert", + "description": { + "en": "CloudConvert is an online file converter. We support nearly all audio, video, document, ebook, archive, image, spreadsheet, and presentation formats. " + }, + "url": [ + "www.cloudconvert.com", + "cloudconvert.com" + ], + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CloudConvert/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CloudConvert/assets/thumbnail.png", + "color": "#b53836", + "category": "other", + "tags": [ + "convert", + "file", + "online" + ] +} diff --git a/websites/C/CloudConvert/presence.ts b/websites/C/CloudConvert/presence.ts index a8d07433c543..036eb212fdfd 100644 --- a/websites/C/CloudConvert/presence.ts +++ b/websites/C/CloudConvert/presence.ts @@ -1,84 +1,84 @@ const presence = new Presence({ - clientId: "1029595348844429382", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1029595348844429382', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CloudConvert/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - mainPath = window.location.pathname.split("/")[1] ?? ""; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CloudConvert/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const mainPath = window.location.pathname.split('/')[1] ?? '' - switch (mainPath) { - case "register": - case "login": { - presenceData.details = "Logging in"; - break; - } - case "create-zip-archive": { - presenceData.details = "Creating zip archives"; - break; - } - case "extract-zip-archive": { - presenceData.details = "Extracting zip archives"; - break; - } - case "merge-pdf": { - presenceData.details = "Merging files into a PDF"; - break; - } - case "apis": { - presenceData.details = "Viewing an API's about page"; - presenceData.state = document.querySelector("h1").textContent; - break; - } - case "api": { - presenceData.details = "Browsing the API documentation"; - presenceData.state = document.querySelector( - ".content-header-title" - ).textContent; - break; - } - case "dashboard": { - presenceData.details = "Viewing dashboard"; - presenceData.state = - document.querySelector(".active").textContent; - break; - } - case "settings": { - presenceData.details = "Managing account settings"; - break; - } - default: { - if ( - mainPath === "" || - mainPath.endsWith("-converter") || - /-to-/.test(mainPath) - ) { - presenceData.details = "Converting files"; - presenceData.state = [ - ...document.querySelectorAll("h2 button"), - ] - .map(button => button.textContent) - .join(" to "); - } else if ( - mainPath === "save-website-pdf" || - /^website-[a-z]+-screenshot$/.test(mainPath) - ) { - presenceData.details = "Creating website screenshots"; - presenceData.state = document.querySelector( - "[aria-describedby='button-add-url']" - ).value; - } else { - presenceData.details = "Browsing"; - presenceData.state = document.title.match( - /^(.*?)( \| CloudConvert)?$/ - )[1]; - } - } - } + switch (mainPath) { + case 'register': + case 'login': { + presenceData.details = 'Logging in' + break + } + case 'create-zip-archive': { + presenceData.details = 'Creating zip archives' + break + } + case 'extract-zip-archive': { + presenceData.details = 'Extracting zip archives' + break + } + case 'merge-pdf': { + presenceData.details = 'Merging files into a PDF' + break + } + case 'apis': { + presenceData.details = 'Viewing an API\'s about page' + presenceData.state = document.querySelector('h1')?.textContent + break + } + case 'api': { + presenceData.details = 'Browsing the API documentation' + presenceData.state = document.querySelector( + '.content-header-title', + )?.textContent + break + } + case 'dashboard': { + presenceData.details = 'Viewing dashboard' + presenceData.state = document.querySelector('.active')?.textContent + break + } + case 'settings': { + presenceData.details = 'Managing account settings' + break + } + default: { + if ( + mainPath === '' + || mainPath.endsWith('-converter') + || /-to-/.test(mainPath) + ) { + presenceData.details = 'Converting files' + presenceData.state = [ + ...document.querySelectorAll('h2 button'), + ] + .map(button => button.textContent) + .join(' to ') + } + else if ( + mainPath === 'save-website-pdf' + || /^website-[a-z]+-screenshot$/.test(mainPath) + ) { + presenceData.details = 'Creating website screenshots' + presenceData.state = document.querySelector( + '[aria-describedby=\'button-add-url\']', + )?.value + } + else { + presenceData.details = 'Browsing' + presenceData.state = document.title.match( + /^(.*?)( \| CloudConvert)?$/, + )?.[1] + } + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/Club Penguin Journey/metadata.json b/websites/C/Club Penguin Journey/metadata.json index 7d17dc577fcb..b8736c7f7b36 100644 --- a/websites/C/Club Penguin Journey/metadata.json +++ b/websites/C/Club Penguin Journey/metadata.json @@ -1,33 +1,33 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "529707020937461760", - "name": "creeper78" - }, - "service": "Club Penguin Journey", - "altnames": [ - "CPJourney" - ], - "description": { - "en": "Club Penguin Journey is a free-to-play, fan-made recreation of the original Club Penguin. Waddle around and meet new friends on a snowy virtual world!" - }, - "url": [ - "www.cpjourney.net", - "cpjourney.net", - "play.cpjourney.net" - ], - "version": "1.0.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Club%20Penguin%20Journey/assets/logo.jpeg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Club%20Penguin%20Journey/assets/thumbnail.png", - "color": "#28a5fa", - "category": "games", - "tags": [ - "penguin", - "club-penguin", - "club-penguin-journey", - "cpjourney", - "cpj", - "cp-journey" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "529707020937461760", + "name": "creeper78" + }, + "service": "Club Penguin Journey", + "altnames": [ + "CPJourney" + ], + "description": { + "en": "Club Penguin Journey is a free-to-play, fan-made recreation of the original Club Penguin. Waddle around and meet new friends on a snowy virtual world!" + }, + "url": [ + "www.cpjourney.net", + "cpjourney.net", + "play.cpjourney.net" + ], + "version": "1.0.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Club%20Penguin%20Journey/assets/logo.jpeg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Club%20Penguin%20Journey/assets/thumbnail.png", + "color": "#28a5fa", + "category": "games", + "tags": [ + "penguin", + "club-penguin", + "club-penguin-journey", + "cpjourney", + "cpj", + "cp-journey" + ] +} diff --git a/websites/C/Club Penguin Journey/presence.ts b/websites/C/Club Penguin Journey/presence.ts index b0685981f916..a3270c1b0316 100644 --- a/websites/C/Club Penguin Journey/presence.ts +++ b/websites/C/Club Penguin Journey/presence.ts @@ -1,40 +1,43 @@ const presence = new Presence({ - clientId: "1312233249438961665", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1312233249438961665', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Club%20Penguin%20Journey/assets/logo.jpeg", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Club%20Penguin%20Journey/assets/logo.jpeg', + startTimestamp: browsingTimestamp, + } - switch (document.location.hostname) { - case "cpjourney.net": { - if (document.location.pathname === "/") { - presenceData.details = "Waddling around"; - presenceData.state = "Viewing Home"; - } else if (document.location.pathname.startsWith("/news/")) { - presenceData.details = "Reading post:"; - presenceData.state = document.querySelector( - "[class*=post_title]" - ).textContent; - } else if (document.location.pathname.startsWith("/news")) { - presenceData.details = "Waddling around"; - presenceData.state = "Scrolling through the news"; - } else presenceData.details = "Waddling around"; - break; - } - case "play.cpjourney.net": - { - if (document.location.pathname === "/") { - presenceData.details = "Waddling around"; - presenceData.state = "Playing Club Penguin Journey"; - } - } - break; - } + switch (document.location.hostname) { + case 'cpjourney.net': { + if (document.location.pathname === '/') { + presenceData.details = 'Waddling around' + presenceData.state = 'Viewing Home' + } + else if (document.location.pathname.startsWith('/news/')) { + presenceData.details = 'Reading post:' + presenceData.state = document.querySelector( + '[class*=post_title]', + )?.textContent + } + else if (document.location.pathname.startsWith('/news')) { + presenceData.details = 'Waddling around' + presenceData.state = 'Scrolling through the news' + } + else { + presenceData.details = 'Waddling around' + } + break + } + case 'play.cpjourney.net': { + if (document.location.pathname === '/') { + presenceData.details = 'Waddling around' + presenceData.state = 'Playing Club Penguin Journey' + } + break + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/CodAre/metadata.json b/websites/C/CodAre/metadata.json index beb650c2afcf..aec25c4f584b 100644 --- a/websites/C/CodAre/metadata.json +++ b/websites/C/CodAre/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "BBQ", - "id": "298888568279924746" - }, - "service": "CodAre", - "description": { - "tr": "CodAre discord botları ve daha fazlası için basit bir kod paylaşım platformudur.", - "en": "CodAre is a simple code sharing platform for discord bots and more.", - "nl": "CodAre is een eenvoudig platform voor het delen van codes voor discord bots en meer.", - "vi_VN": "CodAre là nền tảng chia sẻ mã đơn giản dành cho Discord bot và hơn nữa." - }, - "url": "codare.fun", - "version": "1.0.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CodAre/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CodAre/assets/thumbnail.png", - "color": "#3b1b8a", - "category": "other", - "tags": [ - "discord", - "coding", - "development", - "turkish" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "BBQ", + "id": "298888568279924746" + }, + "service": "CodAre", + "description": { + "tr": "CodAre discord botları ve daha fazlası için basit bir kod paylaşım platformudur.", + "en": "CodAre is a simple code sharing platform for discord bots and more.", + "nl": "CodAre is een eenvoudig platform voor het delen van codes voor discord bots en meer.", + "vi_VN": "CodAre là nền tảng chia sẻ mã đơn giản dành cho Discord bot và hơn nữa." + }, + "url": "codare.fun", + "version": "1.0.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CodAre/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CodAre/assets/thumbnail.png", + "color": "#3b1b8a", + "category": "other", + "tags": [ + "discord", + "coding", + "development", + "turkish" + ] +} diff --git a/websites/C/CodAre/presence.ts b/websites/C/CodAre/presence.ts index 8dcfc29ec627..aec021323fc9 100644 --- a/websites/C/CodAre/presence.ts +++ b/websites/C/CodAre/presence.ts @@ -1,99 +1,114 @@ const presence = new Presence({ - clientId: "737633529738952765", -}); + clientId: '737633529738952765', +}) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CodAre/assets/logo.png", - }, - searchURL = new URL(document.location.href), - searchResult = searchURL.searchParams.get("q"), - searchCategory = searchURL.searchParams.get("k"); - if (window.location.pathname.toLowerCase() === "/") { - presenceData.details = "Bir sayfa görüntülüyor:"; - presenceData.state = "Anasayfa"; - } else if (window.location.pathname.toLowerCase() === "/yetkililer") { - presenceData.details = "Bir sayfa görüntülüyor:"; - presenceData.state = "Yetkililer"; - } else if (window.location.pathname.toLowerCase() === "/sss") { - presenceData.details = "Bir sayfa görüntülüyor:"; - presenceData.state = "Sıkça Sorulan Sorular (S.S.S)"; - } else if (window.location.pathname.toLowerCase() === "/v11tov12") { - presenceData.details = "Bir sayfa görüntülüyor:"; - presenceData.state = "v11 To v12"; - } else if (window.location.pathname.toLowerCase().includes("/profil")) { - presenceData.details = "Bir kullanıcı profili görüntülüyor:"; - presenceData.state = - `${ - document.querySelector( - "#page-top > div.container-fluid > div > div.col-lg-4 > div > div > div > a" - ).textContent - } ` + - `(${ - document.querySelector( - "#page-top > div.container-fluid > div > div.col > div > div.card-body > h4:nth-child(4) > span" - ).textContent - })`; - } else if (document.location.pathname.toLowerCase().includes("/arama")) { - presenceData.details = "Bir kod arıyor:"; - if (!searchCategory) { - presenceData.state = - searchResult.charAt(0).toUpperCase() + - searchResult.slice(1).toLocaleString(); - } else { - presenceData.state = - `${searchCategory - .replace("html", "HTML") - .replace("jsplus", "Javascript+") - .replace("diger", "Diğer") - .replace("altyapi", "Altyapı") - .replace("booster", "Booster") - .replace("py", "PYTHON") - .replace("js", "Javascript")} adlı kategoride` + - ` ${searchResult.charAt(0).toUpperCase()}${searchResult - .slice(1) - .toLocaleString()} adlı kodu arıyor`; - } - } else if (window.location.pathname.toLowerCase().includes("/uptime")) { - presenceData.details = "Bir sayfa görüntülüyor:"; - presenceData.state = "Uptime"; - } else if (window.location.pathname.toLowerCase().includes("/kod")) { - presenceData.details = "Bir kod görüntülüyor:"; - presenceData.state = document.querySelector( - "#page-top > div.container-fluid > div > div > div.card.shadow.mb-4 > div.card-header > center > h4" - ).textContent; - } else if (window.location.pathname.toLowerCase() === "/admin/paylas") { - presenceData.details = "Bir admin sayfası görüntülüyor:"; - presenceData.state = "Paylaş"; - } else if (window.location.pathname.toLowerCase() === "/admin/kodlar") { - presenceData.details = "Bir admin sayfası görüntülüyor:"; - presenceData.state = "Kodlar"; - } else if (window.location.pathname.toLowerCase() === "/admin/yorumlar") { - presenceData.details = "Bir admin sayfası görüntülüyor:"; - presenceData.state = "Yorumlar"; - } else if (window.location.pathname.toLowerCase() === "/kategori/js") { - presenceData.details = "Bir kategori görüntülüyor:"; - presenceData.state = "Javascript"; - } else if (window.location.pathname.toLowerCase() === "/kategori/py") { - presenceData.details = "Bir kategori görüntülüyor:"; - presenceData.state = "Python"; - } else if (window.location.pathname.toLowerCase() === "/kategori/html") { - presenceData.details = "Bir kategori görüntülüyor:"; - presenceData.state = "HTML"; - } else if (window.location.pathname.toLowerCase() === "/kategori/diger") { - presenceData.details = "Bir kategori görüntülüyor:"; - presenceData.state = "Diğer"; - } else if (window.location.pathname.toLowerCase() === "/kategori/js+") { - presenceData.details = "Bir kategori görüntülüyor:"; - presenceData.state = "Javascript+"; - } else if (window.location.pathname.toLowerCase() === "/kategori/booster") { - presenceData.details = "Bir kategori görüntülüyor:"; - presenceData.state = "Booster"; - } else if (window.location.pathname.toLowerCase() === "/kategori/altyapi") { - presenceData.details = "Bir kategori görüntülüyor:"; - presenceData.state = "Altyapı"; - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CodAre/assets/logo.png', + } + const searchURL = new URL(document.location.href) + const searchResult = searchURL.searchParams.get('q') + const searchCategory = searchURL.searchParams.get('k') + if (window.location.pathname.toLowerCase() === '/') { + presenceData.details = 'Bir sayfa görüntülüyor:' + presenceData.state = 'Anasayfa' + } + else if (window.location.pathname.toLowerCase() === '/yetkililer') { + presenceData.details = 'Bir sayfa görüntülüyor:' + presenceData.state = 'Yetkililer' + } + else if (window.location.pathname.toLowerCase() === '/sss') { + presenceData.details = 'Bir sayfa görüntülüyor:' + presenceData.state = 'Sıkça Sorulan Sorular (S.S.S)' + } + else if (window.location.pathname.toLowerCase() === '/v11tov12') { + presenceData.details = 'Bir sayfa görüntülüyor:' + presenceData.state = 'v11 To v12' + } + else if (window.location.pathname.toLowerCase().includes('/profil')) { + presenceData.details = 'Bir kullanıcı profili görüntülüyor:' + presenceData.state = `${ + document.querySelector( + '#page-top > div.container-fluid > div > div.col-lg-4 > div > div > div > a', + )?.textContent + } ` + + `(${ + document.querySelector( + '#page-top > div.container-fluid > div > div.col > div > div.card-body > h4:nth-child(4) > span', + )?.textContent + })` + } + else if (document.location.pathname.toLowerCase().includes('/arama')) { + presenceData.details = 'Bir kod arıyor:' + if (!searchCategory) { + presenceData.state = searchResult!.charAt(0).toUpperCase() + + searchResult!.slice(1).toLocaleString() + } + else { + presenceData.state = `${searchCategory + .replace('html', 'HTML') + .replace('jsplus', 'Javascript+') + .replace('diger', 'Diğer') + .replace('altyapi', 'Altyapı') + .replace('booster', 'Booster') + .replace('py', 'PYTHON') + .replace('js', 'Javascript')} adlı kategoride` + + ` ${searchResult!.charAt(0).toUpperCase()}${searchResult! + .slice(1) + .toLocaleString()} adlı kodu arıyor` + } + } + else if (window.location.pathname.toLowerCase().includes('/uptime')) { + presenceData.details = 'Bir sayfa görüntülüyor:' + presenceData.state = 'Uptime' + } + else if (window.location.pathname.toLowerCase().includes('/kod')) { + presenceData.details = 'Bir kod görüntülüyor:' + presenceData.state = document.querySelector( + '#page-top > div.container-fluid > div > div > div.card.shadow.mb-4 > div.card-header > center > h4', + )?.textContent + } + else if (window.location.pathname.toLowerCase() === '/admin/paylas') { + presenceData.details = 'Bir admin sayfası görüntülüyor:' + presenceData.state = 'Paylaş' + } + else if (window.location.pathname.toLowerCase() === '/admin/kodlar') { + presenceData.details = 'Bir admin sayfası görüntülüyor:' + presenceData.state = 'Kodlar' + } + else if (window.location.pathname.toLowerCase() === '/admin/yorumlar') { + presenceData.details = 'Bir admin sayfası görüntülüyor:' + presenceData.state = 'Yorumlar' + } + else if (window.location.pathname.toLowerCase() === '/kategori/js') { + presenceData.details = 'Bir kategori görüntülüyor:' + presenceData.state = 'Javascript' + } + else if (window.location.pathname.toLowerCase() === '/kategori/py') { + presenceData.details = 'Bir kategori görüntülüyor:' + presenceData.state = 'Python' + } + else if (window.location.pathname.toLowerCase() === '/kategori/html') { + presenceData.details = 'Bir kategori görüntülüyor:' + presenceData.state = 'HTML' + } + else if (window.location.pathname.toLowerCase() === '/kategori/diger') { + presenceData.details = 'Bir kategori görüntülüyor:' + presenceData.state = 'Diğer' + } + else if (window.location.pathname.toLowerCase() === '/kategori/js+') { + presenceData.details = 'Bir kategori görüntülüyor:' + presenceData.state = 'Javascript+' + } + else if (window.location.pathname.toLowerCase() === '/kategori/booster') { + presenceData.details = 'Bir kategori görüntülüyor:' + presenceData.state = 'Booster' + } + else if (window.location.pathname.toLowerCase() === '/kategori/altyapi') { + presenceData.details = 'Bir kategori görüntülüyor:' + presenceData.state = 'Altyapı' + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/CodeChef/metadata.json b/websites/C/CodeChef/metadata.json index aad32b22fde3..8a45895f702f 100644 --- a/websites/C/CodeChef/metadata.json +++ b/websites/C/CodeChef/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Palskie", - "id": "90431685472038912" - }, - "service": "CodeChef", - "description": { - "en": "CodeChef is a competitive programming community of programmers from across the globe.", - "vi_VN": "CodeChef là công đồng cạnh tranh của các lập trình viên toàn cầu." - }, - "url": [ - "www.codechef.com", - "blog.codechef.com", - "discuss.codechef.com" - ], - "version": "1.0.20", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CodeChef/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CodeChef/assets/thumbnail.png", - "color": "#e1d5d5", - "category": "other", - "tags": [ - "coding", - "programming", - "educational", - "competition" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Palskie", + "id": "90431685472038912" + }, + "service": "CodeChef", + "description": { + "en": "CodeChef is a competitive programming community of programmers from across the globe.", + "vi_VN": "CodeChef là công đồng cạnh tranh của các lập trình viên toàn cầu." + }, + "url": [ + "www.codechef.com", + "blog.codechef.com", + "discuss.codechef.com" + ], + "version": "1.0.20", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CodeChef/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CodeChef/assets/thumbnail.png", + "color": "#e1d5d5", + "category": "other", + "tags": [ + "coding", + "programming", + "educational", + "competition" + ] +} diff --git a/websites/C/CodeChef/presence.ts b/websites/C/CodeChef/presence.ts index eabbc963bae7..bbf7e4bc011f 100644 --- a/websites/C/CodeChef/presence.ts +++ b/websites/C/CodeChef/presence.ts @@ -1,127 +1,130 @@ const presence = new Presence({ - clientId: "845716323296083999", - }), - timeElapsed: number = ~~(Date.now() / 1000); + clientId: '845716323296083999', +}) +const timeElapsed: number = ~~(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/CodeChef/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeChef/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: timeElapsed, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: timeElapsed, + } - switch (location.host.split(".")[0]) { - case "blog": { - // ? https://blog.codechef.com - presenceData.details = "Viewing Blogs"; - presenceData.smallImageKey = Assets.Reading; - if (location.pathname.split("/")[1] === "all-blogs") - presenceData.details = "Viewing All Blogs"; - else if (location.pathname.split("/")[1] === "author") { - presenceData.details = "Viewing Profile: "; - presenceData.state = `Author: ${location.pathname.split("/")[2]}`; - } else if (location.pathname.split("/")[4]) { - presenceData.details = `Reading: ${ - document.querySelector(".posttitle").textContent - }`; - presenceData.state = `Author: ${ - document.querySelector(".author-username").textContent - }`; - presenceData.smallImageKey = Assets.Reading; - } - break; - } + switch (location.host.split('.')[0]) { + case 'blog': { + // ? https://blog.codechef.com + presenceData.details = 'Viewing Blogs' + presenceData.smallImageKey = Assets.Reading + if (location.pathname.split('/')[1] === 'all-blogs') { + presenceData.details = 'Viewing All Blogs' + } + else if (location.pathname.split('/')[1] === 'author') { + presenceData.details = 'Viewing Profile: ' + presenceData.state = `Author: ${location.pathname.split('/')[2]}` + } + else if (location.pathname.split('/')[4]) { + presenceData.details = `Reading: ${ + document.querySelector('.posttitle')?.textContent + }` + presenceData.state = `Author: ${ + document.querySelector('.author-username')?.textContent + }` + presenceData.smallImageKey = Assets.Reading + } + break + } - case "discuss": { - // ? https://discuss.codechef.com - presenceData.details = "Viewing Discussions"; - if (location.pathname.split("/")[1] === "t") { - presenceData.details = "Reading Discussions:"; - presenceData.state = document.querySelector(".fancy-title").textContent; - presenceData.smallImageKey = Assets.Reading; - } - break; - } + case 'discuss': { + // ? https://discuss.codechef.com + presenceData.details = 'Viewing Discussions' + if (location.pathname.split('/')[1] === 't') { + presenceData.details = 'Reading Discussions:' + presenceData.state = document.querySelector('.fancy-title')?.textContent + presenceData.smallImageKey = Assets.Reading + } + break + } - default: { - if (location.pathname.split("/")[1] === "") - presenceData.details = "Viewing Home Page"; - else if (location.pathname.split("/").includes("tags")) { - presenceData.details = "Viewing:"; - presenceData.state = "Problems By Tag Name"; - } else if (location.pathname.split("/").includes("problems")) { - presenceData.details = - document.querySelector(".breadcrumbs").lastElementChild.textContent; - presenceData.state = `Solving: ${document.title.split("|")[0]}`; - } else { - // ? https://codechef.com - switch (location.pathname.split("/")[1]) { - case "ide": { - presenceData.details = "Using IDE"; - presenceData.state = `Editing ${ - document.querySelector(".chosen-single").childNodes[0].textContent - } file`; - break; - } + default: { + if (location.pathname.split('/')[1] === '') { + presenceData.details = 'Viewing Home Page' + } + else if (location.pathname.split('/').includes('tags')) { + presenceData.details = 'Viewing:' + presenceData.state = 'Problems By Tag Name' + } + else if (location.pathname.split('/').includes('problems')) { + presenceData.details = document.querySelector('.breadcrumbs')?.lastElementChild?.textContent + presenceData.state = `Solving: ${document.title.split('|')[0]}` + } + else { + // ? https://codechef.com + switch (location.pathname.split('/')[1]) { + case 'ide': { + presenceData.details = 'Using IDE' + presenceData.state = `Editing ${ + document.querySelector('.chosen-single')?.childNodes[0]?.textContent + } file` + break + } - case "AIMICPC": { - presenceData.details = "Viewing:"; - presenceData.state = "AIM ICPC - Weekly Training Series"; - break; - } + case 'AIMICPC': { + presenceData.details = 'Viewing:' + presenceData.state = 'AIM ICPC - Weekly Training Series' + break + } - case "LEARNDSA": { - presenceData.details = "Viewing:"; - presenceData.state = "DSA Learning Series"; - break; - } + case 'LEARNDSA': { + presenceData.details = 'Viewing:' + presenceData.state = 'DSA Learning Series' + break + } - case "contests": { - presenceData.details = "Viewing:"; - presenceData.state = "Contests List"; - break; - } + case 'contests': { + presenceData.details = 'Viewing:' + presenceData.state = 'Contests List' + break + } - case "certification": { - presenceData.details = "Viewing Certification: "; - presenceData.state = - document.querySelector(".page-title").childNodes[3].textContent; - break; - } + case 'certification': { + presenceData.details = 'Viewing Certification: ' + presenceData.state = document.querySelector('.page-title')?.childNodes[3]?.textContent + break + } - case "careers": { - presenceData.details = "Viewing:"; - presenceData.state = "Careers Page"; - break; - } + case 'careers': { + presenceData.details = 'Viewing:' + presenceData.state = 'Careers Page' + break + } - case "signup": { - presenceData.details = "Creating an account"; - break; - } + case 'signup': { + presenceData.details = 'Creating an account' + break + } - case "wiki": { - presenceData.details = "Viewing Wiki:"; - presenceData.state = - document.querySelector(".ns-heading").textContent; - break; - } + case 'wiki': { + presenceData.details = 'Viewing Wiki:' + presenceData.state = document.querySelector('.ns-heading')?.textContent + break + } - case "users": { - presenceData.details = "Viewing Profile:"; - presenceData.state = `${document.title.split("|")[0]} (${ - document.querySelector("header > h2").textContent - })`; - break; - } - } - } - } - } + case 'users': { + presenceData.details = 'Viewing Profile:' + presenceData.state = `${document.title.split('|')[0]} (${ + document.querySelector('header > h2')?.textContent + })` + break + } + } + } + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/CodePen/metadata.json b/websites/C/CodePen/metadata.json index fa5fd1d90f82..40468b787378 100644 --- a/websites/C/CodePen/metadata.json +++ b/websites/C/CodePen/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Chezzer", - "id": "195979856733929472" - }, - "service": "CodePen", - "description": { - "en": "CodePen is an online community for testing and showcasing user-created HTML, CSS and JavaScript code snippets.", - "nl": "CodePen is een online community voor het testen en presenteren van door gebruikers gemaakte HTML-, CSS- en JavaScript-codefragmenten.", - "vi_VN": "CodePan là cộng đồng trực tuyến thử nghiệm và trưng bày đoạn mã HTML, CSS và JavaScript được tạo bởi người dùng." - }, - "url": [ - "codepen.io", - "www.codepen.io" - ], - "version": "1.2.27", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CodePen/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CodePen/assets/thumbnail.png", - "color": "#0ebeff", - "category": "other", - "tags": [ - "other", - "codepen", - "code" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Chezzer", + "id": "195979856733929472" + }, + "service": "CodePen", + "description": { + "en": "CodePen is an online community for testing and showcasing user-created HTML, CSS and JavaScript code snippets.", + "nl": "CodePen is een online community voor het testen en presenteren van door gebruikers gemaakte HTML-, CSS- en JavaScript-codefragmenten.", + "vi_VN": "CodePan là cộng đồng trực tuyến thử nghiệm và trưng bày đoạn mã HTML, CSS và JavaScript được tạo bởi người dùng." + }, + "url": [ + "codepen.io", + "www.codepen.io" + ], + "version": "1.2.27", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CodePen/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CodePen/assets/thumbnail.png", + "color": "#0ebeff", + "category": "other", + "tags": [ + "other", + "codepen", + "code" + ] +} diff --git a/websites/C/CodePen/presence.ts b/websites/C/CodePen/presence.ts index 6e5aea098ac4..40cf696a6619 100644 --- a/websites/C/CodePen/presence.ts +++ b/websites/C/CodePen/presence.ts @@ -1,115 +1,129 @@ const presence = new Presence({ - clientId: "670111348130185267", -}); + clientId: '670111348130185267', +}) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CodePen/assets/logo.png", - smallImageKey: "https://cdn.rcd.gg/PreMiD/websites/C/CodePen/assets/0.png", - smallImageText: "codepen.io", - details: "Codepen.io", - state: "Coding...", - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CodePen/assets/logo.png', + smallImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CodePen/assets/0.png', + smallImageText: 'codepen.io', + details: 'Codepen.io', + state: 'Coding...', + } - if ( - window.location.pathname.includes("/fullpage/") || - window.location.pathname.includes("/pen/") - ) { - presenceData.details = "Editing a pen"; - presenceData.state = `${ - document.querySelector("#editable-title-span").textContent - } by ${ - document - .querySelectorAll(".ItemTitle_ownerLink-tMhWC")[0] - .textContent.split("<")[0] - }`; - } else if (window.location.pathname.includes("/collection/")) { - presenceData.details = `Looking at collection ${ - document.querySelector("#collection-name").textContent - }`; - if (document.querySelector("#collection-desc").textContent === "") { - presenceData.state = `Collection by ${ - document - .querySelectorAll(".content-author")[0] - .textContent.split("\n")[0] - }`; - } else { - presenceData.state = - document.querySelector("#collection-desc").textContent; - } - } else if (window.location.pathname.includes("/topic/")) { - presenceData.details = `Looking at topic ${ - document.querySelectorAll(".Topics_topicTitle-3OfJU")[0].textContent - }`; - presenceData.state = document - .querySelectorAll(".Topics_topicDescription-2CNwF")[0] - .textContent.split("\n")[3]; - } else if (window.location.pathname.includes("/tv/")) { - presenceData.details = `Watching ${document - .querySelectorAll(".collection-details")[0] - .textContent.replace("From “", "") - .replace("”", "")} on Codepen TV`; - presenceData.state = `${ - document.querySelectorAll(".item-title")[0].textContent - } ${document.querySelectorAll(".pen-author")[0].textContent}`; - } else if ( - window.location.pathname.includes("/project/") || - window.location.pathname.includes("/project/") - ) { - presenceData.details = "Editing a project"; - presenceData.state = `${ - document.querySelector("#editable-title-span").textContent - } by ${ - document - .querySelectorAll(".ItemTitle_ownerLink-tMhWC")[0] - .textContent.split("<")[0] - }`; - } else { - switch (window.location.pathname) { - case "/write/": { - presenceData.details = "Making a post"; - if ((document.querySelector("#title") as HTMLInputElement).value === "") - presenceData.state = "Thinking about what the title should be."; - else { - presenceData.state = ( - document.querySelector("#title") as HTMLInputElement - ).value; - } + if ( + window.location.pathname.includes('/fullpage/') + || window.location.pathname.includes('/pen/') + ) { + presenceData.details = 'Editing a pen' + presenceData.state = `${ + document.querySelector('#editable-title-span')?.textContent + } by ${ + document + .querySelectorAll('.ItemTitle_ownerLink-tMhWC')[0] + ?.textContent + ?.split('<')[0] + }` + } + else if (window.location.pathname.includes('/collection/')) { + presenceData.details = `Looking at collection ${ + document.querySelector('#collection-name')?.textContent + }` + if (document.querySelector('#collection-desc')?.textContent === '') { + presenceData.state = `Collection by ${ + document + .querySelectorAll('.content-author')[0] + ?.textContent + ?.split('\n')[0] + }` + } + else { + presenceData.state = document.querySelector('#collection-desc')?.textContent + } + } + else if (window.location.pathname.includes('/topic/')) { + presenceData.details = `Looking at topic ${ + document.querySelectorAll('.Topics_topicTitle-3OfJU')[0].textContent + }` + presenceData.state = document + .querySelectorAll('.Topics_topicDescription-2CNwF')[0] + ?.textContent + ?.split('\n')[3] + } + else if (window.location.pathname.includes('/tv/')) { + presenceData.details = `Watching ${document + .querySelectorAll('.collection-details')[0] + ?.textContent + ?.replace('From “', '') + ?.replace('”', '')} on Codepen TV` + presenceData.state = `${ + document.querySelectorAll('.item-title')[0].textContent + } ${document.querySelectorAll('.pen-author')[0].textContent}` + } + else if ( + window.location.pathname.includes('/project/') + || window.location.pathname.includes('/project/') + ) { + presenceData.details = 'Editing a project' + presenceData.state = `${ + document.querySelector('#editable-title-span')?.textContent + } by ${ + document + .querySelectorAll('.ItemTitle_ownerLink-tMhWC')[0] + ?.textContent + ?.split('<')[0] + }` + } + else { + switch (window.location.pathname) { + case '/write/': { + presenceData.details = 'Making a post' + if ((document.querySelector('#title') as HTMLInputElement).value === '') { + presenceData.state = 'Thinking about what the title should be.' + } + else { + presenceData.state = ( + document.querySelector('#title') as HTMLInputElement + ).value + } - break; - } - case "/": { - presenceData.details = "On the home page"; - presenceData.state = "Looking at code snippets."; + break + } + case '/': { + presenceData.details = 'On the home page' + presenceData.state = 'Looking at code snippets.' - break; - } - case "/dashboard/": { - presenceData.details = "On dashboard"; - presenceData.state = "Admiring their own pens."; + break + } + case '/dashboard/': { + presenceData.details = 'On dashboard' + presenceData.state = 'Admiring their own pens.' - break; - } - default: - if (window.location.pathname.includes("/search/")) { - presenceData.details = "Searching for pens"; - presenceData.state = `Looking for ${location.search.replace( - "?q=", - "" - )}`; - } else if (!document.querySelectorAll(".title-header")[0]) { - presenceData.details = "Looking at page"; - presenceData.state = document.title; - } else { - presenceData.details = "Looking at page"; - [presenceData.state] = document - .querySelectorAll(".title-header")[0] - .textContent.split("\n"); - } - } - } + break + } + default: + if (window.location.pathname.includes('/search/')) { + presenceData.details = 'Searching for pens' + presenceData.state = `Looking for ${location.search.replace( + '?q=', + '', + )}` + } + else if (!document.querySelectorAll('.title-header')[0]) { + presenceData.details = 'Looking at page' + presenceData.state = document.title + } + else { + presenceData.details = 'Looking at page'; + [presenceData.state] = document + .querySelectorAll('.title-header')[0] + ?.textContent + ?.split('\n') ?? [] + } + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/CodeSandbox/metadata.json b/websites/C/CodeSandbox/metadata.json index cdcb1f0ac545..71c2986865d1 100644 --- a/websites/C/CodeSandbox/metadata.json +++ b/websites/C/CodeSandbox/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "BigBoi", - "id": "853932304257908746" - }, - "service": "CodeSandbox", - "description": { - "en": "CodeSandbox is an online code editor and prototyping tool that makes creating and sharing web apps faster" - }, - "url": "codesandbox.io", - "version": "1.0.13", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/thumbnail.png", - "color": "#1c1c1c", - "category": "other", - "tags": [ - "coding", - "developing", - "hosting", - "programing", - "code" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "BigBoi", + "id": "853932304257908746" + }, + "service": "CodeSandbox", + "description": { + "en": "CodeSandbox is an online code editor and prototyping tool that makes creating and sharing web apps faster" + }, + "url": "codesandbox.io", + "version": "1.0.13", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/thumbnail.png", + "color": "#1c1c1c", + "category": "other", + "tags": [ + "coding", + "developing", + "hosting", + "programing", + "code" + ] +} diff --git a/websites/C/CodeSandbox/presence.ts b/websites/C/CodeSandbox/presence.ts index e4d61f971dc9..a720d8436b14 100644 --- a/websites/C/CodeSandbox/presence.ts +++ b/websites/C/CodeSandbox/presence.ts @@ -1,208 +1,225 @@ const presence = new Presence({ - clientId: "961652082027421746", - }), - browsingTimestamp = Math.floor(Date.now()), - formats = [ - "js", - "jsx", - "ts", - "tsx", - "json", - "py", - "cpp", - "cs", - "c", - "py", - "swift", - "java", - "html", - "css", - "php", - "kt", - "sql", - "lua", - "ru", - "bash", - "sh", - "bat", - "cr", - "go", - "rs", - ]; + clientId: '961652082027421746', +}) +const browsingTimestamp = Math.floor(Date.now()) +const formats = [ + 'js', + 'jsx', + 'ts', + 'tsx', + 'json', + 'py', + 'cpp', + 'cs', + 'c', + 'py', + 'swift', + 'java', + 'html', + 'css', + 'php', + 'kt', + 'sql', + 'lua', + 'ru', + 'bash', + 'sh', + 'bat', + 'cr', + 'go', + 'rs', +] const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/logo.png", - Square = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/0.png", - Create = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/1.png", - Dashboard = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/2.png", - Discover = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/3.png", - Drafts = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/4.png", - All = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/5.png", - Templates = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/6.png", - Repositories = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/7.png", - Recent = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/8.png", - Deleted = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/9.png", - Shared = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/10.png", - Liked = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/11.png", - Profile = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/12.png", - Txt = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/13.png", - UserSandbox = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/14.png", - Unknown = "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/15.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/logo.png', + Square = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/0.png', + Create = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/1.png', + Dashboard = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/2.png', + Discover = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/3.png', + Drafts = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/4.png', + All = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/5.png', + Templates = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/6.png', + Repositories = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/7.png', + Recent = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/8.png', + Deleted = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/9.png', + Shared = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/10.png', + Liked = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/11.png', + Profile = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/12.png', + Txt = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/13.png', + UserSandbox = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/14.png', + Unknown = 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/15.png', } const assets = { - py: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/16.png", - js: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/17.png", - ts: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/18.png", - css: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/19.png", - swift: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/20.png", - html: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/21.png", - java: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/22.png", - cpp: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/23.png", - json: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/24.png", - cs: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/25.png", - c: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/26.png", - txt: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/13.png", - tsx: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/27.png", - jsx: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/28.png", - cr: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/29.png", - go: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/30.png", - sh: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/31.png", - bash: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/32.png", - sql: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/33.png", - ru: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/34.png", - lua: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/35.png", - php: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/36.png", - kt: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/37.png", - bat: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/38.png", - rs: "https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/39.png", -}; + py: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/16.png', + js: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/17.png', + ts: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/18.png', + css: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/19.png', + swift: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/20.png', + html: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/21.png', + java: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/22.png', + cpp: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/23.png', + json: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/24.png', + cs: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/25.png', + c: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/26.png', + txt: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/13.png', + tsx: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/27.png', + jsx: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/28.png', + cr: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/29.png', + go: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/30.png', + sh: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/31.png', + bash: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/32.png', + sql: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/33.png', + ru: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/34.png', + lua: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/35.png', + php: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/36.png', + kt: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/37.png', + bat: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/38.png', + rs: 'https://cdn.rcd.gg/PreMiD/websites/C/CodeSandbox/assets/39.png', +} -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - smallImageKey: Assets.Square, - smallImageText: "CodeSandbox", - details: "Loading", - startTimestamp: browsingTimestamp, - }, - { pathname, search } = window.location; - if (pathname.startsWith("/")) { - if (document.querySelector('[class="ReactModalPortal"]')) { - presenceData.details = "Creating a new sandbox!"; - presenceData.largeImageKey = Assets.Create; - } else if (pathname.includes("/dashboard/home")) { - presenceData.details = "Looking at their dashboard"; - presenceData.state = "Page: Home"; - presenceData.largeImageKey = Assets.Dashboard; - } else if (pathname.includes("/dashboard/discover")) { - presenceData.details = "Discovering other sandboxes"; - presenceData.state = "Page: Discover"; - presenceData.largeImageKey = Assets.Discover; - } else if (pathname.includes("/dashboard/drafts")) { - presenceData.details = "Looking at their drafts"; - presenceData.state = "Page: Drafts"; - presenceData.largeImageKey = Assets.Drafts; - } else if (pathname.includes("/dashboard/all")) { - presenceData.details = "Looking through their sandboxes"; - presenceData.state = "Page: All Sandboxes"; - presenceData.largeImageKey = Assets.All; - } else if (pathname.includes("/dashboard/templates")) { - presenceData.details = "Looking through their templates"; - presenceData.state = "Page: Templates"; - presenceData.largeImageKey = Assets.Templates; - } else if (pathname.includes("/dashboard/repositories")) { - presenceData.details = "Looking through their repositories"; - presenceData.state = "Page: Repositories"; - presenceData.largeImageKey = Assets.Repositories; - } else if (pathname.includes("/dashboard/recent")) { - presenceData.details = "Looking through their recent sandboxes"; - presenceData.state = "Page: Recently Modified"; - presenceData.largeImageKey = Assets.Recent; - } else if (pathname.includes("/dashboard/deleted")) { - presenceData.details = "Looking through their trashed sandboxes"; - presenceData.state = "Page: Recently Deleted"; - presenceData.largeImageKey = Assets.Deleted; - } else if (pathname.includes("/dashboard/shared")) { - presenceData.details = "Looking at shared sandboxes"; - presenceData.state = "Page: Shared With Me"; - presenceData.largeImageKey = Assets.Shared; - } else if (pathname.includes("/dashboard/liked")) { - presenceData.details = "Looking at liked sandboxes"; - presenceData.state = "Page: Liked Sandboxes"; - presenceData.largeImageKey = Assets.Liked; - } else if (pathname.includes("/u/")) { - presenceData.details = "Looking at a user's profile:"; - presenceData.state = `${ - document.querySelector( - '[class="sc-bdnylx sc-gtssRu gDXMLZ hHsTZp"]' - ).textContent - } (@${ - document.querySelector( - '[class="sc-bdnylx sc-gtssRu gDXMLZ itZLEx"]' - ).textContent - })`; - presenceData.largeImageKey = Assets.Profile; - presenceData.buttons = [ - { - label: "View Profile", - url: location.href.toString(), - }, - ]; - } else if (pathname.includes("/s/")) { - if ( - document.querySelector('[aria-label="Explorer"]') - ) { - const cfile = search.split("/").filter(elm => elm !== ""), - formatImg = search.split(".").filter(elm => elm !== ""); - presenceData.details = `Editing ${ - search - ? ` ${cfile[cfile.length - 1].replace( - /(:)|[0-9]|(-)/g, - "" - )} (${document - .querySelector('[title="Go to Line"]') - .textContent.replace(/\(|([0-9]*) selected\)/g, "")})` - : "a sandbox" - }`; - presenceData.state = `Workspace: ${document.title.split("-")[0]}`; - if ( - formats.includes( - formatImg[formatImg.length - 1] - /*.toLowerCase()*/ - .replace(/(:)|[0-9]|(-)/g, "") - ) - ) { - presenceData.largeImageKey = - assets[ - `${formatImg[formatImg.length - 1] - .toLowerCase() - .replace(/(:)|[0-9]|(-)/g, "")}` as keyof typeof assets - ]; - } else presenceData.largeImageKey = Assets.Txt; - } else { - presenceData.details = `Looking at ${ - document.querySelector( - '[class="sc-bdnylx sc-gtssRu gDXMLZ kEgnIE"]' - ).textContent - }'s sandbox`; - presenceData.state = `Workspace: ${ - document.querySelector( - '[class="sc-bdnylx sc-gtssRu gDXMLZ efjlMo"]' - ).textContent - }`; - presenceData.largeImageKey = Assets.UserSandbox; - presenceData.buttons = [ - { - label: "View Sandbox", - url: location.href.toString(), - }, - ]; - } - } else { - presenceData.details = "Viewing an unsupported CodeSandbox page"; - presenceData.largeImageKey = Assets.Unknown; - } - } - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + smallImageKey: Assets.Square, + smallImageText: 'CodeSandbox', + details: 'Loading', + startTimestamp: browsingTimestamp, + } + const { pathname, search } = window.location + if (pathname.startsWith('/')) { + if (document.querySelector('[class="ReactModalPortal"]')) { + presenceData.details = 'Creating a new sandbox!' + presenceData.largeImageKey = Assets.Create + } + else if (pathname.includes('/dashboard/home')) { + presenceData.details = 'Looking at their dashboard' + presenceData.state = 'Page: Home' + presenceData.largeImageKey = Assets.Dashboard + } + else if (pathname.includes('/dashboard/discover')) { + presenceData.details = 'Discovering other sandboxes' + presenceData.state = 'Page: Discover' + presenceData.largeImageKey = Assets.Discover + } + else if (pathname.includes('/dashboard/drafts')) { + presenceData.details = 'Looking at their drafts' + presenceData.state = 'Page: Drafts' + presenceData.largeImageKey = Assets.Drafts + } + else if (pathname.includes('/dashboard/all')) { + presenceData.details = 'Looking through their sandboxes' + presenceData.state = 'Page: All Sandboxes' + presenceData.largeImageKey = Assets.All + } + else if (pathname.includes('/dashboard/templates')) { + presenceData.details = 'Looking through their templates' + presenceData.state = 'Page: Templates' + presenceData.largeImageKey = Assets.Templates + } + else if (pathname.includes('/dashboard/repositories')) { + presenceData.details = 'Looking through their repositories' + presenceData.state = 'Page: Repositories' + presenceData.largeImageKey = Assets.Repositories + } + else if (pathname.includes('/dashboard/recent')) { + presenceData.details = 'Looking through their recent sandboxes' + presenceData.state = 'Page: Recently Modified' + presenceData.largeImageKey = Assets.Recent + } + else if (pathname.includes('/dashboard/deleted')) { + presenceData.details = 'Looking through their trashed sandboxes' + presenceData.state = 'Page: Recently Deleted' + presenceData.largeImageKey = Assets.Deleted + } + else if (pathname.includes('/dashboard/shared')) { + presenceData.details = 'Looking at shared sandboxes' + presenceData.state = 'Page: Shared With Me' + presenceData.largeImageKey = Assets.Shared + } + else if (pathname.includes('/dashboard/liked')) { + presenceData.details = 'Looking at liked sandboxes' + presenceData.state = 'Page: Liked Sandboxes' + presenceData.largeImageKey = Assets.Liked + } + else if (pathname.includes('/u/')) { + presenceData.details = 'Looking at a user\'s profile:' + presenceData.state = `${ + document.querySelector( + '[class="sc-bdnylx sc-gtssRu gDXMLZ hHsTZp"]', + )?.textContent + } (@${ + document.querySelector( + '[class="sc-bdnylx sc-gtssRu gDXMLZ itZLEx"]', + )?.textContent + })` + presenceData.largeImageKey = Assets.Profile + presenceData.buttons = [ + { + label: 'View Profile', + url: location.href.toString(), + }, + ] + } + else if (pathname.includes('/s/')) { + if ( + document.querySelector('[aria-label="Explorer"]') + ) { + const cfile = search.split('/').filter(elm => elm !== '') + const formatImg = search.split('.').filter(elm => elm !== '') + presenceData.details = `Editing ${ + search + ? ` ${cfile[cfile.length - 1].replace( + /(:)|\d|(-)/g, + '', + )} (${document + .querySelector('[title="Go to Line"]') + ?.textContent + ?.replace(/\(|(\d*) selected\)/g, '')})` + : 'a sandbox' + }` + presenceData.state = `Workspace: ${document.title.split('-')[0]}` + if ( + formats.includes( + formatImg[formatImg.length - 1] + /* .toLowerCase() */ + .replace(/(:)|\d|(-)/g, ''), + ) + ) { + presenceData.largeImageKey = assets[ + `${formatImg[formatImg.length - 1] + .toLowerCase() + .replace(/(:)|\d|(-)/g, '')}` as keyof typeof assets + ] + } + else { + presenceData.largeImageKey = Assets.Txt + } + } + else { + presenceData.details = `Looking at ${ + document.querySelector( + '[class="sc-bdnylx sc-gtssRu gDXMLZ kEgnIE"]', + )?.textContent + }'s sandbox` + presenceData.state = `Workspace: ${ + document.querySelector( + '[class="sc-bdnylx sc-gtssRu gDXMLZ efjlMo"]', + )?.textContent + }` + presenceData.largeImageKey = Assets.UserSandbox + presenceData.buttons = [ + { + label: 'View Sandbox', + url: location.href.toString(), + }, + ] + } + } + else { + presenceData.details = 'Viewing an unsupported CodeSandbox page' + presenceData.largeImageKey = Assets.Unknown + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/C/Codeberg/metadata.json b/websites/C/Codeberg/metadata.json index 804d9e58efa4..83f24b1f5754 100644 --- a/websites/C/Codeberg/metadata.json +++ b/websites/C/Codeberg/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "756258832526868541", - "name": "spifory" - }, - "service": "Codeberg", - "description": { - "en": "Codeberg is a non-profit, community-led organization that aims to help free and open source projects prosper by giving them a safe and friendly home." - }, - "url": "codeberg.org", - "version": "1.0.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Codeberg/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Codeberg/assets/thumbnail.png", - "color": "#2185D0", - "category": "other", - "tags": [ - "programming", - "sharing", - "coding" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "756258832526868541", + "name": "spifory" + }, + "service": "Codeberg", + "description": { + "en": "Codeberg is a non-profit, community-led organization that aims to help free and open source projects prosper by giving them a safe and friendly home." + }, + "url": "codeberg.org", + "version": "1.0.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Codeberg/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Codeberg/assets/thumbnail.png", + "color": "#2185D0", + "category": "other", + "tags": [ + "programming", + "sharing", + "coding" + ] +} diff --git a/websites/C/Codeberg/presence.ts b/websites/C/Codeberg/presence.ts index f05dcadf0bda..f96ee3056f28 100644 --- a/websites/C/Codeberg/presence.ts +++ b/websites/C/Codeberg/presence.ts @@ -1,235 +1,247 @@ const presence = new Presence({ - clientId: "1248642612169150594", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1248642612169150594', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { // Other default assets can be found at index.d.ts - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Codeberg/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Codeberg/assets/logo.png', } -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }; - - const pages: Record = { - pulls: { - details: "Viewing pull requests", - }, - notifications: { - details: "Viewing notifications", - }, - issues: { - details: "Viewing issues", - }, - milestones: { - details: "Viewing milestones", - }, - "notifications/subscriptions": { - details: "Viewing subscribed notifications", - }, - "user/settings": { - details: "Editing user settings", - }, - "user/login": { - details: "Logging in", - }, - "user/cbrgp/0XUjCUW": { - details: "Signing up", - }, - "explore/repos": { - details: "Exploring repositories", - }, - "explore/users": { - details: "Exploring users", - }, - "explore/organizations": { - details: "Exploring organizations", - }, - "org/create": { - details: "Creating an organization", - }, - "repo/create": { - details: "Creating a repository", - }, - "repo/migrate": { - details: "Migrating a repository", - }, - }, - { href } = document.location; - - for (const [path, data] of Object.entries(pages)) { - if ( - `/${path}` === document.querySelector(".active.item").getAttribute("href") - ) - presenceData = { ...presenceData, ...data }; - } - - // Handle users - if ( - document.querySelector(".user.profile") && - !document.querySelector(".user.profile.settings") - ) { - const profileDisplayName = document - .querySelector(".profile-avatar-name") - .querySelector(".header")?.textContent, - // Returns as {name} · {pronouns} so I have to split it - profileName = document - .querySelector(".profile-avatar-name") - .querySelector(".username") - .textContent.split(" ")[0]; - - let name: string; - if (!profileDisplayName) name = profileName; - else name = `${profileDisplayName} (${profileName})`; - - const tabParam = new URL(href).searchParams.get("tab"); - - if (tabParam) { - switch (tabParam) { - case "stars": { - presenceData.details = `Viewing ${profileName}'s starred repositories`; - - break; - } - case "activity": { - presenceData.details = `Viewing ${profileName}'s public activity`; - - break; - } - case "repositories": { - presenceData.details = `Viewing ${profileName}'s repositories`; - - break; - } - // No default - } - } else if (href.includes("/-/projects")) - presenceData.details = `Viewing ${profileName}'s projects`; - else if (href.includes("/-/packages")) - presenceData.details = `Viewing ${profileName}'s packages`; - else presenceData.details = `Viewing profile: ${name}`; - - presenceData.buttons = [ - { - label: "View Profile", - url: href, - }, - ]; - presenceData.largeImageKey = document - .querySelector("#profile-avatar") - .querySelector("img").src; - presenceData.smallImageKey = Assets.Logo; - } - - // Handle repos - if ( - document.querySelector(".repository") && - !document.querySelector(".repository.new") - ) { - const repoAvatar = document - .querySelector(".flex-item-leading") - .querySelector("img"), - repoTitle = document - .querySelector(".flex-item-main") - .querySelector(".flex-item-title") - .textContent.trim(); - - if (repoAvatar) { - presenceData.largeImageKey = repoAvatar.src; - presenceData.smallImageKey = Assets.Logo; - } else presenceData.largeImageKey = Assets.Logo; - - presenceData.buttons = [ - { - label: "View Repository", - url: href, - }, - ]; - - const repoPages: Record = { - "": { - details: `Viewing repository: ${repoTitle}`, - }, - issues: { - details: `Viewing ${repoTitle}'s issues`, - }, - pulls: { - details: `Viewing ${repoTitle}'s pull requests`, - }, - activity: { - details: `Viewing ${repoTitle}'s public activity`, - }, - settings: { - details: `Editing ${repoTitle}'s settings`, - }, - releases: { - details: `Viewing ${repoTitle}'s releases`, - }, - projects: { - details: `Viewing ${repoTitle}'s projects`, - }, - actions: { - details: `Viewing ${repoTitle}'s actions`, - }, - packages: { - details: `Viewing ${repoTitle}'s packages`, - }, - branches: { - details: `Viewing ${repoTitle}'s branches`, - }, - tags: { - details: `Viewing ${repoTitle}'s tags`, - }, - forks: { - details: `Viewing ${repoTitle}'s forks`, - }, - watchers: { - details: `Viewing ${repoTitle}'s watchers`, - }, - stars: { - details: `Viewing ${repoTitle}'s stargazers`, - }, - }; - - for (const [path, data] of Object.entries(repoPages)) { - if ( - `/${path}` === - document.querySelector(".active.item").getAttribute("href") - ) { - presenceData = { - ...data, - ...presenceData, - }; - } - } - } - - // Handle orgs - if (document.querySelector(".organization.page-content")) { - const orgAvatar = document - .querySelector(".organization") - .querySelector("img"), - orgName = orgAvatar.title; - - if (href.includes("/-/projects")) - presenceData.details = `Viewing ${orgName}'s projects`; - else if (href.includes("/-/packages")) - presenceData.details = `Viewing ${orgName}'s packages`; - else if (href.includes("/org")) - presenceData.details = `Viewing ${orgName}'s teams/members`; - else presenceData.details = `Viewing organization: ${orgName}`; - - presenceData.buttons = [ - { - label: "View Organization", - url: href, - }, - ]; - presenceData.largeImageKey = orgAvatar.src; - presenceData.smallImageKey = Assets.Logo; - } - - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + + const pages: Record = { + 'pulls': { + details: 'Viewing pull requests', + }, + 'notifications': { + details: 'Viewing notifications', + }, + 'issues': { + details: 'Viewing issues', + }, + 'milestones': { + details: 'Viewing milestones', + }, + 'notifications/subscriptions': { + details: 'Viewing subscribed notifications', + }, + 'user/settings': { + details: 'Editing user settings', + }, + 'user/login': { + details: 'Logging in', + }, + 'user/cbrgp/0XUjCUW': { + details: 'Signing up', + }, + 'explore/repos': { + details: 'Exploring repositories', + }, + 'explore/users': { + details: 'Exploring users', + }, + 'explore/organizations': { + details: 'Exploring organizations', + }, + 'org/create': { + details: 'Creating an organization', + }, + 'repo/create': { + details: 'Creating a repository', + }, + 'repo/migrate': { + details: 'Migrating a repository', + }, + } + const { href } = document.location + + for (const [path, data] of Object.entries(pages)) { + if ( + `/${path}` === document.querySelector('.active.item')?.getAttribute('href') + ) + presenceData = { ...presenceData, ...data } as PresenceData + } + + // Handle users + if ( + document.querySelector('.user.profile') + && !document.querySelector('.user.profile.settings') + ) { + const profileDisplayName = document + .querySelector('.profile-avatar-name') + ?.querySelector('.header') + ?.textContent + // Returns as {name} · {pronouns} so I have to split it + const profileName = document + .querySelector('.profile-avatar-name') + ?.querySelector('.username') + ?.textContent + ?.split(' ')[0] + + let name: string + if (!profileDisplayName) + name = profileName! + else name = `${profileDisplayName} (${profileName})` + + const tabParam = new URL(href).searchParams.get('tab') + + if (tabParam) { + switch (tabParam) { + case 'stars': { + presenceData.details = `Viewing ${profileName}'s starred repositories` + + break + } + case 'activity': { + presenceData.details = `Viewing ${profileName}'s public activity` + + break + } + case 'repositories': { + presenceData.details = `Viewing ${profileName}'s repositories` + + break + } + } + } + else if (href.includes('/-/projects')) { + presenceData.details = `Viewing ${profileName}'s projects` + } + else if (href.includes('/-/packages')) { + presenceData.details = `Viewing ${profileName}'s packages` + } + else { + presenceData.details = `Viewing profile: ${name}` + } + + presenceData.buttons = [ + { + label: 'View Profile', + url: href, + }, + ] + presenceData.largeImageKey = document + .querySelector('#profile-avatar') + ?.querySelector('img') + ?.src + presenceData.smallImageKey = Assets.Logo + } + + // Handle repos + if ( + document.querySelector('.repository') + && !document.querySelector('.repository.new') + ) { + const repoAvatar = document + .querySelector('.flex-item-leading') + ?.querySelector('img') + const repoTitle = document + .querySelector('.flex-item-main') + ?.querySelector('.flex-item-title') + ?.textContent + ?.trim() + + if (repoAvatar) { + presenceData.largeImageKey = repoAvatar.src + presenceData.smallImageKey = Assets.Logo + } + else { + presenceData.largeImageKey = Assets.Logo + } + + presenceData.buttons = [ + { + label: 'View Repository', + url: href, + }, + ] + + const repoPages: Record = { + '': { + details: `Viewing repository: ${repoTitle}`, + }, + 'issues': { + details: `Viewing ${repoTitle}'s issues`, + }, + 'pulls': { + details: `Viewing ${repoTitle}'s pull requests`, + }, + 'activity': { + details: `Viewing ${repoTitle}'s public activity`, + }, + 'settings': { + details: `Editing ${repoTitle}'s settings`, + }, + 'releases': { + details: `Viewing ${repoTitle}'s releases`, + }, + 'projects': { + details: `Viewing ${repoTitle}'s projects`, + }, + 'actions': { + details: `Viewing ${repoTitle}'s actions`, + }, + 'packages': { + details: `Viewing ${repoTitle}'s packages`, + }, + 'branches': { + details: `Viewing ${repoTitle}'s branches`, + }, + 'tags': { + details: `Viewing ${repoTitle}'s tags`, + }, + 'forks': { + details: `Viewing ${repoTitle}'s forks`, + }, + 'watchers': { + details: `Viewing ${repoTitle}'s watchers`, + }, + 'stars': { + details: `Viewing ${repoTitle}'s stargazers`, + }, + } + + for (const [path, data] of Object.entries(repoPages)) { + if ( + `/${path}` + === document.querySelector('.active.item')?.getAttribute('href') + ) { + presenceData = { + ...data, + ...presenceData, + } as PresenceData + } + } + } + + // Handle orgs + if (document.querySelector('.organization.page-content')) { + const orgAvatar = document + .querySelector('.organization') + ?.querySelector('img') + const orgName = orgAvatar?.title + + if (href.includes('/-/projects')) + presenceData.details = `Viewing ${orgName}'s projects` + else if (href.includes('/-/packages')) + presenceData.details = `Viewing ${orgName}'s packages` + else if (href.includes('/org')) + presenceData.details = `Viewing ${orgName}'s teams/members` + else presenceData.details = `Viewing organization: ${orgName}` + + presenceData.buttons = [ + { + label: 'View Organization', + url: href, + }, + ] + presenceData.largeImageKey = orgAvatar?.src + presenceData.smallImageKey = Assets.Logo + } + + presence.setActivity(presenceData) +}) diff --git a/websites/C/Codecademy/iframe.ts b/websites/C/Codecademy/iframe.ts index ca93e10797ae..cae7399d279f 100644 --- a/websites/C/Codecademy/iframe.ts +++ b/websites/C/Codecademy/iframe.ts @@ -1,16 +1,16 @@ -const iframe = new iFrame(); -iframe.on("UpdateData", async () => { - const videoElement: HTMLVideoElement = - document.querySelector("#player video"); - if ( - !document.querySelector("div.ytp-title-text > a") || - !videoElement - ) - return; - iframe.send({ - title: videoElement.textContent, - duration: videoElement.duration ?? null, - currentTime: videoElement.currentTime, - paused: videoElement.paused, - }); -}); +const iframe = new iFrame() +iframe.on('UpdateData', async () => { + const videoElement = document.querySelector('#player video') + if ( + !document.querySelector('div.ytp-title-text > a') + || !videoElement + ) { + return + } + iframe.send({ + title: videoElement.textContent, + duration: videoElement.duration ?? null, + currentTime: videoElement.currentTime, + paused: videoElement.paused, + }) +}) diff --git a/websites/C/Codecademy/metadata.json b/websites/C/Codecademy/metadata.json index 46f04177c26f..6d1d8eb03677 100644 --- a/websites/C/Codecademy/metadata.json +++ b/websites/C/Codecademy/metadata.json @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "d0gg3r", - "id": "460318444487704597" - }, - "service": "Codecademy", - "description": { - "en": "Learn the technical skills you need for the job you want. As leaders in online education and learning to code, we’ve taught over 45 million people using a tested curriculum and an interactive learning environment. Start with HTML, CSS, JavaScript, SQL, Python, Data Science, and more.", - "nl": "Leer de technische vaardigheden die u nodig heeft voor de baan die u zoekt. Als leiders op het gebied van online onderwijs en leren coderen, hebben we meer dan 45 miljoen mensen les gegeven met behulp van een getest curriculum en een interactieve leeromgeving. Begin met HTML, CSS, JavaScript, SQL, Python, Data Science en meer.", - "vi_VN": "Học các kĩ năng kỹ thuật cho công việc bạn muốn. Dẫn đầu trong giáo dục trực tuyeesng và dạy lập trình, chúng tôi đã dạt hơn 45 triệu người dùng trong một khoá học được kiểm định và một môi trường giáo dục tương tác. Bắt đầu với HTML, CSS, JavaScript, SQL, Python, Data Science, và hơn nữa." - }, - "url": [ - "www.codecademy.com", - "news.codecademy.com" - ], - "version": "1.1.31", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/thumbnail.png", - "color": "#152B39", - "category": "other", - "tags": [ - "coding", - "programming", - "computer", - "learn" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "d0gg3r", + "id": "460318444487704597" + }, + "service": "Codecademy", + "description": { + "en": "Learn the technical skills you need for the job you want. As leaders in online education and learning to code, we’ve taught over 45 million people using a tested curriculum and an interactive learning environment. Start with HTML, CSS, JavaScript, SQL, Python, Data Science, and more.", + "nl": "Leer de technische vaardigheden die u nodig heeft voor de baan die u zoekt. Als leiders op het gebied van online onderwijs en leren coderen, hebben we meer dan 45 miljoen mensen les gegeven met behulp van een getest curriculum en een interactieve leeromgeving. Begin met HTML, CSS, JavaScript, SQL, Python, Data Science en meer.", + "vi_VN": "Học các kĩ năng kỹ thuật cho công việc bạn muốn. Dẫn đầu trong giáo dục trực tuyeesng và dạy lập trình, chúng tôi đã dạt hơn 45 triệu người dùng trong một khoá học được kiểm định và một môi trường giáo dục tương tác. Bắt đầu với HTML, CSS, JavaScript, SQL, Python, Data Science, và hơn nữa." + }, + "url": [ + "www.codecademy.com", + "news.codecademy.com" + ], + "version": "1.1.31", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/thumbnail.png", + "color": "#152B39", + "category": "other", + "tags": [ + "coding", + "programming", + "computer", + "learn" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git a/websites/C/Codecademy/presence.ts b/websites/C/Codecademy/presence.ts index 3fb179174ea0..c4c9d0fa6f14 100644 --- a/websites/C/Codecademy/presence.ts +++ b/websites/C/Codecademy/presence.ts @@ -1,246 +1,248 @@ const presence = new Presence({ - clientId: "736516965748834336", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }), - start = Date.now(); + clientId: '736516965748834336', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) +const start = Date.now() let videoTitle: string, - videoCurrentTime: number, - videoDuration: number, - videoPaused: boolean; + videoCurrentTime: number, + videoDuration: number, + videoPaused: boolean interface DataInterface { - title: string; - currentTime: number; - duration: number; - paused: boolean; + title: string + currentTime: number + duration: number + paused: boolean } -/* eslint-disable camelcase */ const assets: Record = { - git: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/0.png", - html: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/1.png", - css: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/2.png", - the_command_line: - "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/3.png", - node_with_sqlite: - "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/4.png", - ruby_on_rails: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/5.png", - python_2: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/6.png", - javascript: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/7.png", - go: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/8.png", - authentication_with_ruby_on_rails: - "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/9.png", - java: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/10.png", - python_3: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/11.png", - swift: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/12.png", - r: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/13.png", - kotlin: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/14.png", - ruby: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/15.png", - sql: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/16.png", - php: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/17.png", - csharp: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/18.png", - cplusplus: "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/19.png", -}; -/* eslint-enable camelcase */ + git: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/0.png', + html: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/1.png', + css: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/2.png', + the_command_line: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/3.png', + node_with_sqlite: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/4.png', + ruby_on_rails: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/5.png', + python_2: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/6.png', + javascript: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/7.png', + go: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/8.png', + authentication_with_ruby_on_rails: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/9.png', + java: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/10.png', + python_3: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/11.png', + swift: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/12.png', + r: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/13.png', + kotlin: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/14.png', + ruby: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/15.png', + sql: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/16.png', + php: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/17.png', + csharp: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/18.png', + cplusplus: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/19.png', +} -presence.on("iFrameData", (data: DataInterface) => { - videoTitle = data.title; - videoCurrentTime = data.currentTime; - videoDuration = data.duration; - videoPaused = data.paused; -}); +presence.on('iFrameData', (inc: unknown) => { + const data = inc as DataInterface + videoTitle = data.title + videoCurrentTime = data.currentTime + videoDuration = data.duration + videoPaused = data.paused +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/logo.png", - }, - pathArray: string[] = window.location.pathname - .replace(/^\/|\/$/g, "") - .split("/"); - let heading: Element | string = - document.querySelector("[class^=headerTitle__]") || - document.querySelector("[class^=trackTitle__]"), - premiumPath: boolean; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Codecademy/assets/logo.png', + } + const pathArray: string[] = window.location.pathname + .replace(/^\/|\/$/g, '') + .split('/') + let heading: Element | string = document.querySelector('[class^=headerTitle__]') + || document.querySelector('[class^=trackTitle__]')! + let premiumPath: boolean - switch (pathArray[0]) { - case "learn": - switch (pathArray.length) { - case 1: - presenceData.details = "At the dashboard"; - break; - case 2: - presenceData.details = "Looking at a course"; - presenceData.state = `"${ - document.querySelector("main h1").textContent - }"`; - presenceData.smallImageKey = - assets[ - document - .querySelector("main h1") - .textContent.split(" ") - .slice(1) - .join(" ") - .toLowerCase() - .replace(" ", "_") - .replace("+", "plus") - .replace("#", "sharp") - ]; - presenceData.smallImageText = document - .querySelector("main h1") - .textContent.split(" ") - .slice(1) - .join(" "); - break; - case 3: - presenceData.details = "Looking at a path"; - presenceData.state = `"${ - document.querySelector("[class^=goalHeader__]") - ? document - .querySelector("main h1") - .textContent.slice( - document.querySelector("[class^=goalHeader__]").textContent - .length - ) - : document.querySelector("main h1").textContent - }"`; - break; - case 4: - presenceData.details = "Looking at a course module"; - presenceData.state = `"${ - document.querySelector("main h1").textContent - }"`; - } - break; - case "courses": - case "paths": - premiumPath = false; - if (heading.className.startsWith("trackTitle__")) premiumPath = true; - heading = heading.textContent; - if (pathArray[0] === "courses" && heading.startsWith("Learn ")) { - presenceData.smallImageKey = - assets[ - heading - .split(" ") - .slice(1) - .join(" ") - .toLowerCase() - .replace(" ", "_") - .replace("+", "plus") - .replace("#", "sharp") - ]; - presenceData.smallImageText = heading.split(" ").slice(1).join(" "); - } - presenceData.details = heading.startsWith("Learn ") - ? `Learning ${heading.split(" ").slice(1).join(" ")}` - : premiumPath - ? "Looking at a path" - : heading; - if (videoTitle) { - presenceData.details = "Watching a video"; - presenceData.state = videoTitle; - presenceData.smallImageKey = videoPaused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = videoPaused - ? (await strings).pause - : (await strings).play; - if (videoDuration && !videoPaused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(videoDuration, videoCurrentTime); - } - } else { - presenceData.startTimestamp = start; - const bodyHeading = document.querySelector( - "[class^=contentItemTitle__]" - ), - articleTitle = document.querySelector("[class^=articleTitle_]"); - if (bodyHeading) presenceData.state = bodyHeading.textContent; - if (articleTitle) { - presenceData.details = "Reading an article"; - presenceData.state = articleTitle.textContent; - } - if (premiumPath) { - presenceData.state = heading; - delete presenceData.startTimestamp; - } - } - presenceData.state = `"${presenceData.state}"`; - break; - case "login": - presenceData.details = "Logging in"; - break; - case "register": - presenceData.details = "Registering"; - break; - case "catalog": - if (pathArray[1] === "language") { - presenceData.details = `Looking at ${ - document.querySelector("#catalog-heading").textContent - }`; - presenceData.state = "in the catalog"; - presenceData.smallImageKey = - assets[ - document - .querySelector("#catalog-heading") - .textContent.toLowerCase() - .replace(" ", "_") - .replace("+", "plus") - .replace("#", "sharp") - ]; - presenceData.smallImageText = - document.querySelector("#catalog-heading").textContent; - } else if (pathArray[1] === "subject") { - presenceData.details = "Looking at a subject"; - presenceData.state = `"${ - document.querySelector("#catalog-heading").textContent - }"`; - } else { - presenceData.details = "Browsing the catalog"; - presenceData.state = "of available languages"; - } - break; - case "subscriptions": - presenceData.details = "Considering the PRO"; - presenceData.state = "subscription"; - break; - case "explore": - presenceData.details = "Exploring..."; - break; - case "": - if (window.location.hostname === "news.codecademy.com") - presenceData.details = "Browsing articles"; - else presenceData.details = "At the homepage"; + switch (pathArray[0]) { + case 'learn': + switch (pathArray.length) { + case 1: + presenceData.details = 'At the dashboard' + break + case 2: + presenceData.details = 'Looking at a course' + presenceData.state = `"${ + document.querySelector('main h1')?.textContent + }"` + presenceData.smallImageKey = assets[ + document + .querySelector('main h1') + ?.textContent + ?.split(' ') + ?.slice(1) + ?.join(' ') + ?.toLowerCase() + ?.replace(' ', '_') + ?.replace('+', 'plus') + ?.replace('#', 'sharp') ?? '' + ] + presenceData.smallImageText = document + .querySelector('main h1') + ?.textContent + ?.split(' ') + ?.slice(1) + ?.join(' ') + break + case 3: + presenceData.details = 'Looking at a path' + presenceData.state = `"${ + document.querySelector('[class^=goalHeader__]') + ? document + .querySelector('main h1') + ?.textContent + ?.slice( + document.querySelector('[class^=goalHeader__]')?.textContent?.length, + ) + : document.querySelector('main h1')?.textContent + }"` + break + case 4: + presenceData.details = 'Looking at a course module' + presenceData.state = `"${ + document.querySelector('main h1')?.textContent + }"` + } + break + case 'courses': + case 'paths': + premiumPath = false + if (heading.className.startsWith('trackTitle__')) + premiumPath = true + heading = heading.textContent! + if (pathArray[0] === 'courses' && heading.startsWith('Learn ')) { + presenceData.smallImageKey = assets[ + heading + .split(' ') + .slice(1) + .join(' ') + .toLowerCase() + .replace(' ', '_') + .replace('+', 'plus') + .replace('#', 'sharp') + ] + presenceData.smallImageText = heading.split(' ').slice(1).join(' ') + } + presenceData.details = heading.startsWith('Learn ') + ? `Learning ${heading.split(' ').slice(1).join(' ')}` + : premiumPath + ? 'Looking at a path' + : heading + if (videoTitle) { + presenceData.details = 'Watching a video' + presenceData.state = videoTitle + presenceData.smallImageKey = videoPaused ? Assets.Pause : Assets.Play + presenceData.smallImageText = videoPaused + ? (await strings).pause + : (await strings).play + if (videoDuration && !videoPaused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(videoDuration, videoCurrentTime) + } + } + else { + presenceData.startTimestamp = start + const bodyHeading = document.querySelector( + '[class^=contentItemTitle__]', + ) + const articleTitle = document.querySelector('[class^=articleTitle_]') + if (bodyHeading) + presenceData.state = bodyHeading.textContent + if (articleTitle) { + presenceData.details = 'Reading an article' + presenceData.state = articleTitle.textContent + } + if (premiumPath) { + presenceData.state = heading + delete presenceData.startTimestamp + } + } + presenceData.state = `"${presenceData.state}"` + break + case 'login': + presenceData.details = 'Logging in' + break + case 'register': + presenceData.details = 'Registering' + break + case 'catalog': + if (pathArray[1] === 'language') { + presenceData.details = `Looking at ${ + document.querySelector('#catalog-heading')?.textContent + }` + presenceData.state = 'in the catalog' + presenceData.smallImageKey = assets[ + document + .querySelector('#catalog-heading')!.textContent!.toLowerCase() + .replace(' ', '_') + .replace('+', 'plus') + .replace('#', 'sharp') + ] + presenceData.smallImageText = document.querySelector('#catalog-heading')?.textContent + } + else if (pathArray[1] === 'subject') { + presenceData.details = 'Looking at a subject' + presenceData.state = `"${ + document.querySelector('#catalog-heading')?.textContent + }"` + } + else { + presenceData.details = 'Browsing the catalog' + presenceData.state = 'of available languages' + } + break + case 'subscriptions': + presenceData.details = 'Considering the PRO' + presenceData.state = 'subscription' + break + case 'explore': + presenceData.details = 'Exploring...' + break + case '': + if (window.location.hostname === 'news.codecademy.com') + presenceData.details = 'Browsing articles' + else presenceData.details = 'At the homepage' - break; - case "pricing": - presenceData.details = "Checking out the"; - presenceData.state = "paid plans"; - break; - case "business": - presenceData.details = "Checking out the"; - presenceData.state = "bussiness plans"; - break; - case "articles": - if (pathArray[1]) { - presenceData.details = "Reading an article"; - presenceData.state = `"${ - document.querySelector("[class^=articleHeader__]").textContent - }"`; - } else presenceData.details = "Browsing articles"; + break + case 'pricing': + presenceData.details = 'Checking out the' + presenceData.state = 'paid plans' + break + case 'business': + presenceData.details = 'Checking out the' + presenceData.state = 'bussiness plans' + break + case 'articles': + if (pathArray[1]) { + presenceData.details = 'Reading an article' + presenceData.state = `"${ + document.querySelector('[class^=articleHeader__]')?.textContent + }"` + } + else { + presenceData.details = 'Browsing articles' + } - break; - default: - if (window.location.hostname === "news.codecademy.com") { - presenceData.details = "Reading an article"; - presenceData.state = `"${ - document.querySelector(".post-full-title").textContent - }"`; - } else presenceData.details = "Idle"; - break; - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + break + default: + if (window.location.hostname === 'news.codecademy.com') { + presenceData.details = 'Reading an article' + presenceData.state = `"${ + document.querySelector('.post-full-title')?.textContent + }"` + } + else { + presenceData.details = 'Idle' + } + break + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/Codeforces/metadata.json b/websites/C/Codeforces/metadata.json index e8ad9043b873..92a893ab5a45 100644 --- a/websites/C/Codeforces/metadata.json +++ b/websites/C/Codeforces/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Palskie", - "id": "90431685472038912" - }, - "service": "Codeforces", - "description": { - "en": "Codeforces is a website that hosts competitive programming contests.", - "vi_VN": "Codeforces là trang web tổ chức các cuộc thi lập trình." - }, - "url": "codeforces.com", - "version": "1.0.20", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Codeforces/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Codeforces/assets/thumbnail.png", - "color": "#1381f6", - "category": "other", - "tags": [ - "coding", - "competition", - "education", - "technology" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Palskie", + "id": "90431685472038912" + }, + "service": "Codeforces", + "description": { + "en": "Codeforces is a website that hosts competitive programming contests.", + "vi_VN": "Codeforces là trang web tổ chức các cuộc thi lập trình." + }, + "url": "codeforces.com", + "version": "1.0.20", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Codeforces/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Codeforces/assets/thumbnail.png", + "color": "#1381f6", + "category": "other", + "tags": [ + "coding", + "competition", + "education", + "technology" + ] +} diff --git a/websites/C/Codeforces/presence.ts b/websites/C/Codeforces/presence.ts index 3cd84df9746a..483e68f28e1e 100644 --- a/websites/C/Codeforces/presence.ts +++ b/websites/C/Codeforces/presence.ts @@ -1,375 +1,440 @@ const presence = new Presence({ - clientId: "842486883128705024", - }), - path = location.pathname, - timeElapsed = ~~(Date.now() / 1000); + clientId: '842486883128705024', +}) +const path = location.pathname +const timeElapsed = ~~(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Codeforces/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Codeforces/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: timeElapsed, - }; - - switch (path.split("/")[1]) { - case "top": { - presenceData.details = "Browsing through"; - presenceData.state = "Top Recent Blog Posts"; - break; - } - - case "topComments": { - presenceData.details = "Browsing through"; - presenceData.state = "Top Comments"; - break; - } - - case "blog": { - if (path.includes("new")) presenceData.details = "Creating a new blog"; - else if (path.includes("entry")) { - presenceData.details = - document.querySelector(".title > a > p").textContent; - presenceData.state = `By ${ - document.querySelector(".info > a").textContent - }`; - presenceData.smallImageKey = Assets.Reading; - } else { - presenceData.details = "Browsing through"; - presenceData.state = document - .querySelector("#pageContent") - .lastElementChild.querySelector("div > h3").textContent; - } - - break; - } - - case "contests": { - if (path.includes("with")) { - presenceData.details = "Viewing"; - presenceData.state = `Participated contest of ${path.split("/")[3]}`; - } else if (path.includes("writer")) { - presenceData.details = "Viewing Problemsetting"; - presenceData.state = `Contests of ${path.split("/")[3]}`; - } else if (!location.pathname.split("/")[2]) { - presenceData.details = "Browsing through"; - presenceData.state = "Upcoming contests and Past contests"; - } else { - presenceData.details = "Waiting for contest"; - presenceData.state = document.title.split("-")[0].trim(); - } - break; - } - - case "contestRegistration": { - presenceData.details = "Registering for"; - presenceData.state = - document.querySelector("#pageContent > h2").textContent; - break; - } - - case "contestRegistrants": { - presenceData.details = "Viewing Registrants for"; - presenceData.state = document.title.split("-")[1].trim(); - break; - } - - case "contest": { - const contestTitle = document.querySelector(".left").textContent; - - presenceData.details = "Viewing Contest"; - presenceData.state = contestTitle; - - if (path.includes("problem")) { - presenceData.details = contestTitle; - presenceData.state = document.querySelector(".title").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Solving"; - } else if (path.includes("submit")) - presenceData.details = "Submitting Solution for"; - else if (path.includes("my")) - presenceData.details = "Viewing their submissions"; - else if (path.includes("status")) - presenceData.details = "Viewing Contest Status"; - else if (path.includes("hacks")) presenceData.details = "Viewing Hacks"; - else if (path.includes("room")) { - const [room, contestTitle] = document.title.split("-"); - - presenceData.details = "Viewing Room"; - presenceData.state = `${room.trim()} | ${contestTitle.trim()}`; - } else if (path.includes("standings")) { - presenceData.details = "Viewing Final Standings"; - presenceData.state = document.title.split("-")[1].trim(); - } else if (path.includes("ratings")) { - presenceData.details = "Viewing Rating Changes"; - presenceData.state = document - .querySelector(".title") - .textContent.trim(); - } else if (path.includes("participant")) { - presenceData.details = `Viewing ${path.split("/")[4]}'s submissions`; - presenceData.state = document.querySelector(".left").textContent; - } else if (path.includes("submission")) { - presenceData.details = "Viewing Submission"; - delete presenceData.state; - } else if (path.includes("customtest")) { - presenceData.details = "Performing Custom Test"; - delete presenceData.state; - } - break; - } - - case "gym": { - const gymTitle = document.querySelector(".left").textContent; - - presenceData.details = "Viewing Gym"; - presenceData.state = gymTitle; - - if (path.includes("problem")) { - presenceData.details = gymTitle; - presenceData.state = document.querySelector(".title").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Solving"; - } else if (path.includes("submit")) - presenceData.details = "Submitting Solution for"; - else if (path.includes("my")) - presenceData.details = "Viewing their submissions"; - else if (path.includes("status")) - presenceData.details = "Viewing Contest Status"; - else if (path.includes("standings")) { - presenceData.details = "Viewing Final Standings"; - presenceData.state = document.title.split("-")[1].trim(); - } else if (path.includes("customtest")) { - presenceData.details = "Performing Custom Test"; - delete presenceData.state; - } - break; - } - - case "gyms": { - presenceData.details = "Viewing"; - presenceData.state = "Gyms"; - break; - } - - case "mashups": { - presenceData.details = "Viewing"; - presenceData.state = "Mashups"; - break; - } - - case "problemset": { - presenceData.details = "Browsing through"; - presenceData.state = "Problem Sets"; - - if (path.includes("problem")) { - presenceData.details = document.querySelector(".left").textContent; - presenceData.state = document.querySelector(".title").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Solving"; - } else if (path.includes("submit")) { - presenceData.details = "Submitting Solution for"; - presenceData.state = `${document - .querySelector(".table-form > tbody > tr") - .lastElementChild.textContent.trim()} | ${document - .querySelector("#pageContent") - .childNodes[5].textContent.trim()}`; - } else if (path.includes("status")) { - presenceData.details = "Viewing"; - presenceData.state = "Contest Status"; - } else if (path.includes("standings")) { - presenceData.details = "Viewing"; - presenceData.state = "Standings"; - } else if (path.includes("customtest")) { - presenceData.details = "Performing Custom Test"; - delete presenceData.state; - } - break; - } - - case "group": { - const groupTitle = document.querySelector(".left").textContent; - - if (path.includes("contests")) { - presenceData.details = "Viewing Group Contest"; - presenceData.state = groupTitle; - } else if (path.includes("members")) { - presenceData.details = "Viewing Group members"; - presenceData.state = `in ${groupTitle}`; - } else if (path.includes("problem")) { - presenceData.details = groupTitle; - presenceData.state = document.querySelector(".title").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Solving"; - } else if (path.includes("submit")) { - presenceData.details = "Submitting Solution for"; - presenceData.state = `Gym: ${groupTitle}`; - } else if (path.includes("my")) { - presenceData.details = "Viewing their submissions"; - presenceData.state = `Gym: ${groupTitle}`; - } else if (path.includes("status")) { - presenceData.details = "Viewing Contest Status"; - presenceData.state = `Gym: ${groupTitle}`; - } else if (path.includes("standings")) { - presenceData.details = "Viewing Final Standings"; - presenceData.state = document.title.split("-")[1].trim(); - } else if (path.includes("customtest")) - presenceData.details = "Performing Custom Test"; - else if (path.includes("contest")) { - presenceData.details = `Group Contest: ${groupTitle}`; - presenceData.state = document.title.split("-")[1].trim(); - } - break; - } - - case "groups": { - presenceData.details = "Browsing through"; - presenceData.state = "groups"; - - if (path.includes("create")) { - presenceData.details = "Creating new a group"; - delete presenceData.state; - } - break; - } - - case "ratings": { - presenceData.details = "Browsing through"; - presenceData.state = "Ratings"; - - if (path.includes("all")) presenceData.state = "Ratings (all)"; - else if (path.includes("friends")) { - presenceData.details = "Browsing through their"; - presenceData.state = "friends rating"; - } else if (path.includes("country")) - presenceData.state = "country ratings"; - else if (path.includes("organization")) - presenceData.state = "organization ratings"; - - break; - } - - case "edu": { - presenceData.details = "Viewing"; - presenceData.state = "Edu (Courses)"; - - if (path.includes("problem")) { - presenceData.details = document - .querySelector(".eduCoursePath") - .textContent.trim(); - presenceData.state = document.querySelector(".title").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Solving"; - } else if (path.includes("submit")) { - presenceData.details = "Submitting Solution for"; - presenceData.state = document - .querySelector(".eduCoursePath") - .textContent.trim(); - } else if (path.includes("status")) { - presenceData.details = "Viewing Submissions in"; - presenceData.state = `${document - .querySelector(".eduLessonPath") - .textContent.trim()} | ${document - .querySelector(".eduCoursePath") - .textContent.trim()}`; - } else if (path.includes("hacks")) { - presenceData.details = "Viewing hacks in"; - presenceData.state = `${document - .querySelector(".eduLessonPath") - .textContent.trim()} | ${document - .querySelector(".eduCoursePath") - .textContent.trim()}`; - } else if (path.includes("standings")) { - presenceData.details = "Viewing Final Standings in"; - presenceData.state = `${document - .querySelector(".eduLessonPath") - .textContent.trim()} | ${document - .querySelector(".eduCoursePath") - .textContent.trim()}`; - } else if (path.includes("customtest")) { - presenceData.details = "Performing Custom Test"; - delete presenceData.state; - } else if (path.includes("practice")) { - presenceData.details = "Viewing Edu practice"; - presenceData.state = document.title.split("-")[1].trim(); - } else if (path.includes("lesson")) { - presenceData.details = "Taking a lesson"; - presenceData.state = document - .querySelector(".eduLessonPath") - .textContent.trim(); - presenceData.smallImageKey = Assets.Reading; - } else if (path.split("/")[2] === "courses") { - presenceData.details = "Browsing through"; - presenceData.state = "Edu (Courses)"; - } - - break; - } - - case "apiHelp": { - presenceData.details = "Reading"; - presenceData.state = "API Help"; - presenceData.smallImageKey = Assets.Reading; - break; - } - - case "calendar": { - presenceData.details = "Viewing"; - presenceData.state = "Calendar"; - break; - } - - case "help": { - presenceData.details = "Viewing"; - presenceData.state = "Help"; - break; - } - - case "profile": { - presenceData.details = "Viewing profile"; - presenceData.state = document.title.split("-")[0].trim(); - break; - } - - case "settings": { - presenceData.details = "Editing their settings"; - break; - } - - case "lists": { - presenceData.details = "Viewing their lists"; - - if (path.includes("new")) presenceData.details = "Creating a new list"; - break; - } - - case "submissions": { - presenceData.details = "Viewing"; - presenceData.state = `${path.split("/")[2]}'s submissions`; - break; - } - - case "favourite": { - presenceData.details = "Browsing through their"; - - if (path.includes("blogEntries")) presenceData.state = "favorite blogs"; - else if (path.includes("comments")) - presenceData.state = "favorite blog comments"; - else if (path.includes("problems")) - presenceData.state = "favorite problems"; - else if (path.includes("contest")) - presenceData.state = "favorite contests"; - else if (path.includes("groups")) presenceData.state = "favorite groups"; - break; - } - - default: { - presenceData.details = "Viewing home page"; - break; - } - } - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: timeElapsed, + } + + switch (path.split('/')[1]) { + case 'top': { + presenceData.details = 'Browsing through' + presenceData.state = 'Top Recent Blog Posts' + break + } + + case 'topComments': { + presenceData.details = 'Browsing through' + presenceData.state = 'Top Comments' + break + } + + case 'blog': { + if (path.includes('new')) { + presenceData.details = 'Creating a new blog' + } + else if (path.includes('entry')) { + presenceData.details = document.querySelector('.title > a > p')?.textContent + presenceData.state = `By ${ + document.querySelector('.info > a')?.textContent + }` + presenceData.smallImageKey = Assets.Reading + } + else { + presenceData.details = 'Browsing through' + presenceData.state = document + .querySelector('#pageContent') + ?.lastElementChild + ?.querySelector('div > h3') + ?.textContent + } + + break + } + + case 'contests': { + if (path.includes('with')) { + presenceData.details = 'Viewing' + presenceData.state = `Participated contest of ${path.split('/')[3]}` + } + else if (path.includes('writer')) { + presenceData.details = 'Viewing Problemsetting' + presenceData.state = `Contests of ${path.split('/')[3]}` + } + else if (!location.pathname.split('/')[2]) { + presenceData.details = 'Browsing through' + presenceData.state = 'Upcoming contests and Past contests' + } + else { + presenceData.details = 'Waiting for contest' + presenceData.state = document.title.split('-')[0].trim() + } + break + } + + case 'contestRegistration': { + presenceData.details = 'Registering for' + presenceData.state = document.querySelector('#pageContent > h2')?.textContent + break + } + + case 'contestRegistrants': { + presenceData.details = 'Viewing Registrants for' + presenceData.state = document.title.split('-')[1].trim() + break + } + + case 'contest': { + const contestTitle = document.querySelector('.left')?.textContent + + presenceData.details = 'Viewing Contest' + presenceData.state = contestTitle + + if (path.includes('problem')) { + presenceData.details = contestTitle + presenceData.state = document.querySelector('.title')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Solving' + } + else if (path.includes('submit')) { + presenceData.details = 'Submitting Solution for' + } + else if (path.includes('my')) { + presenceData.details = 'Viewing their submissions' + } + else if (path.includes('status')) { + presenceData.details = 'Viewing Contest Status' + } + else if (path.includes('hacks')) { + presenceData.details = 'Viewing Hacks' + } + else if (path.includes('room')) { + const [room, contestTitle] = document.title.split('-') + + presenceData.details = 'Viewing Room' + presenceData.state = `${room.trim()} | ${contestTitle.trim()}` + } + else if (path.includes('standings')) { + presenceData.details = 'Viewing Final Standings' + presenceData.state = document.title.split('-')[1].trim() + } + else if (path.includes('ratings')) { + presenceData.details = 'Viewing Rating Changes' + presenceData.state = document + .querySelector('.title') + ?.textContent + ?.trim() + } + else if (path.includes('participant')) { + presenceData.details = `Viewing ${path.split('/')[4]}'s submissions` + presenceData.state = document.querySelector('.left')?.textContent + } + else if (path.includes('submission')) { + presenceData.details = 'Viewing Submission' + delete presenceData.state + } + else if (path.includes('customtest')) { + presenceData.details = 'Performing Custom Test' + delete presenceData.state + } + break + } + + case 'gym': { + const gymTitle = document.querySelector('.left')?.textContent + + presenceData.details = 'Viewing Gym' + presenceData.state = gymTitle + + if (path.includes('problem')) { + presenceData.details = gymTitle + presenceData.state = document.querySelector('.title')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Solving' + } + else if (path.includes('submit')) { + presenceData.details = 'Submitting Solution for' + } + else if (path.includes('my')) { + presenceData.details = 'Viewing their submissions' + } + else if (path.includes('status')) { + presenceData.details = 'Viewing Contest Status' + } + else if (path.includes('standings')) { + presenceData.details = 'Viewing Final Standings' + presenceData.state = document.title.split('-')[1].trim() + } + else if (path.includes('customtest')) { + presenceData.details = 'Performing Custom Test' + delete presenceData.state + } + break + } + + case 'gyms': { + presenceData.details = 'Viewing' + presenceData.state = 'Gyms' + break + } + + case 'mashups': { + presenceData.details = 'Viewing' + presenceData.state = 'Mashups' + break + } + + case 'problemset': { + presenceData.details = 'Browsing through' + presenceData.state = 'Problem Sets' + + if (path.includes('problem')) { + presenceData.details = document.querySelector('.left')?.textContent + presenceData.state = document.querySelector('.title')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Solving' + } + else if (path.includes('submit')) { + presenceData.details = 'Submitting Solution for' + presenceData.state = `${document + .querySelector('.table-form > tbody > tr') + ?.lastElementChild + ?.textContent + ?.trim()} | ${document + .querySelector('#pageContent') + ?.childNodes[5] + ?.textContent + ?.trim()}` + } + else if (path.includes('status')) { + presenceData.details = 'Viewing' + presenceData.state = 'Contest Status' + } + else if (path.includes('standings')) { + presenceData.details = 'Viewing' + presenceData.state = 'Standings' + } + else if (path.includes('customtest')) { + presenceData.details = 'Performing Custom Test' + delete presenceData.state + } + break + } + + case 'group': { + const groupTitle = document.querySelector('.left')?.textContent + + if (path.includes('contests')) { + presenceData.details = 'Viewing Group Contest' + presenceData.state = groupTitle + } + else if (path.includes('members')) { + presenceData.details = 'Viewing Group members' + presenceData.state = `in ${groupTitle}` + } + else if (path.includes('problem')) { + presenceData.details = groupTitle + presenceData.state = document.querySelector('.title')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Solving' + } + else if (path.includes('submit')) { + presenceData.details = 'Submitting Solution for' + presenceData.state = `Gym: ${groupTitle}` + } + else if (path.includes('my')) { + presenceData.details = 'Viewing their submissions' + presenceData.state = `Gym: ${groupTitle}` + } + else if (path.includes('status')) { + presenceData.details = 'Viewing Contest Status' + presenceData.state = `Gym: ${groupTitle}` + } + else if (path.includes('standings')) { + presenceData.details = 'Viewing Final Standings' + presenceData.state = document.title.split('-')[1].trim() + } + else if (path.includes('customtest')) { + presenceData.details = 'Performing Custom Test' + } + else if (path.includes('contest')) { + presenceData.details = `Group Contest: ${groupTitle}` + presenceData.state = document.title.split('-')[1].trim() + } + break + } + + case 'groups': { + presenceData.details = 'Browsing through' + presenceData.state = 'groups' + + if (path.includes('create')) { + presenceData.details = 'Creating new a group' + delete presenceData.state + } + break + } + + case 'ratings': { + presenceData.details = 'Browsing through' + presenceData.state = 'Ratings' + + if (path.includes('all')) { + presenceData.state = 'Ratings (all)' + } + else if (path.includes('friends')) { + presenceData.details = 'Browsing through their' + presenceData.state = 'friends rating' + } + else if (path.includes('country')) { + presenceData.state = 'country ratings' + } + else if (path.includes('organization')) { + presenceData.state = 'organization ratings' + } + + break + } + + case 'edu': { + presenceData.details = 'Viewing' + presenceData.state = 'Edu (Courses)' + + if (path.includes('problem')) { + presenceData.details = document + .querySelector('.eduCoursePath') + ?.textContent + ?.trim() + presenceData.state = document.querySelector('.title')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Solving' + } + else if (path.includes('submit')) { + presenceData.details = 'Submitting Solution for' + presenceData.state = document + .querySelector('.eduCoursePath') + ?.textContent + ?.trim() + } + else if (path.includes('status')) { + presenceData.details = 'Viewing Submissions in' + presenceData.state = `${document + .querySelector('.eduLessonPath') + ?.textContent + ?.trim()} | ${document + .querySelector('.eduCoursePath') + ?.textContent + ?.trim()}` + } + else if (path.includes('hacks')) { + presenceData.details = 'Viewing hacks in' + presenceData.state = `${document + .querySelector('.eduLessonPath') + ?.textContent + ?.trim()} | ${document + .querySelector('.eduCoursePath') + ?.textContent + ?.trim()}` + } + else if (path.includes('standings')) { + presenceData.details = 'Viewing Final Standings in' + presenceData.state = `${document + .querySelector('.eduLessonPath') + ?.textContent + ?.trim()} | ${document + .querySelector('.eduCoursePath') + ?.textContent + ?.trim()}` + } + else if (path.includes('customtest')) { + presenceData.details = 'Performing Custom Test' + delete presenceData.state + } + else if (path.includes('practice')) { + presenceData.details = 'Viewing Edu practice' + presenceData.state = document.title.split('-')[1].trim() + } + else if (path.includes('lesson')) { + presenceData.details = 'Taking a lesson' + presenceData.state = document + .querySelector('.eduLessonPath') + ?.textContent + ?.trim() + presenceData.smallImageKey = Assets.Reading + } + else if (path.split('/')[2] === 'courses') { + presenceData.details = 'Browsing through' + presenceData.state = 'Edu (Courses)' + } + + break + } + + case 'apiHelp': { + presenceData.details = 'Reading' + presenceData.state = 'API Help' + presenceData.smallImageKey = Assets.Reading + break + } + + case 'calendar': { + presenceData.details = 'Viewing' + presenceData.state = 'Calendar' + break + } + + case 'help': { + presenceData.details = 'Viewing' + presenceData.state = 'Help' + break + } + + case 'profile': { + presenceData.details = 'Viewing profile' + presenceData.state = document.title.split('-')[0].trim() + break + } + + case 'settings': { + presenceData.details = 'Editing their settings' + break + } + + case 'lists': { + presenceData.details = 'Viewing their lists' + + if (path.includes('new')) + presenceData.details = 'Creating a new list' + break + } + + case 'submissions': { + presenceData.details = 'Viewing' + presenceData.state = `${path.split('/')[2]}'s submissions` + break + } + + case 'favourite': { + presenceData.details = 'Browsing through their' + + if (path.includes('blogEntries')) + presenceData.state = 'favorite blogs' + else if (path.includes('comments')) + presenceData.state = 'favorite blog comments' + else if (path.includes('problems')) + presenceData.state = 'favorite problems' + else if (path.includes('contest')) + presenceData.state = 'favorite contests' + else if (path.includes('groups')) + presenceData.state = 'favorite groups' + break + } + + default: { + presenceData.details = 'Viewing home page' + break + } + } + + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/Codenames/metadata.json b/websites/C/Codenames/metadata.json index d97c813be788..ad0910c95cd7 100644 --- a/websites/C/Codenames/metadata.json +++ b/websites/C/Codenames/metadata.json @@ -1,34 +1,34 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "Codenames", - "description": { - "en": "The two rival spymasters know the secret identities of 25 agents. Their teammates know the agents only by their CODENAMES. The teams compete to see who can make contact with all of their agents first. Spymasters give one-word clues that can point to multiple words on the board. Their teammates try to guess words of the right color while avoiding those that belong to the opposing team.", - "nl": "Twee spymasters is verschillende teams kennen de geheime identiteiten van 25 agents. Hun teamgenoten weten alleen hun CODENAMES. De teams strijden om te zien wie als eerst contact kan leggen met hun agents. Spymasters geven hints van één woord die op meerdere codenames op het bord kunnen wijzen. Hun teamgenoten proberen de woorden van de juiste kleur te raden, maar de agents van de tegenstanders te vermijden.", - "vi_VN": "Hai tổ chức mật thám kình địch biết danh tính của 25 đặc vụ. Các đồng đội của họ chỉ biết đến nhau qua biệt danh. Các đội tranh đấu để xem các có thể liên lạc được với tất cả các đặc vụ của họ trước. Các tổ chức mật thám được phép đưa ra một từ gợi ý trên bàn đấu. Các thành viên trong đội phải đoán các từ thuộc đúng màu trong khi tránh các từ của đối phương." - }, - "url": "codenames.game", - "version": "1.0.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/thumbnail.jpg", - "color": "#fcd611", - "category": "games", - "tags": [ - "spymasters", - "agents", - "operatives", - "boardgame" - ], - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "Codenames", + "description": { + "en": "The two rival spymasters know the secret identities of 25 agents. Their teammates know the agents only by their CODENAMES. The teams compete to see who can make contact with all of their agents first. Spymasters give one-word clues that can point to multiple words on the board. Their teammates try to guess words of the right color while avoiding those that belong to the opposing team.", + "nl": "Twee spymasters is verschillende teams kennen de geheime identiteiten van 25 agents. Hun teamgenoten weten alleen hun CODENAMES. De teams strijden om te zien wie als eerst contact kan leggen met hun agents. Spymasters geven hints van één woord die op meerdere codenames op het bord kunnen wijzen. Hun teamgenoten proberen de woorden van de juiste kleur te raden, maar de agents van de tegenstanders te vermijden.", + "vi_VN": "Hai tổ chức mật thám kình địch biết danh tính của 25 đặc vụ. Các đồng đội của họ chỉ biết đến nhau qua biệt danh. Các đội tranh đấu để xem các có thể liên lạc được với tất cả các đặc vụ của họ trước. Các tổ chức mật thám được phép đưa ra một từ gợi ý trên bàn đấu. Các thành viên trong đội phải đoán các từ thuộc đúng màu trong khi tránh các từ của đối phương." + }, + "url": "codenames.game", + "version": "1.0.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/thumbnail.jpg", + "color": "#fcd611", + "category": "games", + "tags": [ + "spymasters", + "agents", + "operatives", + "boardgame" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": false + } + ] +} diff --git a/websites/C/Codenames/presence.ts b/websites/C/Codenames/presence.ts index 4f6112f28caa..951c6ad1de4d 100644 --- a/websites/C/Codenames/presence.ts +++ b/websites/C/Codenames/presence.ts @@ -1,232 +1,252 @@ -type availableColors = "red" | "blue" | "beige"; +type availableColors = 'red' | 'blue' | 'beige' const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/logo.png", - Beige5 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/0.png", - Red6 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/1.png", - Blue1 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/2.png", - Red8 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/3.png", - Red4 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/4.png", - Beige3 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/5.png", - Blue4 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/6.png", - Codenames = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/7.png", - Blue8 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/8.png", - Blue5 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/9.png", - Blue9 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/10.png", - Beige2 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/11.png", - Blue7 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/12.png", - Blue6 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/13.png", - Blue2 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/14.png", - Blue3 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/15.png", - Red9 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/16.png", - Beige4 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/17.png", - Beige6 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/18.png", - Red5 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/19.png", - Red2 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/20.png", - Red7 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/21.png", - Red1 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/22.png", - Red3 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/23.png", - Beige1 = "https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/24.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/logo.png', + Beige5 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/0.png', + Red6 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/1.png', + Blue1 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/2.png', + Red8 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/3.png', + Red4 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/4.png', + Beige3 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/5.png', + Blue4 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/6.png', + Codenames = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/7.png', + Blue8 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/8.png', + Blue5 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/9.png', + Blue9 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/10.png', + Beige2 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/11.png', + Blue7 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/12.png', + Blue6 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/13.png', + Blue2 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/14.png', + Blue3 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/15.png', + Red9 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/16.png', + Beige4 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/17.png', + Beige6 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/18.png', + Red5 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/19.png', + Red2 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/20.png', + Red7 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/21.png', + Red1 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/22.png', + Red3 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/23.png', + Beige1 = 'https://cdn.rcd.gg/PreMiD/websites/C/Codenames/assets/24.png', } const presence = new Presence({ - clientId: "817859401477259315", - }), - slideshow = presence.createSlideshow(), - icons = { - red: [ - Assets.Red1, - Assets.Red2, - Assets.Red3, - Assets.Red4, - Assets.Red5, - Assets.Red6, - Assets.Red7, - Assets.Red8, - Assets.Red9, - ], - blue: [ - Assets.Blue1, - Assets.Blue2, - Assets.Blue3, - Assets.Blue4, - Assets.Blue5, - Assets.Blue6, - Assets.Blue7, - Assets.Blue8, - Assets.Blue9, - ], - beige: [ - Assets.Beige1, - Assets.Beige2, - Assets.Beige3, - Assets.Beige4, - Assets.Beige5, - Assets.Beige6, - ], - }; + clientId: '817859401477259315', +}) +const slideshow = presence.createSlideshow() +const icons = { + red: [ + Assets.Red1, + Assets.Red2, + Assets.Red3, + Assets.Red4, + Assets.Red5, + Assets.Red6, + Assets.Red7, + Assets.Red8, + Assets.Red9, + ], + blue: [ + Assets.Blue1, + Assets.Blue2, + Assets.Blue3, + Assets.Blue4, + Assets.Blue5, + Assets.Blue6, + Assets.Blue7, + Assets.Blue8, + Assets.Blue9, + ], + beige: [ + Assets.Beige1, + Assets.Beige2, + Assets.Beige3, + Assets.Beige4, + Assets.Beige5, + Assets.Beige6, + ], +} -let browsingTimestamp = Math.floor(Date.now() / 1000), - lastTeamLog: availableColors = "beige", - currentlySetColor: availableColors = "beige"; +let browsingTimestamp = Math.floor(Date.now() / 1000) +let lastTeamLog: availableColors = 'beige' +let currentlySetColor: availableColors = 'beige' -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } - const buttons = await presence.getSetting("buttons"); + const buttons = await presence.getSetting('buttons') - //* If in a game or not - if (document.querySelector("#gamescene")) { - if (buttons) { - presenceData.buttons = [ - { - label: "Join room", - url: document.URL, - }, - ]; - } - if (document.querySelector(".justify-start.items-center")) { - presenceData.details = "Waiting for game"; - presenceData.state = "to start..."; - if (lastTeamLog !== "beige") { - browsingTimestamp = Math.floor(Date.now() / 1000); - lastTeamLog = "beige"; - } - presenceData.startTimestamp = browsingTimestamp; - if (slideshow.getSlides().length) { - presence.info("Removing all cards from SlideShow."); - slideshow.deleteAllSlides(); - } - } else { - const logDataLength = - document.querySelector(".scrollTarget").children.length; - if (logDataLength) { - const team = document - .querySelector(".scrollTarget") - .children[logDataLength - 1].className.split("team-")[1] - .split(" ")[0] as availableColors; - if (team !== lastTeamLog) { - browsingTimestamp = Math.floor(Date.now() / 1000); - slideshow.deleteAllSlides(); - presence.info("Removing all cards from SlideShow."); - lastTeamLog = team; - } - } - presenceData.startTimestamp = browsingTimestamp; - const allCards = Array.from(document.querySelectorAll("section")).filter( - s => s.className?.includes("items-center") - ), - availableCards = Array.from(document.querySelectorAll("section")) - .filter(s => s.className?.includes("items-center")) - .filter(i => { - const style = i.parentElement.parentElement.style.transform; - if ( - Array.from(document.querySelectorAll(".coverToken")).find( - t => - (t as HTMLElement).style.transform.split("scale")[0] === - style.split("scale")[0] - ) - ) - return false; - else return true; - }), - foundCards = allCards.filter(x => !availableCards.includes(x)), - currentClueData = Array.from(document.querySelectorAll("div")).filter( - d => d.className?.includes("items-center text") - ), //Empty array if no clue, else [0] then its split into 2 divs 1 with clue other with amount - color = Array.from(document.querySelectorAll("button")) - .find(b => b.className?.includes("text-base color-")) - .attributes.getNamedItem("color").textContent as availableColors; + //* If in a game or not + if (document.querySelector('#gamescene')) { + if (buttons) { + presenceData.buttons = [ + { + label: 'Join room', + url: document.URL, + }, + ] + } + if (document.querySelector('.justify-start.items-center')) { + presenceData.details = 'Waiting for game' + presenceData.state = 'to start...' + if (lastTeamLog !== 'beige') { + browsingTimestamp = Math.floor(Date.now() / 1000) + lastTeamLog = 'beige' + } + presenceData.startTimestamp = browsingTimestamp + if (slideshow.getSlides().length) { + presence.info('Removing all cards from SlideShow.') + slideshow.deleteAllSlides() + } + } + else { + const logDataLength = document.querySelector('.scrollTarget')?.children.length + if (logDataLength) { + const team = document + .querySelector('.scrollTarget') + ?.children[logDataLength - 1] + ?.className + ?.split('team-')[1] + ?.split(' ')[0] as availableColors + if (team !== lastTeamLog) { + browsingTimestamp = Math.floor(Date.now() / 1000) + slideshow.deleteAllSlides() + presence.info('Removing all cards from SlideShow.') + lastTeamLog = team + } + } + presenceData.startTimestamp = browsingTimestamp + const allCards = Array.from(document.querySelectorAll('section')).filter( + s => s.className?.includes('items-center'), + ) + const availableCards = Array.from(document.querySelectorAll('section')) + .filter(s => s.className?.includes('items-center')) + .filter((i) => { + const style = i.parentElement?.parentElement?.style.transform + if ( + Array.from(document.querySelectorAll('.coverToken')).find( + t => + (t as HTMLElement).style.transform?.split('scale')[0] + === style?.split('scale')[0], + ) + ) { + return false + } + else { + return true + } + }) + const foundCards = allCards.filter(x => !availableCards.includes(x)) + const currentClueData = Array.from(document.querySelectorAll('div')).filter( + d => d.className?.includes('items-center text'), + ) // Empty array if no clue, else [0] then its split into 2 divs 1 with clue other with amount + const color = Array.from(document.querySelectorAll('button')) + ?.find(b => b.className?.includes('text-base color-')) + ?.attributes + ?.getNamedItem('color') + ?.textContent as availableColors - if (color !== currentlySetColor) { - slideshow.deleteAllSlides(); - presence.info("Removing all cards from SlideShow."); - currentlySetColor = color; - } + if (color !== currentlySetColor) { + slideshow.deleteAllSlides() + presence.info('Removing all cards from SlideShow.') + currentlySetColor = color + } - let randomInt = 0; - for (const [index, card] of availableCards.entries()) { - const name = card.textContent; - if (!slideshow.hasSlide(name)) { - presence.info(`Adding ${name} card to SlideShow.`); - if (randomInt > icons[color].length) randomInt = 0; - slideshow.addSlide( - name, - { - smallImageKey: icons[color][randomInt], - smallImageText: `Available cards: ${name} (${index + 1}/${ - availableCards.length - })`, - }, - 5000 - ); - randomInt++; - } - } - for (const card of foundCards) { - const name = card.textContent; - if (slideshow.hasSlide(name)) { - presence.info(`Removing ${name} card from SlideShow.`); - slideshow.deleteSlide(name); - } - } + let randomInt = 0 + for (const [index, card] of availableCards.entries()) { + const name = card.textContent! + if (!slideshow.hasSlide(name)) { + presence.info(`Adding ${name} card to SlideShow.`) + if (randomInt > icons[color].length) + randomInt = 0 + slideshow.addSlide( + name, + { + smallImageKey: icons[color][randomInt], + smallImageText: `Available cards: ${name} (${index + 1}/${ + availableCards.length + })`, + }, + 5000, + ) + randomInt++ + } + } + for (const card of foundCards) { + const name = card.textContent! + if (slideshow.hasSlide(name)) { + presence.info(`Removing ${name} card from SlideShow.`) + slideshow.deleteSlide(name) + } + } - presenceData = { ...presenceData, ...slideshow.currentSlide }; + presenceData = { ...presenceData, ...slideshow.currentSlide } - if (color === "beige") { - //* Spectating - if (currentClueData.length) { - presenceData.details = "Spectating... Current clue:"; - presenceData.state = `${currentClueData[0].firstElementChild.textContent} (Matches ${currentClueData[0].children[1].textContent} cards)`; - } else presenceData.details = "Spectating..."; - } else if (document.querySelector("input")) { - //* is spymaster and has to put in a clue rn - presenceData.details = "Giving a clue"; - presenceData.state = "to their operatives..."; - } else if (document.querySelector(".cursor-pointer")) { - //* their turn to guess the clue - presenceData.details = "Guessing clue:"; - presenceData.state = `${currentClueData[0].firstElementChild.textContent} (Matches ${currentClueData[0].children[1].textContent} cards)`; - } else if (currentClueData.length) { - //* waiting for clue to be guessed - presenceData.details = "Waiting for operatives to guess clue:"; - presenceData.state = `${currentClueData[0].firstElementChild.textContent} (Matches ${currentClueData[0].children[1].textContent} cards)`; - } else { - //* waiting for clue to be given - presenceData.details = "Waiting for spymaster(s)"; - presenceData.state = "to give clue..."; - } - } - } else { - presenceData.startTimestamp = browsingTimestamp; - if (slideshow.getSlides().length) { - presence.info("Removing all cards from SlideShow."); - slideshow.deleteAllSlides(); - } + if (color === 'beige') { + //* Spectating + if (currentClueData.length) { + presenceData.details = 'Spectating... Current clue:' + presenceData.state = `${currentClueData[0]?.firstElementChild?.textContent} (Matches ${currentClueData[0]?.children[1]?.textContent} cards)` + } + else { + presenceData.details = 'Spectating...' + } + } + else if (document.querySelector('input')) { + //* is spymaster and has to put in a clue rn + presenceData.details = 'Giving a clue' + presenceData.state = 'to their operatives...' + } + else if (document.querySelector('.cursor-pointer')) { + //* their turn to guess the clue + presenceData.details = 'Guessing clue:' + presenceData.state = `${currentClueData[0]?.firstElementChild?.textContent} (Matches ${currentClueData[0]?.children[1]?.textContent} cards)` + } + else if (currentClueData.length) { + //* waiting for clue to be guessed + presenceData.details = 'Waiting for operatives to guess clue:' + presenceData.state = `${currentClueData[0]?.firstElementChild?.textContent} (Matches ${currentClueData[0]?.children[1]?.textContent} cards)` + } + else { + //* waiting for clue to be given + presenceData.details = 'Waiting for spymaster(s)' + presenceData.state = 'to give clue...' + } + } + } + else { + presenceData.startTimestamp = browsingTimestamp + if (slideshow.getSlides().length) { + presence.info('Removing all cards from SlideShow.') + slideshow.deleteAllSlides() + } - if (document.location.pathname.includes("/room/create")) { - presenceData.details = "Creating a room..."; - if (buttons) { - presenceData.buttons = [ - { - label: "Join room", - url: document.URL, - }, - ]; - } - } else if (document.location.pathname.includes("/room/")) { - presenceData.details = "Joining a room..."; - if (buttons) { - presenceData.buttons = [ - { - label: "Join room", - url: document.URL, - }, - ]; - } - } else presenceData.details = "Browsing..."; - } - presence.setActivity(presenceData); -}); + if (document.location.pathname.includes('/room/create')) { + presenceData.details = 'Creating a room...' + if (buttons) { + presenceData.buttons = [ + { + label: 'Join room', + url: document.URL, + }, + ] + } + } + else if (document.location.pathname.includes('/room/')) { + presenceData.details = 'Joining a room...' + if (buttons) { + presenceData.buttons = [ + { + label: 'Join room', + url: document.URL, + }, + ] + } + } + else { + presenceData.details = 'Browsing...' + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/C/Codewars/metadata.json b/websites/C/Codewars/metadata.json index 1c229de287e4..db381a1cc0e2 100644 --- a/websites/C/Codewars/metadata.json +++ b/websites/C/Codewars/metadata.json @@ -1,33 +1,33 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": " .•` KIΛRΛ `•. ", - "id": "586905336850677760" - }, - "service": "Codewars", - "description": { - "en": "Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential.", - "nl": "Codewars is waar ontwikkelaars codebeheersing bereiken door middel van uitdaging. Train op kata in de dojo en bereik je hoogste potentieel.", - "vi_VN": "Codewars là nơi các nhà phát triển làm chủ lập trình qua các thử thách. Luyện tập trong võ đường và phát huy tối đa khả năng của bạn." - }, - "url": "www.codewars.com", - "version": "1.1.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Codewars/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Codewars/assets/thumbnail.png", - "color": "#9c1414", - "category": "other", - "tags": [ - "codewars", - "coding", - "social" - ], - "settings": [ - { - "id": "statsdisplay", - "title": "Display Stats", - "icon": "fas fa-bar-chart", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": " .•` KIΛRΛ `•. ", + "id": "586905336850677760" + }, + "service": "Codewars", + "description": { + "en": "Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential.", + "nl": "Codewars is waar ontwikkelaars codebeheersing bereiken door middel van uitdaging. Train op kata in de dojo en bereik je hoogste potentieel.", + "vi_VN": "Codewars là nơi các nhà phát triển làm chủ lập trình qua các thử thách. Luyện tập trong võ đường và phát huy tối đa khả năng của bạn." + }, + "url": "www.codewars.com", + "version": "1.1.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Codewars/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Codewars/assets/thumbnail.png", + "color": "#9c1414", + "category": "other", + "tags": [ + "codewars", + "coding", + "social" + ], + "settings": [ + { + "id": "statsdisplay", + "title": "Display Stats", + "icon": "fas fa-bar-chart", + "value": true + } + ] +} diff --git a/websites/C/Codewars/presence.ts b/websites/C/Codewars/presence.ts index e9c563624121..30a90e47268b 100644 --- a/websites/C/Codewars/presence.ts +++ b/websites/C/Codewars/presence.ts @@ -1,111 +1,121 @@ const presence = new Presence({ - clientId: "821106305241972746", - }), - timebrowsed = Math.floor(Date.now() / 1000); + clientId: '821106305241972746', +}) +const timebrowsed = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const pages = document.location.pathname.split("/").filter(p => p), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Codewars/assets/logo.png", - startTimestamp: timebrowsed, - details: "Browsing...", - }, - displayStats = await presence.getSetting("statsdisplay"); - switch (pages[0]) { - case "dashboard": { - presenceData.details = "Viewing Dashboard"; - if (displayStats) { - presenceData.state = `${ - document.querySelector(".ml-10px").textContent - } Honor`; - } - break; - } - case "topics": { - if (pages[1]) { - presenceData.details = "Viewing Topic"; - presenceData.state = `Topic: ${pages[1]}`; - } else presenceData.details = "Viewing Forum"; - break; - } - case "kumite": { - presenceData.details = "Viewing kumite"; - break; - } - case "subscription": { - presenceData.details = "Viewing Codewars Red"; - break; - } - default: - if (pages[0] === "users" && pages[1] === "leaderboard") - presenceData.details = "Viewing Leaderboard"; - else if (pages[0] === "kata") { - if (pages[2] && pages[2].startsWith("my-languages")) { - const search = - ( - document.querySelectorAll('[name="q"]')[0] as HTMLInputElement - ).getAttribute("value") || "All Katas"; - let difficultyFilter = document - .querySelector('[Label="Difficulty"]') - .getAttribute("value"); - if (difficultyFilter) { - difficultyFilter = difficultyFilter - .split(",") - .map((x: string) => { - return `${x.replace(/-/g, "").trim()} kyu`; - }) - .join(", "); - } else difficultyFilter = "Any kyu"; - presenceData.details = "Searching Katas"; - presenceData.state = `${search} | ${difficultyFilter}`; - } else { - presenceData.details = `Solving Kata | ${ - document.querySelector(".w-full>div>div>div>span").textContent - }`; - presenceData.state = - document.querySelector(".items-center > h4").textContent; - } - } else if (pages[0] === "users" && pages[1] === "edit") - presenceData.details = "Editing Account"; - else if (pages[0] === "trainer" && pages[1] === "setup") { - presenceData.details = "Editing Trainer Setup"; - presenceData.state = `${ - Array.from(document.querySelectorAll(".icon-list > li > .is-active")) - .length - } Languages selected`; - } else if ( - pages[0] === "users" && - pages[1] !== "leaderboard" && - pages[1] !== "edit" - ) { - const urls = Array.from(document.querySelectorAll("img")).map( - e => e.src - ); - if ( - !urls.find( - e => - e.includes("avatar") && e !== urls.find(e => e.includes("avatar")) - ) - ) { - presenceData.details = "Viewing own profile"; - if (displayStats) { - presenceData.state = `${ - document.querySelector(".ml-10px").textContent - } Honor | ${document.querySelector(".small-hex").textContent}`; - } - } else { - presenceData.details = "Viewing profile of"; - if (displayStats) { - presenceData.state = `${pages[1]} | - ${Array.from(document.querySelector(".stat-box").children) - .find(e => e.textContent.startsWith("Clan:")) - .textContent.slice("Clan:".length)}`; - } - } - } - } +presence.on('UpdateData', async () => { + const pages = document.location.pathname.split('/').filter(p => p) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Codewars/assets/logo.png', + startTimestamp: timebrowsed, + details: 'Browsing...', + } + const displayStats = await presence.getSetting('statsdisplay') + switch (pages[0]) { + case 'dashboard': { + presenceData.details = 'Viewing Dashboard' + if (displayStats) { + presenceData.state = `${ + document.querySelector('.ml-10px')?.textContent + } Honor` + } + break + } + case 'topics': { + if (pages[1]) { + presenceData.details = 'Viewing Topic' + presenceData.state = `Topic: ${pages[1]}` + } + else { + presenceData.details = 'Viewing Forum' + } + break + } + case 'kumite': { + presenceData.details = 'Viewing kumite' + break + } + case 'subscription': { + presenceData.details = 'Viewing Codewars Red' + break + } + default: + if (pages[0] === 'users' && pages[1] === 'leaderboard') { + presenceData.details = 'Viewing Leaderboard' + } + else if (pages[0] === 'kata') { + if (pages[2] && pages[2].startsWith('my-languages')) { + const search = ( + document.querySelectorAll('[name="q"]')[0] as HTMLInputElement + ).getAttribute('value') || 'All Katas' + let difficultyFilter = document + .querySelector('[Label="Difficulty"]') + ?.getAttribute('value') + if (difficultyFilter) { + difficultyFilter = difficultyFilter + ?.split(',') + ?.map((x: string) => { + return `${x.replace(/-/g, '').trim()} kyu` + }) + ?.join(', ') + } + else { + difficultyFilter = 'Any kyu' + } + presenceData.details = 'Searching Katas' + presenceData.state = `${search} | ${difficultyFilter}` + } + else { + presenceData.details = `Solving Kata | ${ + document.querySelector('.w-full>div>div>div>span')?.textContent + }` + presenceData.state = document.querySelector('.items-center > h4')?.textContent + } + } + else if (pages[0] === 'users' && pages[1] === 'edit') { + presenceData.details = 'Editing Account' + } + else if (pages[0] === 'trainer' && pages[1] === 'setup') { + presenceData.details = 'Editing Trainer Setup' + presenceData.state = `${ + Array.from(document.querySelectorAll('.icon-list > li > .is-active')) + .length + } Languages selected` + } + else if ( + pages[0] === 'users' + && pages[1] !== 'leaderboard' + && pages[1] !== 'edit' + ) { + const urls = Array.from(document.querySelectorAll('img')).map( + e => e.src, + ) + if ( + !urls.find( + e => + e.includes('avatar') && e !== urls.find(e => e.includes('avatar')), + ) + ) { + presenceData.details = 'Viewing own profile' + if (displayStats) { + presenceData.state = `${ + document.querySelector('.ml-10px')?.textContent + } Honor | ${document.querySelector('.small-hex')?.textContent}` + } + } + else { + presenceData.details = 'Viewing profile of' + if (displayStats) { + presenceData.state = `${pages[1]} | ${Array.from(document.querySelector('.stat-box')?.children ?? []) + .find(e => e.textContent?.startsWith('Clan:')) + ?.textContent + ?.slice('Clan:'.length)}` + } + } + } + } - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/C/CodinGame/metadata.json b/websites/C/CodinGame/metadata.json index c1558196f1c3..34deda43e7ce 100644 --- a/websites/C/CodinGame/metadata.json +++ b/websites/C/CodinGame/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "LighTender", - "id": "338768773865537536" - }, - "service": "CodinGame", - "description": { - "en": "CodinGame is a web site to learn programing", - "fr": "CodinGame est un site pour apprendre la programmation" - }, - "url": "www.codingame.com", - "version": "1.0.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CodinGame/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CodinGame/assets/thumbnail.png", - "color": "#c4bf1c", - "category": "games", - "tags": [ - "code", - "games" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "LighTender", + "id": "338768773865537536" + }, + "service": "CodinGame", + "description": { + "en": "CodinGame is a web site to learn programing", + "fr": "CodinGame est un site pour apprendre la programmation" + }, + "url": "www.codingame.com", + "version": "1.0.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CodinGame/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CodinGame/assets/thumbnail.png", + "color": "#c4bf1c", + "category": "games", + "tags": [ + "code", + "games" + ] +} diff --git a/websites/C/CodinGame/presence.ts b/websites/C/CodinGame/presence.ts index f89df25361e1..25f575f6b632 100644 --- a/websites/C/CodinGame/presence.ts +++ b/websites/C/CodinGame/presence.ts @@ -1,206 +1,259 @@ const presence = new Presence({ - clientId: "991078618866274364", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '991078618866274364', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CodinGame/assets/0.png", - startTimestamp: browsingTimestamp, - }, - { pathname } = document.location; - if (pathname === "/") presenceData.details = "Browsing..."; - else if (pathname.includes("/home")) { - presenceData.details = "On the dashboard"; - presenceData.state = `${ - document.querySelectorAll( - "div[class='home-content'] > div > div > div > div > home > div > home-react > div > div > section > section > div > div > div > div" - )[0].textContent - } - Rank : ${ - document.querySelectorAll( - "div[class='home-content'] > div > div > div > div > home > div > home-react > div > div > section > section > div > div > div > div" - )[4].textContent - }`; - } else if (pathname.includes("/training")) { - if (pathname.includes("/easy/")) { - presenceData.details = "Training: Easy"; - presenceData.state = `${ - document.querySelector("h1[class='title']").textContent - } (${document.querySelector("div[class='chart-inner']").textContent}%)`; - } else if (pathname.includes("/medium/")) { - presenceData.details = "Training: Medium"; - presenceData.state = `${ - document.querySelector("h1[class='title']").textContent - } (${document.querySelector("div[class='chart-inner']").textContent}%)`; - } else if (pathname.includes("/hard/")) { - presenceData.details = "Training: Hard"; - presenceData.state = `${ - document.querySelector("h1[class='title']").textContent - } (${document.querySelector("div[class='chart-inner']").textContent}%)`; - } else if (pathname.includes("/expert/")) { - presenceData.details = "Training: Very Hard"; - presenceData.state = `${ - document.querySelector("h1[class='title']").textContent - } (${document.querySelector("div[class='chart-inner']").textContent}%)`; - } else presenceData.details = "Looking at Practice"; - } else if (pathname.includes("/multiplayer")) { - if (pathname.includes("/clashofcode")) { - presenceData.details = "Looking at Clash of Code"; - presenceData.state = `Rank : ${ - document.querySelector("span[class='rank-value']").textContent - } th`; - } else if (pathname.includes("/bot-programming")) { - presenceData.details = "Training: Bot Programming"; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CodinGame/assets/0.png', + startTimestamp: browsingTimestamp, + } + const { pathname } = document.location + if (pathname === '/') { + presenceData.details = 'Browsing...' + } + else if (pathname.includes('/home')) { + presenceData.details = 'On the dashboard' + presenceData.state = `${ + document.querySelectorAll( + 'div[class=\'home-content\'] > div > div > div > div > home > div > home-react > div > div > section > section > div > div > div > div', + )[0].textContent + } - Rank : ${ + document.querySelectorAll( + 'div[class=\'home-content\'] > div > div > div > div > home > div > home-react > div > div > section > section > div > div > div > div', + )[4].textContent + }` + } + else if (pathname.includes('/training')) { + if (pathname.includes('/easy/')) { + presenceData.details = 'Training: Easy' + presenceData.state = `${ + document.querySelector('h1[class=\'title\']')?.textContent + } (${document.querySelector('div[class=\'chart-inner\']')?.textContent}%)` + } + else if (pathname.includes('/medium/')) { + presenceData.details = 'Training: Medium' + presenceData.state = `${ + document.querySelector('h1[class=\'title\']')?.textContent + } (${document.querySelector('div[class=\'chart-inner\']')?.textContent}%)` + } + else if (pathname.includes('/hard/')) { + presenceData.details = 'Training: Hard' + presenceData.state = `${ + document.querySelector('h1[class=\'title\']')?.textContent + } (${document.querySelector('div[class=\'chart-inner\']')?.textContent}%)` + } + else if (pathname.includes('/expert/')) { + presenceData.details = 'Training: Very Hard' + presenceData.state = `${ + document.querySelector('h1[class=\'title\']')?.textContent + } (${document.querySelector('div[class=\'chart-inner\']')?.textContent}%)` + } + else { + presenceData.details = 'Looking at Practice' + } + } + else if (pathname.includes('/multiplayer')) { + if (pathname.includes('/clashofcode')) { + presenceData.details = 'Looking at Clash of Code' + presenceData.state = `Rank : ${ + document.querySelector('span[class=\'rank-value\']')?.textContent + } th` + } + else if (pathname.includes('/bot-programming')) { + presenceData.details = 'Training: Bot Programming' - try { - presenceData.state = `${ - document.querySelector("h1[class='title']").textContent - } - Rank : ${ - document.querySelectorAll( - "div[id='content-details-league'] > div > div" - )[1].textContent - }`; - } catch { - presenceData.state = `${ - document.querySelector("h1[class='title']").textContent - } - Not yet solved`; - } - } else if (pathname.includes("/codegolf")) { - presenceData.details = "Training: Code Golf"; - try { - if ( - document.querySelector("div[class='chart-inner']").textContent !== "0" - ) { - presenceData.state = `${ - document.querySelector("h1[class='title']").textContent - } (${document.querySelector("span[class='rank-value']").textContent}${ - document.querySelector("span[class='rank-suffix']").textContent - }/${document.querySelector("span[class='rank-total']").textContent})`; - } else presenceData.state = "Not yet solved"; - } catch { - presenceData.state = `${ - document.querySelector("h1[class='title']").textContent - } (${document.querySelector("span[class='rank-value']").textContent}${ - document.querySelector("span[class='rank-suffix']").textContent - }/${document.querySelector("span[class='rank-total']").textContent})`; - } - } else if (pathname.includes("/optimization")) { - presenceData.details = "Training: Optimization"; - try { - if ( - document.querySelector("div[class='chart-inner']").textContent !== "0" - ) { - presenceData.state = `${ - document.querySelector("h1[class='title']").textContent - } (${document.querySelector("span[class='rank-value']").textContent}${ - document.querySelector("span[class='rank-suffix']").textContent - }/${document.querySelector("span[class='rank-total']").textContent})`; - } else presenceData.state = "Not yet solved"; - } catch { - presenceData.state = `${ - document.querySelector("h1[class='title']").textContent - } (${document.querySelector("span[class='rank-value']").textContent}${ - document.querySelector("span[class='rank-suffix']").textContent - }/${document.querySelector("span[class='rank-total']").textContent})`; - } - } else presenceData.details = "Looking at a competition"; - } else if (pathname.includes("/cooperate")) - presenceData.details = "Looking at the corporate page"; - else if (pathname.includes("/learn")) - presenceData.details = "Looking at the learn page"; - else if (pathname.includes("/events")) - presenceData.details = "Looking at the events page"; - else if (pathname.includes("/contribute/community")) - presenceData.details = "Looking at community page"; - else if (pathname.includes("/contribute/my-contributions")) - presenceData.details = "Looking at their contributions"; - else if (pathname.includes("/live-streams")) - presenceData.details = "Looking at live streams"; - else if (pathname.includes("/blog")) - presenceData.details = "Looking at the blog"; - else if (pathname.includes("/forum")) - presenceData.details = "Looking at the forum"; - else if (pathname.includes("/profile")) - presenceData.details = "Looking at a profile"; - else if (pathname.includes("/settings")) - presenceData.details = "Looking at their settings"; - else if (pathname.includes("/about")) - presenceData.details = "Looking at the about page"; - else if (pathname.includes("/careers")) - presenceData.details = "Looking at the careers page"; - else if (pathname.includes("/work")) - presenceData.details = "Looking at the work page"; - else if ( - pathname.includes("/legal/privacy-policy") && - pathname.includes("/playgrounds") - ) - presenceData.details = "Looking at the privacy policy"; - else if (pathname.includes("/help-center")) - presenceData.details = "Looking at the FAQ page"; - else if (pathname.includes("/start")) presenceData.details = "Not logged in"; - else if (pathname.includes("/ide")) { - if (pathname.includes("/ide/puzzle/")) { - presenceData.details = `Solving the challenge: ${ - document.querySelectorAll("h1[class='cg-ide-title'] > span")[ - document.querySelectorAll("h1[class='cg-ide-title'] > span").length - - 1 - ].textContent - }`; - try { - const score = document.querySelector( - "span[class*='score-value']" - ).textContent; - if (score === "N/A") presenceData.state = "0%"; - else { - try { - const rank = document.querySelector( - "span[class='rank-value']" - ).textContent; - if (!rank) { - presenceData.state = `${rank}th/${ - document.querySelector("span[class='rank-total']").textContent - }`; - } else presenceData.state = `${score}%`; - } catch { - presenceData.state = `${score}%`; - } - } - } catch { - presenceData.state = `League: ${ - document.querySelector("span[class='league-value']").textContent - }`; - } - } else { - presenceData.details = document.querySelectorAll( - "h1[class='cg-ide-title'] > span" - )[ - document.querySelectorAll("h1[class='cg-ide-title'] > span").length - 1 - ].textContent; - presenceData.state = `Time left : ${ - document.querySelector("span[class*='minutes']").textContent - }m : ${document.querySelector("span[class*='seconds']").textContent}s`; - } - } else if (pathname.includes("/clashofcode/clash/")) { - presenceData.details = "Waiting for the Clash of Code"; - presenceData.buttons = [ - { - label: "Join clash", - url: document - .querySelector("input[class='copy-url-button']") - .getAttribute("value"), - }, - ]; - } else if ( - !pathname.includes("/legal/privacy-policy") && - pathname.includes("/playgrounds") - ) { - presenceData.details = document.querySelector( - "h1[class='playground_header-title'] > span" - ).textContent; - presenceData.state = "Learning"; - } + try { + presenceData.state = `${ + document.querySelector('h1[class=\'title\']')?.textContent + } - Rank : ${ + document.querySelectorAll( + 'div[id=\'content-details-league\'] > div > div', + )[1].textContent + }` + } + catch { + presenceData.state = `${ + document.querySelector('h1[class=\'title\']')?.textContent + } - Not yet solved` + } + } + else if (pathname.includes('/codegolf')) { + presenceData.details = 'Training: Code Golf' + try { + if ( + document.querySelector('div[class=\'chart-inner\']')?.textContent !== '0' + ) { + presenceData.state = `${ + document.querySelector('h1[class=\'title\']')?.textContent + } (${document.querySelector('span[class=\'rank-value\']')?.textContent}${ + document.querySelector('span[class=\'rank-suffix\']')?.textContent + }/${document.querySelector('span[class=\'rank-total\']')?.textContent})` + } + else { + presenceData.state = 'Not yet solved' + } + } + catch { + presenceData.state = `${ + document.querySelector('h1[class=\'title\']')?.textContent + } (${document.querySelector('span[class=\'rank-value\']')?.textContent}${ + document.querySelector('span[class=\'rank-suffix\']')?.textContent + }/${document.querySelector('span[class=\'rank-total\']')?.textContent})` + } + } + else if (pathname.includes('/optimization')) { + presenceData.details = 'Training: Optimization' + try { + if ( + document.querySelector('div[class=\'chart-inner\']')?.textContent !== '0' + ) { + presenceData.state = `${ + document.querySelector('h1[class=\'title\']')?.textContent + } (${document.querySelector('span[class=\'rank-value\']')?.textContent}${ + document.querySelector('span[class=\'rank-suffix\']')?.textContent + }/${document.querySelector('span[class=\'rank-total\']')?.textContent})` + } + else { + presenceData.state = 'Not yet solved' + } + } + catch { + presenceData.state = `${ + document.querySelector('h1[class=\'title\']')?.textContent + } (${document.querySelector('span[class=\'rank-value\']')?.textContent}${ + document.querySelector('span[class=\'rank-suffix\']')?.textContent + }/${document.querySelector('span[class=\'rank-total\']')?.textContent})` + } + } + else { + presenceData.details = 'Looking at a competition' + } + } + else if (pathname.includes('/cooperate')) { + presenceData.details = 'Looking at the corporate page' + } + else if (pathname.includes('/learn')) { + presenceData.details = 'Looking at the learn page' + } + else if (pathname.includes('/events')) { + presenceData.details = 'Looking at the events page' + } + else if (pathname.includes('/contribute/community')) { + presenceData.details = 'Looking at community page' + } + else if (pathname.includes('/contribute/my-contributions')) { + presenceData.details = 'Looking at their contributions' + } + else if (pathname.includes('/live-streams')) { + presenceData.details = 'Looking at live streams' + } + else if (pathname.includes('/blog')) { + presenceData.details = 'Looking at the blog' + } + else if (pathname.includes('/forum')) { + presenceData.details = 'Looking at the forum' + } + else if (pathname.includes('/profile')) { + presenceData.details = 'Looking at a profile' + } + else if (pathname.includes('/settings')) { + presenceData.details = 'Looking at their settings' + } + else if (pathname.includes('/about')) { + presenceData.details = 'Looking at the about page' + } + else if (pathname.includes('/careers')) { + presenceData.details = 'Looking at the careers page' + } + else if (pathname.includes('/work')) { + presenceData.details = 'Looking at the work page' + } + else if ( + pathname.includes('/legal/privacy-policy') + && pathname.includes('/playgrounds') + ) { + presenceData.details = 'Looking at the privacy policy' + } + else if (pathname.includes('/help-center')) { + presenceData.details = 'Looking at the FAQ page' + } + else if (pathname.includes('/start')) { + presenceData.details = 'Not logged in' + } + else if (pathname.includes('/ide')) { + if (pathname.includes('/ide/puzzle/')) { + presenceData.details = `Solving the challenge: ${ + document.querySelectorAll('h1[class=\'cg-ide-title\'] > span')[ + document.querySelectorAll('h1[class=\'cg-ide-title\'] > span').length + - 1 + ].textContent + }` + try { + const score = document.querySelector( + 'span[class*=\'score-value\']', + )?.textContent + if (score === 'N/A') { + presenceData.state = '0%' + } + else { + try { + const rank = document.querySelector( + 'span[class=\'rank-value\']', + )?.textContent + if (!rank) { + presenceData.state = `${rank}th/${ + document.querySelector('span[class=\'rank-total\']')?.textContent + }` + } + else { + presenceData.state = `${score}%` + } + } + catch { + presenceData.state = `${score}%` + } + } + } + catch { + presenceData.state = `League: ${ + document.querySelector('span[class=\'league-value\']')?.textContent + }` + } + } + else { + presenceData.details = document.querySelectorAll( + 'h1[class=\'cg-ide-title\'] > span', + )[ + document.querySelectorAll('h1[class=\'cg-ide-title\'] > span').length - 1 + ].textContent + presenceData.state = `Time left : ${ + document.querySelector('span[class*=\'minutes\']')?.textContent + }m : ${document.querySelector('span[class*=\'seconds\']')?.textContent}s` + } + } + else if (pathname.includes('/clashofcode/clash/')) { + presenceData.details = 'Waiting for the Clash of Code' + presenceData.buttons = [ + { + label: 'Join clash', + url: document + .querySelector('input[class=\'copy-url-button\']') + ?.getAttribute('value') ?? '', + }, + ] + } + else if ( + !pathname.includes('/legal/privacy-policy') + && pathname.includes('/playgrounds') + ) { + presenceData.details = document.querySelector( + 'h1[class=\'playground_header-title\'] > span', + )?.textContent + presenceData.state = 'Learning' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/CoinMarketCap/metadata.json b/websites/C/CoinMarketCap/metadata.json index fbc73e0b20d2..73977fc7a432 100644 --- a/websites/C/CoinMarketCap/metadata.json +++ b/websites/C/CoinMarketCap/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "jvnxs7", - "id": "209945797918195712" - }, - "service": "CoinMarketCap", - "description": { - "en": "CoinMarketCap is the world's most-referenced price-tracking website for cryptoassets in the rapidly growing cryptocurrency space.", - "de": "CoinMarketCap ist die weltweit am meisten referenzierte Preisverfolgungs-Website für Krypto-Assets im schnell wachsenden Kryptowährungsraum.", - "vi_VN": "CoinMarketCap là trang web nổi tiếng nhất thế giới nhằm theo dõi giá trị của các tài sản số trong nhịp độ ngày càng phát triển của không gian tiền ảo." - }, - "url": [ - "coinmarketcap.com", - "www.coinmarketcap.com" - ], - "version": "1.0.15", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CoinMarketCap/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CoinMarketCap/assets/thumbnail.png", - "color": "#2C6CFC", - "category": "other", - "tags": [ - "coin", - "currency" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "jvnxs7", + "id": "209945797918195712" + }, + "service": "CoinMarketCap", + "description": { + "en": "CoinMarketCap is the world's most-referenced price-tracking website for cryptoassets in the rapidly growing cryptocurrency space.", + "de": "CoinMarketCap ist die weltweit am meisten referenzierte Preisverfolgungs-Website für Krypto-Assets im schnell wachsenden Kryptowährungsraum.", + "vi_VN": "CoinMarketCap là trang web nổi tiếng nhất thế giới nhằm theo dõi giá trị của các tài sản số trong nhịp độ ngày càng phát triển của không gian tiền ảo." + }, + "url": [ + "coinmarketcap.com", + "www.coinmarketcap.com" + ], + "version": "1.0.15", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CoinMarketCap/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CoinMarketCap/assets/thumbnail.png", + "color": "#2C6CFC", + "category": "other", + "tags": [ + "coin", + "currency" + ] +} diff --git a/websites/C/CoinMarketCap/presence.ts b/websites/C/CoinMarketCap/presence.ts index 7236067b957c..f9d0ee512041 100644 --- a/websites/C/CoinMarketCap/presence.ts +++ b/websites/C/CoinMarketCap/presence.ts @@ -1,98 +1,135 @@ const presence = new Presence({ - clientId: "907692817604833281", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '907692817604833281', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CoinMarketCap/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - path = document.location.pathname; - if (path === "/") presenceData.details = "Browsing..."; - else if (path.includes("/portfolio-tracker/")) - presenceData.details = "Looking at Portfolio"; - else if (path.includes("/settings/")) - presenceData.details = "Checking account settings"; - else if (path.includes("/currencies/")) { - presenceData.details = "Checking prices for:"; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CoinMarketCap/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const path = document.location.pathname + if (path === '/') { + presenceData.details = 'Browsing...' + } + else if (path.includes('/portfolio-tracker/')) { + presenceData.details = 'Looking at Portfolio' + } + else if (path.includes('/settings/')) { + presenceData.details = 'Checking account settings' + } + else if (path.includes('/currencies/')) { + presenceData.details = 'Checking prices for:' - presenceData.state = document.querySelector( - "#__next > div.bywovg-1.kkDbhJ > div > div.sc-57oli2-0.comDeo.cmc-body-wrapper > div > div.sc-16r8icm-0.eMxKgr.container > div.n78udj-0.jskEGI > div > div.sc-16r8icm-0.kDzKwW.nameSection > div.sc-16r8icm-0.gpRPnR.nameHeader > h2" - ).textContent; - } else if (path.includes("/rankings/exchanges/")) - presenceData.details = "Looking at top cryptocurrency spot exchanges"; - else if (path.includes("/rankings/exchanges/derivatives/")) { - presenceData.details = - "Looking at top cryptocurrency derivatives exchanges"; - } else if (path.includes("/rankings/exchanges/dex/")) { - presenceData.details = - "Looking at top cryptocurrency decentralized exchanges"; - } else if (path.includes("/how-to-buy-bitcoin/")) - presenceData.details = "Checking out how to buy bitcoin"; - else if (path.includes("/nft/collections/")) - presenceData.details = "Looking at NFT top collections"; - else if (path.includes("/nft/upcoming/")) - presenceData.details = "Looking at upcoming NFT sales"; - else if (path.includes("/ico-calendar/")) - presenceData.details = "Checking the ICO calendar"; - else if (path.includes("/polkadot-parachains/kusama/")) - presenceData.details = "Checking all Kusama PLO Parachain slot auctions"; - else if (path.includes("/events/")) - presenceData.details = "Browsing in crypto events calendar"; - else if (path.includes("/account/my-diamonds/")) { - presenceData.details = "Checking diamonds:"; + presenceData.state = document.querySelector( + '#__next > div.bywovg-1.kkDbhJ > div > div.sc-57oli2-0.comDeo.cmc-body-wrapper > div > div.sc-16r8icm-0.eMxKgr.container > div.n78udj-0.jskEGI > div > div.sc-16r8icm-0.kDzKwW.nameSection > div.sc-16r8icm-0.gpRPnR.nameHeader > h2', + )?.textContent + } + else if (path.includes('/rankings/exchanges/')) { + presenceData.details = 'Looking at top cryptocurrency spot exchanges' + } + else if (path.includes('/rankings/exchanges/derivatives/')) { + presenceData.details = 'Looking at top cryptocurrency derivatives exchanges' + } + else if (path.includes('/rankings/exchanges/dex/')) { + presenceData.details = 'Looking at top cryptocurrency decentralized exchanges' + } + else if (path.includes('/how-to-buy-bitcoin/')) { + presenceData.details = 'Checking out how to buy bitcoin' + } + else if (path.includes('/nft/collections/')) { + presenceData.details = 'Looking at NFT top collections' + } + else if (path.includes('/nft/upcoming/')) { + presenceData.details = 'Looking at upcoming NFT sales' + } + else if (path.includes('/ico-calendar/')) { + presenceData.details = 'Checking the ICO calendar' + } + else if (path.includes('/polkadot-parachains/kusama/')) { + presenceData.details = 'Checking all Kusama PLO Parachain slot auctions' + } + else if (path.includes('/events/')) { + presenceData.details = 'Browsing in crypto events calendar' + } + else if (path.includes('/account/my-diamonds/')) { + presenceData.details = 'Checking diamonds:' - presenceData.state = document.querySelector( - "#__next > div > div > div.sc-57oli2-0.comDeo.cmc-body-wrapper > div > div > div > div:nth-child(2) > div > div.sc-1snuar3-1.hyjDAL > div.sc-1snuar3-2.gqljHA > h1 > span" - ).textContent; - } else if (path.includes("/nft/")) presenceData.details = "Browsing NFTs..."; - else if (path.includes("/watchlist/")) - presenceData.details = "Browsing watchlist..."; - else if (path.includes("/airdrop/")) - presenceData.details = "Looking at Airdrop"; - else if (path.includes("/referral/")) - presenceData.details = "Checking out the referral program"; - else if (path.includes("/api/")) - presenceData.details = "Browsing API page..."; - else if (path.includes("/indices/")) - presenceData.details = "Checking indices..."; - else if (path.includes("/sitemap/cryptocurrencies/")) - presenceData.details = "Browsing sitemap..."; - else if (path.includes("/new/")) - presenceData.details = "Checking out new Cryptocurrencies"; - else if (path.includes("/charts/")) - presenceData.details = "Viewing global cryptocurrency charts"; - else if (path.includes("/best-cryptos/")) { - presenceData.details = - "Looking at the best cryptos based on the latest data"; - } else if (path.includes("/gainers-losers/")) - presenceData.details = "Checking top crypto gainers and losers today"; - else if (path.includes("/historical/")) - presenceData.details = "Browsing cryptocurrency historical data snapshots"; - else if (path.includes("/swap/")) - presenceData.details = "Browsing on the swap page"; - else if (path.includes("/converter/")) - presenceData.details = "Using the converter..."; - else if (path.includes("/widget/ticker/")) - presenceData.details = "Checking out the widget creator"; - else if (path.includes("/newsletter/")) - presenceData.details = "Signing up for the newsletter"; - else if (path.includes("/about/")) - presenceData.details = "Browsing about page"; - else if (path.includes("/terms/")) - presenceData.details = "Checking the terms of use"; - else if (path.includes("/privacy/")) - presenceData.details = "Reading the privacy and cookie policy"; - else if (path.includes("/disclaimer/")) - presenceData.details = "Reading the disclaimer"; - else if (path.includes("/faq/")) presenceData.details = "Reading the FAQ"; - else if (path.includes("/alexandria/glossary")) - presenceData.details = "Reading the glossary"; - else if (path.includes("/trending-cryptocurrencies/")) - presenceData.details = "Browsing the trending cryptocurrencies"; + presenceData.state = document.querySelector( + '#__next > div > div > div.sc-57oli2-0.comDeo.cmc-body-wrapper > div > div > div > div:nth-child(2) > div > div.sc-1snuar3-1.hyjDAL > div.sc-1snuar3-2.gqljHA > h1 > span', + )?.textContent + } + else if (path.includes('/nft/')) { + presenceData.details = 'Browsing NFTs...' + } + else if (path.includes('/watchlist/')) { + presenceData.details = 'Browsing watchlist...' + } + else if (path.includes('/airdrop/')) { + presenceData.details = 'Looking at Airdrop' + } + else if (path.includes('/referral/')) { + presenceData.details = 'Checking out the referral program' + } + else if (path.includes('/api/')) { + presenceData.details = 'Browsing API page...' + } + else if (path.includes('/indices/')) { + presenceData.details = 'Checking indices...' + } + else if (path.includes('/sitemap/cryptocurrencies/')) { + presenceData.details = 'Browsing sitemap...' + } + else if (path.includes('/new/')) { + presenceData.details = 'Checking out new Cryptocurrencies' + } + else if (path.includes('/charts/')) { + presenceData.details = 'Viewing global cryptocurrency charts' + } + else if (path.includes('/best-cryptos/')) { + presenceData.details = 'Looking at the best cryptos based on the latest data' + } + else if (path.includes('/gainers-losers/')) { + presenceData.details = 'Checking top crypto gainers and losers today' + } + else if (path.includes('/historical/')) { + presenceData.details = 'Browsing cryptocurrency historical data snapshots' + } + else if (path.includes('/swap/')) { + presenceData.details = 'Browsing on the swap page' + } + else if (path.includes('/converter/')) { + presenceData.details = 'Using the converter...' + } + else if (path.includes('/widget/ticker/')) { + presenceData.details = 'Checking out the widget creator' + } + else if (path.includes('/newsletter/')) { + presenceData.details = 'Signing up for the newsletter' + } + else if (path.includes('/about/')) { + presenceData.details = 'Browsing about page' + } + else if (path.includes('/terms/')) { + presenceData.details = 'Checking the terms of use' + } + else if (path.includes('/privacy/')) { + presenceData.details = 'Reading the privacy and cookie policy' + } + else if (path.includes('/disclaimer/')) { + presenceData.details = 'Reading the disclaimer' + } + else if (path.includes('/faq/')) { + presenceData.details = 'Reading the FAQ' + } + else if (path.includes('/alexandria/glossary')) { + presenceData.details = 'Reading the glossary' + } + else if (path.includes('/trending-cryptocurrencies/')) { + presenceData.details = 'Browsing the trending cryptocurrencies' + } - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/C/Coinbase/metadata.json b/websites/C/Coinbase/metadata.json index 5e1c7df3316c..5edb93f9b0dc 100644 --- a/websites/C/Coinbase/metadata.json +++ b/websites/C/Coinbase/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kazo", - "id": "393071912189952011" - }, - "service": "Coinbase", - "description": { - "en": "Coinbase is a secure online platform for buying, selling, transferring, and storing digital currency.", - "de": "Coinbase ist eine sichere online Plattform um digitale Währungen zu kaufen, überweisen, verkaufen und zu lagern.", - "nl": "Coinbase is een veilig online platform voor het kopen, verkopen, overdragen en opslaan van digitale valuta.", - "vi_VN": "Coinbase là nền tảng trao đổi và tích trữ tiền ảo bảo mật." - }, - "url": "www.coinbase.com", - "version": "1.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Coinbase/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Coinbase/assets/thumbnail.jpg", - "color": "#1751f0", - "category": "other", - "tags": [ - "coin", - "currency" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Kazo", + "id": "393071912189952011" + }, + "service": "Coinbase", + "description": { + "en": "Coinbase is a secure online platform for buying, selling, transferring, and storing digital currency.", + "de": "Coinbase ist eine sichere online Plattform um digitale Währungen zu kaufen, überweisen, verkaufen und zu lagern.", + "nl": "Coinbase is een veilig online platform voor het kopen, verkopen, overdragen en opslaan van digitale valuta.", + "vi_VN": "Coinbase là nền tảng trao đổi và tích trữ tiền ảo bảo mật." + }, + "url": "www.coinbase.com", + "version": "1.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Coinbase/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Coinbase/assets/thumbnail.jpg", + "color": "#1751f0", + "category": "other", + "tags": [ + "coin", + "currency" + ] +} diff --git a/websites/C/Coinbase/presence.ts b/websites/C/Coinbase/presence.ts index ef288d976968..f8b6deceec72 100644 --- a/websites/C/Coinbase/presence.ts +++ b/websites/C/Coinbase/presence.ts @@ -1,33 +1,41 @@ const presence = new Presence({ - clientId: "796810487177674822", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '796810487177674822', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Coinbase/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - path = document.location.pathname; - if (path === "/") presenceData.details = "Browsing..."; - else if (path.includes("/dashboard")) - presenceData.details = "Looking at Dashboard"; - else if (path.includes("/accounts")) - presenceData.details = "Looking at Portfolio"; - else if (path.includes("/price/")) { - presenceData.details = "Looking at prices for:"; - presenceData.state = document.querySelector( - "#root > div > div > div > div.Flex-l69ttv-0.Layout__Container-sc-140tb7h-0.iOtOlJ > div > div > div.Flex-l69ttv-0.LayoutDesktop__MainContentFlex-bh368c-1.kKKtdZ > div.Flex-l69ttv-0.LayoutDesktop__Wrapper-bh368c-3.gMrngj > div > div > div > div.styles__Outer-vb6gfj-0.HeaderBar__StyledOuter-tvqwd7-0.jjhDbN > div > div > div > div.styles__TopRow-vb6gfj-1.pbrsa > div.styles__TextRow-vb6gfj-2.ftNBen > div > h1.TextElement__Spacer-hxkcw5-0.cicsNy.Header__StyledHeader-sc-1xiyexz-0.JJViP.styles__Name-vb6gfj-5.bHSVaQ" - ).textContent; - } else if (path.includes("/notifications")) - presenceData.details = "Checking notifications"; - else if (path.includes("/settings")) { - presenceData.details = "Changing settings for:"; - presenceData.state = document.querySelector(".active > a").textContent; - } else if (path.includes("/invite")) - presenceData.details = "Inviting someone new"; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Coinbase/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const path = document.location.pathname + if (path === '/') { + presenceData.details = 'Browsing...' + } + else if (path.includes('/dashboard')) { + presenceData.details = 'Looking at Dashboard' + } + else if (path.includes('/accounts')) { + presenceData.details = 'Looking at Portfolio' + } + else if (path.includes('/price/')) { + presenceData.details = 'Looking at prices for:' + presenceData.state = document.querySelector( + '#root > div > div > div > div.Flex-l69ttv-0.Layout__Container-sc-140tb7h-0.iOtOlJ > div > div > div.Flex-l69ttv-0.LayoutDesktop__MainContentFlex-bh368c-1.kKKtdZ > div.Flex-l69ttv-0.LayoutDesktop__Wrapper-bh368c-3.gMrngj > div > div > div > div.styles__Outer-vb6gfj-0.HeaderBar__StyledOuter-tvqwd7-0.jjhDbN > div > div > div > div.styles__TopRow-vb6gfj-1.pbrsa > div.styles__TextRow-vb6gfj-2.ftNBen > div > h1.TextElement__Spacer-hxkcw5-0.cicsNy.Header__StyledHeader-sc-1xiyexz-0.JJViP.styles__Name-vb6gfj-5.bHSVaQ', + )?.textContent + } + else if (path.includes('/notifications')) { + presenceData.details = 'Checking notifications' + } + else if (path.includes('/settings')) { + presenceData.details = 'Changing settings for:' + presenceData.state = document.querySelector('.active > a')?.textContent + } + else if (path.includes('/invite')) { + presenceData.details = 'Inviting someone new' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/Color Coded Lyrics/metadata.json b/websites/C/Color Coded Lyrics/metadata.json index f61aa24ae313..e1dae6a5804a 100644 --- a/websites/C/Color Coded Lyrics/metadata.json +++ b/websites/C/Color Coded Lyrics/metadata.json @@ -1,22 +1,22 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "Color Coded Lyrics", - "description": { - "en": "Color-coded lyrics for songs from Korea, Japan, Taiwan, Thailand and China" - }, - "url": "colorcodedlyrics.com", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Color%20Coded%20Lyrics/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Color%20Coded%20Lyrics/assets/thumbnail.png", - "color": "#755fbf", - "category": "music", - "tags": [ - "translation", - "song" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "Color Coded Lyrics", + "description": { + "en": "Color-coded lyrics for songs from Korea, Japan, Taiwan, Thailand and China" + }, + "url": "colorcodedlyrics.com", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Color%20Coded%20Lyrics/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Color%20Coded%20Lyrics/assets/thumbnail.png", + "color": "#755fbf", + "category": "music", + "tags": [ + "translation", + "song" + ] +} diff --git a/websites/C/Color Coded Lyrics/presence.ts b/websites/C/Color Coded Lyrics/presence.ts index bcd4eddf6637..7931ebb605c5 100644 --- a/websites/C/Color Coded Lyrics/presence.ts +++ b/websites/C/Color Coded Lyrics/presence.ts @@ -1,118 +1,122 @@ const presence = new Presence({ - clientId: "1023360990802366544", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1023360990802366544', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Color%20Coded%20Lyrics/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, href, search } = window.location, - searchParams = new URLSearchParams(search), - pathSplit = pathname.split("/").filter(x => x), - pageTitle = document.querySelector("h1")?.textContent; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Color%20Coded%20Lyrics/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, href, search } = window.location + const searchParams = new URLSearchParams(search) + const pathSplit = pathname.split('/').filter(x => x) + const pageTitle = document.querySelector('h1')?.textContent - switch (pathSplit[0] ?? "") { - case "": - case "page": { - if (searchParams.get("s")) { - presenceData.details = "Searching songs"; - presenceData.state = searchParams.get("s"); - } else { - presenceData.details = "Browsing"; - presenceData.state = "Home page"; - } - break; - } - case "author": { - presenceData.details = "Viewing contributions by an author"; - presenceData.state = pageTitle.match(/^Author: (.*?)$/)[1]; - break; - } - case "calendar": { - presenceData.details = "Viewing calendar"; - if ( - pathSplit[1] === "today" || - pathSplit[1] === "month" || - /^\d{4}-\d{2}(-\d{2})?$/.test(pathSplit[1]) - ) { - presenceData.state = `In ${document - .querySelector( - ".tribe-events-c-top-bar__datepicker-desktop" - ) - .textContent.trim()}`; - } else { - presenceData.details = "Viewing an event"; - presenceData.state = document.querySelector( - ".tribe-events-single-event-title" - ).textContent; - } - break; - } - case "category": { - presenceData.details = "Viewing contributions by a category"; - presenceData.state = pageTitle.match(/^Category: (.*?)$/)[1]; - break; - } - case "index": { - presenceData.details = "Viewing index of songs"; - break; - } - case "requests": { - presenceData.details = "Submitting a request"; - break; - } - case "translations": { - presenceData.details = "Submitting a translation"; - break; - } - case "wp-login.php": { - presenceData.details = "Logging in to WordPress dashboard"; - break; - } - case "wp-admin": { - presenceData.details = "Viewing WordPress page"; - switch (pathSplit[1]) { - case "index.php": { - presenceData.state = "Dashboard"; - break; - } - case "profile.php": { - presenceData.state = "Profile"; - break; - } - default: { - document.title.match( - /(.*?) \u2039 Color Coded Lyrics — WordPress/ - )[1]; - } - } - break; - } - default: { - if (/^\/\d{4}(\/\d{2}\/?(\d{2})?)?\/?$/.test(pathname)) { - presenceData.details = "Viewing contributions by a date"; - presenceData.state = pageTitle.match(/^.*?: (.*?)$/)[1]; - } else if (/^\/\d{4}\/\d{2}\/\d{2}\/.*?\/$/.test(pathname)) { - presenceData.details = "Viewing song lyrics"; - presenceData.state = pageTitle; - presenceData.buttons = [ - { - label: "View Song", - url: href, - }, - ]; - presenceData.largeImageKey = document.querySelector( - ".inner-article-content img" - ).src; - } else { - presenceData.details = "Browsing"; - presenceData.state = pageTitle; - } - } - } + switch (pathSplit[0] ?? '') { + case '': + case 'page': { + if (searchParams.get('s')) { + presenceData.details = 'Searching songs' + presenceData.state = searchParams.get('s') + } + else { + presenceData.details = 'Browsing' + presenceData.state = 'Home page' + } + break + } + case 'author': { + presenceData.details = 'Viewing contributions by an author' + presenceData.state = pageTitle?.match(/^Author: (.*)$/)?.[1] + break + } + case 'calendar': { + presenceData.details = 'Viewing calendar' + if ( + pathSplit[1] === 'today' + || pathSplit[1] === 'month' + || /^\d{4}-\d{2}(?:-\d{2})?$/.test(pathSplit[1]) + ) { + presenceData.state = `In ${document + .querySelector( + '.tribe-events-c-top-bar__datepicker-desktop', + ) + ?.textContent + ?.trim()}` + } + else { + presenceData.details = 'Viewing an event' + presenceData.state = document.querySelector( + '.tribe-events-single-event-title', + )?.textContent + } + break + } + case 'category': { + presenceData.details = 'Viewing contributions by a category' + presenceData.state = pageTitle?.match(/^Category: (.*)$/)?.[1] + break + } + case 'index': { + presenceData.details = 'Viewing index of songs' + break + } + case 'requests': { + presenceData.details = 'Submitting a request' + break + } + case 'translations': { + presenceData.details = 'Submitting a translation' + break + } + case 'wp-login.php': { + presenceData.details = 'Logging in to WordPress dashboard' + break + } + case 'wp-admin': { + presenceData.details = 'Viewing WordPress page' + switch (pathSplit[1]) { + case 'index.php': { + presenceData.state = 'Dashboard' + break + } + case 'profile.php': { + presenceData.state = 'Profile' + break + } + default: { + presenceData.state = document.title?.match( + /(.*?) \u2039 Color Coded Lyrics — WordPress/, + )?.[1] + } + } + break + } + default: { + if (/^\/\d{4}(?:\/\d{2}\/?(?:\d{2})?)?\/?$/.test(pathname)) { + presenceData.details = 'Viewing contributions by a date' + presenceData.state = pageTitle?.match(/^.*?: (.*)$/)?.[1] + } + else if (/^\/\d{4}\/\d{2}\/\d{2}\/.*?\/$/.test(pathname)) { + presenceData.details = 'Viewing song lyrics' + presenceData.state = pageTitle + presenceData.buttons = [ + { + label: 'View Song', + url: href, + }, + ] + presenceData.largeImageKey = document.querySelector( + '.inner-article-content img', + )?.src + } + else { + presenceData.details = 'Browsing' + presenceData.state = pageTitle + } + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/Comedy Central/metadata.json b/websites/C/Comedy Central/metadata.json index 5ab58064b604..eec294246fca 100644 --- a/websites/C/Comedy Central/metadata.json +++ b/websites/C/Comedy Central/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Lacking", - "id": "132693143173857281" - }, - "service": "Comedy Central", - "description": { - "en": "Watch the latest Comedy Central shows such as South Park, The Daily Show, and more.", - "nl": "Bekijk de nieuwste Comedy Central-shows zoals South Park, The Daily Show en meer.", - "vi_VN": "Xem các bộ phim Comedy Central mới nhất như South Park, The Daily Show và hơn nữa." - }, - "url": "www.cc.com", - "version": "1.2.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Comedy%20Central/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Comedy%20Central/assets/thumbnail.png", - "color": "#f8ba00", - "category": "videos", - "tags": [ - "comedy-central", - "cc", - "video", - "tv", - "movies" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Lacking", + "id": "132693143173857281" + }, + "service": "Comedy Central", + "description": { + "en": "Watch the latest Comedy Central shows such as South Park, The Daily Show, and more.", + "nl": "Bekijk de nieuwste Comedy Central-shows zoals South Park, The Daily Show en meer.", + "vi_VN": "Xem các bộ phim Comedy Central mới nhất như South Park, The Daily Show và hơn nữa." + }, + "url": "www.cc.com", + "version": "1.2.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Comedy%20Central/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Comedy%20Central/assets/thumbnail.png", + "color": "#f8ba00", + "category": "videos", + "tags": [ + "comedy-central", + "cc", + "video", + "tv", + "movies" + ] +} diff --git a/websites/C/Comedy Central/presence.ts b/websites/C/Comedy Central/presence.ts index 38a94fe2a188..2bb2ab6913fa 100644 --- a/websites/C/Comedy Central/presence.ts +++ b/websites/C/Comedy Central/presence.ts @@ -1,52 +1,47 @@ const presence = new Presence({ - clientId: "630533580119998496", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }); + clientId: '630533580119998496', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Comedy%20Central/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Comedy%20Central/assets/logo.png', + } - if (document.location.pathname.startsWith("/episodes")) { - const player: HTMLVideoElement = document.querySelector( - ".edge-player-content-element" - ); - let epNumber: string | Element | HTMLElement = - document.querySelector(".meta span"); - epNumber &&= `${(epNumber as HTMLElement).textContent - .replace("Season ", "S") - .replace(" Ep ", ":E")} `; - epNumber ??= ""; + if (document.location.pathname.startsWith('/episodes')) { + const player = document.querySelector( + '.edge-player-content-element', + )! + let epNumber: string | Element | HTMLElement = document.querySelector('.meta span') ?? '' + epNumber &&= `${(epNumber as HTMLElement).textContent?.replace('Season ', 'S').replace(' Ep ', ':E')} ` + epNumber ??= ''; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - Math.floor(player.currentTime), - Math.floor(player.duration) - ); + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + Math.floor(player.currentTime), + Math.floor(player.duration), + ) - presenceData.details = document.querySelector(".header h3 a").textContent; - presenceData.state = - epNumber + document.querySelector(".sub-header h1").textContent; - presenceData.smallImageKey = player.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = player.paused - ? (await strings).pause - : (await strings).play; + presenceData.details = document.querySelector('.header h3 a')?.textContent + presenceData.state = epNumber + document.querySelector('.sub-header h1')?.textContent + presenceData.smallImageKey = player.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = player.paused + ? (await strings).pause + : (await strings).play - if (player.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } + if (player.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } - presence.setActivity(presenceData); - } else { - presenceData.details = "Browsing..."; - presenceData.startTimestamp = Date.now(); + presence.setActivity(presenceData) + } + else { + presenceData.details = 'Browsing...' + presenceData.startTimestamp = Date.now() - presence.setActivity(presenceData); - } -}); + presence.setActivity(presenceData) + } +}) diff --git a/websites/C/ComicK/metadata.json b/websites/C/ComicK/metadata.json index 9f8adaee23bf..2286a0d6da77 100644 --- a/websites/C/ComicK/metadata.json +++ b/websites/C/ComicK/metadata.json @@ -1,47 +1,47 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "वाह्य", - "id": "819696394180100106" - }, - "contributors": [ - { - "name": "Kyrie", - "id": "368399721494216706" - } - ], - "service": "ComicK", - "description": { - "en": "🚀 ComicK - Fastest Comic Reader", - "vi_VN": "🚀 ComicK - Trang đọc truyện tranh nhanh nhất" - }, - "url": [ - "comick.cc", - "comick.ink", - "comick.io" - ], - "version": "1.2.11", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/ComicK/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/ComicK/assets/thumbnail.png", - "color": "#f698c7", - "category": "other", - "tags": [ - "manga", - "comic-reader" - ], - "settings": [ - { - "id": "image", - "title": "Show Image", - "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": "वाह्य", + "id": "819696394180100106" + }, + "contributors": [ + { + "name": "Kyrie", + "id": "368399721494216706" + } + ], + "service": "ComicK", + "description": { + "en": "🚀 ComicK - Fastest Comic Reader", + "vi_VN": "🚀 ComicK - Trang đọc truyện tranh nhanh nhất" + }, + "url": [ + "comick.cc", + "comick.ink", + "comick.io" + ], + "version": "1.2.11", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/ComicK/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/ComicK/assets/thumbnail.png", + "color": "#f698c7", + "category": "other", + "tags": [ + "manga", + "comic-reader" + ], + "settings": [ + { + "id": "image", + "title": "Show Image", + "icon": "fad fa-images", + "value": true + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/C/ComicK/presence.ts b/websites/C/ComicK/presence.ts index f040250dfa11..a12e264f9434 100644 --- a/websites/C/ComicK/presence.ts +++ b/websites/C/ComicK/presence.ts @@ -1,106 +1,108 @@ const presence = new Presence({ - clientId: "866604211248824371", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - staticPages: Record = { - home: { details: "Browsing Homepage" }, - list: { details: "Viewing Followed List" }, - ranking: { details: "Looking at rankings" }, - commentlist: { details: "Looking at comment list" }, - settings: { details: "Settings" }, - languages: { details: "Languages" }, - privacy: { details: "Privacy Policy" }, - installapp: { details: "ComicK App" }, - }; + clientId: '866604211248824371', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const staticPages: Record = { + home: { details: 'Browsing Homepage' }, + list: { details: 'Viewing Followed List' }, + ranking: { details: 'Looking at rankings' }, + commentlist: { details: 'Looking at comment list' }, + settings: { details: 'Settings' }, + languages: { details: 'Languages' }, + privacy: { details: 'Privacy Policy' }, + installapp: { details: 'ComicK App' }, +} const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/ComicK/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/ComicK/assets/logo.png', } -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - details: "Browsing", - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }; - const { pathname, href } = document.location, - arrPath = pathname.replace("_", "").split("/"), - [image, buttons] = await Promise.all([ - presence.getSetting("image"), - presence.getSetting("buttons"), - ]); +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + details: 'Browsing', + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname, href } = document.location + const arrPath = pathname.replace('_', '').split('/') + const [image, buttons] = await Promise.all([ + presence.getSetting('image'), + presence.getSetting('buttons'), + ]) - switch (arrPath[1]) { - case "comic": { - const title = document.querySelector("h1"); - if (title) { - presenceData.details = "Reading Description"; - presenceData.state = title.textContent; - presenceData.largeImageKey = document.querySelector( - "meta[property='og:image']" - ).content; - presenceData.buttons = [ - { - label: "Read Description", - url: href, - }, - ]; - } else if (document.querySelector(".reader-container")) { - const img = document.querySelectorAll( - ".reader-container img" - )[1]; - presenceData.details = `Reading ${img.alt.substring( - 0, - img.alt.indexOf("chapter") - )}`; - presenceData.state = img.alt.substring( - img.alt.indexOf("chapter"), - img.alt.indexOf(",") - ); - presenceData.largeImageKey = document.querySelector( - "meta[property='og:image']" - ).content; - presenceData.buttons = [ - { - label: "Read Chapter", - url: href, - }, - { - label: "Read Description", - url: href.split(/(.+)[\\/]/)[1], - }, - ]; - } - break; - } - case "group": - presenceData.details = "Looking at group"; - presenceData.state = - document.querySelector("h1").textContent; - break; - case "search": { - presenceData.details = "Searching"; - const research = document.querySelector("div > h1")?.textContent; - if (research) presenceData.state = research; - break; - } - case "user": - presenceData.details = "Viewing their profile"; - if (arrPath.length > 2) { - presenceData.details = "Viewing"; - presenceData.state = - document.querySelector("h1").textContent; - presenceData.largeImageKey = document - .querySelector("#__next div > div > img") - .src.replace("size=200", "size=640"); - } - break; - default: - if (Object.keys(staticPages).includes(arrPath[1])) - presenceData = { ...presenceData, ...staticPages[arrPath[1]] }; - } + switch (arrPath[1]) { + case 'comic': { + const title = document.querySelector('h1') + if (title) { + presenceData.details = 'Reading Description' + presenceData.state = title.textContent + presenceData.largeImageKey = document.querySelector( + 'meta[property=\'og:image\']', + )?.content + presenceData.buttons = [ + { + label: 'Read Description', + url: href, + }, + ] + } + else if (document.querySelector('.reader-container')) { + const img = document.querySelectorAll( + '.reader-container img', + )[1] + presenceData.details = `Reading ${img.alt.substring( + 0, + img.alt.indexOf('chapter'), + )}` + presenceData.state = img.alt.substring( + img.alt.indexOf('chapter'), + img.alt.indexOf(','), + ) + presenceData.largeImageKey = document.querySelector( + 'meta[property=\'og:image\']', + )?.content + presenceData.buttons = [ + { + label: 'Read Chapter', + url: href, + }, + { + label: 'Read Description', + url: href.split(/(.+)[\\/]/)[1], + }, + ] + } + break + } + case 'group': + presenceData.details = 'Looking at group' + presenceData.state = document.querySelector('h1')?.textContent + break + case 'search': { + presenceData.details = 'Searching' + const research = document.querySelector('div > h1')?.textContent + if (research) + presenceData.state = research + break + } + case 'user': + presenceData.details = 'Viewing their profile' + if (arrPath.length > 2) { + presenceData.details = 'Viewing' + presenceData.state = document.querySelector('h1')?.textContent + presenceData.largeImageKey = document + .querySelector('#__next div > div > img') + ?.src + .replace('size=200', 'size=640') + } + break + default: + if (Object.keys(staticPages).includes(arrPath[1])) + presenceData = { ...presenceData, ...staticPages[arrPath[1]] } + } - if (!image && presenceData.largeImageKey !== Assets.Logo) - presenceData.largeImageKey = Assets.Logo; - if (!buttons && presenceData.buttons) delete presenceData.buttons; - presence.setActivity(presenceData); -}); + if (!image && presenceData.largeImageKey !== Assets.Logo) + presenceData.largeImageKey = Assets.Logo + if (!buttons && presenceData.buttons) + delete presenceData.buttons + presence.setActivity(presenceData) +}) diff --git a/websites/C/CoolMathGames/metadata.json b/websites/C/CoolMathGames/metadata.json index 6045a424df24..f0b3b76bccda 100644 --- a/websites/C/CoolMathGames/metadata.json +++ b/websites/C/CoolMathGames/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Striker", - "id": "215509157837537280" - }, - "service": "CoolMathGames", - "description": { - "en": "Coolmath Games is a brain-training site, for everyone, where logic & thinking & math meets fun & games.", - "nl": "Coolmath Games is een hersentrainingssite, voor iedereen, waar logica & denken & rekenen samenkomen met plezier & games.", - "vi_VN": "CoolMathGames là trang luyện trí óc, dành cho tất cả mọi người, nơi logic & suy nghĩ & toán gặp gỡ trò chơi & vui nhộn." - }, - "url": [ - "www.coolmathgames.com", - "coolmathgames.com" - ], - "version": "1.2.28", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CoolMathGames/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CoolMathGames/assets/thumbnail.png", - "color": "#3DB5F9", - "category": "games", - "tags": [ - "entertainment", - "fun" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Striker", + "id": "215509157837537280" + }, + "service": "CoolMathGames", + "description": { + "en": "Coolmath Games is a brain-training site, for everyone, where logic & thinking & math meets fun & games.", + "nl": "Coolmath Games is een hersentrainingssite, voor iedereen, waar logica & denken & rekenen samenkomen met plezier & games.", + "vi_VN": "CoolMathGames là trang luyện trí óc, dành cho tất cả mọi người, nơi logic & suy nghĩ & toán gặp gỡ trò chơi & vui nhộn." + }, + "url": [ + "www.coolmathgames.com", + "coolmathgames.com" + ], + "version": "1.2.28", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CoolMathGames/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CoolMathGames/assets/thumbnail.png", + "color": "#3DB5F9", + "category": "games", + "tags": [ + "entertainment", + "fun" + ] +} diff --git a/websites/C/CoolMathGames/presence.ts b/websites/C/CoolMathGames/presence.ts index 7e0cfdd51b2a..e9629bb79963 100644 --- a/websites/C/CoolMathGames/presence.ts +++ b/websites/C/CoolMathGames/presence.ts @@ -1,88 +1,98 @@ const presence = new Presence({ - clientId: "630561466872889344", -}); + clientId: '630561466872889344', +}) enum PageType { - Game = 0, - Category = 1, + Game = 0, + Category = 1, } -const capitalize = (text: string[]): string => { - return text - .map(str => { - return str.charAt(0).toUpperCase() + str.slice(1); - }) - .join(" "); - }, - parse = (path: string): string[] => { - path = path.replace("/", ""); - const split: string[] = path.split("-"); +function capitalize(text: string[]): string { + return text + .map((str) => { + return str.charAt(0).toUpperCase() + str.slice(1) + }) + .join(' ') +} +function parse(path: string): string[] { + path = path.replace('/', '') + const split: string[] = path.split('-') - return [split[0], capitalize(split.slice(1))]; - }; + return [split[0], capitalize(split.slice(1))] +} -let elapsed: number, oldUrl: string; +let elapsed: number, oldUrl: string -presence.on("UpdateData", async () => { - if (window.location.href !== oldUrl) { - oldUrl = window.location.href; - elapsed = Math.floor(Date.now() / 1000); - } +presence.on('UpdateData', async () => { + if (window.location.href !== oldUrl) { + oldUrl = window.location.href + elapsed = Math.floor(Date.now() / 1000) + } - let details, state; + let details, state - const path = window.location.pathname; + const path = window.location.pathname - if (path === "/") details = "Browsing..."; - else if (path.match("/user") || path.match("/signup")) { - if (path.match("signup")) details = "Signing up..."; - else details = "Logging in..."; - } else if (path.match("/terms-use")) details = "Viewing Terms of Use"; - else if (path.match("/trivia")) { - details = "Viewing Trivia"; + if (path === '/') { + details = 'Browsing...' + } + else if (path.match('/user') || path.match('/signup')) { + if (path.match('signup')) + details = 'Signing up...' + else details = 'Logging in...' + } + else if (path.match('/terms-use')) { + details = 'Viewing Terms of Use' + } + else if (path.match('/trivia')) { + details = 'Viewing Trivia' - const title = document.querySelector("#start-the-quiz-title"); - if (title) state = title.textContent; - } else { - const breadcrumb = document.querySelector( - ".pane-content > .breadcrumb > ol" - ), - breadcrumbLast = document.querySelector( - ".pane-content > .breadcrumb > ol > li:last-child > span" - ), - difficulty = document.querySelector("a.active"); - if (breadcrumb && breadcrumbLast && difficulty) { - details = "Viewing Jigsaw Puzzle"; - state = `${breadcrumbLast.textContent} (${difficulty.textContent})`; - } else if (breadcrumb && breadcrumbLast) { - details = "Viewing Jigsaw Puzzles"; - state = breadcrumbLast.textContent; - } else if (document.querySelector(".playlists-queue-wrapper")) { - details = "Viewing Category"; - state = "Jigsaw Puzzles"; - } else { - const [parsedInt, parsedName] = parse(path); - switch (parseInt(parsedInt)) { - case PageType.Category: - details = "Viewing Category"; - break; + const title = document.querySelector('#start-the-quiz-title') + if (title) + state = title.textContent + } + else { + const breadcrumb = document.querySelector( + '.pane-content > .breadcrumb > ol', + ) + const breadcrumbLast = document.querySelector( + '.pane-content > .breadcrumb > ol > li:last-child > span', + ) + const difficulty = document.querySelector('a.active') + if (breadcrumb && breadcrumbLast && difficulty) { + details = 'Viewing Jigsaw Puzzle' + state = `${breadcrumbLast.textContent} (${difficulty.textContent})` + } + else if (breadcrumb && breadcrumbLast) { + details = 'Viewing Jigsaw Puzzles' + state = breadcrumbLast.textContent + } + else if (document.querySelector('.playlists-queue-wrapper')) { + details = 'Viewing Category' + state = 'Jigsaw Puzzles' + } + else { + const [parsedInt, parsedName] = parse(path) + switch (Number.parseInt(parsedInt)) { + case PageType.Category: + details = 'Viewing Category' + break - case PageType.Game: - details = "Viewing Game"; - break; + case PageType.Game: + details = 'Viewing Game' + break - default: - break; - } - state = parsedName; - } - } + default: + break + } + state = parsedName + } + } - presence.setActivity({ - details, - state, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CoolMathGames/assets/logo.png", - startTimestamp: elapsed, - }); -}); + presence.setActivity({ + details, + state, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CoolMathGames/assets/logo.png', + startTimestamp: elapsed, + }) +}) diff --git a/websites/C/Cosmote TV/metadata.json b/websites/C/Cosmote TV/metadata.json index 6feb65a1e0e5..59f10ffd1d9c 100644 --- a/websites/C/Cosmote TV/metadata.json +++ b/websites/C/Cosmote TV/metadata.json @@ -1,46 +1,46 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Vasilis", - "id": "241929388403195914" - }, - "service": "Cosmote TV", - "description": { - "en": "The new COSMOTE TV OTT service upgrades your TV viewing experience with new features that reveal the unsurpassed content of COSMOTE TV.", - "el_GR": "Με τη νέα υπηρεσία COSMOTE TV ΟΤΤ η τηλεοπτική σου εμπειρία αναβαθμίζεται με νέες λειτουργίες που αναδεικνύουν το αξεπέραστο περιεχόμενο της COSMOTE TV.", - "vi_VN": "Dịch vụ COSMOTE TV OTT mới nhất nâng cấp trải nghiệm TV của bạn với các tính năng mới, lật mở lượng nội dung không thể địch nổi của COSMOTE TV." - }, - "url": "www.cosmotetvott.gr", - "version": "2.0.12", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cosmote%20TV/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cosmote%20TV/assets/thumbnail.png", - "color": "#14D900", - "category": "videos", - "tags": [ - "live", - "television", - "greece", - "greek", - "series", - "movies" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "logo", - "title": "Show Channel Logo", - "icon": "fad fa-images", - "value": true - }, - { - "id": "timestamps", - "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": "Vasilis", + "id": "241929388403195914" + }, + "service": "Cosmote TV", + "description": { + "en": "The new COSMOTE TV OTT service upgrades your TV viewing experience with new features that reveal the unsurpassed content of COSMOTE TV.", + "el_GR": "Με τη νέα υπηρεσία COSMOTE TV ΟΤΤ η τηλεοπτική σου εμπειρία αναβαθμίζεται με νέες λειτουργίες που αναδεικνύουν το αξεπέραστο περιεχόμενο της COSMOTE TV.", + "vi_VN": "Dịch vụ COSMOTE TV OTT mới nhất nâng cấp trải nghiệm TV của bạn với các tính năng mới, lật mở lượng nội dung không thể địch nổi của COSMOTE TV." + }, + "url": "www.cosmotetvott.gr", + "version": "2.0.12", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cosmote%20TV/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cosmote%20TV/assets/thumbnail.png", + "color": "#14D900", + "category": "videos", + "tags": [ + "live", + "television", + "greece", + "greek", + "series", + "movies" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "logo", + "title": "Show Channel Logo", + "icon": "fad fa-images", + "value": true + }, + { + "id": "timestamps", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + } + ] +} diff --git a/websites/C/Cosmote TV/presence.ts b/websites/C/Cosmote TV/presence.ts index b8183aa6a97c..d2d0b57fdbc9 100644 --- a/websites/C/Cosmote TV/presence.ts +++ b/websites/C/Cosmote TV/presence.ts @@ -1,210 +1,210 @@ const presence = new Presence({ - clientId: "883446187099840562", -}); + clientId: '883446187099840562', +}) async function getStrings() { - return presence.getStrings( - { - play: "general.playing", - pause: "general.paused", - live: "general.live", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + play: 'general.playing', + pause: 'general.paused', + live: 'general.live', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } -let channel: string, - channelTimestamp: number, - strings: Awaited>, - oldLang: string = null; +let channel: string +let channelTimestamp: number | null = null +let strings: Awaited> +let oldLang: string | null = null -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Cosmote%20TV/assets/logo.png", - }; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Cosmote%20TV/assets/logo.png', + } - const pages: Record = { - "#!": { - details: "Browsing", - }, - search: { - details: "Searching", - state: - document.querySelector("#searchFieldInput")?.value, - smallImageKey: Assets.Search, - smallImageText: "Searching", - }, - loginSplash: { - details: "Logging In", - }, - channels: { - details: "Browsing Channels", - }, - watchlist: { - details: "Viewing Watchlist", - }, - settings: { - details: "Viewing Settings", - }, - privacy: { - details: "Viewing Privacy Policy", - }, - livetv: { - details: "Browsing Live TV", - }, - inbox: { - details: "Viewing Inbox", - }, - "livetv/replaytv": { - details: "Browsing Replay TV", - }, - "livetv/guide": { - details: "Browsing Live TV Guide", - }, - "onDemand/FILMS": { - details: "Browsing Films", - }, - "onDemand/SERIES": { - details: "Browsing Series", - }, - "onDemand/MOVIES_CLUB": { - details: "Browsing Movies Club", - }, - "onDemand/SPORTS": { - details: "Browsing Sports", - }, - "onDemand/DOCUMENTARIES": { - details: "Browsing Documentaries", - }, - "onDemand/KIDS": { - details: "Browsing Kids Content", - }, - }, - [newLang, logo, timestamps] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("logo"), - presence.getSetting("timestamps"), - ]); + const pages: Record = { + '#!': { + details: 'Browsing', + }, + 'search': { + details: 'Searching', + state: document.querySelector('#searchFieldInput')?.value, + smallImageKey: Assets.Search, + smallImageText: 'Searching', + }, + 'loginSplash': { + details: 'Logging In', + }, + 'channels': { + details: 'Browsing Channels', + }, + 'watchlist': { + details: 'Viewing Watchlist', + }, + 'settings': { + details: 'Viewing Settings', + }, + 'privacy': { + details: 'Viewing Privacy Policy', + }, + 'livetv': { + details: 'Browsing Live TV', + }, + 'inbox': { + details: 'Viewing Inbox', + }, + 'livetv/replaytv': { + details: 'Browsing Replay TV', + }, + 'livetv/guide': { + details: 'Browsing Live TV Guide', + }, + 'onDemand/FILMS': { + details: 'Browsing Films', + }, + 'onDemand/SERIES': { + details: 'Browsing Series', + }, + 'onDemand/MOVIES_CLUB': { + details: 'Browsing Movies Club', + }, + 'onDemand/SPORTS': { + details: 'Browsing Sports', + }, + 'onDemand/DOCUMENTARIES': { + details: 'Browsing Documentaries', + }, + 'onDemand/KIDS': { + details: 'Browsing Kids Content', + }, + } + const [newLang, logo, timestamps] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('logo'), + presence.getSetting('timestamps'), + ]) - for (const [path, data] of Object.entries(pages)) { - if (document.location.hash.includes(path)) - presenceData = { ...presenceData, ...data }; - } + for (const [path, data] of Object.entries(pages)) { + if (document.location.hash.includes(path)) + presenceData = { ...presenceData, ...data } as PresenceData + } - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - if (document.querySelector("div[ng-if='showPlayer']")) { - const { paused, currentTime, duration } = - document.querySelector("video#arxPlayer"); - // TV - if ( - document.querySelector( - "div[ng-if='details.channelLogoWide'] > .wide-logo" - ) - ) { - presenceData.details = document.querySelector( - ".meta-title[ng-bind~='details.title']" - )?.textContent; - presenceData.state = document.querySelector( - ".meta-title[ng-bind='details.channel.title']" - )?.textContent; - if (logo) { - presenceData.largeImageKey = document - .querySelector( - "div[ng-if='details.channelLogoWide'] > .wide-logo" - ) - ?.src.replace("-wide", "-normal"); - } + if (document.querySelector('div[ng-if=\'showPlayer\']')) { + const { paused, currentTime, duration } = document.querySelector('video#arxPlayer')! + // TV + if ( + document.querySelector( + 'div[ng-if=\'details.channelLogoWide\'] > .wide-logo', + ) + ) { + presenceData.details = document.querySelector( + '.meta-title[ng-bind~=\'details.title\']', + )?.textContent + presenceData.state = document.querySelector( + '.meta-title[ng-bind=\'details.channel.title\']', + )?.textContent + if (logo) { + presenceData.largeImageKey = document + .querySelector( + 'div[ng-if=\'details.channelLogoWide\'] > .wide-logo', + ) + ?.src + .replace('-wide', '-normal') + } - // Live - if (document.querySelector(".meta-remain")) { - if (channel !== presenceData.state || !channelTimestamp) - channelTimestamp = Math.floor(Date.now() / 1000); + // Live + if (document.querySelector('.meta-remain')) { + if (channel !== presenceData.state || !channelTimestamp) + channelTimestamp = Math.floor(Date.now() / 1000) - presenceData.startTimestamp = channelTimestamp; + presenceData.startTimestamp = channelTimestamp - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Live; - presenceData.smallImageText = paused ? strings.pause : strings.live; - } else { - // Replay / Timeshift - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - presence.timestampFromFormat( - document.querySelector("#VcurrentTime") - .textContent - ), - presence.timestampFromFormat( - document.querySelector("#Vduration").textContent - ) - ); + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Live + presenceData.smallImageText = paused ? strings.pause : strings.live + } + else { + // Replay / Timeshift + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + presence.timestampFromFormat( + document.querySelector('#VcurrentTime')?.textContent ?? '', + ), + presence.timestampFromFormat( + document.querySelector('#Vduration')?.textContent ?? '', + ), + ) - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = paused ? strings.pause : strings.play; - } - channel = presenceData.state; - } else { - // On Demand - presenceData.details = document.querySelector( - ".meta-title[ng-bind~='details.title']" - ).textContent; - // Series - if ( - document.querySelector( - "span[ng-bind='details.seriesSubs']" - )?.textContent.length > 0 - ) { - const episode = document - .querySelector("span[ng-bind='details.seriesSubs']") - .textContent.split(" / ", 3) - .map(str => str.trim()); + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = paused ? strings.pause : strings.play + } + channel = presenceData.state! + } + else { + // On Demand + presenceData.details = document.querySelector( + '.meta-title[ng-bind~=\'details.title\']', + )?.textContent + // Series + if ( + (document.querySelector( + 'span[ng-bind=\'details.seriesSubs\']', + )?.textContent?.length ?? 0) > 0 + ) { + const episode = document + .querySelector('span[ng-bind=\'details.seriesSubs\']')! + .textContent! + .split(' / ', 3) + .map(str => str.trim()) - switch (episode.length) { - case 3: - if ( - presenceData.details !== episode[2] && - !episode[2].endsWith(` ${episode[1]}`) && - !episode[2].endsWith(` ${episode[1].replace("Ε", "E")}`) - ) - presenceData.state = `${episode[0]}:${episode[1]} ${episode[2]}`; - else { - presenceData.state = `${episode[0] - .replace("S", "Season ") - .replace("Κ", "Κύκλος ")} ${episode[1] - .replace("E", "Episode ") - .replace("Ε", "Επεισόδιο ")}`; - } - break; - case 2: - presenceData.state = episode[0] - .replace("E", "Episode ") - .replace("Ε", "Επεισόδιο "); - if ( - presenceData.details !== episode[1] && - !episode[1].endsWith(` ${episode[0]}`) - ) - presenceData.state += `: ${episode[1]}`; - break; - case 1: - presenceData.state = episode[0]; - } - } + switch (episode.length) { + case 3: + if ( + presenceData.details !== episode[2] + && !episode[2].endsWith(` ${episode[1]}`) + && !episode[2].endsWith(` ${episode[1].replace('Ε', 'E')}`) + ) { + presenceData.state = `${episode[0]}:${episode[1]} ${episode[2]}` + } + else { + presenceData.state = `${episode[0] + .replace('S', 'Season ') + .replace('Κ', 'Κύκλος ')} ${episode[1] + .replace('E', 'Episode ') + .replace('Ε', 'Επεισόδιο ')}` + } + break + case 2: + presenceData.state = episode[0] + .replace('E', 'Episode ') + .replace('Ε', 'Επεισόδιο ') + if ( + presenceData.details !== episode[1] + && !episode[1].endsWith(` ${episode[0]}`) + ) { + presenceData.state += `: ${episode[1]}` + } + break + case 1: + presenceData.state = episode[0] + } + } - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(Math.floor(currentTime), Math.floor(duration)); + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(Math.floor(currentTime), Math.floor(duration)) - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = paused ? strings.pause : strings.play; - } + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = paused ? strings.pause : strings.play + } - if (paused || !timestamps) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - channelTimestamp = null; - } - } - presence.setActivity(presenceData); -}); + if (paused || !timestamps) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + channelTimestamp = null + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/C/Coub/metadata.json b/websites/C/Coub/metadata.json index bc02b24798cf..75121cc95250 100644 --- a/websites/C/Coub/metadata.json +++ b/websites/C/Coub/metadata.json @@ -1,58 +1,58 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Cascade", - "id": "442612628104151040" - }, - "contributors": [ - { - "name": "Mirax", - "id": "223355525826347018" - } - ], - "service": "Coub", - "description": { - "ru": "Coub это сайт-видеохостинг, позволяющий своим пользователям публиковать короткие зацикленные видеоролики с несинхронным звуковым сопровождением — «коубы». ", - "en": "Coub is a video sharing website. It allows users to create and share looping videos up to ten seconds long, using existing video from YouTube, Vimeo, or their own files", - "de": "Coub ist eine Video-Sharing-Website, die sowohl für iOS als auch für Android verfügbar ist. Benutzer können Loop-Videos mit einer Länge von bis zu zehn Sekunden erstellen und freigeben, indem sie vorhandene Videos von YouTube, Vimeo oder ihren eigenen Dateien verwenden.", - "nl": "Coub is een website voor het delen van video's. Hiermee kunnen gebruikers looping-video's tot tien seconden lang maken en delen, met behulp van bestaande video van YouTube, Vimeo of hun eigen bestanden", - "vi_VN": "Coub là trang web chia sẻ video trực tuyến. Nó cho phép người dùng tạo và chia sẻ video lặp lại lên tới mười giây, sử dụng các video có sẵn tại YouTube, Vimeo, hoặc tệp riêng của họ" - }, - "url": "coub.com", - "version": "2.1.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Coub/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Coub/assets/thumbnail.png", - "color": "#0084FF", - "category": "videos", - "tags": [ - "socials", - "music", - "video", - "media" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "show_button_watching", - "title": "Show current playing button", - "icon": "fas fa-external-link-alt", - "value": true - }, - { - "id": "show_externalLargeImage", - "title": "Show Thumbnails (community/channel images)", - "icon": "fas fa-image", - "value": true - }, - { - "id": "show_startedBrowsing", - "title": "Show Elapsed Time", - "icon": "fas fa-stopwatch", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Cascade", + "id": "442612628104151040" + }, + "contributors": [ + { + "name": "Mirax", + "id": "223355525826347018" + } + ], + "service": "Coub", + "description": { + "ru": "Coub это сайт-видеохостинг, позволяющий своим пользователям публиковать короткие зацикленные видеоролики с несинхронным звуковым сопровождением — «коубы». ", + "en": "Coub is a video sharing website. It allows users to create and share looping videos up to ten seconds long, using existing video from YouTube, Vimeo, or their own files", + "de": "Coub ist eine Video-Sharing-Website, die sowohl für iOS als auch für Android verfügbar ist. Benutzer können Loop-Videos mit einer Länge von bis zu zehn Sekunden erstellen und freigeben, indem sie vorhandene Videos von YouTube, Vimeo oder ihren eigenen Dateien verwenden.", + "nl": "Coub is een website voor het delen van video's. Hiermee kunnen gebruikers looping-video's tot tien seconden lang maken en delen, met behulp van bestaande video van YouTube, Vimeo of hun eigen bestanden", + "vi_VN": "Coub là trang web chia sẻ video trực tuyến. Nó cho phép người dùng tạo và chia sẻ video lặp lại lên tới mười giây, sử dụng các video có sẵn tại YouTube, Vimeo, hoặc tệp riêng của họ" + }, + "url": "coub.com", + "version": "2.1.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Coub/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Coub/assets/thumbnail.png", + "color": "#0084FF", + "category": "videos", + "tags": [ + "socials", + "music", + "video", + "media" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "show_button_watching", + "title": "Show current playing button", + "icon": "fas fa-external-link-alt", + "value": true + }, + { + "id": "show_externalLargeImage", + "title": "Show Thumbnails (community/channel images)", + "icon": "fas fa-image", + "value": true + }, + { + "id": "show_startedBrowsing", + "title": "Show Elapsed Time", + "icon": "fas fa-stopwatch", + "value": true + } + ] +} diff --git a/websites/C/Coub/presence.ts b/websites/C/Coub/presence.ts index e750a3203c0d..8c48ebda2d5b 100644 --- a/websites/C/Coub/presence.ts +++ b/websites/C/Coub/presence.ts @@ -1,342 +1,357 @@ -type LocalizedStrings = typeof localizedStrings; +type LocalizedStrings = typeof localizedStrings interface PageContext { - middleware: (ref: Window, ...args: unknown[]) => boolean; - exec: ( - context: Presence, - presenceData: PresenceData, - options?: { strings: LocalizedStrings; [key: string]: unknown } - ) => Promise | PresenceData; + middleware: (ref: Window, ...args: unknown[]) => boolean + exec: ( + context: Presence, + presenceData: PresenceData, + options?: any + ) => Promise | PresenceData | null } interface ExecutionArguments { - showWatch?: boolean; - showExternalImages?: boolean; - strings: LocalizedStrings; - images: { [key: string]: string }; - [key: string]: unknown; + showWatch?: boolean + showExternalImages?: boolean + strings: LocalizedStrings + images: { [key: string]: string } + [key: string]: unknown } function getQuery() { - const queryString = location.search.split("?", 2), - query = - queryString && queryString.length > 0 && queryString[1] - ? queryString[1].split("&").reduce(function (l, r) { - const entry = r ? r.split("=", 2) : null; - if (entry === null) return l; - return Object.assign(l, { [entry[0]]: entry[1] }); - }, {}) - : {}; - return query; + const queryString = location.search.split('?', 2) + const query = queryString && queryString.length > 0 && queryString[1] + ? queryString[1].split('&').reduce((l, r) => { + const entry = r ? r.split('=', 2) : null + if (entry === null) + return l + return Object.assign(l, { [entry[0]]: entry[1] }) + }, {}) + : {} + return query } function capitalizeFirstLetter(string: string) { - return string.charAt(0).toUpperCase() + string.slice(1); + return string.charAt(0).toUpperCase() + string.slice(1) } const pages: PageContext[] = [ - { - middleware: ref => - /^\/(hot|tags|rising|fresh|feed|rising|stories|random|bookmarks|likes|weekly|best|stories|royal\.coubs|\/)/gi.test( - ref.location.pathname - ) || location.pathname === "/", - exec: ( - context, - data, - { showWatch, strings, images }: ExecutionArguments - ) => { - if (!context) return null; - const activeMedia = document.querySelector( - ".coub[coub-block].active" - ); - if (!activeMedia) return null; - const title = activeMedia - .querySelector(".description__title") - ?.textContent?.trim(), - activeTab = - document.querySelector( - ".page__content .page-menu > .page-menu__inner > .page-menu__item.-active" - ) || - document.querySelector( - ".best2020__container .page-menu > .page-menu__inner > .page-menu__item.-active" - ) || - document.querySelector( - ".page__content .story__header" - ), - isCoubPicks = location.pathname.startsWith("/royal.coubs"), - activeTabTitle = - activeTab?.textContent?.trim() || - activeTab?.dataset?.title || - "Feed"; - if (!title) return null; - const pageType = document - .querySelector(".page__content") - ?.getAttributeNames() - ?.map(x => x.match(/^pages-(\w+)-page/i)) - .filter(x => !!x && x.length > 1 && x[1]) - .map(x => capitalizeFirstLetter(x[1])); - data.state = `Browsing ${ - isCoubPicks && activeTabTitle.match(/^(\w+)/gi) - ? activeTabTitle.match(/^(\w+)/gi)[0] - : activeTabTitle - }${ - pageType?.length > 0 && - activeTabTitle.toLowerCase() !== pageType[0].toLowerCase() - ? ` in ${pageType[0]}` - : document.querySelector(".page__content .page-menu.weekly__menu") - ? " in Weekly" - : location.pathname.startsWith("/best") - ? " in Best of the Year" - : isCoubPicks - ? " in Coub Picks" - : "" - }`; - data.details = `${title}${ - activeMedia.querySelector( - ".coub__like-button[widget-like-button].-on" - ) - ? " (❤)" - : "" - }`; - data.smallImageKey = - activeMedia.querySelector("video")?.paused === false - ? images.PLAY - : images.PAUSE; - if (showWatch) { - data.buttons = [ - { - label: strings.watchVideo, - url: `${document.location.origin}/view/${activeMedia.dataset.permalink}`, - }, - ]; - } - return data; - }, - }, - { - middleware: ref => - !!ref.document.querySelector(".hero-cover[channel-id]"), - exec: ( - context, - data, - { showWatch, showExternalImages, strings, images }: ExecutionArguments - ) => { - if (!context) return null; - const activeMedia = document.querySelector( - ".coub[coub-block].active" - ); - if (!activeMedia) return null; - const title = activeMedia - .querySelector(".description__title") - .textContent?.trim(), - channelParent = document.querySelector(".channel"), - userName = channelParent.querySelector( - ".channel__description > h1[title]" - ).title, - userImage = channelParent.querySelector( - '.avatar-upload img[src*="coub_storage/channel"]' - )?.src, - activeTab = - document.querySelector( - ".page__content .page-menu > .page-menu__inner > .page-menu__item.-active" - ) || - document.querySelector( - ".best2020__container .page-menu > .page-menu__inner > .page-menu__item.-active" - ) || - document.querySelector( - ".page__content .story__header" - ); + { + middleware: ref => + /^\/(?:hot|tags|rising|fresh|feed|stories|random|bookmarks|likes|weekly|best|royal\.coubs|\/)/i.test( + ref.location.pathname, + ) || location.pathname === '/', + exec: ( + context, + data, + { showWatch, strings, images }: ExecutionArguments, + ) => { + if (!context) + return null + const activeMedia = document.querySelector( + '.coub[coub-block].active', + ) + if (!activeMedia) + return null + const title = activeMedia + .querySelector('.description__title') + ?.textContent + ?.trim() + const activeTab = document.querySelector( + '.page__content .page-menu > .page-menu__inner > .page-menu__item.-active', + ) + || document.querySelector( + '.best2020__container .page-menu > .page-menu__inner > .page-menu__item.-active', + ) + || document.querySelector( + '.page__content .story__header', + ) + const isCoubPicks = location.pathname.startsWith('/royal.coubs') + const activeTabTitle = activeTab?.textContent?.trim() + || activeTab?.dataset?.title + || 'Feed' + if (!title) + return null + const pageType = document + .querySelector('.page__content') + ?.getAttributeNames() + ?.map(x => x.match(/^pages-(\w+)-page/i)) + .filter(x => !!x && x.length > 1 && x[1]) + .map(x => capitalizeFirstLetter(x![1])) + data.state = `Browsing ${ + isCoubPicks && activeTabTitle.match(/^(\w+)/g) + ? activeTabTitle.match(/^(\w+)/g)?.[0] + : activeTabTitle + }${ + (pageType?.length ?? 0) > 0 + && activeTabTitle.toLowerCase() !== pageType![0].toLowerCase() + ? ` in ${pageType![0]}` + : document.querySelector('.page__content .page-menu.weekly__menu') + ? ' in Weekly' + : location.pathname.startsWith('/best') + ? ' in Best of the Year' + : isCoubPicks + ? ' in Coub Picks' + : '' + }` + data.details = `${title}${ + activeMedia.querySelector( + '.coub__like-button[widget-like-button].-on', + ) + ? ' (❤)' + : '' + }` + data.smallImageKey = activeMedia.querySelector('video')?.paused === false + ? images.PLAY + : images.PAUSE + if (showWatch) { + data.buttons = [ + { + label: strings.watchVideo, + url: `${document.location.origin}/view/${activeMedia.dataset.permalink}`, + }, + ] + } + return data + }, + }, + { + middleware: ref => + !!ref.document.querySelector('.hero-cover[channel-id]'), + exec: ( + context, + data, + { showWatch, showExternalImages, strings, images }: ExecutionArguments, + ) => { + if (!context) + return null + const activeMedia = document.querySelector( + '.coub[coub-block].active', + ) + if (!activeMedia) + return null + const title = activeMedia + .querySelector('.description__title') + ?.textContent + ?.trim() + const channelParent = document.querySelector('.channel') + const userName = channelParent?.querySelector( + '.channel__description > h1[title]', + )?.title + const userImage = channelParent?.querySelector( + '.avatar-upload img[src*="coub_storage/channel"]', + )?.src + const activeTab = document.querySelector( + '.page__content .page-menu > .page-menu__inner > .page-menu__item.-active', + ) + || document.querySelector( + '.best2020__container .page-menu > .page-menu__inner > .page-menu__item.-active', + ) + || document.querySelector( + '.page__content .story__header', + ) - if (!title || !userName) return null; - data.state = `Browsing ${ - activeTab?.textContent.trimStart().split("\n")[0]?.trim() || - activeTab?.dataset?.title || - "Feed" - } from ${userName}`; - data.details = `${title}${ - activeMedia.querySelector( - ".coub__like-button[widget-like-button].-on" - ) - ? " (❤)" - : "" - }`; - if (showExternalImages && userImage?.startsWith("https://")) - data.largeImageKey = userImage; - data.smallImageKey = - activeMedia.querySelector("video")?.paused === false - ? images.PLAY - : images.PAUSE; - if (showWatch) { - data.buttons = [ - { - label: strings.watchVideo, - url: `${document.location.origin}/view/${activeMedia.dataset.permalink}`, - }, - { - label: strings.viewProfile, - url: `${document.location.origin}/${ - document.location.pathname.split("/")[1] - }`, - }, - ]; - } - return data; - }, - }, - { - middleware: ref => /^\/view\/(.*)/gi.test(ref.location.pathname), - exec: ( - context, - data, - { strings, showWatch, images }: ExecutionArguments - ) => { - if (!context) return null; - const activeMedia = - document.querySelector(".coub[coub-block]"); - if (!activeMedia) return null; - const title = activeMedia - .querySelector(".coub__description h5.description__title") - ?.textContent?.trim(); + if (!title || !userName) + return null + data.state = `Browsing ${ + activeTab?.textContent?.trimStart().split('\n')[0]?.trim() + || activeTab?.dataset?.title + || 'Feed' + } from ${userName}` + data.details = `${title}${ + activeMedia.querySelector( + '.coub__like-button[widget-like-button].-on', + ) + ? ' (❤)' + : '' + }` + if (showExternalImages && userImage?.startsWith('https://')) + data.largeImageKey = userImage + data.smallImageKey = activeMedia.querySelector('video')?.paused === false + ? images.PLAY + : images.PAUSE + if (showWatch) { + data.buttons = [ + { + label: strings.watchVideo, + url: `${document.location.origin}/view/${activeMedia.dataset.permalink}`, + }, + { + label: strings.viewProfile, + url: `${document.location.origin}/${ + document.location.pathname.split('/')[1] + }`, + }, + ] + } + return data + }, + }, + { + middleware: ref => /^\/view\/.*/i.test(ref.location.pathname), + exec: ( + context, + data, + { strings, showWatch, images }: ExecutionArguments, + ) => { + if (!context) + return null + const activeMedia = document.querySelector('.coub[coub-block]') + if (!activeMedia) + return null + const title = activeMedia + .querySelector('.coub__description h5.description__title') + ?.textContent + ?.trim() - if (!title) return null; - data.state = strings.watching; - data.details = `${title}${ - activeMedia.querySelector( - ".coub__like-button[widget-like-button].-on" - ) - ? " (❤)" - : "" - }`; - data.smallImageKey = - activeMedia.querySelector("video")?.paused === false - ? images.PLAY - : images.PAUSE; + if (!title) + return null + data.state = strings.watching + data.details = `${title}${ + activeMedia.querySelector( + '.coub__like-button[widget-like-button].-on', + ) + ? ' (❤)' + : '' + }` + data.smallImageKey = activeMedia.querySelector('video')?.paused === false + ? images.PLAY + : images.PAUSE - if (showWatch) { - data.buttons = [ - { - label: strings.watchVideo, - url: document.location.href, - }, - ]; - } - return data; - }, - }, - { - middleware: ref => /^\/(community)/gi.test(ref.location.pathname), - exec: ( - context, - data, - { showWatch, showExternalImages, strings, images }: ExecutionArguments - ) => { - if (!context) return null; - const communityParent = document.querySelector( - ".hot__community[data-community-id]" - ); - if (!communityParent) return null; - const activeMedia = document.querySelector(".coub.active"); - if (!activeMedia) return null; - const communityTitle = communityParent - .querySelector(".description > .title > h2") - ?.textContent?.trim(), - communityImage = communityParent.querySelector( - 'img[src*="coub_storage/category"]' - )?.src, - title = activeMedia - .querySelector(".description__title") - ?.textContent?.trim(); + if (showWatch) { + data.buttons = [ + { + label: strings.watchVideo, + url: document.location.href, + }, + ] + } + return data + }, + }, + { + middleware: ref => /^\/community/i.test(ref.location.pathname), + exec: ( + context, + data, + { showWatch, showExternalImages, strings, images }: ExecutionArguments, + ) => { + if (!context) + return null + const communityParent = document.querySelector( + '.hot__community[data-community-id]', + ) + if (!communityParent) + return null + const activeMedia = document.querySelector('.coub.active') + if (!activeMedia) + return null + const communityTitle = communityParent + .querySelector('.description > .title > h2') + ?.textContent + ?.trim() + const communityImage = communityParent.querySelector( + 'img[src*="coub_storage/category"]', + )?.src + const title = activeMedia + .querySelector('.description__title') + ?.textContent + ?.trim() - if (!communityTitle || !title) return null; - data.state = `Browsing ${communityTitle} in ${ - communityParent.parentElement.querySelector( - ".page-menu.hot__menu > .page-menu__inner > .page-menu__item.-active" - )?.dataset?.title || "Hot" - }`; - if (showExternalImages && communityImage?.startsWith("https://")) - data.largeImageKey = communityImage; - data.smallImageKey = - activeMedia.querySelector("video")?.paused === false - ? images.PLAY - : images.PAUSE; - data.details = `${title}`; - if (showWatch) { - data.buttons = [ - { - label: strings.watchVideo, - url: `${document.location.origin}/view/${activeMedia.dataset.permalink}`, - }, - ]; - } + if (!communityTitle || !title) + return null + data.state = `Browsing ${communityTitle} in ${ + communityParent.parentElement?.querySelector( + '.page-menu.hot__menu > .page-menu__inner > .page-menu__item.-active', + )?.dataset?.title || 'Hot' + }` + if (showExternalImages && communityImage?.startsWith('https://')) + data.largeImageKey = communityImage + data.smallImageKey = activeMedia.querySelector('video')?.paused === false + ? images.PLAY + : images.PAUSE + data.details = `${title}` + if (showWatch) { + data.buttons = [ + { + label: strings.watchVideo, + url: `${document.location.origin}/view/${activeMedia.dataset.permalink}`, + }, + ] + } - return data; - }, - }, - { - middleware: ref => !!ref.window, - exec: (context, data, { strings }: { strings: { browsing: string } }) => { - if (!context) return null; - data.state = strings.browsing; - data.details = ""; - if (data.smallImageKey) delete data.smallImageKey; - return data; - }, - }, - ], - presence = new Presence({ - clientId: "818598086984728576", - }), - presenceImageKeys = { - PLAY: Assets.Play, - PAUSE: Assets.Pause, - }; + return data + }, + }, + { + middleware: ref => !!ref.window, + exec: (context, data, { strings }: { strings: { browsing: string } }) => { + if (!context) + return null + data.state = strings.browsing + data.details = '' + if (data.smallImageKey) + delete data.smallImageKey + return data + }, + }, +] +const presence = new Presence({ + clientId: '818598086984728576', +}) +const presenceImageKeys = { + PLAY: Assets.Play, + PAUSE: Assets.Pause, +} function getStrings(newLang?: string) { - return presence.getStrings( - { - browsing: "general.browsing", - watching: "general.playing", - watchVideo: "general.buttonWatchVideo", - viewProfile: "general.buttonViewProfile", - }, - newLang - ); + return presence.getStrings( + { + browsing: 'general.browsing', + watching: 'general.playing', + watchVideo: 'general.buttonWatchVideo', + viewProfile: 'general.buttonViewProfile', + }, + newLang, + ) } let currentLang: string, - localizedStrings: Awaited>; -const startedBrowsingAt = new Date(); -presence.on("UpdateData", async () => { - const newLang = await presence.getSetting("lang").catch(() => "en"); - if (!localizedStrings || newLang !== currentLang) { - currentLang = newLang; - localizedStrings = await getStrings(newLang); - } - const query: { [key: string]: unknown } = getQuery(), - context = pages.find(x => x.middleware(window, [query])); - if (!context) return; - const data: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Coub/assets/logo.png", - }, - showStartedBrowsing = await presence - .getSetting("show_startedBrowsing") - .catch(() => true); + localizedStrings: Awaited> +const startedBrowsingAt = new Date() +presence.on('UpdateData', async () => { + const newLang = await presence.getSetting('lang').catch(() => 'en') + if (!localizedStrings || newLang !== currentLang) { + currentLang = newLang + localizedStrings = await getStrings(newLang) + } + const query: { [key: string]: unknown } = getQuery() + const context = pages.find(x => x.middleware(window, [query])) + if (!context) + return + const data: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Coub/assets/logo.png', + } + const showStartedBrowsing = await presence + .getSetting('show_startedBrowsing') + .catch(() => true) - if (showStartedBrowsing && !data.startTimestamp) - data.startTimestamp = startedBrowsingAt.getTime(); + if (showStartedBrowsing && !data.startTimestamp) + data.startTimestamp = startedBrowsingAt.getTime() - const result = await Promise.resolve( - context.exec(presence, data, { - strings: localizedStrings, - query, - images: presenceImageKeys, - showWatch: await presence - .getSetting("show_button_watching") - .catch(() => true), - showExternalImages: await presence - .getSetting("show_externalLargeImage") - .catch(() => true), - showStartedBrowsing, - }) - ); - if (!result) { - presence.setActivity({ - ...data, - state: localizedStrings.browsing, - }); - } else if (result.details) presence.setActivity(result); -}); + const result = await Promise.resolve( + context.exec(presence, data, { + strings: localizedStrings, + query, + images: presenceImageKeys, + showWatch: await presence + .getSetting('show_button_watching') + .catch(() => true), + showExternalImages: await presence + .getSetting('show_externalLargeImage') + .catch(() => true), + showStartedBrowsing, + }), + ) + if (!result) { + presence.setActivity({ + ...data, + state: localizedStrings.browsing, + }) + } + else if (result.details) { + presence.setActivity(result) + } +}) diff --git a/websites/C/Coup Critique/metadata.json b/websites/C/Coup Critique/metadata.json index 8ef640f6f436..0c2e065f64d0 100644 --- a/websites/C/Coup Critique/metadata.json +++ b/websites/C/Coup Critique/metadata.json @@ -1,54 +1,54 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "240521747852558347", - "name": "RisingSunLight" - }, - "service": "Coup Critique", - "description": { - "en": "Tutorial list about Pokemon strategy and french competitive scene. You will find helpful vocabulary articles and practices in the Pokemon strategy.", - "fr": "Liste des guides sur la stratégie Pokémon et la scène compétitive française. Vous y retrouverez des articles d'aide sur le vocabulaire et les pratiques de la stratégie Pokémon." - }, - "url": [ - "www.coupcritique.fr", - "coupcritique.fr" - ], - "version": "1.0.8", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Coup%20Critique/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Coup%20Critique/assets/thumbnail.png", - "color": "#f38532", - "category": "other", - "tags": [ - "game", - "strategy", - "pokemon", - "tutorials" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fas fa-user-secret", - "value": false - }, - { - "id": "image", - "title": "Show Images", - "icon": "fad fa-images", - "value": true, - "if": { - "privacy": false - } - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true, - "if": { - "privacy": false - } - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "240521747852558347", + "name": "RisingSunLight" + }, + "service": "Coup Critique", + "description": { + "en": "Tutorial list about Pokemon strategy and french competitive scene. You will find helpful vocabulary articles and practices in the Pokemon strategy.", + "fr": "Liste des guides sur la stratégie Pokémon et la scène compétitive française. Vous y retrouverez des articles d'aide sur le vocabulaire et les pratiques de la stratégie Pokémon." + }, + "url": [ + "www.coupcritique.fr", + "coupcritique.fr" + ], + "version": "1.0.8", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Coup%20Critique/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Coup%20Critique/assets/thumbnail.png", + "color": "#f38532", + "category": "other", + "tags": [ + "game", + "strategy", + "pokemon", + "tutorials" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fas fa-user-secret", + "value": false + }, + { + "id": "image", + "title": "Show Images", + "icon": "fad fa-images", + "value": true, + "if": { + "privacy": false + } + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true, + "if": { + "privacy": false + } + } + ] +} diff --git a/websites/C/Coup Critique/presence.ts b/websites/C/Coup Critique/presence.ts index c0fbe88800d9..9512e6111051 100644 --- a/websites/C/Coup Critique/presence.ts +++ b/websites/C/Coup Critique/presence.ts @@ -1,155 +1,154 @@ const presence = new Presence({ - clientId: "1070406808113532989", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - staticPages: Record = { - "": { details: "Parcours la page d'accueil" }, - resources: { details: "Parcours les liens utiles" }, - user: { details: "Consulte son profil" }, - notifications: { details: "Consulte ses notifications" }, - remerciements: { details: "Lit les remerciements" }, - }, - staticDatas: Record = { - guides: ["Parcours les guides", "Lit le guide"], - actualities: ["Parcours les actualités", "Lit l'actualité"], - tournaments: ["Parcours les tournois", "Lit la page du tournoi"], - }, - slideshow = new Slideshow(); + clientId: '1070406808113532989', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const staticPages: Record = { + '': { details: 'Parcours la page d\'accueil' }, + 'resources': { details: 'Parcours les liens utiles' }, + 'user': { details: 'Consulte son profil' }, + 'notifications': { details: 'Consulte ses notifications' }, + 'remerciements': { details: 'Lit les remerciements' }, +} +const staticDatas: Record = { + guides: ['Parcours les guides', 'Lit le guide'], + actualities: ['Parcours les actualités', 'Lit l\'actualité'], + tournaments: ['Parcours les tournois', 'Lit la page du tournoi'], +} +const slideshow = new Slideshow() const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Coup%20Critique/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Coup%20Critique/assets/logo.png', } -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - startTimestamp: browsingTimestamp, - largeImageKey: Assets.Logo, - }; - const { pathname, href } = document.location, - pathArr = pathname.replace("entity/", "").split("/"), - startPath = pathArr[1], - presenceDataSlide: PresenceData = { - startTimestamp: browsingTimestamp, - largeImageKey: Assets.Logo, - }, - [privacy, showImg, showButtons] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("image"), - presence.getSetting("buttons"), - ]); +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + startTimestamp: browsingTimestamp, + largeImageKey: Assets.Logo, + } + const { pathname, href } = document.location + const pathArr = pathname.replace('entity/', '').split('/') + const startPath = pathArr[1] + const presenceDataSlide: PresenceData = { + startTimestamp: browsingTimestamp, + largeImageKey: Assets.Logo, + } + const [privacy, showImg, showButtons] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('image'), + presence.getSetting('buttons'), + ]) - switch (startPath) { - case "teams": - presenceData.details = "Parcours les équipes"; - if (pathArr[2] === "create") { - presenceData.details = presenceDataSlide.details = "Crée une équipe"; - presenceData.state = `Tier : ${ - document.querySelector("input[name='tier']").value - }`; - const name = - document.querySelector("input[name='name']").value; - presenceDataSlide.state = `Nom : ${name === "" ? "aucun nom" : name}`; - slideshow.addSlide("nameSlide", presenceDataSlide, 5000); - slideshow.addSlide("tierSlide", presenceData, 5000); - } else if (pathArr.length > 2) { - presenceData.details = "Regarde l'équipe"; - presenceData.state = document.querySelector("h1").textContent; - presenceData.buttons = [{ label: "Voir l'Equipe", url: href }]; - } - break; - case "pokemons": - presenceData.details = "Parcours la liste des pokemons"; - if (pathArr.length > 2) { - presenceData.details = "Lit la fiche pokemon"; - presenceData.state = document - .querySelector("h1") - .textContent.split("de ")[1]; - presenceData.largeImageKey = - document.querySelector(".art-pokemon").src; - presenceData.smallImageKey = Assets.Reading; - presenceData.buttons = [{ label: "Voir la Fiche", url: href }]; - } - break; - case "tiers": - presenceData.details = - pathArr.length > 2 - ? `[${ - document.querySelector("h1").textContent - }] Parcours les pokemons` - : "Regarde la liste des tiers"; - presenceData.state = `Génération ${ - document.querySelector("div.labeled > a").textContent - }`; - presenceData.buttons = [{ label: "Voir la Liste", url: href }]; - break; - case "items": - case "moves": { - const caseString = startPath === "moves" ? "capacités" : "objets"; - presenceData.details = `Parcours la liste des ${caseString}`; - if (pathArr.length > 2) { - presenceData.details = `Lit la fiche ${caseString.substring( - 0, - caseString.length - 1 - )}`; - presenceData.state = document.querySelector("h1").textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.buttons = [{ label: "Voir la Fiche", url: href }]; - } - break; - } - case "abilities": - case "types": { - const caseString = startPath === "types" ? "types" : "talents"; - presenceData.details = `Regarde la liste des ${caseString}`; - if (pathArr.length > 2) { - presenceData.details = `Parcours la liste du ${caseString.substring( - 0, - caseString.length - 1 - )}`; - presenceData.state = document.querySelector("h1").textContent; - } - break; - } - case "videos": { - presenceData.details = presenceDataSlide.details = "Parcours les vidéos"; - const categories = - document.querySelector('div[name="tags"] a'), - author = document.querySelector( - 'div[label="Auteur"] div[class="text"]' - ); - if (categories) { - presenceData.state = `Catégorie ${categories.textContent}`; - slideshow.addSlide("categoriesSlide", presenceData, 5000); - } - if (author) { - presenceDataSlide.state = `Par ${author.textContent}`; - slideshow.addSlide("authorSlide", presenceDataSlide, 5000); - } - break; - } - case "guides": - case "actualities": - case "tournaments": - presenceData.details = staticDatas[startPath][0]; - if (pathArr.length > 2) { - presenceData.details = staticDatas[startPath][1]; - presenceData.state = document.querySelector("h1").textContent; - presenceData.largeImageKey = - document.querySelector("div > img").src; - presenceData.buttons = [{ label: "Consulter la page", url: href }]; - } - break; - default: - if (Object.keys(staticPages).includes(startPath)) - presenceData = { ...presenceData, ...staticPages[startPath] }; - } + switch (startPath) { + case 'teams': + presenceData.details = 'Parcours les équipes' + if (pathArr[2] === 'create') { + presenceData.details = presenceDataSlide.details = 'Crée une équipe' + presenceData.state = `Tier : ${ + document.querySelector('input[name=\'tier\']')?.value + }` + const name = document.querySelector('input[name=\'name\']')?.value + presenceDataSlide.state = `Nom : ${name === '' ? 'aucun nom' : name}` + slideshow.addSlide('nameSlide', presenceDataSlide, 5000) + slideshow.addSlide('tierSlide', presenceData, 5000) + } + else if (pathArr.length > 2) { + presenceData.details = 'Regarde l\'équipe' + presenceData.state = document.querySelector('h1')?.textContent + presenceData.buttons = [{ label: 'Voir l\'Equipe', url: href }] + } + break + case 'pokemons': + presenceData.details = 'Parcours la liste des pokemons' + if (pathArr.length > 2) { + presenceData.details = 'Lit la fiche pokemon' + presenceData.state = document + .querySelector('h1') + ?.textContent + ?.split('de ')[1] + presenceData.largeImageKey = document.querySelector('.art-pokemon')?.src + presenceData.smallImageKey = Assets.Reading + presenceData.buttons = [{ label: 'Voir la Fiche', url: href }] + } + break + case 'tiers': + presenceData.details = pathArr.length > 2 + ? `[${ + document.querySelector('h1')?.textContent + }] Parcours les pokemons` + : 'Regarde la liste des tiers' + presenceData.state = `Génération ${ + document.querySelector('div.labeled > a')?.textContent + }` + presenceData.buttons = [{ label: 'Voir la Liste', url: href }] + break + case 'items': + case 'moves': { + const caseString = startPath === 'moves' ? 'capacités' : 'objets' + presenceData.details = `Parcours la liste des ${caseString}` + if (pathArr.length > 2) { + presenceData.details = `Lit la fiche ${caseString.substring( + 0, + caseString.length - 1, + )}` + presenceData.state = document.querySelector('h1')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.buttons = [{ label: 'Voir la Fiche', url: href }] + } + break + } + case 'abilities': + case 'types': { + const caseString = startPath === 'types' ? 'types' : 'talents' + presenceData.details = `Regarde la liste des ${caseString}` + if (pathArr.length > 2) { + presenceData.details = `Parcours la liste du ${caseString.substring( + 0, + caseString.length - 1, + )}` + presenceData.state = document.querySelector('h1')?.textContent + } + break + } + case 'videos': { + presenceData.details = presenceDataSlide.details = 'Parcours les vidéos' + const categories = document.querySelector('div[name="tags"] a') + const author = document.querySelector( + 'div[label="Auteur"] div[class="text"]', + ) + if (categories) { + presenceData.state = `Catégorie ${categories.textContent}` + slideshow.addSlide('categoriesSlide', presenceData, 5000) + } + if (author) { + presenceDataSlide.state = `Par ${author.textContent}` + slideshow.addSlide('authorSlide', presenceDataSlide, 5000) + } + break + } + case 'guides': + case 'actualities': + case 'tournaments': + presenceData.details = staticDatas[startPath][0] + if (pathArr.length > 2) { + presenceData.details = staticDatas[startPath][1] + presenceData.state = document.querySelector('h1')?.textContent + presenceData.largeImageKey = document.querySelector('div > img')?.src + presenceData.buttons = [{ label: 'Consulter la page', url: href }] + } + break + default: + if (Object.keys(staticPages).includes(startPath)) + presenceData = { ...presenceData, ...staticPages[startPath] } + } - if ((privacy || !showButtons) && presenceData.buttons) - delete presenceData.buttons; - if ((privacy || !showImg) && presenceData.largeImageKey) - presenceData.largeImageKey = Assets.Logo; + if ((privacy || !showButtons) && presenceData.buttons) + delete presenceData.buttons + if ((privacy || !showImg) && presenceData.largeImageKey) + presenceData.largeImageKey = Assets.Logo - if (slideshow.getSlides().length > 0) presence.setActivity(slideshow); - else if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (slideshow.getSlides().length > 0) + presence.setActivity(slideshow) + else if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/Coursera/metadata.json b/websites/C/Coursera/metadata.json index 8bf3cdce1f2b..04bd7c05c6c2 100644 --- a/websites/C/Coursera/metadata.json +++ b/websites/C/Coursera/metadata.json @@ -1,37 +1,37 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "605894319408283678", - "name": "eljooker" - }, - "service": "Coursera", - "description": { - "en": "Coursera is a global online learning platform that offers anyone, anywhere, access to online courses and degrees from leading universities and companies." - }, - "url": "www.coursera.org", - "version": "1.0.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Coursera/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Coursera/assets/thumbnail.png", - "color": "#294cff", - "category": "other", - "tags": [ - "learning", - "course", - "education" - ], - "settings": [ - { - "id": "timestamp", - "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": { + "id": "605894319408283678", + "name": "eljooker" + }, + "service": "Coursera", + "description": { + "en": "Coursera is a global online learning platform that offers anyone, anywhere, access to online courses and degrees from leading universities and companies." + }, + "url": "www.coursera.org", + "version": "1.0.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Coursera/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Coursera/assets/thumbnail.png", + "color": "#294cff", + "category": "other", + "tags": [ + "learning", + "course", + "education" + ], + "settings": [ + { + "id": "timestamp", + "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/C/Coursera/presence.ts b/websites/C/Coursera/presence.ts index dffd722d5853..5ca977c33ca6 100644 --- a/websites/C/Coursera/presence.ts +++ b/websites/C/Coursera/presence.ts @@ -1,317 +1,326 @@ type Functionlize = { - [P in keyof T]: () => T[P]; -}; + [P in keyof T]: () => T[P]; +} -interface Route extends Functionlize> { - path: RegExp; +interface Route extends Functionlize> { + path: RegExp } const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Coursera/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Coursera/assets/logo.png', } enum Settings { - TIMESTAMP = "timestamp", - BUTTONS = "buttons", + TIMESTAMP = 'timestamp', + BUTTONS = 'buttons', } -const { href, hostname } = document.location, - presence = new Presence({ - clientId: "1179996601327026227", - }), - startTimestamp: number = Math.floor(Date.now() / 1000), - router = ({ path }: { path: string; presenceData: PresenceData }): Route => { - const routes: Route[] = [ - { - path: /^\/$/, - details: () => "On Homepage", - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - }, +const { href, hostname } = document.location +const presence = new Presence({ + clientId: '1179996601327026227', +}) +const startTimestamp: number = Math.floor(Date.now() / 1000) +function router({ path }: { path: string, presenceData: PresenceData }): Route { + const routes: Route[] = [ + { + path: /^\/$/, + details: () => 'On Homepage', + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + }, - { - path: /^\/account-profile$/, - details: () => " Viewing own Profile", - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - }, - { - path: /^\/user\/.*$/, - details: () => { - return `Viewing ${ - document.querySelector( - "[data-testid='profile-photo-invite-section-title']" - ).textContent - }'s Profile`; - }, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - buttons: () => [{ label: "View Profile", url: href }], - }, - { - path: /^\/learn\/(?!.*\bhome\b).*\/$/, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Learning", - state: () => { - return `Subject: ${document.title.substring( - 0, - document.title.lastIndexOf(" ") - 1 - )}`; - }, + { + path: /^\/account-profile$/, + details: () => ' Viewing own Profile', + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + }, + { + path: /^\/user\/.*$/, + details: () => { + return `Viewing ${ + document.querySelector( + '[data-testid=\'profile-photo-invite-section-title\']', + )?.textContent + }'s Profile` + }, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + buttons: () => [{ label: 'View Profile', url: href }], + }, + { + path: /^\/learn\/(?!.*\bhome\b).*\/$/, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Learning', + state: () => { + return `Subject: ${document.title.substring( + 0, + document.title.lastIndexOf(' ') - 1, + )}` + }, - details: () => { - return href.split("/")[4].split("-").join(" "); - }, - buttons: () => [ - { - label: "View Course", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/learn\/.*\/home\/week\/.*$/, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Learning", - state: () => { - return href.split("/")[4].split("-").join(" "); - }, - details: () => { - return `Viewing : ${href - .split("/")[6] - .split("-") - .join(" ") - .toUpperCase()} ${href.split("/")[7]}'s content`; - }, - buttons: () => [ - { - label: "View Course", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/learn\/.*\/home\/(?!.*\bweek\b).*$/, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Learning", - state: () => { - return `Viewing Course ${href.split("/")[6].split("-").join(" ")}`; - }, - details: () => { - return href.split("/")[4].split("-").join(" "); - }, - buttons: () => [ - { - label: "View Course", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/learn\/.*\/discussions$/, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Learning", - state: () => { - return "Reading Course Discussions Forums"; - }, - details: () => { - return href.split("/")[4].split("-").join(" "); - }, - buttons: () => [ - { - label: "View Course", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/learn\/.*\/resources\/.*$/, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Learning", - state: () => { - return "Viewing Course Resources"; - }, - details: () => { - return href.split("/")[4].split("-").join(" "); - }, - buttons: () => [ - { - label: "View Course", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/learn\/.*\/course-inbox$/, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Learning", - state: () => { - return "Checking Course Inbox"; - }, - details: () => { - return href.split("/")[4].split("-").join(" "); - }, - buttons: () => [ - { - label: "View Course", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, + details: () => { + return href.split('/')[4].split('-').join(' ') + }, + buttons: () => [ + { + label: 'View Course', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/learn\/.*\/home\/week\/.*$/, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Learning', + state: () => { + return href.split('/')[4].split('-').join(' ') + }, + details: () => { + return `Viewing : ${href + .split('/')[6] + .split('-') + .join(' ') + .toUpperCase()} ${href.split('/')[7]}'s content` + }, + buttons: () => [ + { + label: 'View Course', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/learn\/.*\/home\/(?!.*\bweek\b).*$/, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Learning', + state: () => { + return `Viewing Course ${href.split('/')[6].split('-').join(' ')}` + }, + details: () => { + return href.split('/')[4].split('-').join(' ') + }, + buttons: () => [ + { + label: 'View Course', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/learn\/.*\/discussions$/, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Learning', + state: () => { + return 'Reading Course Discussions Forums' + }, + details: () => { + return href.split('/')[4].split('-').join(' ') + }, + buttons: () => [ + { + label: 'View Course', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/learn\/.*\/resources\/.*$/, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Learning', + state: () => { + return 'Viewing Course Resources' + }, + details: () => { + return href.split('/')[4].split('-').join(' ') + }, + buttons: () => [ + { + label: 'View Course', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/learn\/.*\/course-inbox$/, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Learning', + state: () => { + return 'Checking Course Inbox' + }, + details: () => { + return href.split('/')[4].split('-').join(' ') + }, + buttons: () => [ + { + label: 'View Course', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, - { - path: /^\/learn\/.+\/lecture\/*/, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Learning", - state: () => { - return `Lecture: ${document.title.substring( - 0, - document.title.lastIndexOf(" ") - 1 - )}`; - }, - details: () => { - return href.split("/")[4].split("-").join(" "); - }, - buttons: () => [ - { - label: "View Course", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/learn\/.+\/quiz\/*/, - smallImageKey: () => Assets.Writing, - smallImageText: () => "Learning", - state: () => { - return "Taking a Quiz"; - }, - details: () => { - return href.split("/")[4].split("-").join(" "); - }, - buttons: () => [ - { - label: "View Course", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/learn\/.+\/exam\/*/, - smallImageKey: () => Assets.Writing, - smallImageText: () => "Learning", - state: () => { - return "Solving an Exam"; - }, - details: () => { - return href.split("/")[4].split("-").join(" "); - }, - buttons: () => [ - { - label: "View Course", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, - { - path: /^\/learn\/.+\/ungraded*\/*/, - smallImageKey: () => Assets.Writing, - smallImageText: () => "Learning", - state: () => { - return `Subject: ${document.title.substring( - 0, - document.title.lastIndexOf(" ") - 1 - )}`; - }, - details: () => { - return href.split("/")[4].split("-").join(" "); - }, - buttons: () => [ - { - label: "View Course", - url: href.split("/").slice(0, 5).join("/"), - }, - ], - }, + { + path: /^\/learn\/.+\/lecture\/*/, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Learning', + state: () => { + return `Lecture: ${document.title.substring( + 0, + document.title.lastIndexOf(' ') - 1, + )}` + }, + details: () => { + return href.split('/')[4].split('-').join(' ') + }, + buttons: () => [ + { + label: 'View Course', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/learn\/.+\/quiz\/*/, + smallImageKey: () => Assets.Writing, + smallImageText: () => 'Learning', + state: () => { + return 'Taking a Quiz' + }, + details: () => { + return href.split('/')[4].split('-').join(' ') + }, + buttons: () => [ + { + label: 'View Course', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/learn\/.+\/exam\/*/, + smallImageKey: () => Assets.Writing, + smallImageText: () => 'Learning', + state: () => { + return 'Solving an Exam' + }, + details: () => { + return href.split('/')[4].split('-').join(' ') + }, + buttons: () => [ + { + label: 'View Course', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, + { + path: /^\/learn\/.+\/ungraded*\/*/, + smallImageKey: () => Assets.Writing, + smallImageText: () => 'Learning', + state: () => { + return `Subject: ${document.title.substring( + 0, + document.title.lastIndexOf(' ') - 1, + )}` + }, + details: () => { + return href.split('/')[4].split('-').join(' ') + }, + buttons: () => [ + { + label: 'View Course', + url: href.split('/').slice(0, 5).join('/'), + }, + ], + }, - { - path: /^\/learn\/.*\/?$/, - smallImageKey: () => Assets.Viewing, - smallImageText: () => "Viewing", - details: () => "Viewing a Course", - state: () => { - return document.querySelector("[data-e2e='hero-title']").textContent; - }, - buttons: () => [{ label: "View Course", url: href }], - }, - { - path: /^\/specializations\/.+$/, - smallImageKey: () => Assets.Viewing, - smallImageText: () => "Viewing", - details: () => "Viewing a Course", - state: () => { - return document.querySelector("[data-e2e='hero-title']").textContent; - }, - buttons: () => [{ label: "View Course", url: href }], - }, - { - path: /^\/search*/, - smallImageKey: () => Assets.Search, - smallImageText: () => "Searching", - details: () => { - return `Searching for "${new URL(href).searchParams.get("query")}"`; - }, + { + path: /^\/learn\/.*$/, + smallImageKey: () => Assets.Viewing, + smallImageText: () => 'Viewing', + details: () => 'Viewing a Course', + state: () => { + return document.querySelector('[data-e2e=\'hero-title\']')?.textContent ?? undefined + }, + buttons: () => [{ label: 'View Course', url: href }], + }, + { + path: /^\/specializations\/.+$/, + smallImageKey: () => Assets.Viewing, + smallImageText: () => 'Viewing', + details: () => 'Viewing a Course', + state: () => { + return document.querySelector('[data-e2e=\'hero-title\']')?.textContent ?? undefined + }, + buttons: () => [{ label: 'View Course', url: href }], + }, + { + path: /^\/search*/, + smallImageKey: () => Assets.Search, + smallImageText: () => 'Searching', + details: () => { + return `Searching for "${new URL(href).searchParams.get('query')}"` + }, - state: () => { - return `Found ${ - document - .querySelector("[data-e2e='NumberOfResultsSection']") - .textContent.split(" ")[0] - } results`; - }, - buttons: () => [{ label: "View Results", url: href }], - }, - { - path: /^\/+.*$/, - details: () => { - const currentUrl = href; - if (currentUrl.includes("my-learning")) return "My Courses"; - else - return currentUrl.split("/")[3].toUpperCase().split("-").join(" "); - }, - smallImageKey: () => Assets.Reading, - smallImageText: () => "Browsing", - }, - ]; + state: () => { + return `Found ${ + document + .querySelector('[data-e2e=\'NumberOfResultsSection\']') + ?.textContent + ?.split(' ')[0] + } results` + }, + buttons: () => [{ label: 'View Results', url: href }], + }, + { + path: /^\/.*$/, + details: () => { + const currentUrl = href + if (currentUrl.includes('my-learning')) + return 'My Courses' + else + return currentUrl.split('/')[3].toUpperCase().split('-').join(' ') + }, + smallImageKey: () => Assets.Reading, + smallImageText: () => 'Browsing', + }, + ] - return routes.find(route => route.path.test(path)); - }; + return routes.find(route => route.path.test(path))! +} -presence.on("UpdateData", async () => { - const [showTimestamp, showButtons] = await Promise.all([ - presence.getSetting(Settings.TIMESTAMP), - presence.getSetting(Settings.BUTTONS), - ]), - presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }; +presence.on('UpdateData', async () => { + const [showTimestamp, showButtons] = await Promise.all([ + presence.getSetting(Settings.TIMESTAMP), + presence.getSetting(Settings.BUTTONS), + ]) + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } - if (showTimestamp) presenceData.startTimestamp = startTimestamp; + if (showTimestamp) + presenceData.startTimestamp = startTimestamp - const route = router({ - presenceData, - path: href.replace(`https://${hostname}`, ""), - }); + const route = router({ + presenceData, + path: href.replace(`https://${hostname}`, ''), + }) - if (!route) return presence.setActivity(presenceData); - if (route.state) presenceData.state = route.state(); - if (route.details) presenceData.details = route.details(); - if (showButtons && route.buttons) presenceData.buttons = route.buttons(); - if (route.largeImageKey) presenceData.largeImageKey = route.largeImageKey(); - if (route.smallImageKey) presenceData.smallImageKey = route.smallImageKey(); - if (route.smallImageText) - presenceData.smallImageText = route.smallImageText(); - if (showTimestamp && route.endTimestamp) - presenceData.endTimestamp = route.endTimestamp(); + if (!route) + return presence.setActivity(presenceData) + if (route.state) + presenceData.state = route.state() + if (route.details) + presenceData.details = route.details() + if (showButtons && route.buttons) + presenceData.buttons = route.buttons() as [ButtonData, (ButtonData | undefined)?] + if (route.largeImageKey) + presenceData.largeImageKey = route.largeImageKey() + if (route.smallImageKey) + presenceData.smallImageKey = route.smallImageKey() + if (route.smallImageText) + presenceData.smallImageText = route.smallImageText() + if (showTimestamp && route.endTimestamp) + presenceData.endTimestamp = route.endTimestamp() - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/Cracked.io/metadata.json b/websites/C/Cracked.io/metadata.json index b580a9721684..7829d88fc40c 100644 --- a/websites/C/Cracked.io/metadata.json +++ b/websites/C/Cracked.io/metadata.json @@ -1,70 +1,70 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "194914323787808771", - "name": "Snowwy" - }, - "contributors": [ - { - "id": "638080361179512853", - "name": "Dark_Ville" - } - ], - "service": "Cracked.io", - "description": { - "en": "Cracked.io is a cracking forum and community. We offer free premium accounts to everyone and we have a variation of cracked and leaked programs to choose from!" - }, - "url": "cracked.io", - "version": "1.0.8", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cracked.io/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cracked.io/assets/thumbnail.png", - "color": "#3F7192", - "category": "other", - "tags": [ - "cracking", - "crack", - "free", - "games", - "software" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fas fa-user-secret", - "value": false - }, - { - "id": "showDmUsername", - "title": "Show Dm Partner's Username", - "icon": "fas fa-message-slash", - "value": true, - "if": { - "privacy": 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": false, - "if": { - "privacy": false - } - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "194914323787808771", + "name": "Snowwy" + }, + "contributors": [ + { + "id": "638080361179512853", + "name": "Dark_Ville" + } + ], + "service": "Cracked.io", + "description": { + "en": "Cracked.io is a cracking forum and community. We offer free premium accounts to everyone and we have a variation of cracked and leaked programs to choose from!" + }, + "url": "cracked.io", + "version": "1.0.8", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cracked.io/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cracked.io/assets/thumbnail.png", + "color": "#3F7192", + "category": "other", + "tags": [ + "cracking", + "crack", + "free", + "games", + "software" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fas fa-user-secret", + "value": false + }, + { + "id": "showDmUsername", + "title": "Show Dm Partner's Username", + "icon": "fas fa-message-slash", + "value": true, + "if": { + "privacy": 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": false, + "if": { + "privacy": false + } + } + ] +} diff --git a/websites/C/Cracked.io/presence.ts b/websites/C/Cracked.io/presence.ts index ba3e6c7f1721..fb9e2d1d85df 100644 --- a/websites/C/Cracked.io/presence.ts +++ b/websites/C/Cracked.io/presence.ts @@ -1,215 +1,237 @@ const presence = new Presence({ - clientId: "1041324883793154098", - }), - browingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1041324883793154098', +}) +const browingTimestamp = Math.floor(Date.now() / 1000) async function getStrings() { - return presence.getStrings( - { - browse: "general.browsing", - search: "general.searchFor", - searchSomething: "general.searchSomething", - viewCategory: "general.viewCategory", - viewHome: "general.viewHome", - buttonViewPage: "general.buttonViewPage", - buttonViewProfile: "buttonViewProfile", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + browse: 'general.browsing', + search: 'general.searchFor', + searchSomething: 'general.searchSomething', + viewCategory: 'general.viewCategory', + viewHome: 'general.viewHome', + buttonViewPage: 'general.buttonViewPage', + buttonViewProfile: 'buttonViewProfile', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } function capitalizeFirstLetter(string: string) { - if (!string) return "Undefined"; - return ( - string.trim().charAt(0).toUpperCase() + string.trim().slice(1).toLowerCase() - ); + if (!string) + return 'Undefined' + return ( + string.trim().charAt(0).toUpperCase() + string.trim().slice(1).toLowerCase() + ) } const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Cracked.io/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Cracked.io/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, - startTimestamp: browingTimestamp, - }, - search = document.querySelector('input[name="keywords"]'), - { pathname, href } = document.location, - [newLang, privacy, showDmUsername, buttons, covers] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("privacy"), - presence.getSetting("showDmUsername"), - presence.getSetting("buttons"), - presence.getSetting("covers"), - ]), - active = - document.querySelector('[class="at ftab"]') ?? - document.querySelector('[class="ftab at"]') ?? - document.querySelector('[class="active"]'); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browingTimestamp, + } + const search = document.querySelector('input[name="keywords"]') + const { pathname, href } = document.location + const [newLang, privacy, showDmUsername, buttons, covers] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('privacy'), + presence.getSetting('showDmUsername'), + presence.getSetting('buttons'), + presence.getSetting('covers'), + ]) + const active = document.querySelector('[class="at ftab"]') + ?? document.querySelector('[class="ftab at"]') + ?? document.querySelector('[class="active"]') - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - if (privacy) { - presenceData.details = strings.browse; - presence.setActivity(presenceData); - return; - } - switch (pathname.split("/")[1].replace(/[.]php/gm, "")) { - case "search": { - if (search?.value) { - presenceData.details = strings.search; - presenceData.state = search.value; - } else presenceData.details = strings.searchSomething; - presenceData.smallImageKey = Assets.Search; - break; - } - case "private": - case "index": - case "": { - const checkForChat = document.querySelector('[name="to"]'); - if (href.includes("action=conversations")) - presenceData.details = "Viewing all conversations"; - else if (showDmUsername && checkForChat) { - presenceData.details = "Sending a private message to"; - presenceData.state = checkForChat.getAttribute("value"); - presenceData.largeImageKey = - document - .querySelector('[class="conv_users_avatar"]') - ?.querySelector("img") - ?.getAttribute("src") ?? Assets.Logo; - } else if (checkForChat) - presenceData.details = "Viewing private messages"; - else if (active) { - presenceData.details = strings.viewHome; - presenceData.state = !active - .getAttribute("title") - ?.toLowerCase() - .replace("home", "") - ? `Category ${active - .getAttribute("title") - ?.toLowerCase() - .replace("home", "")}` - : ""; - } else presenceData.details = strings.viewHome; - break; - } - case "upgrade": { - presenceData.details = "Viewing rank upgrades"; - presenceData.buttons = [ - { - label: strings.buttonViewPage, - url: href, - }, - ]; - break; - } - case "misc": { - if ( - document.querySelector('[class="thead"]')?.textContent === "Forum Rules" - ) { - presenceData.details = "Viewing all help documents"; - presenceData.buttons = [ - { - label: strings.buttonViewPage, - url: href, - }, - ]; - } else { - presenceData.details = "Reading a help document about"; - presenceData.state = active?.textContent; - presenceData.buttons = [ - { - label: "Read Document", - url: href, - }, - ]; - } - break; - } - default: { - if (pathname.toLowerCase().includes("forum-")) { - const seperator = document.querySelectorAll('[class="nav-seperator"]'); - if ( - document.querySelector('[class="navigation hide-mobile"]') - .childElementCount > 2 - ) { - presenceData.details = `Browsing ${ - seperator[seperator.length - 1]?.textContent - }`; - presenceData.state = `${active?.textContent} (Page ${ - document.querySelector('[class="pagination_current"]')?.textContent - })`; - } else - presenceData.details = `Browsing the ${active?.textContent} forum`; - } else if (pathname.toLowerCase().includes("thread-")) { - const thread = document.querySelector('[class="thread-header"]'); - presenceData.details = thread.querySelector("h1")?.textContent; - presenceData.state = `Posted by: ${ - document.querySelector('[class="post-username"]')?.textContent - }`; - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = `${thread - .querySelector("span") - ?.textContent.trim()} views`; - presenceData.largeImageKey = - document - .querySelector('[class="post-avatar-mobile"]') - ?.getAttribute("src") - ?.split("?")[0] ?? Assets.Logo; - presenceData.buttons = [ - { - label: "View Thread", - url: href, - }, - ]; - } else if (active?.textContent.includes("Profile of")) { - presenceData.details = `Viewing ${document - .querySelector('[class="profile_item"]') - ?.parentElement?.textContent.trim()}'s profile`; - presenceData.state = capitalizeFirstLetter( - document - .querySelectorAll( - '[class="trow1 x-smalltext d-flex align-items-center"]' - )[2] - ?.textContent.trim() - ); - presenceData.largeImageKey = - document - .querySelector('[class="p-avatar"]') - ?.lastElementChild?.getAttribute("src") - ?.split("?")[0] ?? Assets.Logo; - presenceData.buttons = [ - { - label: strings.buttonViewProfile, - url: href, - }, - ]; - } else { - if (active) { - presenceData.details = `${strings.browse.replace( - /[.]{3}/gm, - "" - )} ${active.textContent?.toLowerCase()}`; - } else presenceData.details = strings.browse; - presenceData.buttons = [ - { - label: strings.buttonViewPage, - url: href, - }, - ]; - } - } - } + if (privacy) { + presenceData.details = strings.browse + presence.setActivity(presenceData) + return + } + switch (pathname.split('/')[1].replace(/\.php/g, '')) { + case 'search': { + if (search?.value) { + presenceData.details = strings.search + presenceData.state = search.value + } + else { + presenceData.details = strings.searchSomething + } + presenceData.smallImageKey = Assets.Search + break + } + case 'private': + case 'index': + case '': { + const checkForChat = document.querySelector('[name="to"]') + if (href.includes('action=conversations')) { + presenceData.details = 'Viewing all conversations' + } + else if (showDmUsername && checkForChat) { + presenceData.details = 'Sending a private message to' + presenceData.state = checkForChat.getAttribute('value') + presenceData.largeImageKey = document + .querySelector('[class="conv_users_avatar"]') + ?.querySelector('img') + ?.getAttribute('src') ?? Assets.Logo + } + else if (checkForChat) { + presenceData.details = 'Viewing private messages' + } + else if (active) { + presenceData.details = strings.viewHome + presenceData.state = !active + .getAttribute('title') + ?.toLowerCase() + .replace('home', '') + ? `Category ${active + .getAttribute('title') + ?.toLowerCase() + .replace('home', '')}` + : '' + } + else { + presenceData.details = strings.viewHome + } + break + } + case 'upgrade': { + presenceData.details = 'Viewing rank upgrades' + presenceData.buttons = [ + { + label: strings.buttonViewPage, + url: href, + }, + ] + break + } + case 'misc': { + if ( + document.querySelector('[class="thead"]')?.textContent === 'Forum Rules' + ) { + presenceData.details = 'Viewing all help documents' + presenceData.buttons = [ + { + label: strings.buttonViewPage, + url: href, + }, + ] + } + else { + presenceData.details = 'Reading a help document about' + presenceData.state = active?.textContent + presenceData.buttons = [ + { + label: 'Read Document', + url: href, + }, + ] + } + break + } + default: { + if (pathname.toLowerCase().includes('forum-')) { + const seperator = document.querySelectorAll('[class="nav-seperator"]') + if ( + (document.querySelector('[class="navigation hide-mobile"]') + ?.childElementCount ?? 0) > 2 + ) { + presenceData.details = `Browsing ${ + seperator[seperator.length - 1]?.textContent + }` + presenceData.state = `${active?.textContent} (Page ${ + document.querySelector('[class="pagination_current"]')?.textContent + })` + } + else { + presenceData.details = `Browsing the ${active?.textContent} forum` + } + } + else if (pathname.toLowerCase().includes('thread-')) { + const thread = document.querySelector('[class="thread-header"]') + presenceData.details = thread?.querySelector('h1')?.textContent + presenceData.state = `Posted by: ${ + document.querySelector('[class="post-username"]')?.textContent + }` + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = `${thread + ?.querySelector('span') + ?.textContent + ?.trim()} views` + presenceData.largeImageKey = document + .querySelector('[class="post-avatar-mobile"]') + ?.getAttribute('src') + ?.split('?')[0] ?? Assets.Logo + presenceData.buttons = [ + { + label: 'View Thread', + url: href, + }, + ] + } + else if (active?.textContent?.includes('Profile of')) { + presenceData.details = `Viewing ${document + .querySelector('[class="profile_item"]') + ?.parentElement + ?.textContent + ?.trim()}'s profile` + presenceData.state = capitalizeFirstLetter( + document + .querySelectorAll( + '[class="trow1 x-smalltext d-flex align-items-center"]', + )[2] + ?.textContent + ?.trim() ?? '', + ) + presenceData.largeImageKey = document + .querySelector('[class="p-avatar"]') + ?.lastElementChild + ?.getAttribute('src') + ?.split('?')[0] ?? Assets.Logo + presenceData.buttons = [ + { + label: strings.buttonViewProfile, + url: href, + }, + ] + } + else { + if (active) { + presenceData.details = `${strings.browse.replace( + /\.{3}/g, + '', + )} ${active.textContent?.toLowerCase()}` + } + else { + presenceData.details = strings.browse + } + presenceData.buttons = [ + { + label: strings.buttonViewPage, + url: href, + }, + ] + } + } + } - if (!buttons && presenceData.buttons) delete presenceData.buttons; - if (!covers && presenceData.largeImageKey !== Assets.Logo) - presenceData.largeImageKey = Assets.Logo; - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (!buttons && presenceData.buttons) + delete presenceData.buttons + if (!covers && presenceData.largeImageKey !== Assets.Logo) + presenceData.largeImageKey = Assets.Logo + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/Craiyon/metadata.json b/websites/C/Craiyon/metadata.json index 5badf601a0d6..93a7e616e518 100644 --- a/websites/C/Craiyon/metadata.json +++ b/websites/C/Craiyon/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "theusaf", - "id": "193714715631812608" - }, - "service": "Craiyon", - "description": { - "en": "Craiyon is an AI model that can draw images from any text prompt!" - }, - "url": "www.craiyon.com", - "version": "1.2.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Craiyon/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Craiyon/assets/thumbnail.png", - "color": "#ea580c", - "category": "other", - "tags": [ - "ai", - "dalle", - "image", - "generation" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "theusaf", + "id": "193714715631812608" + }, + "service": "Craiyon", + "description": { + "en": "Craiyon is an AI model that can draw images from any text prompt!" + }, + "url": "www.craiyon.com", + "version": "1.2.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Craiyon/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Craiyon/assets/thumbnail.png", + "color": "#ea580c", + "category": "other", + "tags": [ + "ai", + "dalle", + "image", + "generation" + ] +} diff --git a/websites/C/Craiyon/presence.ts b/websites/C/Craiyon/presence.ts index 5b5b55f0f498..fecc18971975 100644 --- a/websites/C/Craiyon/presence.ts +++ b/websites/C/Craiyon/presence.ts @@ -1,139 +1,149 @@ const presence = new Presence({ - clientId: "1015402986534608948", - }), - slideshow = presence.createSlideshow(), - logo = "https://cdn.rcd.gg/PreMiD/websites/C/Craiyon/assets/logo.png"; + clientId: '1015402986534608948', +}) +const slideshow = presence.createSlideshow() +const logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Craiyon/assets/logo.png' -type State = "start" | "generation" | "results"; +type State = 'start' | 'generation' | 'results' -let browsingTimestamp: number = Date.now() / 1000, - oldPrompt: string = null, - oldPath: string = null, - activityState: State = "start", - searchResultCacheTimestamp = 0; +let browsingTimestamp: number = Date.now() / 1000 +let oldPrompt: string | undefined +let oldPath: string | undefined +let activityState: State = 'start' +let searchResultCacheTimestamp = 0 -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: logo, - startTimestamp: browsingTimestamp, - }, - { pathname, href } = document.location, - pathList = pathname.split("/").filter(Boolean); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: logo, + startTimestamp: browsingTimestamp, + } + const { pathname, href } = document.location + const pathList = pathname.split('/').filter(Boolean) - let useSlideshow = false; - if (oldPath !== pathname) { - oldPath = pathname; - slideshow.deleteAllSlides(); - } + let useSlideshow = false + if (oldPath !== pathname) { + oldPath = pathname + slideshow.deleteAllSlides() + } - switch (pathList[0] ?? "/") { - case "/": { - const input = document.querySelector("#prompt"), - imageContainers = document.querySelectorAll( - ".image-container img" - ); - presenceData.state = input.value - ? `"${input.value}"` - : "Waiting for input..."; - if ( - document.querySelector("#generateButton").disabled - ) { - if (activityState !== "generation") { - presenceData.startTimestamp = browsingTimestamp = Date.now() / 1000; - oldPrompt = input.value; - activityState = "generation"; - slideshow.deleteAllSlides(); - } - presenceData.details = "Generating images"; - presenceData.state = `"${oldPrompt}"`; - } else { - if (activityState !== "results") { - presenceData.startTimestamp = browsingTimestamp = Date.now() / 1000; - activityState = "results"; - slideshow.deleteAllSlides(); - } - if ( - (document.activeElement === input && input.value !== oldPrompt) || - !imageContainers.length - ) - presenceData.details = "Thinking of a prompt"; - else { - presenceData.details = "Viewing results"; - presenceData.state = `"${oldPrompt}"`; + switch (pathList[0] ?? '/') { + case '/': { + const input = document.querySelector('#prompt') + const imageContainers = document.querySelectorAll( + '.image-container img', + ) + presenceData.state = input?.value + ? `"${input.value}"` + : 'Waiting for input...' + if ( + document.querySelector('#generateButton')?.disabled + ) { + if (activityState !== 'generation') { + presenceData.startTimestamp = browsingTimestamp = Date.now() / 1000 + oldPrompt = input?.value + activityState = 'generation' + slideshow.deleteAllSlides() + } + presenceData.details = 'Generating images' + presenceData.state = `"${oldPrompt}"` + } + else { + if (activityState !== 'results') { + presenceData.startTimestamp = browsingTimestamp = Date.now() / 1000 + activityState = 'results' + slideshow.deleteAllSlides() + } + if ( + (document.activeElement === input && input?.value !== oldPrompt) + || !imageContainers.length + ) { + presenceData.details = 'Thinking of a prompt' + } + else { + presenceData.details = 'Viewing results' + presenceData.state = `"${oldPrompt}"` - for (const [i, image] of imageContainers.entries()) { - const presenceDataCopy = Object.assign({}, presenceData); - presenceDataCopy.largeImageKey = image; - slideshow.addSlide(`image${i}`, presenceDataCopy, 5000); - } - useSlideshow = true; - } - } - break; - } - case "image": { - presenceData.details = "Viewing an image"; - presenceData.state = ( - document - .evaluate("//p[text()='Prompt']", document.body) - .iterateNext() as HTMLParagraphElement - ).nextElementSibling; - presenceData.largeImageKey = - document.querySelector("main img"); - presenceData.buttons = [ - { - label: "View Image Details", - url: href, - }, - ]; - break; - } - case "search": { - if (pathList.length > 1) { - presenceData.details = "Viewing search results"; - presenceData.state = document.querySelector("input").value; - const now = Date.now(); - if (now - searchResultCacheTimestamp > 5000) { - searchResultCacheTimestamp = now; + for (const [i, image] of imageContainers.entries()) { + const presenceDataCopy = Object.assign({}, presenceData) + presenceDataCopy.largeImageKey = image + slideshow.addSlide(`image${i}`, presenceDataCopy, 5000) + } + useSlideshow = true + } + } + break + } + case 'image': { + presenceData.details = 'Viewing an image' + presenceData.state = ( + document + .evaluate('//p[text()=\'Prompt\']', document.body) + .iterateNext() as HTMLParagraphElement + ).nextElementSibling + presenceData.largeImageKey = document.querySelector('main img') + presenceData.buttons = [ + { + label: 'View Image Details', + url: href, + }, + ] + break + } + case 'search': { + if (pathList.length > 1) { + presenceData.details = 'Viewing search results' + presenceData.state = document.querySelector('input')?.value + const now = Date.now() + if (now - searchResultCacheTimestamp > 5000) { + searchResultCacheTimestamp = now - for (const [i, image] of document - .querySelectorAll("main a img") - .entries()) { - const presenceDataCopy = Object.assign({}, presenceData); - presenceDataCopy.largeImageKey = image; - slideshow.addSlide(`image${i}`, presenceDataCopy, 5000); - } - } - useSlideshow = true; - } else presenceData.details = "Searching for images"; - break; - } - case "blog": { - if (pathList.length > 1) { - presenceData.details = "Reading a blog post"; - presenceData.state = document.querySelector("h1"); - presenceData.largeImageKey = - document.querySelector("main p + img"); - presenceData.buttons = [ - { - label: "View Blog Post", - url: href, - }, - ]; - } else presenceData.details = "Browsing blog posts"; - break; - } - case "privacy": { - presenceData.details = "Reading privacy policy"; - break; - } - case "terms": { - presenceData.details = "Reading terms and conditions"; - break; - } - } - if (presenceData.details) { - if (useSlideshow) presence.setActivity(slideshow); - else presence.setActivity(presenceData); - } else presence.setActivity(); -}); + for (const [i, image] of document + .querySelectorAll('main a img') + .entries()) { + const presenceDataCopy = Object.assign({}, presenceData) + presenceDataCopy.largeImageKey = image + slideshow.addSlide(`image${i}`, presenceDataCopy, 5000) + } + } + useSlideshow = true + } + else { + presenceData.details = 'Searching for images' + } + break + } + case 'blog': { + if (pathList.length > 1) { + presenceData.details = 'Reading a blog post' + presenceData.state = document.querySelector('h1') + presenceData.largeImageKey = document.querySelector('main p + img') + presenceData.buttons = [ + { + label: 'View Blog Post', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing blog posts' + } + break + } + case 'privacy': { + presenceData.details = 'Reading privacy policy' + break + } + case 'terms': { + presenceData.details = 'Reading terms and conditions' + break + } + } + if (presenceData.details) { + if (useSlideshow) + presence.setActivity(slideshow) + else presence.setActivity(presenceData) + } + else { + presence.setActivity() + } +}) diff --git a/websites/C/Crave/metadata.json b/websites/C/Crave/metadata.json index e2468ea7a2f3..abc1a4c3aaeb 100644 --- a/websites/C/Crave/metadata.json +++ b/websites/C/Crave/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Avery<3", - "id": "787415934247108629" - }, - "service": "Crave", - "description": { - "en": "The best series and movies including the latest Originals from Crave, HBO, HBO Max, Showtime, the entire HBO library and the biggest Hollywood blockbusters. Enjoy in English and French." - }, - "url": "www.crave.ca", - "version": "1.0.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Crave/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Crave/assets/thumbnail.png", - "color": "#00c1f3", - "category": "videos", - "tags": [ - "media", - "video", - "crave" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Avery<3", + "id": "787415934247108629" + }, + "service": "Crave", + "description": { + "en": "The best series and movies including the latest Originals from Crave, HBO, HBO Max, Showtime, the entire HBO library and the biggest Hollywood blockbusters. Enjoy in English and French." + }, + "url": "www.crave.ca", + "version": "1.0.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Crave/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Crave/assets/thumbnail.png", + "color": "#00c1f3", + "category": "videos", + "tags": [ + "media", + "video", + "crave" + ] +} diff --git a/websites/C/Crave/presence.ts b/websites/C/Crave/presence.ts index d3e0a25a3ec6..727ca4e9fe9f 100644 --- a/websites/C/Crave/presence.ts +++ b/websites/C/Crave/presence.ts @@ -1,65 +1,65 @@ const presence = new Presence({ - clientId: "1001288215388495953", - }), - browsingStamp = Math.floor(Date.now() / 1000); + clientId: '1001288215388495953', +}) +const browsingStamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Crave/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Crave/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { largeImageKey: Assets.Logo }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { largeImageKey: Assets.Logo } - if (document.querySelector(".jw-video")) { - // if contains video - if (document.querySelector(".jw-icon-playback").ariaLabel !== "Play") { - // video is playing - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - presence.timestampFromFormat( - document.querySelector(".jw-text-elapsed").textContent - ), - presence.timestampFromFormat( - document.querySelector(".jw-text-duration").textContent - ) - ); + if (document.querySelector('.jw-video')) { + // if contains video + if (document.querySelector('.jw-icon-playback')?.ariaLabel !== 'Play') { + // video is playing + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + presence.timestampFromFormat( + document.querySelector('.jw-text-elapsed')?.textContent ?? '', + ), + presence.timestampFromFormat( + document.querySelector('.jw-text-duration')?.textContent ?? '', + ), + ) - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Playing"; - } else { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = "Paused"; - } + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Playing' + } + else { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Paused' + } - presenceData.buttons = [ - { - label: "Watch", - url: document.location.href, - }, - ]; + presenceData.buttons = [ + { + label: 'Watch', + url: document.location.href, + }, + ] - if (document.querySelector(".bm-icon-episode-list")) { - // if the video is an episode - const details = - document.querySelector(".jw-title-primary").textContent || "", - // split episode details to achieve {showName, episodeNumber, episodeName} - // regex finds the season + episode number then split the entire title with said regex - epDetails = details.split(/(S([0-9]+):E([0-9]+))/g.exec(details)[0]); + if (document.querySelector('.bm-icon-episode-list')) { + // if the video is an episode + const details = document.querySelector('.jw-title-primary')?.textContent || '' + // split episode details to achieve {showName, episodeNumber, episodeName} + // regex finds the season + episode number then split the entire title with said regex + const epDetails = details.split(/S\d+:E\d+/.exec(details)?.[0] ?? '') - presenceData.state = `${ - /(S([0-9]+):E([0-9]+))/g.exec(details)[0] - } - ${epDetails[1].trim()}`; // {episodeNumber} - {episodeName} - presenceData.details = epDetails[0].trim(); // {showName} - } else { - // video is a movie - presenceData.details = - document.querySelector(".jw-title-primary").textContent; // movie title - } - } else { - // default to browsing - presenceData.details = "Browsing..."; - presenceData.startTimestamp = browsingStamp; - } + presenceData.state = `${ + /S\d+:E\d+/.exec(details)?.[0] + } - ${epDetails[1].trim()}` // {episodeNumber} - {episodeName} + presenceData.details = epDetails[0].trim() // {showName} + } + else { + // video is a movie + presenceData.details = document.querySelector('.jw-title-primary')?.textContent // movie title + } + } + else { + // default to browsing + presenceData.details = 'Browsing...' + presenceData.startTimestamp = browsingStamp + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/Creepypasta/metadata.json b/websites/C/Creepypasta/metadata.json index 640eb27d88b7..4df8bb554b89 100644 --- a/websites/C/Creepypasta/metadata.json +++ b/websites/C/Creepypasta/metadata.json @@ -1,40 +1,40 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "joerkig", - "id": "205984221859151873" - }, - "service": "Creepypasta", - "description": { - "en": "Welcome to Creepypasta.com! Scaring you since 2008 with paranormal stories and creepy original horror fiction. Sleep well..." - }, - "url": "www.creepypasta.com", - "version": "1.0.15", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Creepypasta/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Creepypasta/assets/thumbnail.png", - "color": "#dd3333", - "category": "other", - "tags": [ - "creepy", - "story", - "stories", - "spooky", - "scary", - "literature" - ], - "settings": [ - { - "id": "time", - "title": "Show Timestamps", - "icon": "fas 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": "joerkig", + "id": "205984221859151873" + }, + "service": "Creepypasta", + "description": { + "en": "Welcome to Creepypasta.com! Scaring you since 2008 with paranormal stories and creepy original horror fiction. Sleep well..." + }, + "url": "www.creepypasta.com", + "version": "1.0.15", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Creepypasta/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Creepypasta/assets/thumbnail.png", + "color": "#dd3333", + "category": "other", + "tags": [ + "creepy", + "story", + "stories", + "spooky", + "scary", + "literature" + ], + "settings": [ + { + "id": "time", + "title": "Show Timestamps", + "icon": "fas fa-stopwatch", + "value": true + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/C/Creepypasta/presence.ts b/websites/C/Creepypasta/presence.ts index 5f461fddaa86..a82af1ed0f34 100644 --- a/websites/C/Creepypasta/presence.ts +++ b/websites/C/Creepypasta/presence.ts @@ -1,150 +1,153 @@ const presence = new Presence({ - clientId: "929823434572202005", - }), - browsingStamp = Math.floor(Date.now() / 1000); + clientId: '929823434572202005', +}) +const browsingStamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const [time, buttons] = await Promise.all([ - presence.getSetting("time"), - presence.getSetting("buttons"), - ]), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Creepypasta/assets/logo.png", - startTimestamp: browsingStamp, - }, - orderBy = document.getElementsByName("_orderby")[0] as HTMLSelectElement; +presence.on('UpdateData', async () => { + const [time, buttons] = await Promise.all([ + presence.getSetting('time'), + presence.getSetting('buttons'), + ]) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Creepypasta/assets/logo.png', + startTimestamp: browsingStamp, + } + const orderBy = document.getElementsByName('_orderby')[0] as HTMLSelectElement - switch (document.location.pathname) { - case "/": - presenceData.details = "Viewing Home Page"; - break; - case "/archive/top-ranked/": - presenceData.details = "Browsing Top-Ranked"; - if (orderBy.selectedIndex !== 0) { - presenceData.state = `Sorted By ${ - orderBy.options[orderBy.selectedIndex].text - }`; - } - break; - case "/archive/famous-creepypastas/": - presenceData.details = "Browsing Famous"; - if (orderBy.selectedIndex !== 0) { - presenceData.state = `Sorted By ${ - orderBy.options[orderBy.selectedIndex].text - }`; - } - break; - case "/archive/": - presenceData.details = "Browsing Recently Published"; - if (orderBy.selectedIndex !== 0) { - presenceData.state = `Sorted By ${ - orderBy.options[orderBy.selectedIndex].text - }`; - } - break; - case "/archive/sorted/": - presenceData.details = "Browsing Sorted Stories"; - if (orderBy.selectedIndex !== 0) { - presenceData.state = `Sorted By ${ - orderBy.options[orderBy.selectedIndex].text - }`; - } - break; - case "/archive/sorted-by-category/": - presenceData.details = `Browsing ${ - ( - document.getElementsByName("tx_category")[0] as HTMLSelectElement - ).options[ - (document.getElementsByName("tx_category")[0] as HTMLSelectElement) - .selectedIndex - ].text.split("(")[0] - }`; - if (orderBy.selectedIndex !== 0) { - presenceData.state = `Sorted By ${ - orderBy.options[orderBy.selectedIndex].text - }`; - } - break; - case "/archive/sorted-by-length/": - if ( - (document.getElementsByName("tx_story_length")[0] as HTMLSelectElement) - .selectedIndex !== 0 - ) { - presenceData.details = `Browsing ${ - ( - document.getElementsByName( - "tx_story_length" - )[0] as HTMLSelectElement - ).options[ - ( - document.getElementsByName( - "tx_story_length" - )[0] as HTMLSelectElement - ).selectedIndex - ].text.split(/\(|\)/)[1] - }`; - } else presenceData.details = "Browsing By Length"; - if (orderBy.selectedIndex !== 0) { - presenceData.state = `Sorted By ${ - orderBy.options[orderBy.selectedIndex].text - }`; - } - break; - case "/archive/sorted-by-author/": - presenceData.details = `Browsing ${ - ( - document.getElementsByName("tx_authors")[0] as HTMLSelectElement - ).options[ - (document.getElementsByName("tx_authors")[0] as HTMLSelectElement) - .selectedIndex - ].text.split("(")[0] - }`; - if (orderBy.selectedIndex !== 0) { - presenceData.state = `Sorted By ${ - orderBy.options[orderBy.selectedIndex].text - }`; - } - break; - case "/archive/sorted-by-title/": - presenceData.details = "Browsing By Title"; - if (orderBy.selectedIndex !== 0) { - presenceData.state = `Sorted By ${ - orderBy.options[orderBy.selectedIndex].text - }`; - } - break; - case "/submit-your-pasta/": - presenceData.details = "Submitting Story"; - break; - case "/submit-your-pasta/guidelines/": - presenceData.details = "Reading Submission Guidelines"; - break; - default: - presenceData.details = `Reading ${ - document.querySelector("h1.entry-title").textContent - }`; - presenceData.state = document.querySelector( - "div.gdrts-rating-text" - ).textContent; - presenceData.buttons = [ - { - label: "View Page", - url: document.location.href, - }, - ]; - } - if ( - document.querySelector("[class$='ast-dropdown-active']") || - document.location.href.includes("?s=") - ) { - presenceData.details = "Searching"; - presenceData.state = - document.querySelector(".search-field").value; - } + switch (document.location.pathname) { + case '/': + presenceData.details = 'Viewing Home Page' + break + case '/archive/top-ranked/': + presenceData.details = 'Browsing Top-Ranked' + if (orderBy.selectedIndex !== 0) { + presenceData.state = `Sorted By ${ + orderBy.options[orderBy.selectedIndex].text + }` + } + break + case '/archive/famous-creepypastas/': + presenceData.details = 'Browsing Famous' + if (orderBy.selectedIndex !== 0) { + presenceData.state = `Sorted By ${ + orderBy.options[orderBy.selectedIndex].text + }` + } + break + case '/archive/': + presenceData.details = 'Browsing Recently Published' + if (orderBy.selectedIndex !== 0) { + presenceData.state = `Sorted By ${ + orderBy.options[orderBy.selectedIndex].text + }` + } + break + case '/archive/sorted/': + presenceData.details = 'Browsing Sorted Stories' + if (orderBy.selectedIndex !== 0) { + presenceData.state = `Sorted By ${ + orderBy.options[orderBy.selectedIndex].text + }` + } + break + case '/archive/sorted-by-category/': + presenceData.details = `Browsing ${ + ( + document.getElementsByName('tx_category')[0] as HTMLSelectElement + ).options[ + (document.getElementsByName('tx_category')[0] as HTMLSelectElement) + .selectedIndex + ].text.split('(')[0] + }` + if (orderBy.selectedIndex !== 0) { + presenceData.state = `Sorted By ${ + orderBy.options[orderBy.selectedIndex].text + }` + } + break + case '/archive/sorted-by-length/': + if ( + (document.getElementsByName('tx_story_length')[0] as HTMLSelectElement) + .selectedIndex !== 0 + ) { + presenceData.details = `Browsing ${ + ( + document.getElementsByName( + 'tx_story_length', + )[0] as HTMLSelectElement + ).options[ + ( + document.getElementsByName( + 'tx_story_length', + )[0] as HTMLSelectElement + ).selectedIndex + ].text.split(/\(|\)/)[1] + }` + } + else { + presenceData.details = 'Browsing By Length' + } + if (orderBy.selectedIndex !== 0) { + presenceData.state = `Sorted By ${ + orderBy.options[orderBy.selectedIndex].text + }` + } + break + case '/archive/sorted-by-author/': + presenceData.details = `Browsing ${ + ( + document.getElementsByName('tx_authors')[0] as HTMLSelectElement + ).options[ + (document.getElementsByName('tx_authors')[0] as HTMLSelectElement) + .selectedIndex + ].text.split('(')[0] + }` + if (orderBy.selectedIndex !== 0) { + presenceData.state = `Sorted By ${ + orderBy.options[orderBy.selectedIndex].text + }` + } + break + case '/archive/sorted-by-title/': + presenceData.details = 'Browsing By Title' + if (orderBy.selectedIndex !== 0) { + presenceData.state = `Sorted By ${ + orderBy.options[orderBy.selectedIndex].text + }` + } + break + case '/submit-your-pasta/': + presenceData.details = 'Submitting Story' + break + case '/submit-your-pasta/guidelines/': + presenceData.details = 'Reading Submission Guidelines' + break + default: + presenceData.details = `Reading ${ + document.querySelector('h1.entry-title')?.textContent + }` + presenceData.state = document.querySelector( + 'div.gdrts-rating-text', + )?.textContent + presenceData.buttons = [ + { + label: 'View Page', + url: document.location.href, + }, + ] + } + if ( + document.querySelector('[class$=\'ast-dropdown-active\']') + || document.location.href.includes('?s=') + ) { + presenceData.details = 'Searching' + presenceData.state = document.querySelector('.search-field')?.value + } - if (!time) delete presenceData.startTimestamp; - if (!buttons && presenceData.buttons) delete presenceData.buttons; + if (!time) + delete presenceData.startTimestamp + if (!buttons && presenceData.buttons) + delete presenceData.buttons - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/C/CritiqueBrainz/metadata.json b/websites/C/CritiqueBrainz/metadata.json index a78871ffd87a..d13f6b6abcc1 100644 --- a/websites/C/CritiqueBrainz/metadata.json +++ b/websites/C/CritiqueBrainz/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "theusaf", - "id": "193714715631812608" - }, - "service": "CritiqueBrainz", - "description": { - "en": "CritiqueBrainz is a repository for Creative Commons licensed music reviews. Here you can read what other people have written about an album or event and write your own review!" - }, - "url": "critiquebrainz.org", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CritiqueBrainz/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CritiqueBrainz/assets/thumbnail.png", - "color": "#36b5b2", - "category": "music", - "tags": [ - "review", - "encyclopedia", - "community" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "theusaf", + "id": "193714715631812608" + }, + "service": "CritiqueBrainz", + "description": { + "en": "CritiqueBrainz is a repository for Creative Commons licensed music reviews. Here you can read what other people have written about an album or event and write your own review!" + }, + "url": "critiquebrainz.org", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CritiqueBrainz/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CritiqueBrainz/assets/thumbnail.png", + "color": "#36b5b2", + "category": "music", + "tags": [ + "review", + "encyclopedia", + "community" + ] +} diff --git a/websites/C/CritiqueBrainz/presence.ts b/websites/C/CritiqueBrainz/presence.ts index 79d0f36f98c6..8717128f29bc 100644 --- a/websites/C/CritiqueBrainz/presence.ts +++ b/websites/C/CritiqueBrainz/presence.ts @@ -1,154 +1,153 @@ const presence = new Presence({ - clientId: "1017821399705985097", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1017821399705985097', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CritiqueBrainz/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, href } = window.location, - pathSplit = pathname.split("/").slice(1); - switch (pathSplit[0]) { - case "": { - presenceData.details = "Browsing home page"; - break; - } - case "profile": { - if (pathSplit[1] === "applications") { - switch (pathSplit[2]) { - case "": { - presenceData.details = "Managing applications"; - break; - } - case "create": { - presenceData.details = "Creating a new application"; - break; - } - default: { - if (/\/edit\/?$/.test(pathname)) { - presenceData.details = "Editing an application"; - presenceData.state = document.querySelector( - "form fieldset input" - ).value; - } - } - } - } else if (pathSplit[1] === "edit") - presenceData.details = "Editing profile"; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CritiqueBrainz/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, href } = window.location + const pathSplit = pathname.split('/').slice(1) + switch (pathSplit[0]) { + case '': { + presenceData.details = 'Browsing home page' + break + } + case 'profile': { + if (pathSplit[1] === 'applications') { + switch (pathSplit[2]) { + case '': { + presenceData.details = 'Managing applications' + break + } + case 'create': { + presenceData.details = 'Creating a new application' + break + } + default: { + if (/\/edit\/?$/.test(pathname)) { + presenceData.details = 'Editing an application' + presenceData.state = document.querySelector( + 'form fieldset input', + )?.value + } + } + } + } + else if (pathSplit[1] === 'edit') { + presenceData.details = 'Editing profile' + } - break; - } - case "user": { - if (pathSplit[1] === "edit") { - presenceData.details = "Editing profile"; - presenceData.state = document - .querySelector(".nav a") - .textContent.replace(/^\s+|\s+$/g, ""); - } else { - presenceData.details = "Viewing a profile"; - const username = document.querySelector("h2").textContent; - switch (pathSplit[2] || "") { - case "": { - presenceData.state = username; - break; - } - case "info": { - presenceData.state = `Statistics for '${username}'`; - break; - } - } - } - break; - } - case "statistics": { - presenceData.details = "Viewing the top 10 contributors"; - break; - } - case "review": { - presenceData.details = "Browsing reviews"; - switch (pathSplit[1]) { - case "": { - presenceData.state = "Home page"; - break; - } - case "write": { - presenceData.details = "Writing a review"; - presenceData.state = - document.querySelector("dd a").textContent; - break; - } - default: { - if (/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(pathSplit[1])) { - presenceData.largeImageKey = - document.querySelector(".cover-art")?.src ?? - presenceData.largeImageKey; - switch (pathSplit[2] || "") { - case "": { - presenceData.details = "Reading a review"; - presenceData.state = `${ - document.querySelector("h3 > a") - .textContent - }'s review of ${ - document.querySelector("h2 > a") - .textContent - }`; - if (!document.querySelector(".alert-warning")) { - presenceData.buttons = [ - { - label: "Read Review", - url: href, - }, - ]; - } - break; - } - case "edit": { - presenceData.details = "Editing review"; - presenceData.state = - document.querySelector("dd a").textContent; - break; - } - case "revisions": { - if (!pathSplit[3]) - presenceData.details = "Viewing review revision history"; - else { - presenceData.details = "Viewing review revision"; - presenceData.state = - document.querySelector( - "h2 a" - ).textContent; - } - break; - } - case "delete": { - presenceData.details = "Deleting review"; - presenceData.state = document - .querySelector(".lead") - .textContent.match(/"(.*?)"/)[1]; - break; - } - } - } - } - } - break; - } - case "search": { - presenceData.details = "Searching"; - presenceData.state = - document.querySelector("#input-query").value; - break; - } - default: { - presenceData.details = "Browsing..."; - presenceData.state = document.title.match( - /(.*?)( - CritiqueBrainz$|$)/ - )[1]; - } - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + break + } + case 'user': { + if (pathSplit[1] === 'edit') { + presenceData.details = 'Editing profile' + presenceData.state = document + .querySelector('.nav a') + ?.textContent + ?.replace(/^\s+|\s+$/g, '') + } + else { + presenceData.details = 'Viewing a profile' + const username = document.querySelector('h2')?.textContent + switch (pathSplit[2] || '') { + case '': { + presenceData.state = username + break + } + case 'info': { + presenceData.state = `Statistics for '${username}'` + break + } + } + } + break + } + case 'statistics': { + presenceData.details = 'Viewing the top 10 contributors' + break + } + case 'review': { + presenceData.details = 'Browsing reviews' + switch (pathSplit[1]) { + case '': { + presenceData.state = 'Home page' + break + } + case 'write': { + presenceData.details = 'Writing a review' + presenceData.state = document.querySelector('dd a')?.textContent + break + } + default: { + if (/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(pathSplit[1])) { + presenceData.largeImageKey = document.querySelector('.cover-art')?.src + ?? presenceData.largeImageKey + switch (pathSplit[2] || '') { + case '': { + presenceData.details = 'Reading a review' + presenceData.state = `${ + document.querySelector('h3 > a') + ?.textContent + }'s review of ${ + document.querySelector('h2 > a') + ?.textContent + }` + if (!document.querySelector('.alert-warning')) { + presenceData.buttons = [ + { + label: 'Read Review', + url: href, + }, + ] + } + break + } + case 'edit': { + presenceData.details = 'Editing review' + presenceData.state = document.querySelector('dd a')?.textContent + break + } + case 'revisions': { + if (!pathSplit[3]) { + presenceData.details = 'Viewing review revision history' + } + else { + presenceData.details = 'Viewing review revision' + presenceData.state = document.querySelector('h2 a')?.textContent + } + break + } + case 'delete': { + presenceData.details = 'Deleting review' + presenceData.state = document + .querySelector('.lead') + ?.textContent + ?.match(/"(.*?)"/)?.[1] + break + } + } + } + } + } + break + } + case 'search': { + presenceData.details = 'Searching' + presenceData.state = document.querySelector('#input-query')?.value + break + } + default: { + presenceData.details = 'Browsing...' + presenceData.state = document.title?.match( + /(.*?)( - CritiqueBrainz$|$)/, + )?.[1] + } + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/Crowdin/metadata.json b/websites/C/Crowdin/metadata.json index e3cd4965d4cb..9adf722a7846 100644 --- a/websites/C/Crowdin/metadata.json +++ b/websites/C/Crowdin/metadata.json @@ -1,67 +1,67 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "TheDrop.", - "id": "293828021134295040" - }, - "contributors": [ - { - "name": "Rodry", - "id": "240875059953139714" - }, - { - "name": "Atom Skully", - "id": "671037171611729920" - } - ], - "service": "Crowdin", - "description": { - "en": "Crowdin is a cloud-based solution that streamlines localization management for your team.", - "fr": "Crowdin est une solution basée sur le cloud qui rationalise la gestion de la localisation pour votre équipe.", - "ro": "Crowdin este o soluție bazată pe cloud care eficientizează gestionarea localizării pentru echipa ta.", - "nl": "Crowdin is een cloudgebaseerde oplossing die lokalisatiebeheer voor uw team stroomlijnt.", - "vi_VN": "Crowdin là giải pháp trực tuyến cho việc quản lý đội ngũ bản địa hoá của bạn.", - "pt": "O Crowdin é uma solução de cloud que facilita a gestão de traduções para a tua equipa.", - "ru": "Crowdin — это облачное решение, которое упрощает управление локализацией для вашей команды." - }, - "url": [ - "crowdin.com", - "support.crowdin.com", - "store.crowdin.com", - "status.crowdin.com", - "blog.crowdin.com" - ], - "version": "4.0.12", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Crowdin/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Crowdin/assets/thumbnail.png", - "color": "#2e3340", - "category": "other", - "tags": [ - "partner", - "translation", - "projects", - "localization", - "localisation" - ], - "settings": [ - { - "id": "showProject", - "title": "Show project names", - "icon": "fa-regular fa-tag", - "value": true - }, - { - "id": "showManager", - "title": "Show manager pages", - "icon": "fa-duotone fa-user-police-tie", - "value": true - }, - { - "id": "showConversations", - "title": "Show conversations", - "icon": "fa-solid fa-envelope", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "TheDrop.", + "id": "293828021134295040" + }, + "contributors": [ + { + "name": "Rodry", + "id": "240875059953139714" + }, + { + "name": "Atom Skully", + "id": "671037171611729920" + } + ], + "service": "Crowdin", + "description": { + "en": "Crowdin is a cloud-based solution that streamlines localization management for your team.", + "fr": "Crowdin est une solution basée sur le cloud qui rationalise la gestion de la localisation pour votre équipe.", + "ro": "Crowdin este o soluție bazată pe cloud care eficientizează gestionarea localizării pentru echipa ta.", + "nl": "Crowdin is een cloudgebaseerde oplossing die lokalisatiebeheer voor uw team stroomlijnt.", + "vi_VN": "Crowdin là giải pháp trực tuyến cho việc quản lý đội ngũ bản địa hoá của bạn.", + "pt": "O Crowdin é uma solução de cloud que facilita a gestão de traduções para a tua equipa.", + "ru": "Crowdin — это облачное решение, которое упрощает управление локализацией для вашей команды." + }, + "url": [ + "crowdin.com", + "support.crowdin.com", + "store.crowdin.com", + "status.crowdin.com", + "blog.crowdin.com" + ], + "version": "4.0.12", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Crowdin/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Crowdin/assets/thumbnail.png", + "color": "#2e3340", + "category": "other", + "tags": [ + "partner", + "translation", + "projects", + "localization", + "localisation" + ], + "settings": [ + { + "id": "showProject", + "title": "Show project names", + "icon": "fa-regular fa-tag", + "value": true + }, + { + "id": "showManager", + "title": "Show manager pages", + "icon": "fa-duotone fa-user-police-tie", + "value": true + }, + { + "id": "showConversations", + "title": "Show conversations", + "icon": "fa-solid fa-envelope", + "value": false + } + ] +} diff --git a/websites/C/Crowdin/presence.ts b/websites/C/Crowdin/presence.ts index ae004482f323..1a5976657a9e 100644 --- a/websites/C/Crowdin/presence.ts +++ b/websites/C/Crowdin/presence.ts @@ -1,457 +1,527 @@ const presence = new Presence({ - clientId: "848293229409337444", - }), - browsingTimestamp = Math.round(Date.now() / 1000); + clientId: '848293229409337444', +}) +const browsingTimestamp = Math.round(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Crowdin/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, host, href } = document.location, - pathnameSplit = pathname.split("/"), - [showProject, showManager, showConversations] = await Promise.all([ - presence.getSetting("showProject"), - presence.getSetting("showManager"), - presence.getSetting("showConversations"), - ]); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Crowdin/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, host, href } = document.location + const pathnameSplit = pathname.split('/') + const [showProject, showManager, showConversations] = await Promise.all([ + presence.getSetting('showProject'), + presence.getSetting('showManager'), + presence.getSetting('showConversations'), + ]) - switch (host) { - case "support.crowdin.com": { - const isEnterprise = pathnameSplit.includes("enterprise"); - if (!pathname || pathname === "/") - presenceData.details = "On the main support page"; - else if ( - pathname.includes("/api/v2/") || - pathname.includes("/enterprise/api/") - ) { - const activeLabel = [...document.querySelectorAll("label")].find(c => - c.className?.includes("active") - ); + switch (host) { + case 'support.crowdin.com': { + const isEnterprise = pathnameSplit.includes('enterprise') + if (!pathname || pathname === '/') { + presenceData.details = 'On the main support page' + } + else if ( + pathname.includes('/api/v2/') + || pathname.includes('/enterprise/api/') + ) { + const activeLabel = [...document.querySelectorAll('label')].find(c => + c.className?.includes('active'), + ) - presenceData.details = `Reading the ${ - isEnterprise ? "Enterprise " : "" - }API documentation`; + presenceData.details = `Reading the ${ + isEnterprise ? 'Enterprise ' : '' + }API documentation` - presenceData.state = [...(activeLabel?.children ?? [])] - .map((c, i, a) => - a.length >= 1 && i === 0 - ? c.textContent.toUpperCase() - : c.textContent - ) - .join(" "); - presenceData.smallImageKey = Assets.Reading; - if (activeLabel) { - presenceData.buttons = [ - { - label: "Read more", - url: href, - }, - ]; - } - } else if (pathname.includes("/search")) { - presenceData.details = "Searching support"; - presenceData.state = document.querySelector( - ".form-control.form-control__result.input-lg" - )?.value; - presenceData.smallImageKey = Assets.Search; - } else { - presenceData.details = `Reading ${ - isEnterprise ? "an Enterprise" : "a" - } support article`; - presenceData.state = document.querySelector(".hero")?.textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.buttons = [ - { - label: "View article", - url: href, - }, - ]; - } + presenceData.state = [...(activeLabel?.children ?? [])] + .map((c, i, a) => + a.length >= 1 && i === 0 + ? c.textContent?.toUpperCase() + : c.textContent, + ) + .join(' ') + presenceData.smallImageKey = Assets.Reading + if (activeLabel) { + presenceData.buttons = [ + { + label: 'Read more', + url: href, + }, + ] + } + } + else if (pathname.includes('/search')) { + presenceData.details = 'Searching support' + presenceData.state = document.querySelector( + '.form-control.form-control__result.input-lg', + )?.value + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = `Reading ${ + isEnterprise ? 'an Enterprise' : 'a' + } support article` + presenceData.state = document.querySelector('.hero')?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.buttons = [ + { + label: 'View article', + url: href, + }, + ] + } - break; - } - case "store.crowdin.com": { - const appName = document - .querySelector("marketplace-item.hydrated") - ?.shadowRoot.querySelector("h1") - .childNodes[0].textContent.trim(); + break + } + case 'store.crowdin.com': { + const appName = document + .querySelector('marketplace-item.hydrated') + ?.shadowRoot + ?.querySelector('h1') + ?.childNodes[0] + ?.textContent + ?.trim() - if (!pathname || pathname === "/") - presenceData.details = "On the main store page"; - else if (pathname.includes("/author/")) { - presenceData.details = "Viewing developer"; - presenceData.state = document - .querySelectorAll("div.sc-marketplace-author")[1] - ?.querySelector("h1").childNodes[0].textContent; - presenceData.buttons = [{ label: "View developer", url: href }]; - } else if (appName) { - presenceData.details = "Viewing app"; - presenceData.state = appName; - presenceData.buttons = [{ label: "View app", url: href }]; - } else { - // Tags and other filter elements are intentionally not supported despite there being pathnames for them - // This is because they are customizable beyond the preset URLs and it would be hard to display all possibilities - const category = document - .querySelector("#category-select") - ?.shadowRoot.querySelector( - "div.select-wrapper.select-wrapper--borderless > div" - ).textContent; - presenceData.details = "Browsing the store"; - presenceData.state = - category && - `${ - category.includes("categories") ? category : `${category} category` - }`; - } + if (!pathname || pathname === '/') { + presenceData.details = 'On the main store page' + } + else if (pathname.includes('/author/')) { + presenceData.details = 'Viewing developer' + presenceData.state = document + .querySelectorAll('div.sc-marketplace-author')[1] + ?.querySelector('h1') + ?.childNodes[0] + .textContent + presenceData.buttons = [{ label: 'View developer', url: href }] + } + else if (appName) { + presenceData.details = 'Viewing app' + presenceData.state = appName + presenceData.buttons = [{ label: 'View app', url: href }] + } + else { + // Tags and other filter elements are intentionally not supported despite there being pathnames for them + // This is because they are customizable beyond the preset URLs and it would be hard to display all possibilities + const category = document + .querySelector('#category-select') + ?.shadowRoot + ?.querySelector( + 'div.select-wrapper.select-wrapper--borderless > div', + ) + ?.textContent + presenceData.details = 'Browsing the store' + presenceData.state = category + && `${ + category.includes('categories') ? category : `${category} category` + }` + } - break; - } - case "status.crowdin.com": { - // TODO add incident page (when they have an incident to report lol) - presenceData.details = "Viewing Crowdin's status"; - if (pathname === "/subscribe") - presenceData.details = "Subscribing to status reports"; + break + } + case 'status.crowdin.com': { + // TODO add incident page (when they have an incident to report lol) + presenceData.details = 'Viewing Crowdin\'s status' + if (pathname === '/subscribe') + presenceData.details = 'Subscribing to status reports' - break; - } - case "blog.crowdin.com": { - presenceData.smallImageKey = Assets.Reading; - if (pathname === "/") presenceData.details = "Browsing the blog"; - else if (pathname.includes("/tag/")) { - presenceData.details = "Viewing tag"; - presenceData.state = document - .querySelector(".text-center.home-bg.home-bg--tags") - ?.textContent.split(":")[1]; - presenceData.buttons = [ - { - label: "View tag", - url: href, - }, - ]; - } else if (pathname.includes("/search")) { - presenceData.details = "Searching the blog"; - presenceData.state = - document.querySelector(".form-control")?.value; - presenceData.smallImageKey = Assets.Search; - } else if (document.querySelector(".hero > h1")) { - presenceData.details = "Reading blog post"; - presenceData.state = document.querySelector(".hero > h1").textContent; - presenceData.buttons = [ - { - label: "View blog post", - url: href, - }, - ]; - } else { - presenceData.details = "Unknown page"; - delete presenceData.smallImageKey; - } + break + } + case 'blog.crowdin.com': { + presenceData.smallImageKey = Assets.Reading + if (pathname === '/') { + presenceData.details = 'Browsing the blog' + } + else if (pathname.includes('/tag/')) { + presenceData.details = 'Viewing tag' + presenceData.state = document + .querySelector('.text-center.home-bg.home-bg--tags') + ?.textContent + ?.split(':')[1] + presenceData.buttons = [ + { + label: 'View tag', + url: href, + }, + ] + } + else if (pathname.includes('/search')) { + presenceData.details = 'Searching the blog' + presenceData.state = document.querySelector('.form-control')?.value + presenceData.smallImageKey = Assets.Search + } + else if (document.querySelector('.hero > h1')) { + presenceData.details = 'Reading blog post' + presenceData.state = document.querySelector('.hero > h1')?.textContent + presenceData.buttons = [ + { + label: 'View blog post', + url: href, + }, + ] + } + else { + presenceData.details = 'Unknown page' + delete presenceData.smallImageKey + } - break; - } - default: - if (pathname === "/" || !pathname) presenceData.details = "Website Home"; - else if (pathname.includes("/project/")) { - if (document.querySelector(".not-found-header")) - presenceData.details = "Viewing an invalid project"; - else { - if (showProject) { - presenceData.details = - document.querySelector("a.side-menu__link--active > span") - ?.textContent ?? - document.querySelector( - "#back-end-header .application__header__breadcrumb a:nth-child(3)" - ).textContent; - presenceData.buttons = [ - { - label: "View project", - url: - document.location.origin + - pathnameSplit.filter((_, i) => i <= 2).join("/"), - }, - ]; - } - if (pathname.includes("/activity-stream")) - presenceData.state = "Viewing activity"; - else if (pathname.includes("/discussions")) { - if (parseInt(pathnameSplit.at(-1))) { - const author = document - .querySelector(".author-info-section > span") - .parentElement.querySelector(".user-name").textContent; + break + } + default: + if (pathname === '/' || !pathname) { + presenceData.details = 'Website Home' + } + else if (pathname.includes('/project/')) { + if (document.querySelector('.not-found-header')) { + presenceData.details = 'Viewing an invalid project' + } + else { + if (showProject) { + presenceData.details = document.querySelector('a.side-menu__link--active > span') + ?.textContent + ?? document.querySelector( + '#back-end-header .application__header__breadcrumb a:nth-child(3)', + )?.textContent + presenceData.buttons = [ + { + label: 'View project', + url: document.location.origin + + pathnameSplit.filter((_, i) => i <= 2).join('/'), + }, + ] + } + if (pathname.includes('/activity-stream')) { + presenceData.state = 'Viewing activity' + } + else if (pathname.includes('/discussions')) { + if (Number.parseInt(pathnameSplit.at(-1) ?? '')) { + const author = document + .querySelector('.author-info-section > span') + ?.parentElement + ?.querySelector('.user-name') + ?.textContent - if (showProject) presenceData.details += " - Discussions"; - else presenceData.details = "Viewing a project's discussion"; - presenceData.state = `${ - ( - document.querySelector( - "#topic-view-container > div > div > h3" - ) ?? - document.querySelector( - "#topic-view-container > div > div > div.topic-title-closed > h3" - ) - ).textContent - } - ${ - author === "You" - ? document.querySelector( - ".textarea-toolbar > .author-avatar > img" - ).title - : author - }`; - } else presenceData.state = "Browsing discussions"; - } else if (pathname.includes("/tasks")) { - if (parseInt(pathnameSplit.at(-1))) { - if (showProject) presenceData.details += " - Tasks"; - else presenceData.details = "Viewing a project's task"; - presenceData.state = - document.querySelector("#task-title").textContent; - } else presenceData.state = "Browsing tasks"; - } else if (pathname.includes("/reports")) { - const currentReport = pathnameSplit.at(-1); - if (showProject) presenceData.details += " - Reports"; - else presenceData.details = "Viewing a project's reports"; - presenceData.state = - !showManager && - ["cost-estimate", "abuse-report"].includes(currentReport) - ? "Project Status" - : !showManager && currentReport === "translation-cost" - ? "My Contribution" - : document.querySelector(".nav-item.active").textContent; - } else if (pathnameSplit.length === 3) - presenceData.state = "Viewing project home"; - else if ( - document.querySelector( - ".language-container .breadcrumb-item > span" - ) - ) { - presenceData.state = `${await getLanguageName( - pathnameSplit.at(-1) - )} translation`; - } else presenceData.state = "In project home"; + if (showProject) + presenceData.details += ' - Discussions' + else presenceData.details = 'Viewing a project\'s discussion' + presenceData.state = `${ + ( + document.querySelector( + '#topic-view-container > div > div > h3', + ) + ?? document.querySelector( + '#topic-view-container > div > div > div.topic-title-closed > h3', + ) + )?.textContent + } - ${ + author === 'You' + ? document.querySelector( + '.textarea-toolbar > .author-avatar > img', + )?.title + : author + }` + } + else { + presenceData.state = 'Browsing discussions' + } + } + else if (pathname.includes('/tasks')) { + if (Number.parseInt(pathnameSplit.at(-1) ?? '')) { + if (showProject) + presenceData.details += ' - Tasks' + else presenceData.details = 'Viewing a project\'s task' + presenceData.state = document.querySelector('#task-title')?.textContent + } + else { + presenceData.state = 'Browsing tasks' + } + } + else if (pathname.includes('/reports')) { + const currentReport = pathnameSplit.at(-1) + if (showProject) + presenceData.details += ' - Reports' + else presenceData.details = 'Viewing a project\'s reports' + presenceData.state = !showManager + && ['cost-estimate', 'abuse-report'].includes(currentReport ?? '') + ? 'Project Status' + : !showManager && currentReport === 'translation-cost' + ? 'My Contribution' + : document.querySelector('.nav-item.active')?.textContent + } + else if (pathnameSplit.length === 3) { + presenceData.state = 'Viewing project home' + } + else if ( + document.querySelector( + '.language-container .breadcrumb-item > span', + ) + ) { + presenceData.state = `${await getLanguageName( + pathnameSplit.at(-1) ?? '', + )} translation` + } + else { + presenceData.state = 'In project home' + } - if (showManager) { - if (pathname.includes("/content")) { - const managedContent = - document.querySelector(".nav-item.active").textContent; - if (showProject) { - presenceData.details += " - Content"; - presenceData.state = `Managing ${managedContent}`; - } else { - presenceData.details = `Managing a project's ${managedContent}`; - delete presenceData.state; - } - } else if (pathname.includes("/resources")) - presenceData.state = "Viewing resources"; - else if (pathname.includes("/members")) - presenceData.state = "Managing members"; - else if (pathname.includes("/tools")) { - // Unfortunately every app has a different selector, so it's virtually impossible to support them all - presenceData.state = "Managing tools"; - } else if (pathname.includes("/apps")) { - if (showProject) presenceData.details += " - Integrations"; - else presenceData.details = "Managing a project's integrations"; - presenceData.state = `Managing ${ - document.querySelector( - ".integration-details > .description > h3" - ).textContent - }`; - } else if (pathname.includes("/settings")) - presenceData.state = "Managing project settings"; - } - if ( - !presenceData.details && - presenceData.state && - !(presenceData.state as string).split(" ").includes("translation") - ) { - const stateSplit = (presenceData.state as string).split(" "); - if (!stateSplit.includes("project")) - stateSplit.splice(1, 0, "a project's"); - else stateSplit[stateSplit.indexOf("project")] = "a project's"; - presenceData.details = stateSplit.join(" "); - delete presenceData.state; - } - } - } else if ( - pathname.includes("/translate") || - pathname.includes("/proofread") - ) { - // Ensure the editor has loaded to prevent undefined text - if (!document.querySelector("#crowdin-editor-wrapper")) return; - const fileName = document.querySelector(".file-name")?.textContent, - languageName = document.querySelector( - ".language-name-wrapper.text-overflow" - )?.textContent; + if (showManager) { + if (pathname.includes('/content')) { + const managedContent = document.querySelector('.nav-item.active')?.textContent + if (showProject) { + presenceData.details += ' - Content' + presenceData.state = `Managing ${managedContent}` + } + else { + presenceData.details = `Managing a project's ${managedContent}` + delete presenceData.state + } + } + else if (pathname.includes('/resources')) { + presenceData.state = 'Viewing resources' + } + else if (pathname.includes('/members')) { + presenceData.state = 'Managing members' + } + else if (pathname.includes('/tools')) { + // Unfortunately every app has a different selector, so it's virtually impossible to support them all + presenceData.state = 'Managing tools' + } + else if (pathname.includes('/apps')) { + if (showProject) + presenceData.details += ' - Integrations' + else presenceData.details = 'Managing a project\'s integrations' + presenceData.state = `Managing ${ + document.querySelector( + '.integration-details > .description > h3', + )?.textContent + }` + } + else if (pathname.includes('/settings')) { + presenceData.state = 'Managing project settings' + } + } + if ( + !presenceData.details + && presenceData.state + && !(presenceData.state as string).split(' ').includes('translation') + ) { + const stateSplit = (presenceData.state as string).split(' ') + if (!stateSplit.includes('project')) + stateSplit.splice(1, 0, 'a project\'s') + else stateSplit[stateSplit.indexOf('project')] = 'a project\'s' + presenceData.details = stateSplit.join(' ') + delete presenceData.state + } + } + } + else if ( + pathname.includes('/translate') + || pathname.includes('/proofread') + ) { + // Ensure the editor has loaded to prevent undefined text + if (!document.querySelector('#crowdin-editor-wrapper')) + return + const fileName = document.querySelector('.file-name')?.textContent + const languageName = document.querySelector( + '.language-name-wrapper.text-overflow', + )?.textContent - if (pathname.includes("/proofread")) - presenceData.details = `Proofreading ${fileName}`; - else presenceData.details = `Translating ${fileName}`; + if (pathname.includes('/proofread')) + presenceData.details = `Proofreading ${fileName}` + else presenceData.details = `Translating ${fileName}` - if (showProject) { - presenceData.state = `${document.title - .split("-")[1] - ?.trim()} - ${languageName}`; - } else presenceData.state = languageName; - presenceData.smallImageKey = Assets.Writing; - presenceData.buttons = [ - { - label: "Translate project", - url: href, - }, - ]; - } else if (pathname.includes("/profile")) { - if (document.querySelector(".error-page")) - presenceData.details = "Viewing an invalid profile"; - else { - const profileName = document.querySelector(".username"), - profileNickname = document.querySelector(".user-login"); + if (showProject) { + presenceData.state = `${document.title + .split('-')[1] + ?.trim()} - ${languageName}` + } + else { + presenceData.state = languageName + } + presenceData.smallImageKey = Assets.Writing + presenceData.buttons = [ + { + label: 'Translate project', + url: href, + }, + ] + } + else if (pathname.includes('/profile')) { + if (document.querySelector('.error-page')) { + presenceData.details = 'Viewing an invalid profile' + } + else { + const profileName = document.querySelector('.username') + const profileNickname = document.querySelector('.user-login') - if ( - // check if "To Do" nav item (third) is present. If so, profile is own profile - document.querySelectorAll(".nav-item")[2] - ) { - if (pathname.includes("/activity")) - presenceData.details = "Viewing own activity"; - else presenceData.details = "Viewing own profile"; - } else if (pathname.includes("/activity")) - presenceData.details = "Viewing user activity"; - else presenceData.details = "Viewing a profile"; + if ( + // check if "To Do" nav item (third) is present. If so, profile is own profile + document.querySelectorAll('.nav-item')[2] + ) { + if (pathname.includes('/activity')) + presenceData.details = 'Viewing own activity' + else presenceData.details = 'Viewing own profile' + } + else if (pathname.includes('/activity')) { + presenceData.details = 'Viewing user activity' + } + else { + presenceData.details = 'Viewing a profile' + } - presenceData.state = `${profileName?.textContent}${ - profileNickname ? ` - ${profileNickname.textContent}` : "" - }`; + presenceData.state = `${profileName?.textContent}${ + profileNickname ? ` - ${profileNickname.textContent}` : '' + }` - presenceData.buttons = [ - { - label: "View profile", - // We can't just use href because own profile may not have the nickname at the end - url: `https://crowdin.com/profile/${ - (profileNickname ?? profileName).textContent - }`, - }, - ]; - } - } else if (pathname.includes("/messages")) { - const participants = [ - ...document - .querySelector(".messages-members-status") - .querySelectorAll(".messages-single-member-status"), - ] - .map(e => e.textContent) - // The elements already come with commas and spaces so we don't need to modify anything. This also accounts for the "X more" button and for single users - .join(""), - subject = document.querySelector("#subject-text > h3").textContent; - if ( - parseInt( - document.querySelector(".users-counter > :nth-child(2)").textContent - ) === 1 - ) { - if (showConversations) { - presenceData.details = "Messaging user"; - presenceData.state = `${subject} - ${participants}`; - } else presenceData.details = "Messaging a user"; - } else if (showConversations) { - presenceData.details = "Messaging group"; - presenceData.state = `${subject} - ${participants}`; - } else presenceData.details = "Messaging a group"; + presenceData.buttons = [ + { + label: 'View profile', + // We can't just use href because own profile may not have the nickname at the end + url: `https://crowdin.com/profile/${ + (profileNickname ?? profileName)?.textContent + }`, + }, + ] + } + } + else if (pathname.includes('/messages')) { + const participants = [ + ...document + .querySelector('.messages-members-status')! + .querySelectorAll('.messages-single-member-status'), + ] + .map(e => e.textContent) + // The elements already come with commas and spaces so we don't need to modify anything. This also accounts for the "X more" button and for single users + .join('') + const subject = document.querySelector('#subject-text > h3')?.textContent + if ( + Number.parseInt( + document.querySelector('.users-counter > :nth-child(2)')?.textContent ?? '', + ) === 1 + ) { + if (showConversations) { + presenceData.details = 'Messaging user' + presenceData.state = `${subject} - ${participants}` + } + else { + presenceData.details = 'Messaging a user' + } + } + else if (showConversations) { + presenceData.details = 'Messaging group' + presenceData.state = `${subject} - ${participants}` + } + else { + presenceData.details = 'Messaging a group' + } - presenceData.smallImageKey = Assets.Writing; - } else if (pathname.includes("/projects")) { - const searchValue = document.querySelector( - "#search_query > input" - ).value; + presenceData.smallImageKey = Assets.Writing + } + else if (pathname.includes('/projects')) { + const searchValue = document.querySelector( + '#search_query > input', + )?.value - presenceData.details = "Exploring projects"; - presenceData.state = - document.querySelector(".nav-item.active").textContent; + presenceData.details = 'Exploring projects' + presenceData.state = document.querySelector('.nav-item.active')?.textContent - if (searchValue) { - presenceData.state += ` - ${searchValue}`; - presenceData.smallImageKey = Assets.Search; - } - } else if (pathname.includes("/resources")) { - presenceData.details = "Viewing resources"; - presenceData.state = - document.querySelector(".active")?.textContent; - } else if (pathname.includes("/release-notes")) { - presenceData.details = "Reading release notes"; - presenceData.state = document.querySelector( - ".selected-release-item" - )?.textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.buttons = [ - { - label: "View release notes", - url: href, - }, - ]; - } else if (pathname === "/features") - presenceData.details = "Viewing Crowdin's features"; - else if (pathname === "/demo-request") - presenceData.details = "Requesting a demo"; - else if (pathname.includes("/page/") || pathname.includes("/teams/")) { - presenceData.details = "Reading page"; - // The header of each page is inconsistent and sometimes too big, thus we use the document title - presenceData.state = document.title.split("|")[0]; - presenceData.smallImageKey = Assets.Reading; - presenceData.buttons = [ - { - label: "View page", - url: href, - }, - ]; - } else if (pathname.includes("/pricing")) - presenceData.details = "Viewing pricing"; - else if (pathname.includes("/enterprise")) - presenceData.details = "Viewing enterprise"; - else if (pathname.includes("/contacts")) - presenceData.details = "Contacting Crowdin"; - else if (pathname.includes("/feature-request")) - presenceData.details = "Viewing feature requests"; - else if (pathname === "/createproject") - presenceData.details = "Creating a project"; - else { - presence.info( - "This page is currently not supported in the Crowdin presence! Please open an issue on GitHub about this." - ); - presenceData.details = "Viewing an unsupported page"; - } - } + if (searchValue) { + presenceData.state += ` - ${searchValue}` + presenceData.smallImageKey = Assets.Search + } + } + else if (pathname.includes('/resources')) { + presenceData.details = 'Viewing resources' + presenceData.state = document.querySelector('.active')?.textContent + } + else if (pathname.includes('/release-notes')) { + presenceData.details = 'Reading release notes' + presenceData.state = document.querySelector( + '.selected-release-item', + )?.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.buttons = [ + { + label: 'View release notes', + url: href, + }, + ] + } + else if (pathname === '/features') { + presenceData.details = 'Viewing Crowdin\'s features' + } + else if (pathname === '/demo-request') { + presenceData.details = 'Requesting a demo' + } + else if (pathname.includes('/page/') || pathname.includes('/teams/')) { + presenceData.details = 'Reading page' + // The header of each page is inconsistent and sometimes too big, thus we use the document title + presenceData.state = document.title.split('|')[0] + presenceData.smallImageKey = Assets.Reading + presenceData.buttons = [ + { + label: 'View page', + url: href, + }, + ] + } + else if (pathname.includes('/pricing')) { + presenceData.details = 'Viewing pricing' + } + else if (pathname.includes('/enterprise')) { + presenceData.details = 'Viewing enterprise' + } + else if (pathname.includes('/contacts')) { + presenceData.details = 'Contacting Crowdin' + } + else if (pathname.includes('/feature-request')) { + presenceData.details = 'Viewing feature requests' + } + else if (pathname === '/createproject') { + presenceData.details = 'Creating a project' + } + else { + presence.info( + 'This page is currently not supported in the Crowdin presence! Please open an issue on GitHub about this.', + ) + presenceData.details = 'Viewing an unsupported page' + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) async function getLanguageName(id: string) { - const languages = await fetch( - "https://api.crowdin.com/api/v2/languages?limit=500", - { - headers: { Accept: "application/json" }, - } - ) - .then( - r => - r.json() as Promise<{ - data: { data: CrowdinLanguage }[]; - pagination: { limit: number; offset: number }; - }> - ) - .then(r => r.data.map(l => l.data)); - return languages.find(l => l.id === id)?.name; + const languages = await fetch( + 'https://api.crowdin.com/api/v2/languages?limit=500', + { + headers: { Accept: 'application/json' }, + }, + ) + .then( + r => + r.json() as Promise<{ + data: { data: CrowdinLanguage }[] + pagination: { limit: number, offset: number } + }>, + ) + .then(r => r.data.map(l => l.data)) + return languages.find(l => l.id === id)?.name } interface CrowdinLanguage { - id: string; - name: string; - editorCode: string; - twoLettersCode: string; - threeLettersCode: string; - locale: string; - androidCode: string; - osxCode: string; - osxLocale: string; - pluralCategoryNames: string[]; - pluralRules: string; - pluralExamples: string[]; - textDirection: string; - dialectOf: string; + id: string + name: string + editorCode: string + twoLettersCode: string + threeLettersCode: string + locale: string + androidCode: string + osxCode: string + osxLocale: string + pluralCategoryNames: string[] + pluralRules: string + pluralExamples: string[] + textDirection: string + dialectOf: string } diff --git a/websites/C/Crunchyroll/iframe.ts b/websites/C/Crunchyroll/iframe.ts index f7544a2a1ca6..33a8359206e9 100644 --- a/websites/C/Crunchyroll/iframe.ts +++ b/websites/C/Crunchyroll/iframe.ts @@ -1,21 +1,18 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -setInterval(function () { - if (document.location.hostname === "static.crunchyroll.com") { - const video: HTMLVideoElement = - document.querySelector("#player0") !== null - ? document.querySelector("#player0") - : document.querySelector("#player_html5_api"); +setInterval(() => { + if (document.location.hostname === 'static.crunchyroll.com') { + const video = document.querySelector('#player0') ?? document.querySelector('#player_html5_api') - if (video && !isNaN(video.duration)) { - iframe.send({ - iFrameVideoData: { - iFrameVideo: true, - currTime: video.currentTime, - dur: video.duration, - paused: video.paused, - }, - }); - } - } -}, 100); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iFrameVideoData: { + iFrameVideo: true, + currTime: video.currentTime, + dur: video.duration, + paused: video.paused, + }, + }) + } + } +}, 100) diff --git a/websites/C/Crunchyroll/metadata.json b/websites/C/Crunchyroll/metadata.json index c5fd63aaa92f..b3822ca68a8d 100644 --- a/websites/C/Crunchyroll/metadata.json +++ b/websites/C/Crunchyroll/metadata.json @@ -1,60 +1,60 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "TheDrop.", - "id": "293828021134295040" - }, - "contributors": [ - { - "name": "RisingSunLight", - "id": "240521747852558347" - }, - { - "name": "ScarVite", - "id": "141218912934166528" - }, - { - "name": "theusaf", - "id": "193714715631812608" - } - ], - "service": "Crunchyroll", - "description": { - "en": "Crunchyroll is the world’s largest destination for anime and manga, boasting a global community of more than 45 million registered users and over 2 million subscribers.", - "de": "Crunchyroll ist die weltweit größte Anlaufstelle für Anime und Manga und verfügt über eine weltweite Community von mehr als 45 Millionen registrierten Benutzern und über 2 Millionen Abonnenten.", - "ro": "Crunchyroll este cel mai mare site din lume pentru anime și manga, având o comunitate de peste 45 milioane de oameni înregistrați și peste 2 miloande de abonați.", - "pt_BR": "Crunchyroll é o maior destino para animes e mangás, com uma comunidade global com mais de 45 milhões de contas registradas e mais de 2 milhões de inscritos.", - "fr": "Crunchyroll est la plus grande destination pour des animés et mangas, avec une communauté globale de plus de 45 millions de comptes enregistrés et plus de 2 millions de souscrivants.", - "uk_UA": "Crunchyroll — найбільше у світі місце аніме та манги, яке може похвалитися світовою спільнотою з понад 45 мільйонів зареєстрованих користувачів та понад 2 мільйони підписників.", - "nl": "Crunchyroll is 's werelds grootste bestemming voor anime en mange, met een wereldwijde gemeenschap met meer dan 45 miljoen geregistreerde gebruikers en meer dan 2 miljoen abonnees.", - "zh_CN": "Crunchyroll是美国的一家提供东亚相关流媒体影视服务和国际交流社区的网站。", - "zh_TW": "Crunchyroll是美國的一家提供東亞相關串流媒體影視服務和國際交流社區的網站。", - "vi_VN": "Crunchyroll là điểm đến lớn nhất thế giới dành cho anime và manga, với một cộng đồng trực tuyến với hơn 45 triệu người dùng đã đăng ký và 2 triệu người dùng đang theo dõi." - }, - "url": "www.crunchyroll.com", - "version": "3.1.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Crunchyroll/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Crunchyroll/assets/thumbnail.png", - "color": "#f47521", - "category": "anime", - "tags": [ - "video", - "anime", - "manga" - ], - "iframe": true, - "iFrameRegExp": ".*", - "settings": [ - { - "id": "lang", - "multiLanguage": 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": "TheDrop.", + "id": "293828021134295040" + }, + "contributors": [ + { + "name": "RisingSunLight", + "id": "240521747852558347" + }, + { + "name": "ScarVite", + "id": "141218912934166528" + }, + { + "name": "theusaf", + "id": "193714715631812608" + } + ], + "service": "Crunchyroll", + "description": { + "en": "Crunchyroll is the world’s largest destination for anime and manga, boasting a global community of more than 45 million registered users and over 2 million subscribers.", + "de": "Crunchyroll ist die weltweit größte Anlaufstelle für Anime und Manga und verfügt über eine weltweite Community von mehr als 45 Millionen registrierten Benutzern und über 2 Millionen Abonnenten.", + "ro": "Crunchyroll este cel mai mare site din lume pentru anime și manga, având o comunitate de peste 45 milioane de oameni înregistrați și peste 2 miloande de abonați.", + "pt_BR": "Crunchyroll é o maior destino para animes e mangás, com uma comunidade global com mais de 45 milhões de contas registradas e mais de 2 milhões de inscritos.", + "fr": "Crunchyroll est la plus grande destination pour des animés et mangas, avec une communauté globale de plus de 45 millions de comptes enregistrés et plus de 2 millions de souscrivants.", + "uk_UA": "Crunchyroll — найбільше у світі місце аніме та манги, яке може похвалитися світовою спільнотою з понад 45 мільйонів зареєстрованих користувачів та понад 2 мільйони підписників.", + "nl": "Crunchyroll is 's werelds grootste bestemming voor anime en mange, met een wereldwijde gemeenschap met meer dan 45 miljoen geregistreerde gebruikers en meer dan 2 miljoen abonnees.", + "zh_CN": "Crunchyroll是美国的一家提供东亚相关流媒体影视服务和国际交流社区的网站。", + "zh_TW": "Crunchyroll是美國的一家提供東亞相關串流媒體影視服務和國際交流社區的網站。", + "vi_VN": "Crunchyroll là điểm đến lớn nhất thế giới dành cho anime và manga, với một cộng đồng trực tuyến với hơn 45 triệu người dùng đã đăng ký và 2 triệu người dùng đang theo dõi." + }, + "url": "www.crunchyroll.com", + "version": "3.1.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Crunchyroll/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Crunchyroll/assets/thumbnail.png", + "color": "#f47521", + "category": "anime", + "tags": [ + "video", + "anime", + "manga" + ], + "iframe": true, + "iFrameRegExp": ".*", + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "cover", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true + } + ] +} diff --git a/websites/C/Crunchyroll/presence.ts b/websites/C/Crunchyroll/presence.ts index 2c4ba65fb411..bb5502ff0618 100644 --- a/websites/C/Crunchyroll/presence.ts +++ b/websites/C/Crunchyroll/presence.ts @@ -1,213 +1,214 @@ const presence = new Presence({ - clientId: "608065709741965327", -}); + clientId: '608065709741965327', +}) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Crunchyroll/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Crunchyroll/assets/logo.png', - OpenBook = "https://cdn.rcd.gg/PreMiD/websites/C/Crunchyroll/assets/0.png", + OpenBook = 'https://cdn.rcd.gg/PreMiD/websites/C/Crunchyroll/assets/0.png', } async function getStrings() { - return presence.getStrings( - { - play: "general.playing", - pause: "general.paused", - browse: "general.browsing", - reading: "general.reading", - viewPage: "general.viewPage", - viewManga: "general.viewManga", - viewSeries: "general.buttonViewSeries", - watchEpisode: "general.buttonViewEpisode", - readingArticle: "general.readingArticle", - viewCategory: "general.viewCategory", - chapter: "general.chapter", - search: "general.search", - manga: "general.manga", - page: "general.page", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + play: 'general.playing', + pause: 'general.paused', + browse: 'general.browsing', + reading: 'general.reading', + viewPage: 'general.viewPage', + viewManga: 'general.viewManga', + viewSeries: 'general.buttonViewSeries', + watchEpisode: 'general.buttonViewEpisode', + readingArticle: 'general.readingArticle', + viewCategory: 'general.viewCategory', + chapter: 'general.chapter', + search: 'general.search', + manga: 'general.manga', + page: 'general.page', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } -let strings: Awaited>, - oldLang: string = null, - lastPlaybackState = null, - playback: boolean, - browsingTimestamp = Math.floor(Date.now() / 1000); +let strings: Awaited> +let oldLang: string | null = null +let lastPlaybackState = null +let playback: boolean = false +let browsingTimestamp = Math.floor(Date.now() / 1000) if (lastPlaybackState !== playback) { - lastPlaybackState = playback; - browsingTimestamp = Math.floor(Date.now() / 1000); + lastPlaybackState = playback + browsingTimestamp = Math.floor(Date.now() / 1000) } let iFrameVideo: boolean, - currentTime: number, - duration: number, - paused: boolean; + currentTime: number, + duration: number, + paused: boolean interface iFrameData { - iFrameVideoData: { - iFrameVideo: boolean; - currTime: number; - dur: number; - paused: boolean; - }; + iFrameVideoData: { + iFrameVideo: boolean + currTime: number + dur: number + paused: boolean + } } -presence.on("iFrameData", (data: iFrameData) => { - playback = data.iFrameVideoData !== null ? true : false; - - if (playback) { - ({ - iFrameVideo, - currTime: currentTime, - dur: duration, - paused, - } = data.iFrameVideoData); - } -}); - -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - type: ActivityType.Watching, - }, - { href, pathname } = window.location, - [newLang, showCover] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("cover"), - ]); - - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } - - if (pathname.includes("/manga")) { - if (pathname.includes("/read")) { - const queryTitle = - document.querySelector(".chapter-header h1"); - presenceData.details = queryTitle.children[0].textContent.trim(); - presenceData.state = `${ - strings.reading - } ${queryTitle.lastChild.textContent.trim()}`; - presenceData.startTimestamp = browsingTimestamp; - presenceData.smallImageKey = Assets.OpenBook; - const pageNumber: string = - document.querySelector( - ".first-page-number" - ).textContent; - presenceData.smallImageText = `${strings.page} ${ - pageNumber === "" ? "1" : pageNumber - }/${document.querySelector(".images").children.length}`; - presenceData.buttons = [ - { - label: `Read ${strings.chapter}`, - url: href, - }, - ]; - } else if (pathname.includes("/volumes")) { - presenceData.details = strings.viewManga; - presenceData.state = document - .querySelector(".ellipsis") - .textContent.split("Manga > ")[1]; - presenceData.buttons = [ - { - label: `View ${strings.manga}`, - url: href, - }, - ]; - } else { - presenceData.details = strings.browse; - presenceData.startTimestamp = browsingTimestamp; - - delete presenceData.state; - delete presenceData.smallImageKey; - } - } else if ( - iFrameVideo !== false && - !isNaN(duration) && - pathname.includes("/watch/") - ) { - const videoTitle = - document.querySelector("a > h4").textContent; - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = paused ? strings.pause : strings.play; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(Math.floor(currentTime), Math.floor(duration)); - - presenceData.details = videoTitle ?? "Title not found..."; - presenceData.state = - document.querySelector("h1.title").textContent; - - presenceData.largeImageKey = - document.querySelector("[property='og:image']") - ?.content ?? Assets.Logo; - - if (paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - - if (videoTitle) { - presenceData.buttons = [ - { - label: strings.watchEpisode, - url: href, - }, - { - label: strings.viewSeries, - url: document.querySelector(".show-title-link") - .href, - }, - ]; - } - } else if (pathname.includes("/series")) { - presenceData.details = strings.viewPage; - presenceData.state = - document.querySelector("h1.title").textContent; - presenceData.largeImageKey = - document.querySelector("[property='og:image']") - ?.content ?? Assets.Logo; - presenceData.buttons = [ - { - label: strings.viewSeries, - url: href, - }, - ]; - } else if (pathname.includes("/search")) { - presenceData.details = strings.search; - presenceData.state = - document.querySelector(".search-input").value; - presenceData.smallImageKey = Assets.Search; - } else if (pathname.includes("/simulcasts")) { - presenceData.details = strings.viewPage; - presenceData.state = `${ - document.querySelector("h1 + div span").textContent - } ${document.querySelector("h1").textContent}`; - } else if (pathname.includes("/videos")) { - presenceData.details = strings.viewCategory; - presenceData.state = document.querySelector("h1").textContent; - } else if (/\/anime-.*?\/\d{4}\//.test(pathname)) { - presenceData.details = strings.readingArticle; - presenceData.state = document.querySelector( - ".crunchynews-header" - ).textContent; - if (showCover) { - presenceData.largeImageKey = - document.querySelector(".mug").src; - } - } else { - presenceData.details = strings.browse; - presenceData.startTimestamp = browsingTimestamp; - - delete presenceData.state; - delete presenceData.smallImageKey; - } - - if (!showCover) presenceData.largeImageKey = Assets.Logo; - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); +presence.on('iFrameData', (inc: unknown) => { + const data = inc as iFrameData + playback = data.iFrameVideoData !== null + + if (playback) { + ({ + iFrameVideo, + currTime: currentTime, + dur: duration, + paused, + } = data.iFrameVideoData) + } +}) + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + type: ActivityType.Watching, + } + const { href, pathname } = window.location + const [newLang, showCover] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('cover'), + ]) + + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } + + if (pathname.includes('/manga')) { + if (pathname.includes('/read')) { + const queryTitle = document.querySelector('.chapter-header h1') + presenceData.details = queryTitle?.children[0].textContent?.trim() + presenceData.state = `${ + strings.reading + } ${queryTitle?.lastChild?.textContent?.trim()}` + presenceData.startTimestamp = browsingTimestamp + presenceData.smallImageKey = Assets.OpenBook + const pageNumber = document.querySelector( + '.first-page-number', + )?.textContent + presenceData.smallImageText = `${strings.page} ${ + pageNumber === '' ? '1' : pageNumber + }/${document.querySelector('.images')?.children.length}` + presenceData.buttons = [ + { + label: `Read ${strings.chapter}`, + url: href, + }, + ] + } + else if (pathname.includes('/volumes')) { + presenceData.details = strings.viewManga + presenceData.state = document + .querySelector('.ellipsis') + ?.textContent + ?.split('Manga > ')[1] + presenceData.buttons = [ + { + label: `View ${strings.manga}`, + url: href, + }, + ] + } + else { + presenceData.details = strings.browse + presenceData.startTimestamp = browsingTimestamp + + delete presenceData.state + delete presenceData.smallImageKey + } + } + else if ( + iFrameVideo !== false + && !Number.isNaN(duration) + && pathname.includes('/watch/') + ) { + const videoTitle = document.querySelector('a > h4')?.textContent + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = paused ? strings.pause : strings.play; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(Math.floor(currentTime), Math.floor(duration)) + + presenceData.details = videoTitle ?? 'Title not found...' + presenceData.state = document.querySelector('h1.title')?.textContent + + presenceData.largeImageKey = document.querySelector('[property=\'og:image\']') + ?.content ?? Assets.Logo + + if (paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + + if (videoTitle) { + presenceData.buttons = [ + { + label: strings.watchEpisode, + url: href, + }, + { + label: strings.viewSeries, + url: document.querySelector('.show-title-link')?.href ?? '', + }, + ] + } + } + else if (pathname.includes('/series')) { + presenceData.details = strings.viewPage + presenceData.state = document.querySelector('h1.title')?.textContent + presenceData.largeImageKey = document.querySelector('[property=\'og:image\']')?.content ?? Assets.Logo + presenceData.buttons = [ + { + label: strings.viewSeries, + url: href, + }, + ] + } + else if (pathname.includes('/search')) { + presenceData.details = strings.search + presenceData.state = document.querySelector('.search-input')?.value + presenceData.smallImageKey = Assets.Search + } + else if (pathname.includes('/simulcasts')) { + presenceData.details = strings.viewPage + presenceData.state = `${ + document.querySelector('h1 + div span')?.textContent + } ${document.querySelector('h1')?.textContent}` + } + else if (pathname.includes('/videos')) { + presenceData.details = strings.viewCategory + presenceData.state = document.querySelector('h1')?.textContent + } + else if (/\/anime-.*?\/\d{4}\//.test(pathname)) { + presenceData.details = strings.readingArticle + presenceData.state = document.querySelector( + '.crunchynews-header', + )?.textContent + if (showCover) { + presenceData.largeImageKey = document.querySelector('.mug')?.src + } + } + else { + presenceData.details = strings.browse + presenceData.startTimestamp = browsingTimestamp + + delete presenceData.state + delete presenceData.smallImageKey + } + + if (!showCover) + presenceData.largeImageKey = Assets.Logo + + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/Cuevana 3/iframe.ts b/websites/C/Cuevana 3/iframe.ts index 5183dca046fb..1e55ec9a1419 100644 --- a/websites/C/Cuevana 3/iframe.ts +++ b/websites/C/Cuevana 3/iframe.ts @@ -1,15 +1,15 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", async () => { - if (document.querySelector("video")) { - const video: HTMLVideoElement = document.querySelector("video"); - if (video && !isNaN(video.duration)) { - iframe.send({ - exists: true, - duration: video.duration, - currentTime: video.currentTime, - paused: video.paused, - }); - } - } -}); +iframe.on('UpdateData', async () => { + if (document.querySelector('video')) { + const video = document.querySelector('video') + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + exists: true, + duration: video.duration, + currentTime: video.currentTime, + paused: video.paused, + }) + } + } +}) diff --git a/websites/C/Cuevana 3/metadata.json b/websites/C/Cuevana 3/metadata.json index 4acb3c3cb296..c0204eefa27f 100644 --- a/websites/C/Cuevana 3/metadata.json +++ b/websites/C/Cuevana 3/metadata.json @@ -1,55 +1,55 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Rare Akuma ☆", - "id": "250044591686811669" - }, - "service": "Cuevana 3", - "description": { - "en": "Cuevana 3 is a streaming website where you can watch and download movies and series in spanish, english and subtitled.", - "es": "Cuevana 3 es una pagina web donde puedes ver y descargar películas y series en latino, español, ingles y subtitulado.", - "nl": "Cuevana 3 is een streamingwebsite waar je films en series in het Spaans, Engels en ondertiteld kunt bekijken en downloaden." - }, - "url": "cuevana3.nu", - "regExp": "((www)?(wvw)?(ww)?([0-9]?[0-9])?[.])?(cuevana).*[.].*", - "version": "3.1.7", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cuevana%203/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cuevana%203/assets/thumbnail.png", - "color": "#007AFF", - "category": "videos", - "tags": [ - "cuevana", - "streaming", - "movies", - "series" - ], - "iframe": true, - "iFrameRegExp": ".*", - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "thumbnails", - "if": { - "privacy": false - }, - "title": "Show Thumbnail", - "icon": "fad fa-album", - "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": "Rare Akuma ☆", + "id": "250044591686811669" + }, + "service": "Cuevana 3", + "description": { + "en": "Cuevana 3 is a streaming website where you can watch and download movies and series in spanish, english and subtitled.", + "es": "Cuevana 3 es una pagina web donde puedes ver y descargar películas y series en latino, español, ingles y subtitulado.", + "nl": "Cuevana 3 is een streamingwebsite waar je films en series in het Spaans, Engels en ondertiteld kunt bekijken en downloaden." + }, + "url": "cuevana3.nu", + "regExp": "((www)?(wvw)?(ww)?([0-9]?[0-9])?[.])?(cuevana).*[.].*", + "version": "3.1.7", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cuevana%203/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cuevana%203/assets/thumbnail.png", + "color": "#007AFF", + "category": "videos", + "tags": [ + "cuevana", + "streaming", + "movies", + "series" + ], + "iframe": true, + "iFrameRegExp": ".*", + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "thumbnails", + "if": { + "privacy": false + }, + "title": "Show Thumbnail", + "icon": "fad fa-album", + "value": false + }, + { + "id": "buttons", + "if": { + "privacy": false + }, + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/C/Cuevana 3/presence.ts b/websites/C/Cuevana 3/presence.ts index 67cf4bc175fe..94c9df08d7dd 100644 --- a/websites/C/Cuevana 3/presence.ts +++ b/websites/C/Cuevana 3/presence.ts @@ -1,168 +1,161 @@ const presence = new Presence({ - clientId: "804448815942860821", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '804448815942860821', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) async function getStrings() { - return presence.getStrings( - { - buttonViewEpisode: "general.buttonViewEpisode", - buttonWatchMovie: "general.buttonWatchMovie", - play: "general.playing", - pause: "general.paused", - browsing: "general.browsing", - viewHome: "general.viewHome", - viewAMovie: "general.viewAMovie", - viewASeries: "general.viewASeries", - watchingSeries: "general.watchingSeries", - watchingMovie: "general.watchingMovie", - }, - "es_419" - ); + return presence.getStrings( + { + buttonViewEpisode: 'general.buttonViewEpisode', + buttonWatchMovie: 'general.buttonWatchMovie', + play: 'general.playing', + pause: 'general.paused', + browsing: 'general.browsing', + viewHome: 'general.viewHome', + viewAMovie: 'general.viewAMovie', + viewASeries: 'general.viewASeries', + watchingSeries: 'general.watchingSeries', + watchingMovie: 'general.watchingMovie', + }, + 'es_419', + ) } const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Cuevana%203/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Cuevana%203/assets/logo.png', } function fullURL(cover: string, hostname: string) { - const cover2 = - cover ?? - document - ?.querySelector("article") - ?.querySelector("img") - ?.getAttribute("src"); - if (cover2?.startsWith("/_next")) return `https://${hostname}${cover2}`; - else if (cover2?.startsWith("//")) - return `https://${cover2.replace("//", "")}`; - else if (cover2) return cover2; - else return Assets.Logo; + const cover2 = cover + ?? document + ?.querySelector('article') + ?.querySelector('img') + ?.getAttribute('src') + if (cover2?.startsWith('/_next')) + return `https://${hostname}${cover2}` + else if (cover2?.startsWith('//')) + return `https://${cover2.replace('//', '')}` + else if (cover2) + return cover2 + else return Assets.Logo } let video: { - exists: boolean; - duration: number; - currentTime: number; - paused: boolean; - }, - videoPaused: boolean; + exists: boolean + duration: number + currentTime: number + paused: boolean + }, + videoPaused: boolean presence.on( - "iFrameData", - (data: { - exists: boolean; - duration: number; - currentTime: number; - paused: boolean; - }) => { - video = data; - videoPaused = data.paused; - } -); + 'iFrameData', + (inc: unknown) => { + const data = inc as typeof video + video = data + videoPaused = data.paused + }, +) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname, hostname, href } = document.location, - [privacy, thumbnails, buttons] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("thumbnails"), - presence.getSetting("buttons"), - ]), - strings = await getStrings(); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname, hostname, href } = document.location + const [privacy, thumbnails, buttons] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('thumbnails'), + presence.getSetting('buttons'), + ]) + const strings = await getStrings() - switch (true) { - case pathname === "/": { - presenceData.details = strings.viewHome; - break; - } - case pathname.includes("/episodio/"): - case pathname.includes("/watch/"): - case pathname.includes("/peliculas-online/"): - case pathname.includes("episodio/"): - case pathname.includes("/series-online/"): { - const isSeries = pathname.includes("/series-online/") - ? true - : document.querySelector('[class="select-season"]') - ? true - : false, - title = document.querySelector('[class="Title"]')?.textContent, - episodeNumber = document.querySelector('[class="Title"] > span') - ?.textContent - ? document.querySelector('[class="Title"] > span')?.textContent - : title?.match(/[0-9]{1,}x[0-9]{1,}/gm)?.length ?? 0 !== 0 - ? title.match(/[0-9]{1,}x[0-9]{1,}/gm)[0] - : ""; - presenceData.largeImageKey = - fullURL( - document - .querySelector('[class="Image"]') - .querySelector("img") - ?.getAttribute("src"), - hostname - ) || - fullURL( - document.querySelector("figure > img")?.getAttribute("src") ?? - document - .querySelector('[class="Image"]') - .querySelector("img") - ?.getAttribute("src") ?? - document - ?.querySelector('[itemprop="image"]') - ?.getAttribute("src") ?? - "", - hostname - ); - if (video.exists) { - delete presenceData.startTimestamp; - presenceData.details = !privacy - ? title.replace(episodeNumber, "") - : isSeries - ? strings.watchingSeries - : strings.watchingMovie; - presenceData.state = - episodeNumber && - episodeNumber.match(/[0-9]{1,}x[0-9]{1,}/gm)?.length !== 0 - ? `S${episodeNumber.split("x")[0]}:E${episodeNumber.split("x")[1]}` - : ""; - presenceData.smallImageKey = videoPaused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = videoPaused - ? strings.pause - : strings.play; - if (!videoPaused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(video.currentTime, video.duration); - } + switch (true) { + case pathname === '/': { + presenceData.details = strings.viewHome + break + } + case pathname.includes('/episodio/'): + case pathname.includes('/watch/'): + case pathname.includes('/peliculas-online/'): + case pathname.includes('episodio/'): + case pathname.includes('/series-online/'): { + const isSeries = pathname.includes('/series-online/') + ? true + : !!document.querySelector('[class="select-season"]') + const title = document.querySelector('[class="Title"]')?.textContent + const episodeNumber = document.querySelector('[class="Title"] > span') + ?.textContent + ? document.querySelector('[class="Title"] > span')?.textContent + : (title?.match(/\d+x\d+/g)?.length ?? 0) !== 0 + ? title?.match(/\d+x\d+/g)?.[0] + : '' + presenceData.largeImageKey = fullURL( + document + .querySelector('[class="Image"]') + ?.querySelector('img') + ?.getAttribute('src') ?? '', + hostname, + ) + || fullURL( + document.querySelector('figure > img')?.getAttribute('src') + ?? document + .querySelector('[class="Image"]') + ?.querySelector('img') + ?.getAttribute('src') + ?? document + ?.querySelector('[itemprop="image"]') + ?.getAttribute('src') + ?? '', + hostname, + ) + if (video.exists) { + delete presenceData.startTimestamp + presenceData.details = !privacy + ? title!.replace(episodeNumber!, '') + : isSeries + ? strings.watchingSeries + : strings.watchingMovie + presenceData.state = episodeNumber + && episodeNumber.match(/\d+x\d+/g)?.length !== 0 + ? `S${episodeNumber.split('x')[0]}:E${episodeNumber.split('x')[1]}` + : '' + presenceData.smallImageKey = videoPaused ? Assets.Pause : Assets.Play + presenceData.smallImageText = videoPaused + ? strings.pause + : strings.play + if (!videoPaused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(video.currentTime, video.duration) + } - if (buttons) { - presenceData.buttons = isSeries - ? [{ label: strings.buttonViewEpisode, url: href }] - : [{ label: strings.buttonWatchMovie, url: href }]; - } - } else { - presenceData.details = !privacy - ? title.replace(episodeNumber, "") - : isSeries - ? strings.viewASeries - : strings.viewAMovie; - presenceData.state = - episodeNumber && - episodeNumber.match(/[0-9]{1,}x[0-9]{1,}/gm)?.length !== 0 - ? `S${episodeNumber.split("x")[0]}:E${episodeNumber.split("x")[1]}` - : ""; - } - break; - } - default: { - presenceData.details = strings.browsing; - break; - } - } + if (buttons) { + presenceData.buttons = isSeries + ? [{ label: strings.buttonViewEpisode, url: href }] + : [{ label: strings.buttonWatchMovie, url: href }] + } + } + else { + presenceData.details = !privacy + ? title!.replace(episodeNumber!, '') + : isSeries + ? strings.viewASeries + : strings.viewAMovie + presenceData.state = episodeNumber + && episodeNumber.match(/\d+x\d+/g)?.length !== 0 + ? `S${episodeNumber.split('x')[0]}:E${episodeNumber.split('x')[1]}` + : '' + } + break + } + default: { + presenceData.details = strings.browsing + break + } + } - if (privacy && presenceData.state) delete presenceData.state; - if (!thumbnails && presenceData.largeImageKey !== Assets.Logo) - presenceData.largeImageKey = Assets.Logo; - presence.setActivity(presenceData); -}); + if (privacy && presenceData.state) + delete presenceData.state + if (!thumbnails && presenceData.largeImageKey !== Assets.Logo) + presenceData.largeImageKey = Assets.Logo + presence.setActivity(presenceData) +}) diff --git a/websites/C/Currys/metadata.json b/websites/C/Currys/metadata.json index 87ea294b17eb..4d1928e64ac6 100644 --- a/websites/C/Currys/metadata.json +++ b/websites/C/Currys/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "xFutuxe", - "id": "299406904344576000" - }, - "service": "Currys", - "description": { - "en": "Currys is a British electrical retailer and repairer operating in the United Kingdom and Republic of Ireland, selling all kind of electrical goods" - }, - "url": [ - "currys.co.uk", - "www.currys.co.uk" - ], - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/thumbnail.png", - "color": "#4b0ba3", - "category": "other", - "tags": [ - "currys", - "curryspcworld" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "xFutuxe", + "id": "299406904344576000" + }, + "service": "Currys", + "description": { + "en": "Currys is a British electrical retailer and repairer operating in the United Kingdom and Republic of Ireland, selling all kind of electrical goods" + }, + "url": [ + "currys.co.uk", + "www.currys.co.uk" + ], + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/thumbnail.png", + "color": "#4b0ba3", + "category": "other", + "tags": [ + "currys", + "curryspcworld" + ] +} diff --git a/websites/C/Currys/presence.ts b/websites/C/Currys/presence.ts index 8a80e844bb7b..62e9b5e226f8 100644 --- a/websites/C/Currys/presence.ts +++ b/websites/C/Currys/presence.ts @@ -1,78 +1,80 @@ const presence = new Presence({ - clientId: "996516483150663721", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '996516483150663721', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - smallImageKey: "https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/0.png", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/logo.png", - startTimestamp: browsingTimestamp, - details: "Browsing", - state: "Currys Website", - }; - const { pathname } = document.location; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + smallImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/0.png', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/logo.png', + startTimestamp: browsingTimestamp, + details: 'Browsing', + state: 'Currys Website', + } + const { pathname } = document.location - switch (true) { - case !!document.querySelector(".amp-herobanner-headline"): - presenceData.state = document.querySelector( - ".amp-herobanner-headline" - ).textContent; - break; - case !!document.querySelector(".plp-heading"): - presenceData.state = document.querySelector(".plp-heading").textContent; - break; - case !!document.querySelector("#clp-row-1 > div > div > h1"): - presenceData.state = document.querySelector( - "#clp-row-1 > div > div > h1" - ).textContent; - break; - case !!document.querySelector("#clp-row-1 > div > h1"): - presenceData.state = document.querySelector( - "#clp-row-1 > div > h1" - ).textContent; - break; - case pathname.includes("/products/") && - !!document.querySelector(".product-name"): - presenceData.state = document.querySelector(".product-name").textContent; - break; - default: - break; - } + switch (true) { + case !!document.querySelector('.amp-herobanner-headline'): + presenceData.state = document.querySelector( + '.amp-herobanner-headline', + )?.textContent + break + case !!document.querySelector('.plp-heading'): + presenceData.state = document.querySelector('.plp-heading')?.textContent + break + case !!document.querySelector('#clp-row-1 > div > div > h1'): + presenceData.state = document.querySelector( + '#clp-row-1 > div > div > h1', + )?.textContent + break + case !!document.querySelector('#clp-row-1 > div > h1'): + presenceData.state = document.querySelector( + '#clp-row-1 > div > h1', + )?.textContent + break + case pathname.includes('/products/') + && !!document.querySelector('.product-name'): + presenceData.state = document.querySelector('.product-name')?.textContent + break + default: + break + } - const pages: Record = { - "/account": { details: "Viewing", state: "My Account" }, - "/wishlist-show": { details: "Viewing", state: "Wishlist" }, - "/order": { details: "Viewing", state: "Orders" }, - "/manage-your-details": { details: "Managing", state: "Account Details" }, - "/cart": { details: "Viewing", state: "Basket" }, - "/store-finder": { details: "Finding", state: "Stores" }, - "/services/": { details: "Viewing", state: "Services" }, - }; + const pages: Record = { + '/account': { details: 'Viewing', state: 'My Account' }, + '/wishlist-show': { details: 'Viewing', state: 'Wishlist' }, + '/order': { details: 'Viewing', state: 'Orders' }, + '/manage-your-details': { details: 'Managing', state: 'Account Details' }, + '/cart': { details: 'Viewing', state: 'Basket' }, + '/store-finder': { details: 'Finding', state: 'Stores' }, + '/services/': { details: 'Viewing', state: 'Services' }, + } - 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 + } - // When searching for product - const search = document.querySelector('[id="Search"]'); - if (search?.value) { - presenceData.details = "Searching for:"; - presenceData.state = search.value; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/0.png"; - return presence.setActivity(presenceData); - } + // When searching for product + const search = document.querySelector('[id="Search"]') + if (search?.value) { + presenceData.details = 'Searching for:' + presenceData.state = search.value + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/0.png' + return presence.setActivity(presenceData) + } - if (pathname === "/search") { - presenceData.details = "Viewing search results for:"; - presenceData.state = document - .querySelector('[class="breadcrumb"]') - .lastElementChild?.textContent?.trim(); - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/0.png"; - } + if (pathname === '/search') { + presenceData.details = 'Viewing search results for:' + presenceData.state = document + .querySelector('[class="breadcrumb"]') + ?.lastElementChild + ?.textContent + ?.trim() + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/C/Currys/assets/0.png' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/C/CurseForge/metadata.json b/websites/C/CurseForge/metadata.json index 63d7deaffb5d..70af9da2ccf6 100644 --- a/websites/C/CurseForge/metadata.json +++ b/websites/C/CurseForge/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "CurseForge", - "description": { - "en": "CurseForge allows for the uploading and reviewing of plugins, add-ons, and modifications for various games.", - "nl": "CurseForge zorgt voor het uploaden en beoordelen van plugins, add-ons en mods voor verschillende games." - }, - "url": "www.curseforge.com", - "regExp": "([a-z0-9-]+[.])*curseforge[.]com[/]", - "version": "1.2.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CurseForge/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CurseForge/assets/thumbnail.png", - "color": "#f16725", - "category": "games", - "tags": [ - "mods", - "plugins", - "curseforge" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "CurseForge", + "description": { + "en": "CurseForge allows for the uploading and reviewing of plugins, add-ons, and modifications for various games.", + "nl": "CurseForge zorgt voor het uploaden en beoordelen van plugins, add-ons en mods voor verschillende games." + }, + "url": "www.curseforge.com", + "regExp": "([a-z0-9-]+[.])*curseforge[.]com[/]", + "version": "1.2.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CurseForge/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CurseForge/assets/thumbnail.png", + "color": "#f16725", + "category": "games", + "tags": [ + "mods", + "plugins", + "curseforge" + ] +} diff --git a/websites/C/CurseForge/presence.ts b/websites/C/CurseForge/presence.ts index 6b0ce8ab9079..4d8345f1b569 100644 --- a/websites/C/CurseForge/presence.ts +++ b/websites/C/CurseForge/presence.ts @@ -1,308 +1,364 @@ const presence = new Presence({ - clientId: "626536244670889985", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '626536244670889985', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let user: HTMLElement | string | Element, - search: HTMLElement, - title: string | Element | HTMLElement; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/CurseForge/assets/logo.png', + startTimestamp: browsingTimestamp, + } + function setStateGame( + game: string, + categoryURL: string, + categoryText: string, + categoryTextSingle: string, + ): void { + if (document.location.pathname.includes(`/${categoryURL}/`)) { + const title = document.querySelector( + 'body > div.flex.flex-col.min-h-full.min-h-screen > main > div.z-0 > header > div.container.mx-auto.mt-auto.flex.justify-between > div:nth-child(1) > div > div:nth-child(1) > h2', + ) + if (!title) { + const title = document.querySelector( + 'body > div.flex.flex-col.min-h-full.min-h-screen > main > div.z-0 > div > section > div.px-2.flex-1 > div > div.flex.flex-col.mb-4 > h2', + )! + presenceData.details = `${game}, Viewing category:` + presenceData.state = `${categoryText} - ${title.textContent?.replace('All ', '')}` -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/CurseForge/assets/logo.png", - startTimestamp: browsingTimestamp, - }; - function setStateGame( - game: string, - categoryURL: string, - categoryText: string, - categoryTextSingle: string - ): void { - if (document.location.pathname.includes(`/${categoryURL}/`)) { - title = document.querySelector( - "body > div.flex.flex-col.min-h-full.min-h-screen > main > div.z-0 > header > div.container.mx-auto.mt-auto.flex.justify-between > div:nth-child(1) > div > div:nth-child(1) > h2" - ); - if (!title) { - title = document.querySelector( - "body > div.flex.flex-col.min-h-full.min-h-screen > main > div.z-0 > div > section > div.px-2.flex-1 > div > div.flex.flex-col.mb-4 > h2" - ); - presenceData.details = `${game}, Viewing category:`; - presenceData.state = `${categoryText} - ${( - title as HTMLElement - ).textContent.replace("All ", "")}`; + delete presenceData.smallImageKey + } + else { + presenceData.details = `${game}, Viewing ${categoryTextSingle}:` + if (title.textContent!.length > 128) { + presenceData.state = `${title.textContent!.substring( + 0, + 125, + )}...` + } + else { + presenceData.state = title.textContent + } - delete presenceData.smallImageKey; - } else { - presenceData.details = `${game}, Viewing ${categoryTextSingle}:`; - if ((title as HTMLElement).textContent.length > 128) { - presenceData.state = `${(title as HTMLElement).textContent.substring( - 0, - 125 - )}...`; - } else presenceData.state = (title as HTMLElement).textContent; + delete presenceData.smallImageKey + } + } + else if (document.location.pathname.includes(`/${categoryURL}`)) { + presenceData.details = `${game}, Viewing category:` + presenceData.state = categoryText - delete presenceData.smallImageKey; - } - } else if (document.location.pathname.includes(`/${categoryURL}`)) { - presenceData.details = `${game}, Viewing category:`; - presenceData.state = categoryText; + delete presenceData.smallImageKey + } + else { + presenceData.details = `CurseForge - ${game}` + delete presenceData.state - delete presenceData.smallImageKey; - } else { - presenceData.details = `CurseForge - ${game}`; - delete presenceData.state; + delete presenceData.smallImageKey + } + } - delete presenceData.smallImageKey; - } - } + if (document.location.hostname === 'www.curseforge.com') { + if (document.location.pathname.includes('/minecraft/')) { + if (document.location.pathname.includes('/modpacks')) { + setStateGame('MC', 'modpacks', 'Modpacks', 'modpack') + } + else if (document.location.pathname.includes('/bukkit-plugins')) { + setStateGame('MC', 'bukkit-plugins', 'Bukkit plugins', 'Bukkit plugin') + } + else if (document.location.pathname.includes('/customization')) { + setStateGame('MC', 'customization', 'Customizations', 'customization') + } + else if (document.location.pathname.includes('/mc-addons')) { + setStateGame('MC', 'mc-addons', 'Addons', 'addon') + } + else if (document.location.pathname.includes('/mc-mods')) { + setStateGame('MC', 'mc-mods', 'Mods', 'mod') + } + else if (document.location.pathname.includes('/texture-packs')) { + setStateGame('MC', 'texture-packs', 'Texture Packs', 'texturepack') + } + else if (document.location.pathname.includes('/worlds')) { + setStateGame('MC', 'worlds', 'Worlds', 'world') + } + else { + presenceData.details = 'CurseForge - MC' + delete presenceData.state - if (document.location.hostname === "www.curseforge.com") { - if (document.location.pathname.includes("/minecraft/")) { - if (document.location.pathname.includes("/modpacks")) - setStateGame("MC", "modpacks", "Modpacks", "modpack"); - else if (document.location.pathname.includes("/bukkit-plugins")) - setStateGame("MC", "bukkit-plugins", "Bukkit plugins", "Bukkit plugin"); - else if (document.location.pathname.includes("/customization")) - setStateGame("MC", "customization", "Customizations", "customization"); - else if (document.location.pathname.includes("/mc-addons")) - setStateGame("MC", "mc-addons", "Addons", "addon"); - else if (document.location.pathname.includes("/mc-mods")) - setStateGame("MC", "mc-mods", "Mods", "mod"); - else if (document.location.pathname.includes("/texture-packs")) - setStateGame("MC", "texture-packs", "Texture Packs", "texturepack"); - else if (document.location.pathname.includes("/worlds")) - setStateGame("MC", "worlds", "Worlds", "world"); - else { - presenceData.details = "CurseForge - MC"; - delete presenceData.state; + delete presenceData.smallImageKey + } + } + else if (document.location.pathname.includes('/wow/')) { + setStateGame('WoW', 'addons', 'Addons', 'addon') + } + else if (document.location.pathname.includes('/sc2/')) { + setStateGame('SC2', 'assets', 'Assets', 'asset') + } + else if (document.location.pathname.includes('/kerbal/')) { + setStateGame('Kerbal', 'ksp-mods', 'Mods', 'mod') + } + else if (document.location.pathname.includes('/wildstar/')) { + setStateGame('WildStar', 'ws-addons', 'Addons', 'addon') + } + else if (document.location.pathname.includes('/terraria/')) { + if (document.location.pathname.includes('/maps')) { + setStateGame('Terraria', 'maps', 'Maps', 'map') + } + else if (document.location.pathname.includes('/mods')) { + setStateGame('Terraria', 'mods', 'Mods', 'mod') + } + else { + presenceData.details = 'CurseForge - Terraria' + delete presenceData.state - delete presenceData.smallImageKey; - } - } else if (document.location.pathname.includes("/wow/")) - setStateGame("WoW", "addons", "Addons", "addon"); - else if (document.location.pathname.includes("/sc2/")) - setStateGame("SC2", "assets", "Assets", "asset"); - else if (document.location.pathname.includes("/kerbal/")) - setStateGame("Kerbal", "ksp-mods", "Mods", "mod"); - else if (document.location.pathname.includes("/wildstar/")) - setStateGame("WildStar", "ws-addons", "Addons", "addon"); - else if (document.location.pathname.includes("/terraria/")) { - if (document.location.pathname.includes("/maps")) - setStateGame("Terraria", "maps", "Maps", "map"); - else if (document.location.pathname.includes("/mods")) - setStateGame("Terraria", "mods", "Mods", "mod"); - else { - presenceData.details = "CurseForge - Terraria"; - delete presenceData.state; + delete presenceData.smallImageKey + } + } + else if (document.location.pathname.includes('/worldoftanks/')) { + if (document.location.pathname.includes('/wot-mods')) { + setStateGame('WoT', 'wot-mods', 'Mods', 'mod') + } + else if (document.location.pathname.includes('/wot-skins')) { + setStateGame('WoT', 'wot-skins', 'Skins', 'skin') + } + else { + presenceData.details = 'CurseForge - WoT' + delete presenceData.state - delete presenceData.smallImageKey; - } - } else if (document.location.pathname.includes("/worldoftanks/")) { - if (document.location.pathname.includes("/wot-mods")) - setStateGame("WoT", "wot-mods", "Mods", "mod"); - else if (document.location.pathname.includes("/wot-skins")) - setStateGame("WoT", "wot-skins", "Skins", "skin"); - else { - presenceData.details = "CurseForge - WoT"; - delete presenceData.state; + delete presenceData.smallImageKey + } + } + else if (document.location.pathname.includes('/rift/')) { + setStateGame('Rift', 'addons', 'Addons', 'addon') + } + else if (document.location.pathname.includes('/rom/')) { + setStateGame('RoM', 'addons', 'Addons', 'addon') + } + else if (document.location.pathname.includes('/skyrim/')) { + setStateGame('Skyrim', 'mods', 'Mods', 'mod') + } + else if (document.location.pathname.includes('/tsw/')) { + setStateGame('TSW', 'tsw-mods', 'Mods', 'mod') + } + else if (document.location.pathname.includes('/teso/')) { + setStateGame('TESO', 'teso-addons', 'Addons', 'addon') + } + else if (document.location.pathname.includes('/stardewvalley/')) { + setStateGame('Stardew Valley', 'mods', 'Mods', 'mod') + } + else if (document.location.pathname.includes('/swlegends/')) { + setStateGame('SWLegends', 'tswl-mods', 'Mods', 'mod') + } + else if (document.location.pathname.includes('/chronicles-of-arcadia/')) { + setStateGame('Chronicles of Arcadia', 'addons', 'Addons', 'addon') + } + else if (document.location.pathname.includes('/surviving-mars/')) { + setStateGame('Surviving Mars', 'mods', 'Mods', 'mod') + } + else if (document.location.pathname.includes('/darkestdungeon/')) { + setStateGame('Darkest Dungeon', 'dd-mods', 'Mods', 'mod') + } + else if (document.location.pathname.includes('/gta5/')) { + if (document.location.pathname.includes('/gta-v-mods')) { + setStateGame('GTA5', 'gta-v-mods', 'Mods', 'mod') + } + else if (document.location.pathname.includes('/gta-v-tools')) { + setStateGame('GTA5', 'gta-v-tools', 'Tools', 'tool') + } + else { + presenceData.details = 'CurseForge - GTA5' + delete presenceData.state - delete presenceData.smallImageKey; - } - } else if (document.location.pathname.includes("/rift/")) - setStateGame("Rift", "addons", "Addons", "addon"); - else if (document.location.pathname.includes("/rom/")) - setStateGame("RoM", "addons", "Addons", "addon"); - else if (document.location.pathname.includes("/skyrim/")) - setStateGame("Skyrim", "mods", "Mods", "mod"); - else if (document.location.pathname.includes("/tsw/")) - setStateGame("TSW", "tsw-mods", "Mods", "mod"); - else if (document.location.pathname.includes("/teso/")) - setStateGame("TESO", "teso-addons", "Addons", "addon"); - else if (document.location.pathname.includes("/stardewvalley/")) - setStateGame("Stardew Valley", "mods", "Mods", "mod"); - else if (document.location.pathname.includes("/swlegends/")) - setStateGame("SWLegends", "tswl-mods", "Mods", "mod"); - else if (document.location.pathname.includes("/chronicles-of-arcadia/")) - setStateGame("Chronicles of Arcadia", "addons", "Addons", "addon"); - else if (document.location.pathname.includes("/surviving-mars/")) - setStateGame("Surviving Mars", "mods", "Mods", "mod"); - else if (document.location.pathname.includes("/darkestdungeon/")) - setStateGame("Darkest Dungeon", "dd-mods", "Mods", "mod"); - else if (document.location.pathname.includes("/gta5/")) { - if (document.location.pathname.includes("/gta-v-mods")) - setStateGame("GTA5", "gta-v-mods", "Mods", "mod"); - else if (document.location.pathname.includes("/gta-v-tools")) - setStateGame("GTA5", "gta-v-tools", "Tools", "tool"); - else { - presenceData.details = "CurseForge - GTA5"; - delete presenceData.state; + delete presenceData.smallImageKey + } + } + else if (document.location.pathname.includes('/staxel/')) { + setStateGame('Staxel', 'staxel-mods', 'Mods', 'mod') + } + else if (document.location.pathname.includes('/members/')) { + const user = document.querySelector( + 'body > div.flex.flex-col.min-h-full.min-h-screen > main > section > div > div.text-base > div.username.text-xl', + ) + presenceData.details = 'Viewing user:' + presenceData.state = user?.textContent - delete presenceData.smallImageKey; - } - } else if (document.location.pathname.includes("/staxel/")) - setStateGame("Staxel", "staxel-mods", "Mods", "mod"); - else if (document.location.pathname.includes("/members/")) { - user = document.querySelector( - "body > div.flex.flex-col.min-h-full.min-h-screen > main > section > div > div.text-base > div.username.text-xl" - ); - presenceData.details = "Viewing user:"; - presenceData.state = (user as HTMLElement).textContent; + delete presenceData.smallImageKey + } + else if (document.location.pathname.includes('/private-messages')) { + presenceData.details = 'Reading DMs' + delete presenceData.state - delete presenceData.smallImageKey; - } else if (document.location.pathname.includes("/private-messages")) { - presenceData.details = "Reading DMs"; - delete presenceData.state; + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/account')) { + presenceData.details = 'Viewing account settings' + delete presenceData.state - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/account")) { - presenceData.details = "Viewing account settings"; - delete presenceData.state; + delete presenceData.smallImageKey + } + else if (document.location.pathname.includes('/all-games')) { + presenceData.details = 'Viewing all games' + delete presenceData.state - delete presenceData.smallImageKey; - } else if (document.location.pathname.includes("/all-games")) { - presenceData.details = "Viewing all games"; - delete presenceData.state; + delete presenceData.smallImageKey + } + else if (document.location.pathname.includes('/project/')) { + presenceData.details = 'CurseForge - Projects' + delete presenceData.state - delete presenceData.smallImageKey; - } else if (document.location.pathname.includes("/project/")) { - presenceData.details = "CurseForge - Projects"; - delete presenceData.state; + delete presenceData.smallImageKey + } + } + else if ( + document.location.hostname === 'minecraft.curseforge.com' + || document.location.hostname === 'authors.curseforge.com' + ) { + if (document.location.pathname.includes('/forums/')) { + const title = document.querySelector('#content > section > div > header > h2') + if (title) { + presenceData.details = 'Forums, viewing category:' + presenceData.state = title.textContent - delete presenceData.smallImageKey; - } - } else if ( - document.location.hostname === "minecraft.curseforge.com" || - document.location.hostname === "authors.curseforge.com" - ) { - if (document.location.pathname.includes("/forums/")) { - title = document.querySelector("#content > section > div > header > h2"); - if (title) { - presenceData.details = "Forums, viewing category:"; - presenceData.state = (title as HTMLElement).textContent; + delete presenceData.smallImageKey + } + else if ( + document.querySelector('#content > section > div > div > header > h2') + ) { + const title = document.querySelector( + '#content > section > div > div > header > h2', + )! + presenceData.details = 'Forums, reading thread:' + if (title.textContent!.length > 128) { + presenceData.state = `${title.textContent!.substring( + 0, + 125, + )}...` + } + else { + presenceData.state = title.textContent + } - delete presenceData.smallImageKey; - } else if ( - document.querySelector("#content > section > div > div > header > h2") - ) { - title = document.querySelector( - "#content > section > div > div > header > h2" - ); - presenceData.details = "Forums, reading thread:"; - if ((title as HTMLElement).textContent.length > 128) { - presenceData.state = `${(title as HTMLElement).textContent.substring( - 0, - 125 - )}...`; - } else presenceData.state = (title as HTMLElement).textContent; + presenceData.smallImageKey = Assets.Reading + } + else { + presenceData.details = 'Forums, Browsing...' + delete presenceData.state + delete presenceData.smallImageKey + } + } + else if (document.location.pathname.includes('/search')) { + const search = document.querySelector('#field-search') + if (search?.value && search.value.length > 1) { + presenceData.details = 'Forums, Searching for:' + presenceData.state = search.value + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = 'Forums, Going to search' + presenceData.state = 'something up' + presenceData.smallImageKey = Assets.Search + } + } + else if (document.location.pathname.includes('/account')) { + presenceData.details = 'Forums, viewing:' + presenceData.state = 'Account Settings' + delete presenceData.smallImageKey + } + else if (document.location.pathname.includes('/knowledge-base')) { + presenceData.details = 'Forums, viewing:' + presenceData.state = 'Knowledge Base' + delete presenceData.smallImageKey + } + else if (document.location.pathname.includes('/store')) { + presenceData.details = 'Forums, viewing:' + presenceData.state = 'Reward Store' + delete presenceData.smallImageKey + } + else if (document.location.pathname.includes('/dashboard')) { + presenceData.details = 'Forums, viewing:' + presenceData.state = 'Dashboard' + delete presenceData.smallImageKey + } + else if (document.location.pathname.includes('/paste')) { + presenceData.details = 'Forums, viewing:' + presenceData.state = 'Paste' + delete presenceData.smallImageKey + } + else if (document.location.pathname.includes('/members')) { + if (document.URL.includes('filter-user-sort=')) { + const [title] = document.URL.split('filter-user-sort=')[1].split('&') + switch (title) { + case '1': + presenceData.details = 'Forums, Viewing list of' + presenceData.state = 'members in alphabetical order' - presenceData.smallImageKey = Assets.Reading; - } else { - presenceData.details = "Forums, Browsing..."; - delete presenceData.state; - delete presenceData.smallImageKey; - } - } else if (document.location.pathname.includes("/search")) { - search = document.querySelector("#field-search"); - if ((search as HTMLInputElement).value.length > 1) { - presenceData.details = "Forums, Searching for:"; - presenceData.state = (search as HTMLInputElement).value; - presenceData.smallImageKey = Assets.Search; - } else { - presenceData.details = "Forums, Going to search"; - presenceData.state = "something up"; - presenceData.smallImageKey = Assets.Search; - } - } else if (document.location.pathname.includes("/account")) { - presenceData.details = "Forums, viewing:"; - presenceData.state = "Account Settings"; - delete presenceData.smallImageKey; - } else if (document.location.pathname.includes("/knowledge-base")) { - presenceData.details = "Forums, viewing:"; - presenceData.state = "Knowledge Base"; - delete presenceData.smallImageKey; - } else if (document.location.pathname.includes("/store")) { - presenceData.details = "Forums, viewing:"; - presenceData.state = "Reward Store"; - delete presenceData.smallImageKey; - } else if (document.location.pathname.includes("/dashboard")) { - presenceData.details = "Forums, viewing:"; - presenceData.state = "Dashboard"; - delete presenceData.smallImageKey; - } else if (document.location.pathname.includes("/paste")) { - presenceData.details = "Forums, viewing:"; - presenceData.state = "Paste"; - delete presenceData.smallImageKey; - } else if (document.location.pathname.includes("/members")) { - if (document.URL.includes("filter-user-sort=")) { - [title] = document.URL.split("filter-user-sort=")[1].split("&"); - switch (title) { - case "1": - presenceData.details = "Forums, Viewing list of"; - presenceData.state = "members in alphabetical order"; + delete presenceData.smallImageKey + break + case '2': + presenceData.details = 'Forums, Viewing list of' + presenceData.state = 'members with most messages' - delete presenceData.smallImageKey; - break; - case "2": - presenceData.details = "Forums, Viewing list of"; - presenceData.state = "members with most messages"; + delete presenceData.smallImageKey + break + case '3': + presenceData.details = 'Forums, Viewing list of' + presenceData.state = 'members which are online' - delete presenceData.smallImageKey; - break; - case "3": - presenceData.details = "Forums, Viewing list of"; - presenceData.state = "members which are online"; + delete presenceData.smallImageKey + break + case '4': + presenceData.details = 'Forums, Viewing the list' + presenceData.state = 'members sorted by newest' - delete presenceData.smallImageKey; - break; - case "4": - presenceData.details = "Forums, Viewing the list"; - presenceData.state = "members sorted by newest"; + delete presenceData.smallImageKey + break + case '5': + presenceData.details = 'Forums, Viewing the list' + presenceData.state = 'members sorted by oldest' - delete presenceData.smallImageKey; - break; - case "5": - presenceData.details = "Forums, Viewing the list"; - presenceData.state = "members sorted by oldest"; + delete presenceData.smallImageKey + break + } + } + else if ( + document.querySelector( + '#content > section > section > div.p-user-info > ul.p-user-details > li.username', + ) !== null + ) { + const user = document.querySelector( + '#content > section > section > div.p-user-info > ul.p-user-details > li.username', + )! + presenceData.details = 'Forums, Viewing user:' + presenceData.state = user.textContent - delete presenceData.smallImageKey; - break; - } - } else if ( - document.querySelector( - "#content > section > section > div.p-user-info > ul.p-user-details > li.username" - ) !== null - ) { - user = document.querySelector( - "#content > section > section > div.p-user-info > ul.p-user-details > li.username" - ); - presenceData.details = "Forums, Viewing user:"; - presenceData.state = (user as HTMLElement).textContent; + delete presenceData.smallImageKey + } + else { + presenceData.details = 'Forums, Viewing list of' + presenceData.state = 'members which are online' - delete presenceData.smallImageKey; - } else { - presenceData.details = "Forums, Viewing list of"; - presenceData.state = "members which are online"; + delete presenceData.smallImageKey + } + } + else { + presenceData.details = 'Forums, Browsing...' + delete presenceData.state - delete presenceData.smallImageKey; - } - } else { - presenceData.details = "Forums, Browsing..."; - delete presenceData.state; + delete presenceData.smallImageKey + } + } + else if ( + document.querySelector( + '#content > section > div.featured-site-info-container > div > h2', + ) !== null + ) { + const title = document.querySelector( + '#content > section > div.featured-site-info-container > div > h2', + )! + presenceData.details = 'Viewing game:' + presenceData.state = title.textContent - delete presenceData.smallImageKey; - } - } else if ( - document.querySelector( - "#content > section > div.featured-site-info-container > div > h2" - ) !== null - ) { - title = document.querySelector( - "#content > section > div.featured-site-info-container > div > h2" - ); - presenceData.details = "Viewing game:"; - presenceData.state = (title as HTMLElement).textContent; - - delete presenceData.smallImageKey; - } else presence.setActivity(); -}); + delete presenceData.smallImageKey + } + else { + presence.setActivity() + } +}) diff --git a/websites/C/Curve Fever Pro/metadata.json b/websites/C/Curve Fever Pro/metadata.json index 5c8cd1ce52fe..2951bc537a18 100644 --- a/websites/C/Curve Fever Pro/metadata.json +++ b/websites/C/Curve Fever Pro/metadata.json @@ -1,22 +1,22 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Robin", - "id": "284370397535666188" - }, - "service": "Curve Fever Pro", - "description": { - "en": "The smash hit Curve Fever is back with a new multiplayer browser game: Curve Fever Pro. Cut off opponents, squeeze through tiny holes and unlock new powers.", - "nl": "De grote hit Curve Fever is terug met een nieuw multiplayer browsergame: Curve Fever Pro. Snijd tegenstanders af, wurm door kleine gaatjes en ontgrendel nieuwe krachten." - }, - "url": "curvefever.pro", - "version": "1.0.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/thumbnail.png", - "color": "#1f3559", - "category": "games", - "tags": [ - "curvefever" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Robin", + "id": "284370397535666188" + }, + "service": "Curve Fever Pro", + "description": { + "en": "The smash hit Curve Fever is back with a new multiplayer browser game: Curve Fever Pro. Cut off opponents, squeeze through tiny holes and unlock new powers.", + "nl": "De grote hit Curve Fever is terug met een nieuw multiplayer browsergame: Curve Fever Pro. Snijd tegenstanders af, wurm door kleine gaatjes en ontgrendel nieuwe krachten." + }, + "url": "curvefever.pro", + "version": "1.0.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/thumbnail.png", + "color": "#1f3559", + "category": "games", + "tags": [ + "curvefever" + ] +} diff --git a/websites/C/Curve Fever Pro/presence.ts b/websites/C/Curve Fever Pro/presence.ts index d3b24994b40a..d9c911ce1dbc 100644 --- a/websites/C/Curve Fever Pro/presence.ts +++ b/websites/C/Curve Fever Pro/presence.ts @@ -1,205 +1,213 @@ const presence = new Presence({ - clientId: "775356824240128021", -}); + clientId: '775356824240128021', +}) const enum Assets { - Index = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/0.png", - Angel = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/1.png", - BlueRacer = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/2.png", - CandyCane = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/3.png", - BumbleBee = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/4.png", - Joker = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/5.png", - JackoLantern = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/6.png", - Poopy = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/7.png", - JungleLeaf = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/8.png", - OChristmasTree = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/9.png", - Robot = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/10.png", - Vampire = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/11.png", - RedYellow = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/12.png", - TheMummy = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/13.png", - ThinkPink = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/14.png", - WitchyCauldron = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/15.png", - VipGold = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/16.png", - ZombieHand = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/17.png", - SpiderCurve = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/18.png", - Starfish = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/19.png", - IceCream = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/20.png", - Rasta = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/21.png", - Pineapple = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/22.png", - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/logo.png", + Index = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/0.png', + Angel = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/1.png', + BlueRacer = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/2.png', + CandyCane = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/3.png', + BumbleBee = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/4.png', + Joker = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/5.png', + JackoLantern = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/6.png', + Poopy = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/7.png', + JungleLeaf = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/8.png', + OChristmasTree = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/9.png', + Robot = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/10.png', + Vampire = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/11.png', + RedYellow = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/12.png', + TheMummy = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/13.png', + ThinkPink = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/14.png', + WitchyCauldron = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/15.png', + VipGold = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/16.png', + ZombieHand = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/17.png', + SpiderCurve = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/18.png', + Starfish = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/19.png', + IceCream = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/20.png', + Rasta = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/21.png', + Pineapple = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/22.png', + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/Curve%20Fever%20Pro/assets/logo.png', } const skinNames = new Map() - .set("Angel", Assets.Angel) - .set("Blue Racer", Assets.BlueRacer) - .set("Bumble Bee", Assets.BumbleBee) - .set("Candy Cane", Assets.CandyCane) - .set("Jack-o'-lantern", Assets.JackoLantern) - .set("Joker", Assets.Joker) - .set("Jungle Leaf", Assets.JungleLeaf) - .set("O Christmas Tree", Assets.OChristmasTree) - .set("Poopy", Assets.Poopy) - .set("Red&Yellow", Assets.RedYellow) - .set("Robot", Assets.Robot) - .set("Spider Curve", Assets.SpiderCurve) - .set("Starfish", Assets.Starfish) - .set("The Mummy", Assets.TheMummy) - .set("Think Pink", Assets.ThinkPink) - .set("Vampire", Assets.Vampire) - .set("VIP Gold", Assets.VipGold) - .set("Witchy Cauldron", Assets.WitchyCauldron) - .set("Zombie Hand", Assets.ZombieHand) - .set("Ice-Cream", Assets.IceCream) - .set("Pineapple", Assets.Pineapple) - .set("Rasta", Assets.Rasta); - -let lastlobbyName = "", - lastName = "Unnamed"; + .set('Angel', Assets.Angel) + .set('Blue Racer', Assets.BlueRacer) + .set('Bumble Bee', Assets.BumbleBee) + .set('Candy Cane', Assets.CandyCane) + .set('Jack-o\'-lantern', Assets.JackoLantern) + .set('Joker', Assets.Joker) + .set('Jungle Leaf', Assets.JungleLeaf) + .set('O Christmas Tree', Assets.OChristmasTree) + .set('Poopy', Assets.Poopy) + .set('Red&Yellow', Assets.RedYellow) + .set('Robot', Assets.Robot) + .set('Spider Curve', Assets.SpiderCurve) + .set('Starfish', Assets.Starfish) + .set('The Mummy', Assets.TheMummy) + .set('Think Pink', Assets.ThinkPink) + .set('Vampire', Assets.Vampire) + .set('VIP Gold', Assets.VipGold) + .set('Witchy Cauldron', Assets.WitchyCauldron) + .set('Zombie Hand', Assets.ZombieHand) + .set('Ice-Cream', Assets.IceCream) + .set('Pineapple', Assets.Pineapple) + .set('Rasta', Assets.Rasta) + +let lastlobbyName = '' +let lastName = 'Unnamed' const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: Date.now(), - details: "Main Menu", - state: "Just Started Playing", -}; + largeImageKey: Assets.Logo, + startTimestamp: Date.now(), + details: 'Main Menu', + state: 'Just Started Playing', +} -presence.on("UpdateData", async () => { - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) function RefreshData() { - const statePage = getActualGamePage(); - switch (statePage) { - case "in_lobby_picking_powers": { - const [skinSlot] = document.querySelectorAll(".skin-slot.skin-slot--0"), - [groupTitle] = document.querySelectorAll(".group-name__title"), - skinName = skinSlot - ? skinSlot.children[0].getAttribute("title") - : "skin_unknown", - lobbyName = groupTitle ? groupTitle.textContent : "Unknown lobby"; - - presenceData.details = "Picking Powers"; - presenceData.state = `In Lobby, ${lobbyName} (${ - document.querySelectorAll(".c-user.c-user--small").length - }/6)`; - - if (skinNames.has(skinName)) { - presenceData.smallImageKey = skinNames.get(skinName); - presenceData.smallImageText = `Playing as ${skinName}`; - } - - lastlobbyName = lobbyName; - - break; - } - case "in_lobby_ready": { - const [groupTitle] = document.querySelectorAll(".group-name__title"), - userRows = document.querySelectorAll(".group-players-list__row"), - lobbyName = groupTitle ? groupTitle.textContent : "Unknown lobby"; - let playerCount = 0; - for (const userRow of userRows) { - if (!userRow.className.includes("group-players-list__row--empty")) - playerCount++; - } - - presenceData.details = "Ready In Lobby"; - presenceData.state = `${lobbyName} (${playerCount}/6)`; - lastlobbyName = lobbyName; - - break; - } - case "in_game": { - presenceData.details = "Playing"; - presenceData.state = lastlobbyName; - - break; - } - case "in_game_finished": { - presenceData.details = "Checking Match Results"; - presenceData.state = lastlobbyName; - - break; - } - default: { - const [nickElement] = document.querySelectorAll(".c-user__name"); - lastName = nickElement ? nickElement.textContent : "Unnamed"; - presenceData.state = lastName; - } - } - - switch (statePage) { - case "in_menu": { - presenceData.details = "Main Menu"; - break; - } - case "browsing_lobbies": { - presenceData.details = "Browsing Lobbies"; - break; - } - case "in_shop": { - presenceData.details = "In Shop"; - break; - } - case "in_leaderboard": { - presenceData.details = "In Leaderboards"; - break; - } - case "in_locker": { - presenceData.details = "In Locker"; - break; - } - case "in_battlepass": { - presenceData.details = "In Battlepass"; - break; - } - case "in_progress": { - presenceData.details = "Checking XP Progress"; - break; - } - case "opening_crates": { - presenceData.details = "Opening Crates"; - break; - } - case "creating_match": - { - presenceData.details = "Creating Match"; - // No default - } - break; - } - - presenceData.largeImageKey = Assets.Index; + const statePage = getActualGamePage() + switch (statePage) { + case 'in_lobby_picking_powers': { + const [skinSlot] = document.querySelectorAll('.skin-slot.skin-slot--0') + const [groupTitle] = document.querySelectorAll('.group-name__title') + const skinName = skinSlot + ? skinSlot.children[0].getAttribute('title')! + : 'skin_unknown' + const lobbyName = groupTitle ? groupTitle.textContent! : 'Unknown lobby' + + presenceData.details = 'Picking Powers' + presenceData.state = `In Lobby, ${lobbyName} (${ + document.querySelectorAll('.c-user.c-user--small').length + }/6)` + + if (skinNames.has(skinName)) { + presenceData.smallImageKey = skinNames.get(skinName) + presenceData.smallImageText = `Playing as ${skinName}` + } + + lastlobbyName = lobbyName + + break + } + case 'in_lobby_ready': { + const [groupTitle] = document.querySelectorAll('.group-name__title') + const userRows = document.querySelectorAll('.group-players-list__row') + const lobbyName = groupTitle ? groupTitle.textContent! : 'Unknown lobby' + let playerCount = 0 + for (const userRow of userRows) { + if (!userRow.className.includes('group-players-list__row--empty')) + playerCount++ + } + + presenceData.details = 'Ready In Lobby' + presenceData.state = `${lobbyName} (${playerCount}/6)` + lastlobbyName = lobbyName + + break + } + case 'in_game': { + presenceData.details = 'Playing' + presenceData.state = lastlobbyName + + break + } + case 'in_game_finished': { + presenceData.details = 'Checking Match Results' + presenceData.state = lastlobbyName + + break + } + default: { + const [nickElement] = document.querySelectorAll('.c-user__name') + lastName = nickElement ? nickElement.textContent! : 'Unnamed' + presenceData.state = lastName + } + } + + switch (statePage) { + case 'in_menu': { + presenceData.details = 'Main Menu' + break + } + case 'browsing_lobbies': { + presenceData.details = 'Browsing Lobbies' + break + } + case 'in_shop': { + presenceData.details = 'In Shop' + break + } + case 'in_leaderboard': { + presenceData.details = 'In Leaderboards' + break + } + case 'in_locker': { + presenceData.details = 'In Locker' + break + } + case 'in_battlepass': { + presenceData.details = 'In Battlepass' + break + } + case 'in_progress': { + presenceData.details = 'Checking XP Progress' + break + } + case 'opening_crates': { + presenceData.details = 'Opening Crates' + break + } + case 'creating_match': { + presenceData.details = 'Creating Match' + break + } + } + + presenceData.largeImageKey = Assets.Index } function getActualGamePage() { - if (document.querySelectorAll(".game-overlay")[0]) return "in_game"; - else if (document.querySelectorAll(".post-game-rewards__title")[0]) - return "in_game_finished"; - else if (document.querySelectorAll(".popup-header")[0]) { - switch (document.querySelectorAll(".popup-header")[0].textContent) { - case "Room settings": - return "creating_match"; - case "Crates": - return "opening_crates"; - case "XP progression": - return "in_progress"; - case "Battlepass": - return "in_battlepass"; - case "Locker": - return "in_locker"; - case "Leaderboard": - return "in_leaderboard"; - case "Shop": - return "in_shop"; - // No default - } - } else if (document.querySelectorAll(".menu.side-menu")[0]) return "in_menu"; - else if (document.querySelectorAll(".lobby")[0]) return "browsing_lobbies"; - else if (document.querySelectorAll(".module-inventory-top")[0]) - return "in_lobby_picking_powers"; - else if (document.querySelectorAll(".group-ready-state__title")[0]) - return "in_lobby_ready"; - - return "in_menu"; + if (document.querySelectorAll('.game-overlay')[0]) { + return 'in_game' + } + else if (document.querySelectorAll('.post-game-rewards__title')[0]) { + return 'in_game_finished' + } + else if (document.querySelectorAll('.popup-header')[0]) { + switch (document.querySelectorAll('.popup-header')[0].textContent) { + case 'Room settings': + return 'creating_match' + case 'Crates': + return 'opening_crates' + case 'XP progression': + return 'in_progress' + case 'Battlepass': + return 'in_battlepass' + case 'Locker': + return 'in_locker' + case 'Leaderboard': + return 'in_leaderboard' + case 'Shop': + return 'in_shop' + } + } + else if (document.querySelectorAll('.menu.side-menu')[0]) { + return 'in_menu' + } + else if (document.querySelectorAll('.lobby')[0]) { + return 'browsing_lobbies' + } + else if (document.querySelectorAll('.module-inventory-top')[0]) { + return 'in_lobby_picking_powers' + } + else if (document.querySelectorAll('.group-ready-state__title')[0]) { + return 'in_lobby_ready' + } + + return 'in_menu' } -setInterval(RefreshData, 1000); +setInterval(RefreshData, 1000) diff --git a/websites/C/Custom Status/metadata.json b/websites/C/Custom Status/metadata.json index bfda174f4360..e0d73050f21d 100644 --- a/websites/C/Custom Status/metadata.json +++ b/websites/C/Custom Status/metadata.json @@ -1,33 +1,33 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "EGGSY", - "id": "162969778699501569" - }, - "service": "Custom Status", - "description": { - "en": "Custom Status is a way to set custom statuses using PreMiD. You can customize everything except the name. You have to visit [this page](https://eggsy.xyz/projects/premid/custom-status) to start using it!", - "tr": "Custom Status, Discord’un kendi özelliği gibi isteğinize göre ayarlanabilen bir oynuyor kısmıdır. Bu servis ile PreMiD kullanarak bir RPC ile yapabileceğiniz her şeyi yapabilirsiniz. Servisin çalışması için servisi ekleyip, [buradaki](https://eggsy.xyz/projects/premid/custom-status) adrese gitmelisiniz.", - "nl": "Custom Status staat je toe aangepaste statussen weer te geven met PreMiD. Je kunt alles aanpassen behalve de naam. Bezoek [deze pagina](https://eggsy.xyz/projects/premid/custom-status) om te beginnen!", - "vi_VN": "Custom Status là một cách để bạn đặt trạng thái tuỳ chọn qua PreMiD. Bạn có thể tuỳ chỉnh tất cả mọi thứ. Bạn phải vào [đường dẫn này](https://eggsy.xyz/projects/premid/custom-status) để bắt đầu sử dụng!", - "es": "Custom Status es la manera de establecer un estado personalizado usando PreMiD. Puedes personalizar todo excepto el nombre. ¡Tienes que visitar [esta página](https://eggsy.xyz/projects/premid/custom-status) para empezar a usarlo!.", - "es_419": "Custom Status es la forma de ponerte un estado personalizado usando PreMiD. Puedes personalizar todo menos el nombre. ¡Tienes que ir a [esta página](https://eggsy.xyz/projects/premid/custom-status) para poder usarlo!" - }, - "url": [ - "eggsy.xyz", - "eggsy-tailwind.netlify.app" - ], - "regExp": "(new[.]eggsy[.]xyz|eggsy[.]xyz|eggsy-tailwind[.]netlify[.]app)[/]projects[/]premid[/]custom-status", - "version": "1.3.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Custom%20Status/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Custom%20Status/assets/thumbnail.jpg", - "color": "#6c82cf", - "category": "other", - "tags": [ - "eggsy", - "premid", - "custom", - "status" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "EGGSY", + "id": "162969778699501569" + }, + "service": "Custom Status", + "description": { + "en": "Custom Status is a way to set custom statuses using PreMiD. You can customize everything except the name. You have to visit [this page](https://eggsy.xyz/projects/premid/custom-status) to start using it!", + "tr": "Custom Status, Discord’un kendi özelliği gibi isteğinize göre ayarlanabilen bir oynuyor kısmıdır. Bu servis ile PreMiD kullanarak bir RPC ile yapabileceğiniz her şeyi yapabilirsiniz. Servisin çalışması için servisi ekleyip, [buradaki](https://eggsy.xyz/projects/premid/custom-status) adrese gitmelisiniz.", + "nl": "Custom Status staat je toe aangepaste statussen weer te geven met PreMiD. Je kunt alles aanpassen behalve de naam. Bezoek [deze pagina](https://eggsy.xyz/projects/premid/custom-status) om te beginnen!", + "vi_VN": "Custom Status là một cách để bạn đặt trạng thái tuỳ chọn qua PreMiD. Bạn có thể tuỳ chỉnh tất cả mọi thứ. Bạn phải vào [đường dẫn này](https://eggsy.xyz/projects/premid/custom-status) để bắt đầu sử dụng!", + "es": "Custom Status es la manera de establecer un estado personalizado usando PreMiD. Puedes personalizar todo excepto el nombre. ¡Tienes que visitar [esta página](https://eggsy.xyz/projects/premid/custom-status) para empezar a usarlo!.", + "es_419": "Custom Status es la forma de ponerte un estado personalizado usando PreMiD. Puedes personalizar todo menos el nombre. ¡Tienes que ir a [esta página](https://eggsy.xyz/projects/premid/custom-status) para poder usarlo!" + }, + "url": [ + "eggsy.xyz", + "eggsy-tailwind.netlify.app" + ], + "regExp": "(new[.]eggsy[.]xyz|eggsy[.]xyz|eggsy-tailwind[.]netlify[.]app)[/]projects[/]premid[/]custom-status", + "version": "1.3.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Custom%20Status/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Custom%20Status/assets/thumbnail.jpg", + "color": "#6c82cf", + "category": "other", + "tags": [ + "eggsy", + "premid", + "custom", + "status" + ] +} diff --git a/websites/C/Custom Status/presence.ts b/websites/C/Custom Status/presence.ts index 7f4351416b20..53d6aab1adb8 100644 --- a/websites/C/Custom Status/presence.ts +++ b/websites/C/Custom Status/presence.ts @@ -1,20 +1,23 @@ const presence = new Presence({ - clientId: "673651706139246612", -}); + clientId: '673651706139246612', +}) -presence.on("UpdateData", () => { - if ( - document.querySelector("#__nuxt")?.classList?.contains("presence") === false - ) - document.querySelector("#__nuxt").classList.add("presence"); +presence.on('UpdateData', () => { + if ( + document.querySelector('#__nuxt')?.classList?.contains('presence') === false + ) + document.querySelector('#__nuxt')?.classList.add('presence') - const objectElement = document.querySelector("#object"); + const objectElement = document.querySelector('#object') - if ( - Object.keys(JSON.parse(objectElement?.textContent || "{}")).length > 0 && - JSON.parse(objectElement.textContent).details && - JSON.parse(objectElement.textContent).largeImageKey - ) - presence.setActivity(JSON.parse(objectElement.textContent)); - else presence.setActivity(); -}); + if ( + Object.keys(JSON.parse(objectElement?.textContent ?? '{}')).length > 0 + && JSON.parse(objectElement?.textContent ?? '{}').details + && JSON.parse(objectElement?.textContent ?? '{}').largeImageKey + ) { + presence.setActivity(JSON.parse(objectElement?.textContent ?? '{}')) + } + else { + presence.setActivity() + } +}) diff --git a/websites/C/CyTube/iframe.ts b/websites/C/CyTube/iframe.ts index 3fe10ca3a9cc..67f963aa7b8c 100644 --- a/websites/C/CyTube/iframe.ts +++ b/websites/C/CyTube/iframe.ts @@ -1,27 +1,27 @@ -const iframe = new iFrame(); +const iframe = new iFrame() let sendback: { - audio: boolean; - currentTime: number; - duration: number; - paused: boolean; - site: string; -}; + audio: boolean + currentTime: number + duration: number + paused: boolean + site: string +} function send(): void { - iframe.send(sendback); + iframe.send(sendback) } -iframe.on("UpdateData", () => { - if (document.querySelectorAll("video").length !== 0) { - const [video] = document.querySelectorAll("video"); - sendback = { - audio: false, - currentTime: video.currentTime, - duration: video.duration, - paused: video.paused, - site: document.location.href, - }; - } - send(); -}); +iframe.on('UpdateData', () => { + if (document.querySelectorAll('video').length !== 0) { + const [video] = document.querySelectorAll('video') + sendback = { + audio: false, + currentTime: video.currentTime, + duration: video.duration, + paused: video.paused, + site: document.location.href, + } + } + send() +}) diff --git a/websites/C/CyTube/metadata.json b/websites/C/CyTube/metadata.json index 79f55871b577..880d963da4f8 100644 --- a/websites/C/CyTube/metadata.json +++ b/websites/C/CyTube/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "MulverineX", - "id": "178551656714076161" - }, - "service": "CyTube", - "description": { - "en": "Content Sharing Platform with wide platform support of simultaneously enjoying videos/music with a live chat and tons of customization/moderation tools", - "nl": "Content Sharing Platform met brede platformondersteuning om tegelijkertijd te genieten van video's/muziek met een live chat en tal van aanpassingstools/moderatietools" - }, - "url": "cytu.be", - "version": "1.1.32", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/thumbnail.png", - "color": "#263144", - "category": "videos", - "tags": [ - "video", - "music", - "media" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "MulverineX", + "id": "178551656714076161" + }, + "service": "CyTube", + "description": { + "en": "Content Sharing Platform with wide platform support of simultaneously enjoying videos/music with a live chat and tons of customization/moderation tools", + "nl": "Content Sharing Platform met brede platformondersteuning om tegelijkertijd te genieten van video's/muziek met een live chat en tal van aanpassingstools/moderatietools" + }, + "url": "cytu.be", + "version": "1.1.32", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/thumbnail.png", + "color": "#263144", + "category": "videos", + "tags": [ + "video", + "music", + "media" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git a/websites/C/CyTube/presence.ts b/websites/C/CyTube/presence.ts index 0d1f0e301c36..7d3352c2ef40 100644 --- a/websites/C/CyTube/presence.ts +++ b/websites/C/CyTube/presence.ts @@ -1,187 +1,200 @@ const presence = new Presence({ - clientId: "653639828826750976", // Contact if you want me to edit the discord assets/keys/whatever - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }); + clientId: '653639828826750976', // Contact if you want me to edit the discord assets/keys/whatever +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) function getTimes(time: number): Record { - let seconds = Math.round(time), - minutes = Math.floor(seconds / 60); + let seconds = Math.round(time) + let minutes = Math.floor(seconds / 60) - seconds -= minutes * 60; + seconds -= minutes * 60 - const hours = Math.floor(minutes / 60); + const hours = Math.floor(minutes / 60) - minutes -= hours * 60; + minutes -= hours * 60 - return { - sec: seconds, - min: minutes, - hrs: hours, - }; + return { + sec: seconds, + min: minutes, + hrs: hours, + } } function lessTen(digit: number): string { - return digit < 10 ? "0" : ""; + return digit < 10 ? '0' : '' } function getTimestamp(time: number): string { - const { sec, min, hrs } = getTimes(time); + const { sec, min, hrs } = getTimes(time) - return hrs > 0 - ? `${hrs}:${lessTen(min)}${min}:${lessTen(sec)}${sec}` - : `${min}:${lessTen(sec)}${sec}`; + return hrs > 0 + ? `${hrs}:${lessTen(min)}${min}:${lessTen(sec)}${sec}` + : `${min}:${lessTen(sec)}${sec}` } interface Match { - display: string; - imageKey: string; + display: string + imageKey: string } interface MatchList { - [key: string]: Match; + [key: string]: Match } const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/logo.png", - ServiceYT = "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/0.png", - ServiceGD = "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/1.png", - ServiceDBX = "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/2.png", - ServiceAWS = "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/3.png", - ServiceDC = "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/4.png", - ServiceGC = "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/5.png", - ServiceUK = "https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/6.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/logo.png', + ServiceYT = 'https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/0.png', + ServiceGD = 'https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/1.png', + ServiceDBX = 'https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/2.png', + ServiceAWS = 'https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/3.png', + ServiceDC = 'https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/4.png', + ServiceGC = 'https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/5.png', + ServiceUK = 'https://cdn.rcd.gg/PreMiD/websites/C/CyTube/assets/6.png', } const matches: MatchList = { - youtube: { display: "YouTube", imageKey: Assets.ServiceYT }, - googlevideo: { display: "YouTube", imageKey: Assets.ServiceYT }, + 'youtube': { display: 'YouTube', imageKey: Assets.ServiceYT }, + 'googlevideo': { display: 'YouTube', imageKey: Assets.ServiceYT }, - "docs.google": { display: "Google Drive", imageKey: Assets.ServiceGD }, - googleusercontent: { - display: "Google Drive", - imageKey: Assets.ServiceGD, - }, + 'docs.google': { display: 'Google Drive', imageKey: Assets.ServiceGD }, + 'googleusercontent': { + display: 'Google Drive', + imageKey: Assets.ServiceGD, + }, - appspot: { display: "Google Cloud", imageKey: Assets.ServiceGC }, - blogspot: { display: "Google Cloud", imageKey: Assets.ServiceGC }, + 'appspot': { display: 'Google Cloud', imageKey: Assets.ServiceGC }, + 'blogspot': { display: 'Google Cloud', imageKey: Assets.ServiceGC }, - dropbox: { display: "Dropbox", imageKey: Assets.ServiceDBX }, + 'dropbox': { display: 'Dropbox', imageKey: Assets.ServiceDBX }, - amazonaws: { display: "Amazon AWS", imageKey: Assets.ServiceAWS }, + 'amazonaws': { display: 'Amazon AWS', imageKey: Assets.ServiceAWS }, - soundcloud: { display: "Soundcloud", imageKey: Assets.Question }, // asset not found + 'soundcloud': { display: 'Soundcloud', imageKey: Assets.Question }, // asset not found - discordapp: { display: "Discord", imageKey: Assets.ServiceDC }, + 'discordapp': { display: 'Discord', imageKey: Assets.ServiceDC }, - "vimeo-prod-": { display: "Vimeo", imageKey: Assets.Question }, // asset not found -}; + 'vimeo-prod-': { display: 'Vimeo', imageKey: Assets.Question }, // asset not found +} function service(service: string): Match { - let returnMatch: Match = { - display: "Unknown Service", - imageKey: Assets.ServiceUK, - }; + let returnMatch: Match = { + display: 'Unknown Service', + imageKey: Assets.ServiceUK, + } + + for (const key of Object.keys(matches)) + service.includes(key) && (returnMatch = matches[key]) - for (const key of Object.keys(matches)) - service.includes(key) && (returnMatch = matches[key]); + return returnMatch +} - return returnMatch; +interface VideoData { + audio: boolean + paused: boolean + duration: number + currentTime: number + site: string } -class VideoData { - audio = false; - paused = true; - duration = 0; - currentTime = 0; - site: string; +let iFrameResponse: VideoData = { + audio: false, + paused: true, + duration: 0, + currentTime: 0, + site: '', } -let iFrameResponse = new VideoData(); - -presence.on("iFrameData", (data: VideoData) => { - iFrameResponse = data; -}); - -presence.on("UpdateData", async () => { - const path = document.location.pathname, - presenceData: PresenceData = { - largeImageKey: Assets.Logo, - details: "loading", - state: "CyTube", - }, - translate = { - pause: (await strings).pause, - play: (await strings).play, - }; - - async function setVideo(data: VideoData) { - const currentService: Match = service(data.site); - - presenceData.details = `Watching ${document - .querySelector("#currenttitle") - .textContent.replace("Currently Playing:", "")} - - ${currentService.display}`; - - presenceData.largeImageKey = currentService.imageKey; - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - Math.floor(data.currentTime), - Math.floor(data.duration) - ); - - if (data.paused) { - presenceData.startTimestamp = null; - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = `${translate.pause} - ${getTimestamp( - data.currentTime - )}`; - } else { - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = translate.play; - } - } - - if (path.includes("/r/")) { - presenceData.state = `${document.querySelector("#motd").textContent} - /r/${ - path.split("r/")[0] - }`; - if ( - document.body.className.includes("chatOnly") || - !document.querySelector("#videowrap") - ) { - presenceData.details = "Chatting"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } else if (!document.querySelector("#videowrap").querySelector("video")) { - presenceData.details = "Waiting to Start"; - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Waiting"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - - if (iFrameResponse?.site) setVideo(iFrameResponse); - } else { - const video = document.querySelector("#videowrap").querySelector("video"); - - setVideo({ - audio: false, - currentTime: video.currentTime, - duration: video.duration, - paused: video.paused, - site: video.src, - }); - } - } else if (path === "/") { - presenceData.details = "On Homepage"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } else if (path.includes("/account/")) { - presenceData.details = "Managing Account"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } else if (path === "/contact") { - presenceData.details = "Contacting Support"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } - presence.setActivity(presenceData, true); -}); +presence.on('iFrameData', (data: unknown) => { + iFrameResponse = data as VideoData +}) + +presence.on('UpdateData', async () => { + const path = document.location.pathname + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + details: 'loading', + state: 'CyTube', + } + const translate = { + pause: (await strings).pause, + play: (await strings).play, + } + + async function setVideo(data: VideoData) { + const currentService: Match = service(data.site) + + presenceData.details = `Watching ${document + .querySelector('#currenttitle') + ?.textContent + ?.replace('Currently Playing:', '')} + - ${currentService.display}` + + presenceData.largeImageKey = currentService.imageKey; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + Math.floor(data.currentTime), + Math.floor(data.duration), + ) + + if (data.paused) { + presenceData.startTimestamp = null + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = `${translate.pause} - ${getTimestamp( + data.currentTime, + )}` + } + else { + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = translate.play + } + } + + if (path.includes('/r/')) { + presenceData.state = `${document.querySelector('#motd')?.textContent} - /r/${ + path.split('r/')[0] + }` + if ( + document.body.className.includes('chatOnly') + || !document.querySelector('#videowrap') + ) { + presenceData.details = 'Chatting' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } + else if (!document.querySelector('#videowrap')?.querySelector('video')) { + presenceData.details = 'Waiting to Start' + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Waiting' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + + if (iFrameResponse?.site) + setVideo(iFrameResponse) + } + else { + const video = document.querySelector('#videowrap')!.querySelector('video')! + + setVideo({ + audio: false, + currentTime: video.currentTime, + duration: video.duration, + paused: video.paused, + site: video.src, + }) + } + } + else if (path === '/') { + presenceData.details = 'On Homepage' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } + else if (path.includes('/account/')) { + presenceData.details = 'Managing Account' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } + else if (path === '/contact') { + presenceData.details = 'Contacting Support' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } + presence.setActivity(presenceData, true) +}) diff --git a/websites/C/Cytoid/metadata.json b/websites/C/Cytoid/metadata.json index 977f8cd5d27d..09762722fecc 100644 --- a/websites/C/Cytoid/metadata.json +++ b/websites/C/Cytoid/metadata.json @@ -1,44 +1,44 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "joerkig", - "id": "205984221859151873" - }, - "service": "Cytoid", - "description": { - "en": "Cytoid is a music game where you can create, share and play your own levels! Powered by community, with many dedicated creators, Cytoid provides a huge variety of musical genres to enjoy and a diverse range of gameplay design." - }, - "url": "cytoid.io", - "version": "2.0.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cytoid/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cytoid/assets/thumbnail.png", - "color": "#476ADC", - "category": "games", - "tags": [ - "rhythm", - "music", - "gaming", - "touch" - ], - "settings": [ - { - "id": "timestamps", - "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": "joerkig", + "id": "205984221859151873" + }, + "service": "Cytoid", + "description": { + "en": "Cytoid is a music game where you can create, share and play your own levels! Powered by community, with many dedicated creators, Cytoid provides a huge variety of musical genres to enjoy and a diverse range of gameplay design." + }, + "url": "cytoid.io", + "version": "2.0.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/Cytoid/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/Cytoid/assets/thumbnail.png", + "color": "#476ADC", + "category": "games", + "tags": [ + "rhythm", + "music", + "gaming", + "touch" + ], + "settings": [ + { + "id": "timestamps", + "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/C/Cytoid/presence.ts b/websites/C/Cytoid/presence.ts index 69769205aa5c..d68842410ee3 100644 --- a/websites/C/Cytoid/presence.ts +++ b/websites/C/Cytoid/presence.ts @@ -1,155 +1,153 @@ -const presence = new Presence({ - clientId: "939893108827635712", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); +const presence = new Presence({ + clientId: '939893108827635712', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const [timestamps, buttons, cover] = await Promise.all([ - presence.getSetting("timestamps"), - presence.getSetting("buttons"), - presence.getSetting("cover"), - ]), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/Cytoid/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const [timestamps, buttons, cover] = await Promise.all([ + presence.getSetting('timestamps'), + presence.getSetting('buttons'), + presence.getSetting('cover'), + ]) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/Cytoid/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (document.location.pathname === "/") - presenceData.details = "Viewing Homepage"; - if (document.location.pathname.startsWith("/levels")) { - if (document.location.pathname === "/levels") { - presenceData.details = "Browsing Levels"; - presenceData.state = `${ - document.querySelector("div.dropdown > div.btn")?.textContent - } ${ - new URL(document.location.href).searchParams.get("order") === "asc" - ? "↑" - : "↓" - }`; - const previewedCard = document.querySelector( - ".btn-ghost > div.radial-progress" - )?.parentElement.parentElement.parentElement.parentElement.parentElement; - if (previewedCard) { - presenceData.details = - previewedCard.querySelector(".card-title").textContent; - presenceData.state = - previewedCard.querySelector( - ".card-title" - ).nextElementSibling.textContent; - presenceData.largeImageKey = previewedCard - .querySelector(".base-card-bg") - .style.backgroundImage.slice(5, -2); - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Playing Preview"; - presenceData.buttons = [ - { - label: "View Level", - url: previewedCard.parentElement as HTMLAnchorElement, - }, - ]; - } - } else { - presenceData.details = - document.querySelector("#contentTitle > h1").textContent; - presenceData.state = - document.querySelector("#contentTitle > p").textContent; - presenceData.largeImageKey = document.querySelector( - "head > meta[property='og:image']" - ).content; - presenceData.buttons = [ - { - label: "View Level", - url: document.location.href, - }, - { - label: "View Uploader", - url: document.querySelector(".card-body > a").href, - }, - ]; - } - } - if (document.location.pathname.startsWith("/collections")) { - if (document.location.pathname === "/collections") - presenceData.details = "Browsing Collections"; - else { - presenceData.details = "Viewing Collection"; - presenceData.state = - document.querySelector("#contentTitle > h1").textContent; - presenceData.largeImageKey = document.querySelector( - "head > meta[property='og:image']" - ).content; - presenceData.buttons = [ - { - label: "View Collection", - url: document.location.href, - }, - { - label: "View Uploader", - url: document.querySelector(".card-body > a").href, - }, - ]; - } - } - if (document.location.pathname.startsWith("/posts")) { - if (document.location.pathname === "/posts") - presenceData.details = "Browsing Posts"; - else { - presenceData.details = "Viewing Post"; - presenceData.state = - document.querySelector("#contentTitle > h1").textContent; - presenceData.buttons = [ - { - label: "View Post", - url: document.location.href, - }, - ]; - } - } - if (document.location.pathname.startsWith("/profile")) { - presenceData.details = "Viewing Profile"; - presenceData.state = document.querySelector("p.card-title").textContent; - presenceData.largeImageKey = - document.querySelector("#contentTitle img").src; - presenceData.buttons = [ - { - label: "View Profile", - url: document.location.href, - }, - ]; - } - if (document.location.pathname.startsWith("/studio")) { - presenceData.details = "Viewing Studio"; - presenceData.state = document.querySelector( - "#StudioMenu .active" - ).textContent; - } - if (document.location.pathname.startsWith("/settings")) { - presenceData.details = "Viewing Settings"; - presenceData.state = document.querySelector( - "#StudioMenu .active" - ).textContent; - } - if (document.location.pathname === "/library") - presenceData.details = "Viewing Library"; - if (document.location.pathname.startsWith("/pages/")) { - presenceData.details = `Viewing ${ - document.querySelector("h1").textContent - }`; - } - if (document.location.pathname === "/credits") - presenceData.details = "Viewing Credits"; + if (document.location.pathname === '/') + presenceData.details = 'Viewing Homepage' + if (document.location.pathname.startsWith('/levels')) { + if (document.location.pathname === '/levels') { + presenceData.details = 'Browsing Levels' + presenceData.state = `${ + document.querySelector('div.dropdown > div.btn')?.textContent + } ${ + new URL(document.location.href).searchParams.get('order') === 'asc' + ? '↑' + : '↓' + }` + const previewedCard = document.querySelector( + '.btn-ghost > div.radial-progress', + )?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement + if (previewedCard) { + presenceData.details = previewedCard.querySelector('.card-title')?.textContent + presenceData.state = previewedCard.querySelector( + '.card-title', + )?.nextElementSibling?.textContent + presenceData.largeImageKey = previewedCard + .querySelector('.base-card-bg') + ?.style + .backgroundImage + .slice(5, -2) + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Playing Preview' + presenceData.buttons = [ + { + label: 'View Level', + url: previewedCard.parentElement as HTMLAnchorElement, + }, + ] + } + } + else { + presenceData.details = document.querySelector('#contentTitle > h1')?.textContent + presenceData.state = document.querySelector('#contentTitle > p')?.textContent + presenceData.largeImageKey = document.querySelector( + 'head > meta[property=\'og:image\']', + )?.content + presenceData.buttons = [ + { + label: 'View Level', + url: document.location.href, + }, + { + label: 'View Uploader', + url: document.querySelector('.card-body > a')!.href, + }, + ] + } + } + if (document.location.pathname.startsWith('/collections')) { + if (document.location.pathname === '/collections') { + presenceData.details = 'Browsing Collections' + } + else { + presenceData.details = 'Viewing Collection' + presenceData.state = document.querySelector('#contentTitle > h1')?.textContent + presenceData.largeImageKey = document.querySelector( + 'head > meta[property=\'og:image\']', + )?.content + presenceData.buttons = [ + { + label: 'View Collection', + url: document.location.href, + }, + { + label: 'View Uploader', + url: document.querySelector('.card-body > a')!.href, + }, + ] + } + } + if (document.location.pathname.startsWith('/posts')) { + if (document.location.pathname === '/posts') { + presenceData.details = 'Browsing Posts' + } + else { + presenceData.details = 'Viewing Post' + presenceData.state = document.querySelector('#contentTitle > h1')?.textContent + presenceData.buttons = [ + { + label: 'View Post', + url: document.location.href, + }, + ] + } + } + if (document.location.pathname.startsWith('/profile')) { + presenceData.details = 'Viewing Profile' + presenceData.state = document.querySelector('p.card-title')?.textContent + presenceData.largeImageKey = document.querySelector( + '#contentTitle img', + )?.src + presenceData.buttons = [ + { + label: 'View Profile', + url: document.location.href, + }, + ] + } + if (document.location.pathname.startsWith('/studio')) { + presenceData.details = 'Viewing Studio' + presenceData.state = document.querySelector('#StudioMenu .active')?.textContent + } + if (document.location.pathname.startsWith('/settings')) { + presenceData.details = 'Viewing Settings' + presenceData.state = document.querySelector( + '#StudioMenu .active', + )?.textContent + } + if (document.location.pathname === '/library') + presenceData.details = 'Viewing Library' + if (document.location.pathname.startsWith('/pages/')) { + presenceData.details = `Viewing ${ + document.querySelector('h1')?.textContent + }` + } + if (document.location.pathname === '/credits') + presenceData.details = 'Viewing Credits' - if (!timestamps) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - if (!cover) { - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/C/Cytoid/assets/logo.png"; - } - if (!buttons && presenceData.buttons) delete presenceData.buttons; + if (!timestamps) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + if (!cover) { + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/C/Cytoid/assets/logo.png' + } + if (!buttons && presenceData.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/C/cda.pl/metadata.json b/websites/C/cda.pl/metadata.json index 8fc04340ebcb..2ab7962e35db 100644 --- a/websites/C/cda.pl/metadata.json +++ b/websites/C/cda.pl/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "xKubson_", - "id": "404217213873029120" - }, - "service": "cda.pl", - "description": { - "en": "The largest independent VOD service in Poland. Offering high quality films and series.", - "pl": "Największy niezależny serwis VOD w Polsce. Oferuje wysokiej jakości filmy i seriale.", - "nl": "De grootste onafhankelijke VOD-service in Polen. Het aanbieden van films en series van hoge kwaliteit.", - "vi_VN": "Dịch vụ cung cấp VOD độc lập lớn nhất Phần Lan. Cung cấp phim và sê-ri chất lượng cao." - }, - "url": "www.cda.pl", - "version": "2.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/C/cda.pl/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/cda.pl/assets/thumbnail.png", - "color": "#B22907", - "category": "videos", - "tags": [ - "video", - "movies", - "vod" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "xKubson_", + "id": "404217213873029120" + }, + "service": "cda.pl", + "description": { + "en": "The largest independent VOD service in Poland. Offering high quality films and series.", + "pl": "Największy niezależny serwis VOD w Polsce. Oferuje wysokiej jakości filmy i seriale.", + "nl": "De grootste onafhankelijke VOD-service in Polen. Het aanbieden van films en series van hoge kwaliteit.", + "vi_VN": "Dịch vụ cung cấp VOD độc lập lớn nhất Phần Lan. Cung cấp phim và sê-ri chất lượng cao." + }, + "url": "www.cda.pl", + "version": "2.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/C/cda.pl/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/C/cda.pl/assets/thumbnail.png", + "color": "#B22907", + "category": "videos", + "tags": [ + "video", + "movies", + "vod" + ] +} diff --git a/websites/C/cda.pl/presence.ts b/websites/C/cda.pl/presence.ts index 1600475ca1fa..e4615181702b 100644 --- a/websites/C/cda.pl/presence.ts +++ b/websites/C/cda.pl/presence.ts @@ -1,111 +1,124 @@ const presence = new Presence({ - clientId: "979472267044069477", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - getTimestamps = (videoTime: number, videoDuration: number): number[] => { - return [ - Math.floor(Date.now() / 1000), - Math.floor(Date.now() / 1000) - videoTime + videoDuration, - ]; - }; + clientId: '979472267044069477', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +function getTimestamps(videoTime: number, videoDuration: number): number[] { + return [ + Math.floor(Date.now() / 1000), + Math.floor(Date.now() / 1000) - videoTime + videoDuration, + ] +} -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/C/cda.pl/assets/logo.jpg", - startTimestamp: browsingTimestamp, - }, - pathname = document.location.pathname.toLowerCase(); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/C/cda.pl/assets/logo.jpg', + startTimestamp: browsingTimestamp, + } + const pathname = document.location.pathname.toLowerCase() - if (pathname === "/") presenceData.details = "Przegląda stronę główną"; - else if (pathname.endsWith("/ustawienia")) - presenceData.details = "Przegląda ustawienia"; - else if (pathname.endsWith("/poczta")) - presenceData.details = "Przegląda pocztę"; - else if (pathname.endsWith("/premium")) - presenceData.details = "Przegląda filmy CDA Premium"; - else if (pathname.endsWith("/powiazanekonta")) - presenceData.details = "Przegląda powiązane konta"; - else if (pathname.endsWith("/historia")) - presenceData.details = "Przegląda historię oglądania"; - else if (pathname.endsWith("/obejrzyj-pozniej")) - presenceData.details = 'Przegląda "Obejrzyj później"'; - else if (pathname.includes("/tv")) { - if (pathname === "/tv") - presenceData.details = "Przegląda kanały telewizyjne"; - else { - presenceData.details = `Ogląda TV: ${ - document.querySelector( - "#gora > div.tv-one-canal-list > div.tv-canal-title > span.tv-program-title" - ).textContent - }`; - presenceData.state = `Teraz: ${ - document.querySelector( - "#gora > div.tv-one-canal-list > div.tv-guide-well.tv-f > div.tv-list-pr.tv-list-pr-actual > span > span.tvm-b.relative > div.tvpr-title-header > h2" - ).textContent - }`; - } - } else if (pathname.includes("/video")) { - if (pathname === "/video") - presenceData.details = "Przegląda stronę główną wideo"; - else presenceData.state = `Kategoria: ${pathname.split("/")[2]}`; + if (pathname === '/') { + presenceData.details = 'Przegląda stronę główną' + } + else if (pathname.endsWith('/ustawienia')) { + presenceData.details = 'Przegląda ustawienia' + } + else if (pathname.endsWith('/poczta')) { + presenceData.details = 'Przegląda pocztę' + } + else if (pathname.endsWith('/premium')) { + presenceData.details = 'Przegląda filmy CDA Premium' + } + else if (pathname.endsWith('/powiazanekonta')) { + presenceData.details = 'Przegląda powiązane konta' + } + else if (pathname.endsWith('/historia')) { + presenceData.details = 'Przegląda historię oglądania' + } + else if (pathname.endsWith('/obejrzyj-pozniej')) { + presenceData.details = 'Przegląda "Obejrzyj później"' + } + else if (pathname.includes('/tv')) { + if (pathname === '/tv') { + presenceData.details = 'Przegląda kanały telewizyjne' + } + else { + presenceData.details = `Ogląda TV: ${ + document.querySelector( + '#gora > div.tv-one-canal-list > div.tv-canal-title > span.tv-program-title', + )?.textContent + }` + presenceData.state = `Teraz: ${ + document.querySelector( + '#gora > div.tv-one-canal-list > div.tv-guide-well.tv-f > div.tv-list-pr.tv-list-pr-actual > span > span.tvm-b.relative > div.tvpr-title-header > h2', + )?.textContent + }` + } + } + else if (pathname.includes('/video')) { + if (pathname === '/video') + presenceData.details = 'Przegląda stronę główną wideo' + else presenceData.state = `Kategoria: ${pathname.split('/')[2]}` - if (document.querySelector("#naglowek > span > span > h1")) { - delete presenceData.startTimestamp; - presenceData.details = document.querySelector( - "#naglowek > span > span > h1" - ).textContent; - presenceData.state = `Przesłał: ${ - document.querySelector( - "#leftCol > div:nth-child(2) > div.DescrVID > div.DescrVID-left > div > div > div > div:nth-child(1) > a > span > span" - ).textContent - }`; - presenceData.buttons = [ - { label: "Obejrzyj film", url: document.location.href }, - ]; + if (document.querySelector('#naglowek > span > span > h1')) { + delete presenceData.startTimestamp + presenceData.details = document.querySelector( + '#naglowek > span > span > h1', + )?.textContent + presenceData.state = `Przesłał: ${ + document.querySelector( + '#leftCol > div:nth-child(2) > div.DescrVID > div.DescrVID-left > div > div > div > div:nth-child(1) > a > span > span', + )?.textContent + }` + presenceData.buttons = [ + { label: 'Obejrzyj film', url: document.location.href }, + ] - const video: HTMLVideoElement = document.querySelector("video"); - [presenceData.startTimestamp, presenceData.endTimestamp] = getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ); - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } - } else if (pathname.includes("/info")) { - presenceData.details = "Szuka:"; - presenceData.state = pathname.split("/")[2].replace("_", " "); - } else if ( - pathname.split("/")[2] && - document.querySelector( - "#placeholder-foldery > div:nth-child(1) > div.panel-heading.smoke" - ).textContent === "Foldery " - ) { - presenceData.details = `Przegląda folder od ${ - document.location.pathname.split("/")[1] - }`; - presenceData.state = document.querySelector( - "#folder-replace > div.panel-heading.smoke > span > span > a" - ).textContent; - presenceData.buttons = [ - { label: "Przejdź do folderu", url: document.location.href }, - ]; - } else if ( - document.querySelector( - "#gora > div:nth-child(2) > div > div > div > div > div > h4 > span > strong > a" - ) - ) { - presenceData.details = "Przegląda profil"; - presenceData.state = document.querySelector( - "#gora > div:nth-child(2) > div > div > div > div > div > h4 > span > strong > a" - ).textContent; - presenceData.buttons = [ - { label: "Zobacz profil", url: document.location.href }, - ]; - } + const video = document.querySelector('video')!; + [presenceData.startTimestamp, presenceData.endTimestamp] = getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + } + else if (pathname.includes('/info')) { + presenceData.details = 'Szuka:' + presenceData.state = pathname.split('/')[2].replace('_', ' ') + } + else if ( + pathname.split('/')[2] + && document.querySelector( + '#placeholder-foldery > div:nth-child(1) > div.panel-heading.smoke', + )?.textContent === 'Foldery ' + ) { + presenceData.details = `Przegląda folder od ${ + document.location.pathname.split('/')[1] + }` + presenceData.state = document.querySelector( + '#folder-replace > div.panel-heading.smoke > span > span > a', + )?.textContent + presenceData.buttons = [ + { label: 'Przejdź do folderu', url: document.location.href }, + ] + } + else if ( + document.querySelector( + '#gora > div:nth-child(2) > div > div > div > div > div > h4 > span > strong > a', + ) + ) { + presenceData.details = 'Przegląda profil' + presenceData.state = document.querySelector( + '#gora > div:nth-child(2) > div > div > div > div > div > h4 > span > strong > a', + )?.textContent + presenceData.buttons = [ + { label: 'Zobacz profil', url: document.location.href }, + ] + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +})