diff --git a/websites/P/PCGamingWiki/metadata.json b/websites/P/PCGamingWiki/metadata.json index 266902ba706f..c319c18d5dec 100644 --- a/websites/P/PCGamingWiki/metadata.json +++ b/websites/P/PCGamingWiki/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "354233941550694400", - "name": "kuriel." - }, - "service": "PCGamingWiki", - "description": { - "en": "PCGamingWiki aims to list fixes and workarounds for every single PC game. " - }, - "url": [ - "www.pcgamingwiki.com", - "pcgamingwiki.com", - "community.pcgamingwiki.com" - ], - "version": "1.0.1", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PCGamingWiki/assets/logo.jpeg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PCGamingWiki/assets/thumbnail.png", - "color": "#556db3", - "category": "other", - "tags": [ - "wiki", - "information", - "pc", - "gaming" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "354233941550694400", + "name": "kuriel." + }, + "service": "PCGamingWiki", + "description": { + "en": "PCGamingWiki aims to list fixes and workarounds for every single PC game. " + }, + "url": [ + "www.pcgamingwiki.com", + "pcgamingwiki.com", + "community.pcgamingwiki.com" + ], + "version": "1.0.1", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PCGamingWiki/assets/logo.jpeg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PCGamingWiki/assets/thumbnail.png", + "color": "#556db3", + "category": "other", + "tags": [ + "wiki", + "information", + "pc", + "gaming" + ] +} diff --git a/websites/P/PCGamingWiki/presence.ts b/websites/P/PCGamingWiki/presence.ts index 7cc9b32e64cc..686c91ff1f31 100644 --- a/websites/P/PCGamingWiki/presence.ts +++ b/websites/P/PCGamingWiki/presence.ts @@ -1,143 +1,153 @@ const presence = new Presence({ - clientId: "1325499066565656647", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1325499066565656647', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/PCGamingWiki/assets/0.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/PCGamingWiki/assets/0.png', } -presence.on("UpdateData", async () => { - const { pathname, search, href, hostname } = document.location, - presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - details: "Viewing Page:", - }; +presence.on('UpdateData', async () => { + const { pathname, search, href, hostname } = document.location + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + details: 'Viewing Page:', + } - switch (hostname) { - case "community.pcgamingwiki.com": { - switch (pathname.split("/")[1]) { - case "topic": { - presenceData.details = "On Topic:"; - presenceData.state = document.querySelector( - "span.ipsType_break > span:nth-child(1)" - ); - presenceData.buttons = [{ label: "View Topic", url: href }]; - break; - } - case "forum": { - presenceData.details = "On Forum:"; - presenceData.state = document.querySelector(".ipsType_pageTitle"); - presenceData.buttons = [{ label: "View Forum", url: href }]; - break; - } - case "profile": { - presenceData.details = "Viewing Profile:"; - presenceData.state = document.querySelector("h1.ipsType_reset"); - break; - } - case "staff": { - presenceData.details = "On Staff page"; - break; - } - case "leaderboard": - case "pastleaders": - case "topmembers": { - presenceData.details = "On Leaderboard page"; - break; - } - case "gallery": { - if (pathname.split("/")[2] === "image") { - presenceData.details = "Viewing Image:"; - presenceData.state = document.querySelector("span.ipsContained"); - presenceData.buttons = [{ label: "View Image", url: href }]; - } else presenceData.details = "On Gallery page"; - break; - } - case "online": { - presenceData.details = "Viewing Online Users"; - break; - } - case "files": { - if (pathname.split("/")[2] === "file") { - presenceData.details = "Viewing File:"; - presenceData.state = document.querySelector( - "h1.ipsType_pageTitle > span:nth-child(1)" - ); - presenceData.buttons = [{ label: "View File", url: href }]; - } else presenceData.details = "Viewing Files page"; - break; - } - case "tags": { - presenceData.details = "Searching for tag:"; - presenceData.state = decodeURIComponent(pathname.split("/")[2]); - break; - } - case "search": { - presenceData.details = "On Search Page"; - if (search.split("=")[1]) { - presenceData.details = "Searching the Community for:"; - presenceData.state = decodeURIComponent( - search.split("=")[1] - ).replace("&search_and_or", ""); - } - break; - } - case "discover": { - presenceData.details = "Viewing All Activity"; - break; - } - default: { - presenceData.details = "Exploring Community"; - break; - } - } - break; - } - default: { - switch (pathname.split("/")[2]) { - case "Home": { - presenceData.details = "In Home"; - break; - } - case "PCGamingWiki:About": { - presenceData.state = "About Us"; - break; - } - case "index.php": { - if (decodeURIComponent(search.split("=")[2]) === "edit") { - presenceData.details = "Viewing Source of:"; - presenceData.state = document - .querySelector(".article-title") - ?.textContent?.trim() - .replace("View source for ", ""); - } - if (decodeURIComponent(search.split("=")[2]) === "history") { - presenceData.details = "Viewing revision history of:"; - presenceData.state = document - .querySelector(".article-title") - ?.textContent?.trim() - .replace("Revision history of ", "") - .slice(1, -1); - } else { - presenceData.details = "Searching for:"; - presenceData.state = decodeURIComponent( - search.split("=")[1] - ).replace("&title", ""); - } - break; - } - default: { - presenceData.state = document - .querySelector(".article-title") - ?.textContent?.trim(); - break; - } - } - break; - } - } + switch (hostname) { + case 'community.pcgamingwiki.com': { + switch (pathname.split('/')[1]) { + case 'topic': { + presenceData.details = 'On Topic:' + presenceData.state = document.querySelector( + 'span.ipsType_break > span:nth-child(1)', + ) + presenceData.buttons = [{ label: 'View Topic', url: href }] + break + } + case 'forum': { + presenceData.details = 'On Forum:' + presenceData.state = document.querySelector('.ipsType_pageTitle') + presenceData.buttons = [{ label: 'View Forum', url: href }] + break + } + case 'profile': { + presenceData.details = 'Viewing Profile:' + presenceData.state = document.querySelector('h1.ipsType_reset') + break + } + case 'staff': { + presenceData.details = 'On Staff page' + break + } + case 'leaderboard': + case 'pastleaders': + case 'topmembers': { + presenceData.details = 'On Leaderboard page' + break + } + case 'gallery': { + if (pathname.split('/')[2] === 'image') { + presenceData.details = 'Viewing Image:' + presenceData.state = document.querySelector('span.ipsContained') + presenceData.buttons = [{ label: 'View Image', url: href }] + } + else { + presenceData.details = 'On Gallery page' + } + break + } + case 'online': { + presenceData.details = 'Viewing Online Users' + break + } + case 'files': { + if (pathname.split('/')[2] === 'file') { + presenceData.details = 'Viewing File:' + presenceData.state = document.querySelector( + 'h1.ipsType_pageTitle > span:nth-child(1)', + ) + presenceData.buttons = [{ label: 'View File', url: href }] + } + else { + presenceData.details = 'Viewing Files page' + } + break + } + case 'tags': { + presenceData.details = 'Searching for tag:' + presenceData.state = decodeURIComponent(pathname.split('/')[2]) + break + } + case 'search': { + presenceData.details = 'On Search Page' + if (search.split('=')[1]) { + presenceData.details = 'Searching the Community for:' + presenceData.state = decodeURIComponent( + search.split('=')[1], + ).replace('&search_and_or', '') + } + break + } + case 'discover': { + presenceData.details = 'Viewing All Activity' + break + } + default: { + presenceData.details = 'Exploring Community' + break + } + } + break + } + default: { + switch (pathname.split('/')[2]) { + case 'Home': { + presenceData.details = 'In Home' + break + } + case 'PCGamingWiki:About': { + presenceData.state = 'About Us' + break + } + case 'index.php': { + if (decodeURIComponent(search.split('=')[2]) === 'edit') { + presenceData.details = 'Viewing Source of:' + presenceData.state = document + .querySelector('.article-title') + ?.textContent + ?.trim() + .replace('View source for ', '') + } + if (decodeURIComponent(search.split('=')[2]) === 'history') { + presenceData.details = 'Viewing revision history of:' + presenceData.state = document + .querySelector('.article-title') + ?.textContent + ?.trim() + .replace('Revision history of ', '') + .slice(1, -1) + } + else { + presenceData.details = 'Searching for:' + presenceData.state = decodeURIComponent( + search.split('=')[1], + ).replace('&title', '') + } + break + } + default: { + presenceData.state = document + .querySelector('.article-title') + ?.textContent + ?.trim() + break + } + } + break + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/PERPHeads/metadata.json b/websites/P/PERPHeads/metadata.json index 81e034193198..2e6fefbf9c3f 100644 --- a/websites/P/PERPHeads/metadata.json +++ b/websites/P/PERPHeads/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Jackelele", - "id": "377175513372033024" - }, - "service": "PERPHeads", - "description": { - "en": "An awesome Garry's Mod community", - "nl": "Een geweldige Garry's Mod-community" - }, - "url": "perpheads.com", - "regExp": "([a-z0-9-]+[.])*perpheads[.]com[/]", - "version": "1.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PERPHeads/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PERPHeads/assets/thumbnail.png", - "color": "#FFA500", - "category": "games", - "tags": [ - "garrysmod", - "perpheads" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Jackelele", + "id": "377175513372033024" + }, + "service": "PERPHeads", + "description": { + "en": "An awesome Garry's Mod community", + "nl": "Een geweldige Garry's Mod-community" + }, + "url": "perpheads.com", + "regExp": "([a-z0-9-]+[.])*perpheads[.]com[/]", + "version": "1.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PERPHeads/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PERPHeads/assets/thumbnail.png", + "color": "#FFA500", + "category": "games", + "tags": [ + "garrysmod", + "perpheads" + ] +} diff --git a/websites/P/PERPHeads/presence.ts b/websites/P/PERPHeads/presence.ts index 6ac4ce7463a8..7583c9dd7b82 100644 --- a/websites/P/PERPHeads/presence.ts +++ b/websites/P/PERPHeads/presence.ts @@ -1,163 +1,166 @@ const presence = new Presence({ - clientId: "798312419260104705", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); - -let user: HTMLElement, search: HTMLElement, title: HTMLElement; - -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PERPHeads/assets/logo.png", - startTimestamp: browsingTimestamp, - }; - if (document.location.hostname === "perpheads.com") { - title = document.querySelector( - "div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1" - ); - } - if (document.location.pathname.includes("/threads/")) { - title = document.querySelector( - "div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1" - ); - if (title) { - title = document.querySelector( - "div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1" - ); - presenceData.state = title.textContent; - presenceData.details = "Forums, viewing thread:"; - - delete presenceData.smallImageKey; - presence.setActivity(presenceData); - } else { - presenceData.details = "Forums, Browsing..."; - delete presenceData.state; - delete presenceData.smallImageKey; - presence.setActivity(presenceData); - } - } else if (document.location.pathname.includes("/forums/")) { - title = document.querySelector( - "div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1" - ); - if (title) { - title = document.querySelector( - "div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1" - ); - presenceData.state = title.textContent; - presenceData.details = "Forums, viewing category:"; - - delete presenceData.smallImageKey; - presence.setActivity(presenceData); - } else { - presenceData.details = "Forums, Browsing..."; - delete presenceData.state; - delete presenceData.smallImageKey; - presence.setActivity(presenceData); - } - } else if ( - document.location.pathname.includes("/whats-new/") && - document.location.pathname.includes("/profile-posts/") - ) { - presenceData.details = "Forums, viewing the list of"; - presenceData.state = "latest profile posts"; - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if ( - document.location.pathname.includes("/whats-new/") && - document.location.pathname.includes("/posts/") - ) { - presenceData.details = "Forums, viewing the list of"; - presenceData.state = "latest posts"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/search/")) { - search = document.querySelector( - "div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1 > a > em" - ); - if (search) { - presenceData.details = "Forums, searching for:"; - presenceData.state = search.textContent; - - presenceData.smallImageKey = Assets.Search; - - presence.setActivity(presenceData); - } - } else if (document.location.pathname.includes("/members/")) { - user = document.querySelector( - "div.p-body-content > div.block > div.block-container > div.block-body > div.memberHeader > div.memberProfileBanner > div.memberHeader-mainContent > div.memberHeader-content > h1 > span > span > span > span" - ); - presenceData.details = "Forums, viewing user:"; - presenceData.state = user.textContent; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/account/")) { - presenceData.details = "Forums, account settings"; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if (document.location.pathname.includes("/watched/")) { - if (document.location.pathname.includes("/threads")) { - presenceData.details = "Forums, Viewing their"; - presenceData.state = "watched threads"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else { - presenceData.details = "Forums, Viewing their"; - presenceData.state = "watched forums"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } - } else if (document.location.pathname.includes("/conversations/")) { - if ( - document.querySelector( - "div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1" - ) - ) { - title = document.querySelector( - "div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1" - ); - presenceData.state = title.textContent; - presenceData.details = "Forums, Reading a DM"; - presenceData.state = `${title}...`; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else { - presenceData.details = "Forums, Browsing"; - presenceData.state = "through DMs"; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } - } else if (document.location.hostname === "help.perpheads.com") { - presenceData.details = "PERPHeads Help"; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else if ( - document.location.pathname.includes("/pages/") && - document.location.pathname.includes("/donate/") - ) { - presenceData.details = "PERPHeads Donate"; - delete presenceData.state; - - delete presenceData.smallImageKey; - - presence.setActivity(presenceData); - } else presence.setActivity(); -}); + clientId: '798312419260104705', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PERPHeads/assets/logo.png', + startTimestamp: browsingTimestamp, + } + if (document.location.pathname.includes('/threads/')) { + const title = document.querySelector( + 'div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1', + ) + if (title) { + presenceData.state = title.textContent + presenceData.details = 'Forums, viewing thread:' + + delete presenceData.smallImageKey + presence.setActivity(presenceData) + } + else { + presenceData.details = 'Forums, Browsing...' + delete presenceData.state + delete presenceData.smallImageKey + presence.setActivity(presenceData) + } + } + else if (document.location.pathname.includes('/forums/')) { + const title = document.querySelector( + 'div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1', + ) + if (title) { + presenceData.state = title.textContent + presenceData.details = 'Forums, viewing category:' + + delete presenceData.smallImageKey + presence.setActivity(presenceData) + } + else { + presenceData.details = 'Forums, Browsing...' + delete presenceData.state + delete presenceData.smallImageKey + presence.setActivity(presenceData) + } + } + else if ( + document.location.pathname.includes('/whats-new/') + && document.location.pathname.includes('/profile-posts/') + ) { + presenceData.details = 'Forums, viewing the list of' + presenceData.state = 'latest profile posts' + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if ( + document.location.pathname.includes('/whats-new/') + && document.location.pathname.includes('/posts/') + ) { + presenceData.details = 'Forums, viewing the list of' + presenceData.state = 'latest posts' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/search/')) { + const search = document.querySelector( + 'div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1 > a > em', + ) + if (search) { + presenceData.details = 'Forums, searching for:' + presenceData.state = search.textContent + + presenceData.smallImageKey = Assets.Search + + presence.setActivity(presenceData) + } + } + else if (document.location.pathname.includes('/members/')) { + const user = document.querySelector( + 'div.p-body-content > div.block > div.block-container > div.block-body > div.memberHeader > div.memberProfileBanner > div.memberHeader-mainContent > div.memberHeader-content > h1 > span > span > span > span', + ) + presenceData.details = 'Forums, viewing user:' + presenceData.state = user?.textContent + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/account/')) { + presenceData.details = 'Forums, account settings' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if (document.location.pathname.includes('/watched/')) { + if (document.location.pathname.includes('/threads')) { + presenceData.details = 'Forums, Viewing their' + presenceData.state = 'watched threads' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else { + presenceData.details = 'Forums, Viewing their' + presenceData.state = 'watched forums' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + } + else if (document.location.pathname.includes('/conversations/')) { + if ( + document.querySelector( + 'div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1', + ) + ) { + const title = document.querySelector( + 'div.p-body > div.p-body-inner > div.p-body-header > div.p-title > h1', + ) + presenceData.state = title?.textContent + presenceData.details = 'Forums, Reading a DM' + presenceData.state = `${title}...` + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else { + presenceData.details = 'Forums, Browsing' + presenceData.state = 'through DMs' + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + } + else if (document.location.hostname === 'help.perpheads.com') { + presenceData.details = 'PERPHeads Help' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else if ( + document.location.pathname.includes('/pages/') + && document.location.pathname.includes('/donate/') + ) { + presenceData.details = 'PERPHeads Donate' + delete presenceData.state + + delete presenceData.smallImageKey + + presence.setActivity(presenceData) + } + else { + presence.setActivity() + } +}) diff --git a/websites/P/PHP.net/metadata.json b/websites/P/PHP.net/metadata.json index bf3848e5b5b0..2241693c1fe7 100644 --- a/websites/P/PHP.net/metadata.json +++ b/websites/P/PHP.net/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "iLazlow", - "id": "132835232289259520" - }, - "service": "PHP.net", - "description": { - "en": "PHP is a popular general-purpose scripting language that is especially suited to web development. Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world." - }, - "url": [ - "php.net", - "www.php.net" - ], - "version": "1.0.12", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PHP.net/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PHP.net/assets/thumbnail.png", - "color": "#8892BF", - "category": "other", - "tags": [ - "development", - "programming", - "documentation" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "iLazlow", + "id": "132835232289259520" + }, + "service": "PHP.net", + "description": { + "en": "PHP is a popular general-purpose scripting language that is especially suited to web development. Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world." + }, + "url": [ + "php.net", + "www.php.net" + ], + "version": "1.0.12", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PHP.net/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PHP.net/assets/thumbnail.png", + "color": "#8892BF", + "category": "other", + "tags": [ + "development", + "programming", + "documentation" + ] +} diff --git a/websites/P/PHP.net/presence.ts b/websites/P/PHP.net/presence.ts index e999b7733835..bb96d4e0064c 100644 --- a/websites/P/PHP.net/presence.ts +++ b/websites/P/PHP.net/presence.ts @@ -1,69 +1,75 @@ const presence = new Presence({ - clientId: "952575137180442626", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '952575137180442626', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PHP.net/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - route = document.location.pathname.split("/"); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PHP.net/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const route = document.location.pathname.split('/') - switch (route[1]) { - case "": - presenceData.details = "Browsing the main page..."; - break; - case "downloads": - case "downloads.php": - presenceData.details = "Browsing the download section"; - break; - case "docs.php": - presenceData.details = "Browsing the documentation"; - break; - case "download-docs.php": - presenceData.details = "Downloading the documentation"; - break; - case "download-logos.php": - presenceData.details = "Viewing the official logos"; - break; - case "manual-lookup.php": - presenceData.details = "Searching the documentation"; - break; - case "manual": { - presenceData.details = "Viewing the documentation: "; - const manualTitle = document.title - .replaceAll("PHP: ", "") - .replaceAll(" - Manual", ""); - presenceData.buttons = [ - { label: "Open Documentation", url: document.location.href }, - ]; - if (route[3].includes("function.")) { - presenceData.state = `Function: ${manualTitle}`; - presenceData.buttons = [ - { label: "View Function", url: document.location.href }, - ]; - } else if (route[3].includes("language.")) { - const c = route[3].split(".")[1]; - presenceData.state = `${ - c.charAt(0).toUpperCase() + c.slice(1) - }: ${manualTitle}`; - } else presenceData.state = manualTitle; - break; - } - case "releases": - if (route[2]) { - presenceData.details = "Viewing an release version:"; - presenceData.state = `PHP v${route[2]}`; - } else presenceData.details = "Viewing the releases"; - break; - default: - presenceData.details = "Browsing the website"; - } + switch (route[1]) { + case '': + presenceData.details = 'Browsing the main page...' + break + case 'downloads': + case 'downloads.php': + presenceData.details = 'Browsing the download section' + break + case 'docs.php': + presenceData.details = 'Browsing the documentation' + break + case 'download-docs.php': + presenceData.details = 'Downloading the documentation' + break + case 'download-logos.php': + presenceData.details = 'Viewing the official logos' + break + case 'manual-lookup.php': + presenceData.details = 'Searching the documentation' + break + case 'manual': { + presenceData.details = 'Viewing the documentation: ' + const manualTitle = document.title + .replaceAll('PHP: ', '') + .replaceAll(' - Manual', '') + presenceData.buttons = [ + { label: 'Open Documentation', url: document.location.href }, + ] + if (route[3].includes('function.')) { + presenceData.state = `Function: ${manualTitle}` + presenceData.buttons = [ + { label: 'View Function', url: document.location.href }, + ] + } + else if (route[3].includes('language.')) { + const c = route[3].split('.')[1] + presenceData.state = `${ + c.charAt(0).toUpperCase() + c.slice(1) + }: ${manualTitle}` + } + else { + presenceData.state = manualTitle + } + break + } + case 'releases': + if (route[2]) { + presenceData.details = 'Viewing an release version:' + presenceData.state = `PHP v${route[2]}` + } + else { + presenceData.details = 'Viewing the releases' + } + break + default: + presenceData.details = 'Browsing the website' + } - if (route[1].toLowerCase().includes("changelog")) - presenceData.details = "Reading the changelogs"; + if (route[1].toLowerCase().includes('changelog')) + presenceData.details = 'Reading the changelogs' - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/Panda Novel/metadata.json b/websites/P/Panda Novel/metadata.json index b80230056458..c15c425e4ed9 100644 --- a/websites/P/Panda Novel/metadata.json +++ b/websites/P/Panda Novel/metadata.json @@ -1,59 +1,59 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "257151906038677504", - "name": "SHISEN" - }, - "service": "Panda Novel", - "description": { - "en": "Explore the wonderful novel world at Panda Novel. Read free light novels of Chinese, Korean and Japanese in English translation online" - }, - "url": "www.panda-novel.com", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Panda%20Novel/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Panda%20Novel/assets/thumbnail.png", - "color": "#77d48f", - "category": "anime", - "tags": [ - "panda", - "novel", - "manga" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "logo", - "if": { - "privacy": false - }, - "title": "Show covers", - "icon": "fad fa-images", - "value": true - }, - { - "id": "time", - "title": "Show timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "buttons", - "if": { - "privacy": false - }, - "title": "Show buttons", - "icon": "fad fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "257151906038677504", + "name": "SHISEN" + }, + "service": "Panda Novel", + "description": { + "en": "Explore the wonderful novel world at Panda Novel. Read free light novels of Chinese, Korean and Japanese in English translation online" + }, + "url": "www.panda-novel.com", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Panda%20Novel/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Panda%20Novel/assets/thumbnail.png", + "color": "#77d48f", + "category": "anime", + "tags": [ + "panda", + "novel", + "manga" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "logo", + "if": { + "privacy": false + }, + "title": "Show covers", + "icon": "fad fa-images", + "value": true + }, + { + "id": "time", + "title": "Show timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "buttons", + "if": { + "privacy": false + }, + "title": "Show buttons", + "icon": "fad fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/P/Panda Novel/presence.ts b/websites/P/Panda Novel/presence.ts index c4cdae82b0da..5d981bc13c62 100644 --- a/websites/P/Panda Novel/presence.ts +++ b/websites/P/Panda Novel/presence.ts @@ -1,225 +1,227 @@ const presence = new Presence({ - clientId: "1064394161807167568", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1064394161807167568', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Panda%20Novel/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Panda%20Novel/assets/logo.png', } async function getStrings() { - return presence.getStrings( - { - viewHome: "general.viewHome", - buttonViewPage: "general.buttonViewPage", - viewing: "general.viewing", - reading: "general.reading", - search: "general.search", - searchFor: "general.searchFor", - searchSomething: "general.searchSomething", - chapter: "general.chapter", - manga: "general.manga", - viewAccount: "general.viewAccount", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + viewHome: 'general.viewHome', + buttonViewPage: 'general.buttonViewPage', + viewing: 'general.viewing', + reading: 'general.reading', + search: 'general.search', + searchFor: 'general.searchFor', + searchSomething: 'general.searchSomething', + chapter: 'general.chapter', + manga: 'general.manga', + viewAccount: 'general.viewAccount', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } -let strings: Awaited>; +let strings: Awaited> enum NotTranslated { - Authors = "authors", - Comments = "comments", - Library = "library", - Novel = "novel", - NovelPage = "novel page", - PopularManga = "popular manga", - ThisWeeksNewNovels = "this weeks new novels", - TopNovelsRead = "top novels read", - WorksOfTheAuthor = "works of the author", + Authors = 'authors', + Comments = 'comments', + Library = 'library', + Novel = 'novel', + NovelPage = 'novel page', + PopularManga = 'popular manga', + ThisWeeksNewNovels = 'this weeks new novels', + TopNovelsRead = 'top novels read', + WorksOfTheAuthor = 'works of the author', } function textContent(tags: string) { - return document.querySelector(tags)?.textContent?.trim(); + return document.querySelector(tags)?.textContent?.trim() } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - details: "Somewhere on the site", - }, - [privacy, logo, time, buttons] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("logo"), - presence.getSetting("time"), - presence.getSetting("buttons"), - ]), - { pathname, href } = document.location, - path = pathname.split("/"); - - if (!strings) strings = await getStrings(); - - switch (path[1]) { - case "top": - presenceData.details = strings.viewHome; - break; - - case "details": - presenceData.details = `${strings.viewing} ${NotTranslated.NovelPage}`; - presenceData.state = textContent(".novel-desc h1"); - presenceData.largeImageKey = - document.querySelector( - ".novel-cover i" - )?.dataset?.src; - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = "Viewing"; - presenceData.buttons = [{ label: strings.buttonViewPage, url: href }]; - break; - - case "content": - presenceData.details = `${strings.reading} ${ - privacy - ? NotTranslated.Novel - : textContent(".breadcrumb li:nth-child(2) h1") - }`; - presenceData.state = textContent(".breadcrumb li:nth-child(3) span"); - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - presenceData.buttons = [ - { - label: strings.buttonViewPage, - url: document.querySelector( - ".breadcrumb li:nth-child(2) a" - )?.href, - }, - ]; - break; - - case "browsenovel": - presenceData.details = !privacy - ? strings.searchFor - : strings.searchSomething; - presenceData.state = textContent(".filter-list .current"); - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Searching"; - break; - - case "rankings": - presenceData.details = `${strings.viewing} ${NotTranslated.TopNovelsRead}`; - presenceData.state = textContent(".ranking-tabs .current"); - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = "Viewing"; - break; - - case "author": - presenceData.details = !privacy - ? `${strings.searchFor} ${NotTranslated.Authors}` - : strings.searchSomething; - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Searching"; - if (path[2] === "works") { - presenceData.details = `${strings.viewing} ${NotTranslated.WorksOfTheAuthor}`; - presenceData.state = textContent(".author-desc dl dd h4"); - presenceData.largeImageKey = - document.querySelector( - ".author-portrait i" - )?.dataset?.src; - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = "Viewing"; - presenceData.buttons = [ - { - label: strings.buttonViewPage, - url: href, - }, - ]; - } - break; - - case "manga": - presenceData.details = `${strings.viewing} ${NotTranslated.PopularManga}`; - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = "Viewing"; - switch (path[2]) { - case "details": - case "novel": - presenceData.details = `${ - strings.viewing - } ${strings.chapter.toLowerCase()} ${textContent( - ".details-tabs .current" - ).toLowerCase()}`; - presenceData.state = textContent(".section-title span"); - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = "Viewing"; - presenceData.buttons = [ - { - label: strings.buttonViewPage, - url: href, - }, - ]; - break; - - case "content": - presenceData.details = `${strings.reading} ${ - privacy - ? strings.manga.toLowerCase() - : textContent(".breadcrumb li:nth-child(2) h1") - }`; - presenceData.state = textContent(".breadcrumb li:nth-child(3) span"); - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - presenceData.buttons = [ - { - label: strings.buttonViewPage, - url: document.querySelector( - ".breadcrumb li:nth-child(2) a" - )?.href, - }, - ]; - break; - } - break; - - case "newnovel": - presenceData.details = `${strings.viewing} ${NotTranslated.ThisWeeksNewNovels}`; - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = "Viewing"; - break; - - case "presearch": - case "search": - presenceData.details = !privacy - ? `${strings.searchFor} ${NotTranslated.Novel}` - : strings.searchSomething; - presenceData.state = - document.querySelector("input")?.value; - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Searching"; - if (path[2]) presenceData.state = textContent(".header-content h4 i"); - break; - - case "ucenter": - presenceData.details = strings.viewAccount; - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = "Viewing"; - if (path[2] === "reviews") { - presenceData.details = `${strings.viewing} ${NotTranslated.Comments}`; - presenceData.state = textContent(".header-tabs .current"); - } - break; - - case "library": - case "history": - presenceData.details = `${strings.viewing} ${NotTranslated.Library}`; - presenceData.state = textContent(".header-tabs .current"); - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = "Viewing"; - break; - } - - if ((!logo || privacy) && presenceData.largeImageKey !== Assets.Logo) - presenceData.largeImageKey = Assets.Logo; - if (!buttons || privacy) delete presenceData.buttons; - if (time) presenceData.startTimestamp = browsingTimestamp; - if (privacy) delete presenceData.state; - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + details: 'Somewhere on the site', + } + const [privacy, logo, time, buttons] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('logo'), + presence.getSetting('time'), + presence.getSetting('buttons'), + ]) + const { pathname, href } = document.location + const path = pathname.split('/') + + if (!strings) + strings = await getStrings() + + switch (path[1]) { + case 'top': + presenceData.details = strings.viewHome + break + + case 'details': + presenceData.details = `${strings.viewing} ${NotTranslated.NovelPage}` + presenceData.state = textContent('.novel-desc h1') + presenceData.largeImageKey = document.querySelector( + '.novel-cover i', + )?.dataset?.src + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = 'Viewing' + presenceData.buttons = [{ label: strings.buttonViewPage, url: href }] + break + + case 'content': + presenceData.details = `${strings.reading} ${ + privacy + ? NotTranslated.Novel + : textContent('.breadcrumb li:nth-child(2) h1') + }` + presenceData.state = textContent('.breadcrumb li:nth-child(3) span') + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + presenceData.buttons = [ + { + label: strings.buttonViewPage, + url: document.querySelector( + '.breadcrumb li:nth-child(2) a', + )?.href ?? '', + }, + ] + break + + case 'browsenovel': + presenceData.details = !privacy + ? strings.searchFor + : strings.searchSomething + presenceData.state = textContent('.filter-list .current') + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Searching' + break + + case 'rankings': + presenceData.details = `${strings.viewing} ${NotTranslated.TopNovelsRead}` + presenceData.state = textContent('.ranking-tabs .current') + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = 'Viewing' + break + + case 'author': + presenceData.details = !privacy + ? `${strings.searchFor} ${NotTranslated.Authors}` + : strings.searchSomething + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Searching' + if (path[2] === 'works') { + presenceData.details = `${strings.viewing} ${NotTranslated.WorksOfTheAuthor}` + presenceData.state = textContent('.author-desc dl dd h4') + presenceData.largeImageKey = document.querySelector( + '.author-portrait i', + )?.dataset?.src + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = 'Viewing' + presenceData.buttons = [ + { + label: strings.buttonViewPage, + url: href, + }, + ] + } + break + + case 'manga': + presenceData.details = `${strings.viewing} ${NotTranslated.PopularManga}` + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = 'Viewing' + switch (path[2]) { + case 'details': + case 'novel': + presenceData.details = `${ + strings.viewing + } ${strings.chapter.toLowerCase()} ${textContent( + '.details-tabs .current', + )?.toLowerCase()}` + presenceData.state = textContent('.section-title span') + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = 'Viewing' + presenceData.buttons = [ + { + label: strings.buttonViewPage, + url: href, + }, + ] + break + + case 'content': + presenceData.details = `${strings.reading} ${ + privacy + ? strings.manga.toLowerCase() + : textContent('.breadcrumb li:nth-child(2) h1') + }` + presenceData.state = textContent('.breadcrumb li:nth-child(3) span') + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + presenceData.buttons = [ + { + label: strings.buttonViewPage, + url: document.querySelector( + '.breadcrumb li:nth-child(2) a', + )?.href ?? '', + }, + ] + break + } + break + + case 'newnovel': + presenceData.details = `${strings.viewing} ${NotTranslated.ThisWeeksNewNovels}` + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = 'Viewing' + break + + case 'presearch': + case 'search': + presenceData.details = !privacy + ? `${strings.searchFor} ${NotTranslated.Novel}` + : strings.searchSomething + presenceData.state = document.querySelector('input')?.value + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Searching' + if (path[2]) + presenceData.state = textContent('.header-content h4 i') + break + + case 'ucenter': + presenceData.details = strings.viewAccount + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = 'Viewing' + if (path[2] === 'reviews') { + presenceData.details = `${strings.viewing} ${NotTranslated.Comments}` + presenceData.state = textContent('.header-tabs .current') + } + break + + case 'library': + case 'history': + presenceData.details = `${strings.viewing} ${NotTranslated.Library}` + presenceData.state = textContent('.header-tabs .current') + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = 'Viewing' + break + } + + if ((!logo || privacy) && presenceData.largeImageKey !== Assets.Logo) + presenceData.largeImageKey = Assets.Logo + if (!buttons || privacy) + delete presenceData.buttons + if (time) + presenceData.startTimestamp = browsingTimestamp + if (privacy) + delete presenceData.state + presence.setActivity(presenceData) +}) diff --git a/websites/P/Pandora/metadata.json b/websites/P/Pandora/metadata.json index 13acff82e635..e0656cd9f789 100644 --- a/websites/P/Pandora/metadata.json +++ b/websites/P/Pandora/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Striker", - "id": "215509157837537280" - }, - "contributors": [ - { - "name": "FireController1847", - "id": "112732946774962176" - } - ], - "service": "Pandora", - "description": { - "en": "Play the songs, albums, playlists and podcasts you love on the all-new Pandora.", - "de": "Genieße die Songs, Alben, Playlisten und Podcasts, die du liebst, auf dem brandneuem Pandora.", - "nl": "Speel de nummers, albums, afspeellijsten en podcasts af die je leuk vindt op de geheel nieuwe Pandora." - }, - "url": "www.pandora.com", - "version": "2.1.15", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pandora/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pandora/assets/thumbnail.png", - "color": "#224099", - "category": "music", - "tags": [ - "music", - "audio" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Striker", + "id": "215509157837537280" + }, + "contributors": [ + { + "name": "FireController1847", + "id": "112732946774962176" + } + ], + "service": "Pandora", + "description": { + "en": "Play the songs, albums, playlists and podcasts you love on the all-new Pandora.", + "de": "Genieße die Songs, Alben, Playlisten und Podcasts, die du liebst, auf dem brandneuem Pandora.", + "nl": "Speel de nummers, albums, afspeellijsten en podcasts af die je leuk vindt op de geheel nieuwe Pandora." + }, + "url": "www.pandora.com", + "version": "2.1.15", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pandora/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pandora/assets/thumbnail.png", + "color": "#224099", + "category": "music", + "tags": [ + "music", + "audio" + ] +} diff --git a/websites/P/Pandora/presence.ts b/websites/P/Pandora/presence.ts index 9f0ab142ab4c..ae330f153676 100644 --- a/websites/P/Pandora/presence.ts +++ b/websites/P/Pandora/presence.ts @@ -1,107 +1,117 @@ const presence = new Presence({ - clientId: "608109837657702566", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }); + clientId: '608109837657702566', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) -function stripText(element: HTMLElement, id = "None", log = true) { - if (element && element.firstChild) return element.firstChild.textContent; - else { - if (log) { - presence.error( - `An error occurred while stripping data off the page. Please contact FireController1847 on the PreMiD Discord server, and send him a screenshot of this error. ID: ${id}` - ); - } - return null; - } +function stripText(element: HTMLElement, id = 'None', log = true) { + if (element && element.firstChild) { + return element.firstChild.textContent + } + else { + if (log) { + presence.error( + `An error occurred while stripping data off the page. Please contact FireController1847 on the PreMiD Discord server, and send him a screenshot of this error. ID: ${id}`, + ) + } + return null + } } -presence.on("UpdateData", async () => { - // Define presence data - const presenceData: PresenceData = { - details: "Browsing...", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Pandora/assets/logo.png", - }; +presence.on('UpdateData', async () => { + // Define presence data + const presenceData: PresenceData = { + details: 'Browsing...', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Pandora/assets/logo.png', + } - // Define whether or not we're currently playing - let isPlaying = false; + // Define whether or not we're currently playing + let isPlaying = false - // If the audio bar exists, assume we're listening to something - if (document.querySelector(".Tuner__Audio__NowPlayingHitArea")) { - // Fetch title and artist - const title = document.querySelector( - ".Tuner__Audio__TrackDetail__title" - ), - artist = document.querySelector( - ".Tuner__Audio__TrackDetail__artist" - ); + // If the audio bar exists, assume we're listening to something + if (document.querySelector('.Tuner__Audio__NowPlayingHitArea')) { + // Fetch title and artist + const title = document.querySelector( + '.Tuner__Audio__TrackDetail__title', + ) + const artist = document.querySelector( + '.Tuner__Audio__TrackDetail__artist', + ) - // Only apply them to presence if they're not null - if (title && artist) { - // Set them to the presence - presenceData.details = stripText(title, "Title"); - presenceData.state = stripText(artist, "Artist"); - } else presence.error("Title and artist are null!"); + // Only apply them to presence if they're not null + if (title && artist) { + // Set them to the presence + presenceData.details = stripText(title, 'Title') + presenceData.state = stripText(artist, 'Artist') + } + else { + presence.error('Title and artist are null!') + } - // Fetch play button - const playButton = document.querySelector( - ".Tuner__Control__Play__Button" - ); + // Fetch play button + const playButton = document.querySelector( + '.Tuner__Control__Play__Button', + ) - // Return if null - if (playButton) { - // Check if we're paused or playing - isPlaying = playButton.getAttribute("aria-checked") === "true"; + // Return if null + if (playButton) { + // Check if we're paused or playing + isPlaying = playButton.getAttribute('aria-checked') === 'true' - // If we're not paused, set the small image to playing and fetch the timestamps - // Otherwise, set the small image to paused - if (isPlaying) { - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = (await strings).play; + // If we're not paused, set the small image to playing and fetch the timestamps + // Otherwise, set the small image to paused + if (isPlaying) { + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = (await strings).play - // Get duration control - const timeElapsed = document.querySelector( - ".VolumeDurationControl__Duration [data-qa=elapsed_time]" - ), - timeRemaining = document.querySelector( - ".VolumeDurationControl__Duration [data-qa=remaining_time]" - ); + // Get duration control + const timeElapsed = document.querySelector( + '.VolumeDurationControl__Duration [data-qa=elapsed_time]', + ) + const timeRemaining = document.querySelector( + '.VolumeDurationControl__Duration [data-qa=remaining_time]', + ) - // If duration controls exist, set the timestamps and small image text appropriately - if (timeElapsed && timeRemaining) { - // Get timestamps - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - presence.timestampFromFormat( - stripText(timeElapsed, "Time Elapsed") - ), - presence.timestampFromFormat( - stripText(timeRemaining, "Time Remaining") - ) - ); - } else presence.error("Timestamps are null!"); - } else { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = (await strings).pause; - } + // If duration controls exist, set the timestamps and small image text appropriately + if (timeElapsed && timeRemaining) { + // Get timestamps + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + presence.timestampFromFormat( + stripText(timeElapsed, 'Time Elapsed')!, + ), + presence.timestampFromFormat( + stripText(timeRemaining, 'Time Remaining')!, + ), + ) + } + else { + presence.error('Timestamps are null!') + } + } + else { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = (await strings).pause + } - // Even if we're not playing, we still want the album art if it exists - // Check multiple locations for the art and if it does not exist, use the default 'pandora' key - const art = - document.querySelector( - ".Tuner__Audio__TrackDetail__img :first-child :first-child" - ) ?? - document.querySelector( - ".nowPlayingTopInfo__artContainer__art :first-child :first-child" - ) ?? - document.querySelector(".HeroCard__image"); - if (art) presenceData.largeImageKey = art.src; - else presence.error("Art is null!"); - } else presence.error("Play button is null!"); - } + // Even if we're not playing, we still want the album art if it exists + // Check multiple locations for the art and if it does not exist, use the default 'pandora' key + const art = document.querySelector( + '.Tuner__Audio__TrackDetail__img :first-child :first-child', + ) + ?? document.querySelector( + '.nowPlayingTopInfo__artContainer__art :first-child :first-child', + ) + ?? document.querySelector('.HeroCard__image') + if (art) + presenceData.largeImageKey = art.src + else presence.error('Art is null!') + } + else { + presence.error('Play button is null!') + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/Pantip/metadata.json b/websites/P/Pantip/metadata.json index 099358698be5..b4124e958956 100644 --- a/websites/P/Pantip/metadata.json +++ b/websites/P/Pantip/metadata.json @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Yusaki", - "id": "439582316873121793" - }, - "service": "Pantip", - "description": { - "en": "Pantip is the most popular forum in Thailand for participate in discussions on all issues including entertainment, stocks, beauty, travel, cars, sports, mobile phones, food, politics, family, home, science, health, business", - "th": "ร่วมพูดคุยแลกเปลี่ยนความคิดเห็นในทุกประเด็น ทั้งบันเทิง หุ้น ความงาม ท่องเที่ยว รถยนต์ กีฬา โทรศัพท์มือถือ อาหาร การเมือง ครอบครัว บ้าน วิทยาศาสตร์ สุขภาพ ธุรกิจ.", - "nl": "Pantip is het populairste forum in Thailand om deel te nemen aan discussies over alle onderwerpen, waaronder entertainment, aandelen, schoonheid, reizen, auto's, sport, mobiele telefoons, eten, politiek, gezin, huis, wetenschap, gezondheid, zaken" - }, - "url": "www.pantip.com", - "regExp": "([a-z0-9-]+[.])*pantip[.]com[/]", - "version": "1.0.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pantip/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pantip/assets/thumbnail.png", - "color": "#9d93f5", - "category": "other", - "tags": [ - "pantip", - "forum", - "tags", - "tag", - "discussions", - "issues", - "entertainment", - "more" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Yusaki", + "id": "439582316873121793" + }, + "service": "Pantip", + "description": { + "en": "Pantip is the most popular forum in Thailand for participate in discussions on all issues including entertainment, stocks, beauty, travel, cars, sports, mobile phones, food, politics, family, home, science, health, business", + "th": "ร่วมพูดคุยแลกเปลี่ยนความคิดเห็นในทุกประเด็น ทั้งบันเทิง หุ้น ความงาม ท่องเที่ยว รถยนต์ กีฬา โทรศัพท์มือถือ อาหาร การเมือง ครอบครัว บ้าน วิทยาศาสตร์ สุขภาพ ธุรกิจ.", + "nl": "Pantip is het populairste forum in Thailand om deel te nemen aan discussies over alle onderwerpen, waaronder entertainment, aandelen, schoonheid, reizen, auto's, sport, mobiele telefoons, eten, politiek, gezin, huis, wetenschap, gezondheid, zaken" + }, + "url": "www.pantip.com", + "regExp": "([a-z0-9-]+[.])*pantip[.]com[/]", + "version": "1.0.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pantip/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pantip/assets/thumbnail.png", + "color": "#9d93f5", + "category": "other", + "tags": [ + "pantip", + "forum", + "tags", + "tag", + "discussions", + "issues", + "entertainment", + "more" + ] +} diff --git a/websites/P/Pantip/presence.ts b/websites/P/Pantip/presence.ts index 62d5949899d0..5c9a0145754b 100644 --- a/websites/P/Pantip/presence.ts +++ b/websites/P/Pantip/presence.ts @@ -1,140 +1,168 @@ const presence = new Presence({ - clientId: "714416728448434218", - }), - // Const thing - browsingTimestamp = Math.floor(Date.now() / 1000), - tag1 = - document.querySelector( - "#__next > div > div > div:nth-child(4) > div > div > nav > div > a:nth-child(2)" - )?.textContent ?? "เเท็กที่ไม่ทราบ", - forum1 = - document.querySelector( - "#__next > div > div > div:nth-child(4) > div > div > nav > div > a" - )?.textContent ?? "ห้องที่ไม่ทราบ", - topic1 = - document.querySelector("head > title")?.textContent ?? "หัวข้อที่ไม่ทราบ", - message1 = - document.querySelector( - "#main-body-content > div.content > div.container-outer.container-liquid > div.display-post-wrapper.main-post.main-post-msg > div > div:nth-child(1) > h2" - )?.textContent ?? "ไม่ทราบข้อความ", - club1 = - document.querySelector( - "#main-body-content > div.content > div.container-wrap.bottombdr.bottomspc > div > div > ul > li" - )?.textContent ?? "คลับที่ไม่ทราบ", - path = document.location; + clientId: '714416728448434218', +}) +// Const thing +const browsingTimestamp = Math.floor(Date.now() / 1000) +const tag1 = document.querySelector( + '#__next > div > div > div:nth-child(4) > div > div > nav > div > a:nth-child(2)', +)?.textContent ?? 'เเท็กที่ไม่ทราบ' +const forum1 = document.querySelector( + '#__next > div > div > div:nth-child(4) > div > div > nav > div > a', +)?.textContent ?? 'ห้องที่ไม่ทราบ' +const topic1 = document.querySelector('head > title')?.textContent ?? 'หัวข้อที่ไม่ทราบ' +const message1 = document.querySelector( + '#main-body-content > div.content > div.container-outer.container-liquid > div.display-post-wrapper.main-post.main-post-msg > div > div:nth-child(1) > h2', +)?.textContent ?? 'ไม่ทราบข้อความ' +const club1 = document.querySelector( + '#main-body-content > div.content > div.container-wrap.bottombdr.bottomspc > div > div > ul > li', +)?.textContent ?? 'คลับที่ไม่ทราบ' +const path = document.location -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Pantip/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Pantip/assets/logo.png', + startTimestamp: browsingTimestamp, + } - // Presence - if ( - path.hostname === "pantip.com" || - path.hostname.includes("([a-z0-9-]+[.])*") - ) { - if (document.location.pathname === "/") presenceData.details = "หน้าหลัก"; - else if (path.pathname.includes("index.php")) - presenceData.details = "หน้าหลัก"; - else if (path.pathname.includes("tags")) { - presenceData.details = "เเท็ก "; - if (path.pathname.includes("#myfollowing")) - presenceData.details = "ที่ติดตาม"; - else if (path.pathname.includes("#tags")) - presenceData.details = "ทั้งหมด"; - } else if (path.pathname.includes("tag")) { - presenceData.details = "เเท็ก "; - presenceData.state = tag1; - } else if (path.pathname.includes("notifications")) - presenceData.details = "การเเจ้งเตือน "; - else if (path.pathname.includes("new_topic")) - presenceData.details = "กำลังตั้งกระทู้ใหม่ "; - else if (path.pathname.includes("forum")) { - presenceData.details = "ห้อง "; - presenceData.state = forum1; - } else if (path.pathname.includes("search")) { - presenceData.details = "กำลังค้นหา "; - presenceData.state = - document.querySelector("#search-text").getAttribute("value") ?? - "ไม่ทราบการค้นหา"; - presenceData.smallImageKey = Assets.Search; - } else if (path.pathname.includes("topic")) { - presenceData.details = "กำลังอ่าน "; - presenceData.state = topic1; - presenceData.smallImageKey = Assets.Reading; - } else if (path.pathname.includes("tos")) { - presenceData.details = "กำลังอ่าน "; - presenceData.state = "กฎ กติกา และมารยาท"; - presenceData.smallImageKey = Assets.Reading; - } else if (path.pathname.includes("defamation")) { - presenceData.details = "กำลังอ่าน "; - presenceData.state = "การโพสต์ความคิดเห็นที่เข้าข่าย หมิ่นประมาท"; - presenceData.smallImageKey = Assets.Reading; - } else if (path.pathname.includes("privacy")) { - presenceData.details = "กำลังอ่าน "; - presenceData.state = "นโยบายเกี่ยวกับข้อมูลส่วนบุคคล"; - presenceData.smallImageKey = Assets.Reading; - } else if (path.pathname.includes("contect")) { - presenceData.details = "กำลังอ่าน "; - presenceData.state = "ติดต่อทีมงานพันทิป"; - presenceData.smallImageKey = Assets.Reading; - } else if (path.pathname.includes("login")) - presenceData.details = "กำลังเข้าสู่ระบบ "; - else if (path.pathname.includes("register_member")) - presenceData.details = "กำลังสมัครใช้งาน "; - else if (path.pathname.includes("activities")) - presenceData.details = "กิจกรรม "; - else if (path.href.includes("profile")) { - presenceData.details = "กำลังดูโปรไฟล์"; - if (path.href.includes("#topics")) { - presenceData.details = "กำลังดูโปรไฟล์"; - presenceData.state = "กระทู้ที่สร้าง"; - } else if (path.href.includes("#comments")) { - presenceData.details = "กำลังดูโปรไฟล์"; - presenceData.state = "กระทู้ที่ตอบ"; - } else if (path.href.includes("#bookmarks")) { - presenceData.details = "กำลังดูโปรไฟล์"; - presenceData.state = "กระทู้ที่ชอบ"; - } else if (path.href.includes("#history")) { - presenceData.details = "กำลังดูโปรไฟล์"; - presenceData.state = "กระทู้ที่เคยอ่าน"; - } else if (path.href.includes("#pantip_point")) { - presenceData.details = "กำลังดูโปรไฟล์"; - presenceData.state = "คะเเนนพันทิป"; - } else if (path.href.includes("#my_following")) { - presenceData.details = "กำลังดูโปรไฟล์"; - presenceData.state = "เเท็กที่ติดตาม"; - } else if (path.href.includes("#blogs")) { - presenceData.details = "กำลังดูโปรไฟล์"; - presenceData.state = "บล็อกเเก้ง"; - } else if (path.pathname.includes("settings")) - presenceData.details = "จัดการข้อมูลส่วนตัว "; - } else if (path.pathname.includes("message")) { - presenceData.details = "กล่องข้อความ "; - if (path.href.includes("#outbox")) - presenceData.details = "ข้อความที่ส่งเเล้ว "; - else if (path.href.includes("#unblock")) - presenceData.details = "สมาชิกที่ถูกบล็อค "; - else if (path.href.includes("#inbox")) - presenceData.details = "กล่องข้อความ "; - else if (path.href) { - presenceData.details = "อยู่ในสนทนา "; - presenceData.state = message1; - } - } else if (path.pathname.includes("club")) { - presenceData.details = "รายชื่อ Club"; - if (path.pathname.includes("new_topic")) { - presenceData.details = "กำลังตั้งกระทู้ใหม่ใน Club"; - presenceData.state = club1; - } else if (path.href) { - presenceData.details = "กำลังดูใน Club"; - presenceData.state = club1; - } - } else if (path.href) presenceData.details = "หน้าที่ไม่ทราบ"; - } + // Presence + if ( + path.hostname === 'pantip.com' + || path.hostname.includes('([a-z0-9-]+[.])*') + ) { + if (document.location.pathname === '/') { + presenceData.details = 'หน้าหลัก' + } + else if (path.pathname.includes('index.php')) { + presenceData.details = 'หน้าหลัก' + } + else if (path.pathname.includes('tags')) { + presenceData.details = 'เเท็ก ' + if (path.pathname.includes('#myfollowing')) + presenceData.details = 'ที่ติดตาม' + else if (path.pathname.includes('#tags')) + presenceData.details = 'ทั้งหมด' + } + else if (path.pathname.includes('tag')) { + presenceData.details = 'เเท็ก ' + presenceData.state = tag1 + } + else if (path.pathname.includes('notifications')) { + presenceData.details = 'การเเจ้งเตือน ' + } + else if (path.pathname.includes('new_topic')) { + presenceData.details = 'กำลังตั้งกระทู้ใหม่ ' + } + else if (path.pathname.includes('forum')) { + presenceData.details = 'ห้อง ' + presenceData.state = forum1 + } + else if (path.pathname.includes('search')) { + presenceData.details = 'กำลังค้นหา ' + presenceData.state = document.querySelector('#search-text')?.getAttribute('value') + ?? 'ไม่ทราบการค้นหา' + presenceData.smallImageKey = Assets.Search + } + else if (path.pathname.includes('topic')) { + presenceData.details = 'กำลังอ่าน ' + presenceData.state = topic1 + presenceData.smallImageKey = Assets.Reading + } + else if (path.pathname.includes('tos')) { + presenceData.details = 'กำลังอ่าน ' + presenceData.state = 'กฎ กติกา และมารยาท' + presenceData.smallImageKey = Assets.Reading + } + else if (path.pathname.includes('defamation')) { + presenceData.details = 'กำลังอ่าน ' + presenceData.state = 'การโพสต์ความคิดเห็นที่เข้าข่าย หมิ่นประมาท' + presenceData.smallImageKey = Assets.Reading + } + else if (path.pathname.includes('privacy')) { + presenceData.details = 'กำลังอ่าน ' + presenceData.state = 'นโยบายเกี่ยวกับข้อมูลส่วนบุคคล' + presenceData.smallImageKey = Assets.Reading + } + else if (path.pathname.includes('contect')) { + presenceData.details = 'กำลังอ่าน ' + presenceData.state = 'ติดต่อทีมงานพันทิป' + presenceData.smallImageKey = Assets.Reading + } + else if (path.pathname.includes('login')) { + presenceData.details = 'กำลังเข้าสู่ระบบ ' + } + else if (path.pathname.includes('register_member')) { + presenceData.details = 'กำลังสมัครใช้งาน ' + } + else if (path.pathname.includes('activities')) { + presenceData.details = 'กิจกรรม ' + } + else if (path.href.includes('profile')) { + presenceData.details = 'กำลังดูโปรไฟล์' + if (path.href.includes('#topics')) { + presenceData.details = 'กำลังดูโปรไฟล์' + presenceData.state = 'กระทู้ที่สร้าง' + } + else if (path.href.includes('#comments')) { + presenceData.details = 'กำลังดูโปรไฟล์' + presenceData.state = 'กระทู้ที่ตอบ' + } + else if (path.href.includes('#bookmarks')) { + presenceData.details = 'กำลังดูโปรไฟล์' + presenceData.state = 'กระทู้ที่ชอบ' + } + else if (path.href.includes('#history')) { + presenceData.details = 'กำลังดูโปรไฟล์' + presenceData.state = 'กระทู้ที่เคยอ่าน' + } + else if (path.href.includes('#pantip_point')) { + presenceData.details = 'กำลังดูโปรไฟล์' + presenceData.state = 'คะเเนนพันทิป' + } + else if (path.href.includes('#my_following')) { + presenceData.details = 'กำลังดูโปรไฟล์' + presenceData.state = 'เเท็กที่ติดตาม' + } + else if (path.href.includes('#blogs')) { + presenceData.details = 'กำลังดูโปรไฟล์' + presenceData.state = 'บล็อกเเก้ง' + } + else if (path.pathname.includes('settings')) { + presenceData.details = 'จัดการข้อมูลส่วนตัว ' + } + } + else if (path.pathname.includes('message')) { + presenceData.details = 'กล่องข้อความ ' + if (path.href.includes('#outbox')) { + presenceData.details = 'ข้อความที่ส่งเเล้ว ' + } + else if (path.href.includes('#unblock')) { + presenceData.details = 'สมาชิกที่ถูกบล็อค ' + } + else if (path.href.includes('#inbox')) { + presenceData.details = 'กล่องข้อความ ' + } + else if (path.href) { + presenceData.details = 'อยู่ในสนทนา ' + presenceData.state = message1 + } + } + else if (path.pathname.includes('club')) { + presenceData.details = 'รายชื่อ Club' + if (path.pathname.includes('new_topic')) { + presenceData.details = 'กำลังตั้งกระทู้ใหม่ใน Club' + presenceData.state = club1 + } + else if (path.href) { + presenceData.details = 'กำลังดูใน Club' + presenceData.state = club1 + } + } + else if (path.href) { + presenceData.details = 'หน้าที่ไม่ทราบ' + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/Panzoid/iframe.ts b/websites/P/Panzoid/iframe.ts index c1ef95a3dab6..ba3f0914bcd2 100644 --- a/websites/P/Panzoid/iframe.ts +++ b/websites/P/Panzoid/iframe.ts @@ -1,51 +1,55 @@ -import { Details, States, format, getRenderingState } from "./shared"; +import { Details, format, getRenderingState, States } from './shared' -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", async () => { - const presenceData: PresenceData = {}; +iframe.on('UpdateData', async () => { + const presenceData: PresenceData = {} - if (document.location.pathname === "/legacy/gen3/clipmaker.html") - getCM3Data(presenceData); - else if (document.location.pathname === "/legacy/gen2/clipmaker.html") - getCM2Data(presenceData); + if (document.location.pathname === '/legacy/gen3/clipmaker.html') + getCM3Data(presenceData) + else if (document.location.pathname === '/legacy/gen2/clipmaker.html') + getCM2Data(presenceData) - // Trigger the iframe event in presence.ts - iframe.send(presenceData); -}); + // Trigger the iframe event in presence.ts + iframe.send(presenceData) +}) function getCM3Data(presenceData: PresenceData): void { - presenceData.details = Details.CM3; - const renderingState = getRenderingState(); - - // Check if rendering is running or not - if (renderingState !== null) presenceData.state = renderingState; - else { - // Get the number of tracks and the number of clips - presenceData.state = format( - States.CM3, - document.querySelectorAll("span.noselect").length, - document.querySelectorAll(".clip").length - ); - } + presenceData.details = Details.CM3 + const renderingState = getRenderingState() + + // Check if rendering is running or not + if (renderingState !== null) { + presenceData.state = renderingState + } + else { + // Get the number of tracks and the number of clips + presenceData.state = format( + States.CM3, + document.querySelectorAll('span.noselect').length, + document.querySelectorAll('.clip').length, + ) + } } function getCM2Data(presenceData: PresenceData): void { - presenceData.details = Details.CM2; - const renderingState = getRenderingState(); - - // Check if rendering is running or not - if (renderingState !== null) presenceData.state = renderingState; - else { - // Get the number of objects and the number of effects - presenceData.state = format( - States.CM2, - document.querySelectorAll( - "#controls > div:nth-child(4) > ul.pz-listbox > li" - ).length, - document.querySelectorAll( - "#controls > div:nth-child(5) > ul.pz-listbox > li" - ).length - ); - } + presenceData.details = Details.CM2 + const renderingState = getRenderingState() + + // Check if rendering is running or not + if (renderingState !== null) { + presenceData.state = renderingState + } + else { + // Get the number of objects and the number of effects + presenceData.state = format( + States.CM2, + document.querySelectorAll( + '#controls > div:nth-child(4) > ul.pz-listbox > li', + ).length, + document.querySelectorAll( + '#controls > div:nth-child(5) > ul.pz-listbox > li', + ).length, + ) + } } diff --git a/websites/P/Panzoid/metadata.json b/websites/P/Panzoid/metadata.json index f5047cbc2565..75b4c19f506d 100644 --- a/websites/P/Panzoid/metadata.json +++ b/websites/P/Panzoid/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "576435921390403623", - "name": "rag404" - }, - "service": "Panzoid", - "description": { - "en": "Panzoid is a free online video editor that offers a wide range of features to help users create and edit their videos.", - "fr": "Panzoid est un outil en ligne gratuit fournissant une large palette de fonctionnalités afin de créer et modifier des vidéos." - }, - "url": [ - "app.panzoid.com", - "panzoid.com" - ], - "version": "2.0.5", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Panzoid/assets/logo.webp", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Panzoid/assets/thumbnail.png", - "color": "#000000", - "category": "other", - "tags": [ - "video", - "editing", - "animation", - "clipmaker" - ], - "iframe": true, - "iFrameRegExp": "https://panzoid\\.com/legacy/gen[23]/clipmaker\\.html" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "576435921390403623", + "name": "rag404" + }, + "service": "Panzoid", + "description": { + "en": "Panzoid is a free online video editor that offers a wide range of features to help users create and edit their videos.", + "fr": "Panzoid est un outil en ligne gratuit fournissant une large palette de fonctionnalités afin de créer et modifier des vidéos." + }, + "url": [ + "app.panzoid.com", + "panzoid.com" + ], + "version": "2.0.5", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Panzoid/assets/logo.webp", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Panzoid/assets/thumbnail.png", + "color": "#000000", + "category": "other", + "tags": [ + "video", + "editing", + "animation", + "clipmaker" + ], + "iframe": true, + "iFrameRegExp": "https://panzoid\\.com/legacy/gen[23]/clipmaker\\.html" +} diff --git a/websites/P/Panzoid/presence.ts b/websites/P/Panzoid/presence.ts index 3d5ae1c257f0..aaeca5ae7c48 100644 --- a/websites/P/Panzoid/presence.ts +++ b/websites/P/Panzoid/presence.ts @@ -1,104 +1,107 @@ import { - Icons, - Details, - States, - ImageTexts, - format, - getRenderingState, -} from "./shared"; + Details, + format, + getRenderingState, + Icons, + ImageTexts, + States, +} from './shared' -const presence = new Presence({ clientId: "1241878965535248527" }), - browsingTimestamp = Math.floor(Date.now() / 1000); +const presence = new Presence({ clientId: '1241878965535248527' }) +const browsingTimestamp = Math.floor(Date.now() / 1000) let legacyData: PresenceData = { - details: "", - state: "", -}; + details: '', + state: '', +} // CM3 and CM2 are built inside iframes, unlike Gen4 -presence.on("iFrameData", (data: { details: string; state: string }) => { - legacyData = data; -}); +presence.on('iFrameData', (data: unknown) => { + legacyData = data as typeof legacyData +}) -presence.on("UpdateData", async () => { - // Default presence data - const presenceData: PresenceData = { - largeImageKey: Icons.Discord, - startTimestamp: browsingTimestamp, - details: Details.Website, - }; +presence.on('UpdateData', async () => { + // Default presence data + const presenceData: PresenceData = { + largeImageKey: Icons.Discord, + startTimestamp: browsingTimestamp, + details: Details.Website, + } - // The order in which the URL is checked matters here - if (document.location.hostname === "app.panzoid.com") - getGen4Data(presenceData); - else if (document.location.pathname.startsWith("/community")) - presenceData.details = Details.Community; - else if (document.location.pathname.includes("/backgrounder")) - presenceData.details = Details.Backgrounder; - else if (document.location.pathname.includes("/videoeditor")) - presenceData.details = Details.VideoEditor; - else if (document.location.pathname.includes("/gen1")) - presenceData.details = Details.CM1; - else if (document.location.pathname.includes("/clipmaker")) - getLegacyData(presenceData); + // The order in which the URL is checked matters here + if (document.location.hostname === 'app.panzoid.com') + getGen4Data(presenceData) + else if (document.location.pathname.startsWith('/community')) + presenceData.details = Details.Community + else if (document.location.pathname.includes('/backgrounder')) + presenceData.details = Details.Backgrounder + else if (document.location.pathname.includes('/videoeditor')) + presenceData.details = Details.VideoEditor + else if (document.location.pathname.includes('/gen1')) + presenceData.details = Details.CM1 + else if (document.location.pathname.includes('/clipmaker')) + getLegacyData(presenceData) - // Finally set the presence - presence.setActivity(presenceData); -}); + // Finally set the presence + presence.setActivity(presenceData) +}) function getGen4Data(presenceData: PresenceData): void { - presenceData.smallImageKey = Icons.Gen4; - presenceData.smallImageText = ImageTexts.Gen4; + presenceData.smallImageKey = Icons.Gen4 + presenceData.smallImageText = ImageTexts.Gen4 - if (document.location.pathname.startsWith("/edit")) - getGen4EditorData(presenceData); - else getGen4MenuData(presenceData); + if (document.location.pathname.startsWith('/edit')) + getGen4EditorData(presenceData) + else getGen4MenuData(presenceData) } -function getGen4EditorData(presenceData: PresenceData): Promise { - // Look for the project name - const projectNameInput = document.querySelector( - ".editortabs-name > input" - ); +function getGen4EditorData(presenceData: PresenceData): void { + // Look for the project name + const projectNameInput = document.querySelector( + '.editortabs-name > input', + ) - // Project name not found means the editor is still loading - if (projectNameInput === null) { - presenceData.details = Details.Gen4Loading; - return; - } else { - presenceData.details = format( - Details.Gen4Editor, - projectNameInput.value.trim() - ); - } + // Project name not found means the editor is still loading + if (projectNameInput === null) { + presenceData.details = Details.Gen4Loading + return + } + else { + presenceData.details = format( + Details.Gen4Editor, + projectNameInput.value.trim(), + ) + } - const renderingState = getRenderingState(); + const renderingState = getRenderingState() - // Check if rendering is running or not - if (renderingState !== null) presenceData.state = renderingState; - else { - presenceData.state = format( - States.Gen4Editor, - document.querySelectorAll(".trackTimeline-track").length, - document.querySelectorAll(".clip:not(.empty)").length - ); - } + // Check if rendering is running or not + if (renderingState !== null) { + presenceData.state = renderingState + } + else { + presenceData.state = format( + States.Gen4Editor, + document.querySelectorAll('.trackTimeline-track').length, + document.querySelectorAll('.clip:not(.empty)').length, + ) + } } function getGen4MenuData(presenceData: PresenceData): void { - presenceData.details = Details.Gen4Menu; + presenceData.details = Details.Gen4Menu - // Get the total number of projects - presenceData.state = format( - States.Gen4Menu, - document.querySelectorAll("button[class*=projectItem]").length - ); + // Get the total number of projects + presenceData.state = format( + States.Gen4Menu, + document.querySelectorAll('button[class*=projectItem]').length, + ) } function getLegacyData(presenceData: PresenceData): void { - // See iframe.ts for CM3 and CM2 specifically - presenceData.details = legacyData.details; - presenceData.state = legacyData.state; - presenceData.smallImageKey = Icons.Legacy; - presenceData.smallImageText = ImageTexts.Legacy; + // See iframe.ts for CM3 and CM2 specifically + presenceData.details = legacyData.details + presenceData.state = legacyData.state + presenceData.smallImageKey = Icons.Legacy + presenceData.smallImageText = ImageTexts.Legacy } diff --git a/websites/P/Panzoid/shared.ts b/websites/P/Panzoid/shared.ts index 9225ff24c27c..99dec4ab0e46 100644 --- a/websites/P/Panzoid/shared.ts +++ b/websites/P/Panzoid/shared.ts @@ -1,33 +1,34 @@ export const enum Icons { - Discord = "https://cdn.rcd.gg/PreMiD/websites/P/Panzoid/assets/logo.webp", - Legacy = "https://cdn.rcd.gg/PreMiD/websites/P/Panzoid/assets/0.png", - Gen4 = "https://cdn.rcd.gg/PreMiD/websites/P/Panzoid/assets/1.png", + Discord = 'https://cdn.rcd.gg/PreMiD/websites/P/Panzoid/assets/logo.webp', + Legacy = 'https://cdn.rcd.gg/PreMiD/websites/P/Panzoid/assets/0.png', + Gen4 = 'https://cdn.rcd.gg/PreMiD/websites/P/Panzoid/assets/1.png', } export const enum Details { - Gen4Menu = "In Gen4 menu", - Gen4Loading = "Loading project...", - Gen4Editor = "Editing: {0}", - CM3 = "Editing in Clipmaker 3", - CM2 = "Editing in Clipmaker 2", - CM1 = "Editing in Clipmaker 1", - Backgrounder = "Editing in Backgrounder", - VideoEditor = "Editing in Video Editor", - Community = "Chatting with the community", - Website = "Lurking around the website", + Gen4Menu = 'In Gen4 menu', + Gen4Loading = 'Loading project...', + Gen4Editor = 'Editing: {0}', + CM3 = 'Editing in Clipmaker 3', + CM2 = 'Editing in Clipmaker 2', + CM1 = 'Editing in Clipmaker 1', + Backgrounder = 'Editing in Backgrounder', + VideoEditor = 'Editing in Video Editor', + Community = 'Chatting with the community', + Website = 'Lurking around the website', } export const enum States { - Gen4Menu = "{0} projects", - Gen4Editor = "{0} tracks | {1} clips", - CM3 = "{0} tracks | {1} clips", - CM2 = "{0} objects | {1} effects", - Rendering = "Rendering {0}%", + Gen4Menu = '{0} projects', + Gen4Editor = '{0} tracks | {1} clips', + // eslint-disable-next-line ts/no-duplicate-enum-values + CM3 = '{0} tracks | {1} clips', + CM2 = '{0} objects | {1} effects', + Rendering = 'Rendering {0}%', } export const enum ImageTexts { - Gen4 = "Gen4", - Legacy = "Legacy", + Gen4 = 'Gen4', + Legacy = 'Legacy', } /** @@ -38,22 +39,21 @@ export const enum ImageTexts { * @return The formatted string with placeholders replaced. */ export function format(text: string, ...args: string[] | number[]): string { - return text.replace(/{(\d+)}/g, (match, number) => - typeof args[number] !== "undefined" ? String(args[number]) : match - ); + return text.replace(/\{(\d+)\}/g, (match, number) => + typeof args[number] !== 'undefined' ? String(args[number]) : match) } -export function getRenderingState(): string { - const element = document.querySelector( - "div.pz-progress > span" - ); - // Get the width percentage and trim the % symbol - // Or if the element was not found, return null - if (element) { - return format( - States.Rendering, - Number(element.style.width.slice(0, -1)).toFixed(2) - ); - } - return null; +export function getRenderingState(): string | null { + const element = document.querySelector( + 'div.pz-progress > span', + ) + // Get the width percentage and trim the % symbol + // Or if the element was not found, return null + if (element) { + return format( + States.Rendering, + Number(element.style.width.slice(0, -1)).toFixed(2), + ) + } + return null } diff --git a/websites/P/Papara Topluluk/metadata.json b/websites/P/Papara Topluluk/metadata.json index c412af625002..41806745f8d7 100644 --- a/websites/P/Papara Topluluk/metadata.json +++ b/websites/P/Papara Topluluk/metadata.json @@ -1,32 +1,32 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "162969778699501569", - "name": "EGGSY#3388" - }, - "service": "Papara Topluluk", - "description": { - "en": "Papara Community where you can ask questions to other users, get instant answers and share your ideas about the application, shape the future of Papara.", - "tr": "Diğer kullanıcılara soru sorabileceğiniz, anında yanıt alabileceğiniz ve uygulama ile ilgili fikirlerinizi paylaşabileceğiniz Papara Topluluğu, Papara'nın geleceğini şekillendiriyor." - }, - "url": "topluluk.papara.com", - "version": "1.0.11", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Papara%20Topluluk/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Papara%20Topluluk/assets/thumbnail.png", - "color": "#8C00A1", - "category": "socials", - "tags": [ - "turkish", - "community", - "forum" - ], - "settings": [ - { - "id": "privacyMode", - "title": "Gizlilik Modu", - "icon": "fas fa-eye", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "162969778699501569", + "name": "EGGSY#3388" + }, + "service": "Papara Topluluk", + "description": { + "en": "Papara Community where you can ask questions to other users, get instant answers and share your ideas about the application, shape the future of Papara.", + "tr": "Diğer kullanıcılara soru sorabileceğiniz, anında yanıt alabileceğiniz ve uygulama ile ilgili fikirlerinizi paylaşabileceğiniz Papara Topluluğu, Papara'nın geleceğini şekillendiriyor." + }, + "url": "topluluk.papara.com", + "version": "1.0.11", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Papara%20Topluluk/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Papara%20Topluluk/assets/thumbnail.png", + "color": "#8C00A1", + "category": "socials", + "tags": [ + "turkish", + "community", + "forum" + ], + "settings": [ + { + "id": "privacyMode", + "title": "Gizlilik Modu", + "icon": "fas fa-eye", + "value": false + } + ] +} diff --git a/websites/P/Papara Topluluk/presence.ts b/websites/P/Papara Topluluk/presence.ts index 4cc7d320a4f1..9fe50feb9cef 100644 --- a/websites/P/Papara Topluluk/presence.ts +++ b/websites/P/Papara Topluluk/presence.ts @@ -1,97 +1,102 @@ const presence = new Presence({ - clientId: "1092957554365182033", - }), - strings = presence.getStrings({ - reading: "general.readingThread", - viewingUser: "general.viewUser", - }), - pages: { [k: string]: string } = { - "/": "Ana Sayfa", - "/categories": "Kategoriler", - "/g": "Gruplar", - "/about": "Hakkında", - "/guidelines": "Kılavuz", - "/tos": "Hizmet Şartları", - "/privacy": "Gizlilik", - "/tags": "Etiketler", - "/cakeday/anniversaries/today": "Yıl Dönümleri", - "/cakeday/birthdays/today": "Doğum Günleri", - "/latest": "Son Konular", - "/new": "Yeni Konular", - "/top": "Popüler Konular", - "/activity": "Aktivite", - "/notifications": "Bildirimler", - "/messages": "Mesajlar", - "/invited": "Davetler", - "/badges": "Rozetler", - }, - dateNow = Math.floor(Date.now() / 1000); + clientId: '1092957554365182033', +}) +const strings = presence.getStrings({ + reading: 'general.readingThread', + viewingUser: 'general.viewUser', +}) +const pages: { [k: string]: string } = { + '/': 'Ana Sayfa', + '/categories': 'Kategoriler', + '/g': 'Gruplar', + '/about': 'Hakkında', + '/guidelines': 'Kılavuz', + '/tos': 'Hizmet Şartları', + '/privacy': 'Gizlilik', + '/tags': 'Etiketler', + '/cakeday/anniversaries/today': 'Yıl Dönümleri', + '/cakeday/birthdays/today': 'Doğum Günleri', + '/latest': 'Son Konular', + '/new': 'Yeni Konular', + '/top': 'Popüler Konular', + '/activity': 'Aktivite', + '/notifications': 'Bildirimler', + '/messages': 'Mesajlar', + '/invited': 'Davetler', + '/badges': 'Rozetler', +} +const dateNow = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Papara%20Topluluk/assets/logo.png", - startTimestamp: dateNow, - }, - page = document.location.pathname, - privacyMode = await presence.getSetting("privacyMode"), - { reading, viewingUser } = await strings; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Papara%20Topluluk/assets/logo.png', + startTimestamp: dateNow, + } + const page = document.location.pathname + const privacyMode = await presence.getSetting('privacyMode') + const { reading, viewingUser } = await strings - if (page.includes("/t/")) { - presenceData.details = reading; - presenceData.smallImageKey = Assets.Reading; - presenceData.state = document.querySelector( - ".title-wrapper .fancy-title" - ).textContent; + if (page.includes('/t/')) { + presenceData.details = reading + presenceData.smallImageKey = Assets.Reading + presenceData.state = document.querySelector( + '.title-wrapper .fancy-title', + )?.textContent - if (!privacyMode) { - presenceData.buttons = [ - { - label: "Konuyu Görüntüle", - url: document.location.href, - }, - ]; - } - } else if (page.includes("/c/")) { - presenceData.details = "Bir kategoriye göz atıyor:"; - presenceData.state = document.querySelector(".category-name").textContent; - } else if (page.includes("/tag/")) { - presenceData.details = "Bir etikete göz atıyor:"; - presenceData.state = `#${decodeURIComponent(page.split("/")[2])}`; - presenceData.smallImageKey = Assets.Search; - } else if (!privacyMode && page.includes("/u/")) { - const username = document.querySelector( - ".details .user-profile-names .username" - ).textContent; + if (!privacyMode) { + presenceData.buttons = [ + { + label: 'Konuyu Görüntüle', + url: document.location.href, + }, + ] + } + } + else if (page.includes('/c/')) { + presenceData.details = 'Bir kategoriye göz atıyor:' + presenceData.state = document.querySelector('.category-name')?.textContent + } + else if (page.includes('/tag/')) { + presenceData.details = 'Bir etikete göz atıyor:' + presenceData.state = `#${decodeURIComponent(page.split('/')[2])}` + presenceData.smallImageKey = Assets.Search + } + else if (!privacyMode && page.includes('/u/')) { + const username = document.querySelector( + '.details .user-profile-names .username', + )?.textContent - if (Object.keys(pages).includes(`/${page.split("/")[3]}`)) { - presenceData.details = "Bir kullanıcı sayfasında:"; - presenceData.state = pages[`/${page.split("/")[3]}`]; - presenceData.smallImageText = username; - } else { - presenceData.details = viewingUser; - presenceData.state = username; - } + if (Object.keys(pages).includes(`/${page.split('/')[3]}`)) { + presenceData.details = 'Bir kullanıcı sayfasında:' + presenceData.state = pages[`/${page.split('/')[3]}`] + presenceData.smallImageText = username + } + else { + presenceData.details = viewingUser + presenceData.state = username + } - presenceData.buttons = [ - { - label: "Kullanıcıyı Görüntüle", - url: document.location.href, - }, - ]; + presenceData.buttons = [ + { + label: 'Kullanıcıyı Görüntüle', + url: document.location.href, + }, + ] - presenceData.smallImageKey = document.querySelector( - ".details .user-profile-avatar img" - ).src; - } else if (page.includes("/g/")) { - presenceData.details = "Bir gruba göz atıyor:"; - presenceData.state = document.querySelector( - ".group-info-names .group-info-name" - )?.textContent; - } else if (pages[page] || pages[page.slice(0, -1)]) { - presenceData.details = "Bir sayfaya göz atıyor:"; - presenceData.state = pages[page] || pages[page.slice(0, -1)]; - } + presenceData.smallImageKey = document.querySelector( + '.details .user-profile-avatar img', + )?.src + } + else if (page.includes('/g/')) { + presenceData.details = 'Bir gruba göz atıyor:' + presenceData.state = document.querySelector( + '.group-info-names .group-info-name', + )?.textContent + } + else if (pages[page] || pages[page.slice(0, -1)]) { + presenceData.details = 'Bir sayfaya göz atıyor:' + presenceData.state = pages[page] || pages[page.slice(0, -1)] + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/PaperMC/metadata.json b/websites/P/PaperMC/metadata.json index 0eca4d0ea14d..b6bc8c80e0e8 100644 --- a/websites/P/PaperMC/metadata.json +++ b/websites/P/PaperMC/metadata.json @@ -1,37 +1,37 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "387062216030945281", - "name": "Romvnly" - }, - "service": "PaperMC", - "description": { - "en": "PaperMC improves Minecraft's ecosystem with fast, secure software and an expanding plugin API, providing quick releases and helpful support as the most widely used, performant, and stable software available." - }, - "url": [ - "papermc.io", - "docs.papermc.io", - "jd.papermc.io", - "hangar.papermc.io", - "hangar.papermc.dev", - "forums.papermc.io" - ], - "version": "1.0.8", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PaperMC/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PaperMC/assets/thumbnail.png", - "color": "#FFC0CB", - "category": "games", - "tags": [ - "minecraft", - "minecraft-server", - "hangar", - "velocity", - "plugins", - "waterfall", - "spigot", - "paper", - "paperspigot", - "bukkit" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "387062216030945281", + "name": "Romvnly" + }, + "service": "PaperMC", + "description": { + "en": "PaperMC improves Minecraft's ecosystem with fast, secure software and an expanding plugin API, providing quick releases and helpful support as the most widely used, performant, and stable software available." + }, + "url": [ + "papermc.io", + "docs.papermc.io", + "jd.papermc.io", + "hangar.papermc.io", + "hangar.papermc.dev", + "forums.papermc.io" + ], + "version": "1.0.8", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PaperMC/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PaperMC/assets/thumbnail.png", + "color": "#FFC0CB", + "category": "games", + "tags": [ + "minecraft", + "minecraft-server", + "hangar", + "velocity", + "plugins", + "waterfall", + "spigot", + "paper", + "paperspigot", + "bukkit" + ] +} diff --git a/websites/P/PaperMC/presence.ts b/websites/P/PaperMC/presence.ts index aa27de1c10a6..d955601abc71 100644 --- a/websites/P/PaperMC/presence.ts +++ b/websites/P/PaperMC/presence.ts @@ -1,282 +1,286 @@ const presence = new Presence({ - clientId: "1088185685682430002", - }), - logoURL = "https://cdn.rcd.gg/PreMiD/websites/P/PaperMC/assets/logo.png", - browsingTimestamp = Math.floor(Date.now() / 1000), - // https://stackoverflow.com/a/7224605 - // to always return type string event when s may be falsy other than empty-string - capitalize = (s: string) => (s && s[0].toUpperCase() + s.slice(1)) || ""; + clientId: '1088185685682430002', +}) +const logoURL = 'https://cdn.rcd.gg/PreMiD/websites/P/PaperMC/assets/logo.png' +const browsingTimestamp = Math.floor(Date.now() / 1000) +// https://stackoverflow.com/a/7224605 +// to always return type string event when s may be falsy other than empty-string +const capitalize = (s: string) => (s && s[0].toUpperCase() + s.slice(1)) || '' // Many thanks to the Modrinth Presence for the inspiration and the code for the Hangar Presence. // Only relevant for Hangar - Because Hangar is a different beast than the rest of PaperMC's websites. enum PageType { - Project = "project", - User = "user", - Unknown = "unknown", + Project = 'project', + User = 'user', + Unknown = 'unknown', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: logoURL, - startTimestamp: browsingTimestamp, - }, - { pathname, hostname, href } = document.location, - { title } = document, - pathSplit = pathname.split("/").filter(x => x); - let attributes; - if (hostname.includes("hangar")) { - attributes = [...document.querySelector("main").attributes].map( - x => x.value - ); - } +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: logoURL, + startTimestamp: browsingTimestamp, + } + const { pathname, hostname, href } = document.location + const { title } = document + const pathSplit = pathname.split('/').filter(x => x) + let attributes + if (hostname.includes('hangar')) { + attributes = [...document.querySelector('main')?.attributes ?? []].map( + x => x.value, + ) + } - switch (hostname) { - case "hangar.papermc.io": - case "hangar.papermc.dev": { - let pageType: PageType; - if ( - pathSplit[0] && - pathSplit[1] && - attributes?.toString().includes(PageType.Project) - ) { - presenceData.details = `Viewing ${pathSplit[0]}'s plugin ${pathSplit[1]}`; - pageType = PageType.Project; - } else if (attributes?.toString().includes(PageType.User)) { - presenceData.details = `Viewing ${pathSplit[0]}'s profile`; - pageType = PageType.User; - } else presenceData.details = "Browsing Hangar"; - const variable = title.replace("| Hangar", ""); - if (pageType === PageType.Project) { - presenceData.state = !pathSplit[2] - ? "Viewing Project Overview" - : `Viewing Project ${variable.split("|")[0].trim()}`; - // Project Image URL has no special class, so we're using the alt attribute of the image. - // I doubt this will change anytime soon. - presenceData.largeImageKey = document.querySelector( - `[alt=${pathSplit[0]}]` - ).src; - presenceData.smallImageKey = logoURL; - } else if (pageType === PageType.User) { - const memberSince = new Date( - [...document.querySelectorAll("span")] - .find(span => span.textContent.includes("Member")) - .textContent.replace(/Member since /i, "") - .trim() - ), - // I expect HangarMC's devs to eventually fix the capitalization on this span - projectCount = Number( - [...document.querySelectorAll("span")] - .find(x => x.textContent.toLowerCase().includes("projects")) - .textContent.replace(/\D/g, "") - .trim() - ), - downloads = [...document.querySelectorAll("span")] - .filter(span => span.textContent.includes("Downloads")) - .map(x => x.textContent.replace(/\D/g, "").trim()) - .map(x => Number(x)) - .reduce((partialSum, a) => partialSum + a, 0); - presenceData.state = `${memberSince.toLocaleDateString()} | ${downloads} plugin downloads | ${projectCount} projects`; - } else presenceData.state = variable; - pageType = pageType || PageType.Unknown; - // We cannot add an "Download" button for Hangar, because the download button is only visible after multiple clicks. - // This is the best you're gonna get. - presenceData.buttons = [ - { - label: `View ${ - pageType === PageType.Unknown - ? "Page" - : capitalize(pageType.toString()) - }`, - url: href, - }, - ]; - break; - } - case "papermc.io": { - switch (pathSplit[0]) { - case "downloads": { - switch (pathSplit[1]) { - case "paper": { - presenceData.details = "Browsing Paper downloads"; - break; - } - case "velocity": { - presenceData.details = "Browsing Velocity downloads"; - break; - } - case "waterfall": { - presenceData.details = "Browsing Waterfall downloads"; - break; - } - default: { - presenceData.details = "Browsing download portal"; - break; - } - } - break; - } - case "community": { - presenceData.details = "Viewing Community page"; - break; - } - case "contribute": { - presenceData.details = "Viewing Contribute page"; - break; - } - case "sponsors": { - presenceData.details = "Viewing Sponsors page"; - break; - } - case "javadocs": { - presenceData.details = "Viewing Javadocs portal"; - break; - } - case "software": { - switch (pathSplit[1]) { - case "paper": { - presenceData.details = "Viewing Paper's homepage"; - break; - } - case "velocity": { - presenceData.details = "Viewing Velocity's homepage"; - break; - } - case "waterfall": { - presenceData.details = "Viewing Waterfall's homepage"; - break; - } - default: { - presenceData.details = "Browsing software"; - break; - } - } - break; - } - default: { - presenceData.details = - location.pathname === "/" ? "Viewing homepage" : "Browsing website"; - presenceData.state = document.querySelector("h1").textContent; - break; - } - } - break; - } - case "docs.papermc.io": { - switch (pathSplit[0]) { - case "docs": { - switch (pathSplit[1]) { - case "tutorials": { - presenceData.details = "Browsing docs tutorials"; - break; - } - case "details": { - presenceData.details = "Reading about the API"; - break; - } - case "modpacks": { - presenceData.details = "Reading about modpacks"; - break; - } - default: { - presenceData.details = "Browsing API information"; - break; - } - } - break; - } - case "api-spec": { - presenceData.details = "Browsing API documentation"; - break; - } - case "misc": { - presenceData.details = "Browsing docs misc information"; - presenceData.state = - document.querySelector("h1").textContent; - break; - } - case "waterfall": { - presenceData.details = "Browsing Waterfall docs"; - presenceData.state = - document.querySelector("h1").textContent; - break; - } - case "velocity": { - presenceData.details = "Browsing Velocity docs"; - presenceData.state = - document.querySelector("h1").textContent; - break; - } - case "paper": { - switch (pathSplit[1]) { - case "admin": { - presenceData.details = "Reading Paper's Docs for Server Admins"; - presenceData.state = - document.querySelector("h1").textContent; - break; - } - case "dev": { - presenceData.details = "Reading Paper's Docs for Developers"; - presenceData.state = - document.querySelector("h1").textContent; - break; - } - default: { - if (pathSplit[3]) { - presenceData.details = "Reading Paper's Docs"; - presenceData.state = - document.querySelector("h1").textContent; - } else presenceData.details = "Reading Paper's Docs"; + switch (hostname) { + case 'hangar.papermc.io': + case 'hangar.papermc.dev': { + let pageType: PageType | undefined + if ( + pathSplit[0] + && pathSplit[1] + && attributes?.toString().includes(PageType.Project) + ) { + presenceData.details = `Viewing ${pathSplit[0]}'s plugin ${pathSplit[1]}` + pageType = PageType.Project + } + else if (attributes?.toString().includes(PageType.User)) { + presenceData.details = `Viewing ${pathSplit[0]}'s profile` + pageType = PageType.User + } + else { + presenceData.details = 'Browsing Hangar' + } + const variable = title.replace('| Hangar', '') + if (pageType === PageType.Project) { + presenceData.state = !pathSplit[2] + ? 'Viewing Project Overview' + : `Viewing Project ${variable.split('|')[0].trim()}` + // Project Image URL has no special class, so we're using the alt attribute of the image. + // I doubt this will change anytime soon. + presenceData.largeImageKey = document.querySelector( + `[alt=${pathSplit[0]}]`, + )?.src + presenceData.smallImageKey = logoURL + } + else if (pageType === PageType.User) { + const memberSince = new Date( + [...document.querySelectorAll('span')] + .find(span => span.textContent?.includes('Member')) + ?.textContent + ?.replace(/Member since /i, '') + .trim() ?? '', + ) + // I expect HangarMC's devs to eventually fix the capitalization on this span + const projectCount = Number( + [...document.querySelectorAll('span')] + .find(x => x.textContent?.toLowerCase().includes('projects')) + ?.textContent + ?.replace(/\D/g, '') + .trim(), + ) + const downloads = [...document.querySelectorAll('span')] + .filter(span => span.textContent?.includes('Downloads')) + .map(x => x.textContent?.replace(/\D/g, '').trim()) + .map(x => Number(x)) + .reduce((partialSum, a) => partialSum + a, 0) + presenceData.state = `${memberSince.toLocaleDateString()} | ${downloads} plugin downloads | ${projectCount} projects` + } + else { + presenceData.state = variable + } + pageType = pageType || PageType.Unknown + // We cannot add an "Download" button for Hangar, because the download button is only visible after multiple clicks. + // This is the best you're gonna get. + presenceData.buttons = [ + { + label: `View ${ + pageType === PageType.Unknown + ? 'Page' + : capitalize(pageType.toString()) + }`, + url: href, + }, + ] + break + } + case 'papermc.io': { + switch (pathSplit[0]) { + case 'downloads': { + switch (pathSplit[1]) { + case 'paper': { + presenceData.details = 'Browsing Paper downloads' + break + } + case 'velocity': { + presenceData.details = 'Browsing Velocity downloads' + break + } + case 'waterfall': { + presenceData.details = 'Browsing Waterfall downloads' + break + } + default: { + presenceData.details = 'Browsing download portal' + break + } + } + break + } + case 'community': { + presenceData.details = 'Viewing Community page' + break + } + case 'contribute': { + presenceData.details = 'Viewing Contribute page' + break + } + case 'sponsors': { + presenceData.details = 'Viewing Sponsors page' + break + } + case 'javadocs': { + presenceData.details = 'Viewing Javadocs portal' + break + } + case 'software': { + switch (pathSplit[1]) { + case 'paper': { + presenceData.details = 'Viewing Paper\'s homepage' + break + } + case 'velocity': { + presenceData.details = 'Viewing Velocity\'s homepage' + break + } + case 'waterfall': { + presenceData.details = 'Viewing Waterfall\'s homepage' + break + } + default: { + presenceData.details = 'Browsing software' + break + } + } + break + } + default: { + presenceData.details = location.pathname === '/' ? 'Viewing homepage' : 'Browsing website' + presenceData.state = document.querySelector('h1')?.textContent + break + } + } + break + } + case 'docs.papermc.io': { + switch (pathSplit[0]) { + case 'docs': { + switch (pathSplit[1]) { + case 'tutorials': { + presenceData.details = 'Browsing docs tutorials' + break + } + case 'details': { + presenceData.details = 'Reading about the API' + break + } + case 'modpacks': { + presenceData.details = 'Reading about modpacks' + break + } + default: { + presenceData.details = 'Browsing API information' + break + } + } + break + } + case 'api-spec': { + presenceData.details = 'Browsing API documentation' + break + } + case 'misc': { + presenceData.details = 'Browsing docs misc information' + presenceData.state = document.querySelector('h1')?.textContent + break + } + case 'waterfall': { + presenceData.details = 'Browsing Waterfall docs' + presenceData.state = document.querySelector('h1')?.textContent + break + } + case 'velocity': { + presenceData.details = 'Browsing Velocity docs' + presenceData.state = document.querySelector('h1')?.textContent + break + } + case 'paper': { + switch (pathSplit[1]) { + case 'admin': { + presenceData.details = 'Reading Paper\'s Docs for Server Admins' + presenceData.state = document.querySelector('h1')?.textContent + break + } + case 'dev': { + presenceData.details = 'Reading Paper\'s Docs for Developers' + presenceData.state = document.querySelector('h1')?.textContent + break + } + default: { + if (pathSplit[3]) { + presenceData.details = 'Reading Paper\'s Docs' + presenceData.state = document.querySelector('h1')?.textContent + } + else { + presenceData.details = 'Reading Paper\'s Docs' + } - break; - } - } - break; - } - default: { - presenceData.details = "Browsing docs"; - } - } - break; - } - case "jd.papermc.io": { - presenceData.details = "Browsing Javadocs"; - presenceData.state = - document.querySelector("h1").textContent; - break; - } - case "forums.papermc.io": { - switch (pathSplit[0]) { - case "threads": { - presenceData.details = "Reading a thread on the forums"; - presenceData.state = - document.querySelector("h1").textContent; - break; - } - case "members": { - const username = document.querySelector(".username").textContent; - presenceData.details = `Viewing ${username}'s profile on the forums`; - presenceData.state = document.querySelector( - ".memberHeader-blurb" - ).textContent; - presenceData.largeImageKey = document.querySelector( - `[alt=${username}]` - ).src; - presenceData.smallImageKey = logoURL; - break; - } - default: { - presenceData.details = "Browsing Forums"; - presenceData.state = - document.querySelector("h1")?.textContent || - document.querySelector("h2")?.textContent; - break; - } - } - break; - } - } + break + } + } + break + } + default: { + presenceData.details = 'Browsing docs' + } + } + break + } + case 'jd.papermc.io': { + presenceData.details = 'Browsing Javadocs' + presenceData.state = document.querySelector('h1')?.textContent + break + } + case 'forums.papermc.io': { + switch (pathSplit[0]) { + case 'threads': { + presenceData.details = 'Reading a thread on the forums' + presenceData.state = document.querySelector('h1')?.textContent + break + } + case 'members': { + const username = document.querySelector('.username')?.textContent + presenceData.details = `Viewing ${username}'s profile on the forums` + presenceData.state = document.querySelector( + '.memberHeader-blurb', + )?.textContent + presenceData.largeImageKey = document.querySelector( + `[alt=${username}]`, + )?.src + presenceData.smallImageKey = logoURL + break + } + default: { + presenceData.details = 'Browsing Forums' + presenceData.state = document.querySelector('h1')?.textContent + || document.querySelector('h2')?.textContent + break + } + } + break + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/Paramount+/metadata.json b/websites/P/Paramount+/metadata.json index a0fa21e6b88a..839583cf3630 100644 --- a/websites/P/Paramount+/metadata.json +++ b/websites/P/Paramount+/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Katsu", - "id": "713439286552297556" - }, - "service": "Paramount+", - "description": { - "en": "Paramount+ is an American subscription video on-demand over-the-top streaming service. This service contains Paramount+ originals and even includes shows from Nick, Nick. Jr and Nick Toons.", - "nl": "Paramount + is een Amerikaanse over-the-top streamingdienst voor video-on-demand met een abonnement. Deze service bevat Paramount + originelen en zelfs shows van Nick, Nick. Jr en Nick Toons." - }, - "url": [ - "www.paramountplus.com", - "paramountplus.com" - ], - "version": "2.0.8", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/thumbnail.png", - "color": "#6c8fd0", - "category": "videos", - "tags": [ - "entertainment", - "paramount-plus", - "paramountplus", - "paramount", - "video", - "media" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Katsu", + "id": "713439286552297556" + }, + "service": "Paramount+", + "description": { + "en": "Paramount+ is an American subscription video on-demand over-the-top streaming service. This service contains Paramount+ originals and even includes shows from Nick, Nick. Jr and Nick Toons.", + "nl": "Paramount + is een Amerikaanse over-the-top streamingdienst voor video-on-demand met een abonnement. Deze service bevat Paramount + originelen en zelfs shows van Nick, Nick. Jr en Nick Toons." + }, + "url": [ + "www.paramountplus.com", + "paramountplus.com" + ], + "version": "2.0.8", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/thumbnail.png", + "color": "#6c8fd0", + "category": "videos", + "tags": [ + "entertainment", + "paramount-plus", + "paramountplus", + "paramount", + "video", + "media" + ] +} diff --git a/websites/P/Paramount+/presence.ts b/websites/P/Paramount+/presence.ts index 66ca9eeecb0c..f632ae436861 100644 --- a/websites/P/Paramount+/presence.ts +++ b/websites/P/Paramount+/presence.ts @@ -1,187 +1,192 @@ const presence = new Presence({ - clientId: "821433038335377418", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); - -let title: string, seasonEpisode: string, liveTitle: string; + clientId: '821433038335377418', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) function pathIncludes(path: string, str: string) { - return path.includes(str); + return path.includes(str) } const enum Logos { - Paramount = "https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/logo.jpg", - CBS = "https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/0.png", - BET = "https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/1.png", - ComedyCentral = "https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/2.png", - MTV = "https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/3.png", - Nickelodeon = "https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/4.jpg", - Smithsonian = "https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/5.png", + Paramount = 'https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/logo.jpg', + CBS = 'https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/0.png', + BET = 'https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/1.png', + ComedyCentral = 'https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/2.png', + MTV = 'https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/3.png', + Nickelodeon = 'https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/4.jpg', + Smithsonian = 'https://cdn.rcd.gg/PreMiD/websites/P/Paramount+/assets/5.png', } -presence.on("UpdateData", async () => { - const strings = await presence.getStrings({ - play: "general.playing", - pause: "general.paused", - live: "general.live", - }); - let video: HTMLVideoElement = null; - const vidArea = document.querySelector(".video__player-area"), - presenceData: PresenceData = { - largeImageKey: Logos.Paramount, - startTimestamp: browsingTimestamp, - }, - { pathname: path } = document.location; - - switch (true) { - case pathIncludes(path, "/home"): - presenceData.details = "Browsing"; - presenceData.state = "Viewing home page"; - break; - - case pathIncludes(path, "/search"): - presenceData.details = "Searching"; - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Searching"; - break; - - case pathIncludes(path, "/shows"): { - if (vidArea && pathIncludes(path, "/video")) { - const data = JSON.parse( - document.querySelector('[type="application/ld+json"]').textContent - ); - - video = document.querySelector("video"); - - title = data.partOfSeries.name; - - seasonEpisode = `S${data.partOfSeason.seasonNumber}:E${data.episodeNumber} - ${data.name}`; - - if (title) presenceData.details = title; - - if (seasonEpisode) presenceData.state = seasonEpisode; - - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? strings.pause - : strings.play; - presenceData.largeImageKey = data.image || Logos.Paramount; - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else if ( - !vidArea && - document.querySelector('[type="application/ld+json"]') !== null - ) { - presenceData.details = "Viewing series"; - presenceData.state = JSON.parse( - document.querySelector('[type="application/ld+json"]').textContent - ).name; - } else { - presenceData.details = "Browsing"; - presenceData.state = "Viewing Shows"; - } - break; - } - - case pathIncludes(path, "/movies"): - if ( - vidArea && - document.querySelector("video.marqueeVideo") && - !vidArea.querySelector("video") - ) { - presenceData.details = "Previewing a movie"; - presenceData.state = JSON.parse( - document.querySelector('[type="application/ld+json"]').textContent - ).name; - } else if (vidArea && vidArea.querySelector("video")) { - const movData = JSON.parse( - document.querySelector('[type="application/ld+json"]').textContent - ); - - video = vidArea.querySelector("video"); - - if (movData.name) presenceData.state = movData.name; - presenceData.details = "Watching a movie"; - - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? strings.pause - : strings.play; - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else { - presenceData.details = "Browsing"; - presenceData.state = "Viewing Movies"; - } - break; - - case pathIncludes(path, "/live"): - liveTitle = document.querySelector( - ".video__metadata.padded-container > p" - ).textContent; - - presenceData.details = "Watching Live TV"; - presenceData.state = liveTitle; - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = strings.live; - break; - - case pathIncludes(path, "/brands"): - presenceData.details = "Browsing Brands"; - presenceData.state = "Viewing Brands"; - - if (pathIncludes(path, "/cbs/")) { - presenceData.details = "Browsing Brand"; - presenceData.state = "CBS"; - presenceData.largeImageKey = Logos.CBS; - } else if (pathIncludes(path, "/bet/")) { - presenceData.details = "Browsing Brand"; - presenceData.state = "BET"; - presenceData.largeImageKey = Logos.BET; - } else if (pathIncludes(path, "/comedy-central/")) { - presenceData.details = "Browsing Brand"; - presenceData.state = "Comedy Central"; - presenceData.largeImageKey = Logos.ComedyCentral; - } else if (pathIncludes(path, "/mtv/")) { - presenceData.details = "Browsing Brand"; - presenceData.state = "MTV"; - presenceData.largeImageKey = Logos.MTV; - } else if (pathIncludes(path, "/nickelodeon/")) { - presenceData.details = "Browsing Brand"; - presenceData.state = "Nickelodeon"; - presenceData.largeImageKey = Logos.Nickelodeon; - } else if (pathIncludes(path, "/smithsonian-channel/")) { - presenceData.details = "Browsing Brand"; - presenceData.state = "Smithsonian Channel"; - presenceData.largeImageKey = Logos.Smithsonian; - } - - break; - - case pathIncludes(path, "/my-list"): - presenceData.details = "Browsing My List"; - break; - - case pathIncludes(path, "/news"): - presenceData.details = "Browsing News"; - break; - - case pathIncludes(path, "/collections/sports-hub/"): - presenceData.details = "Browsing Sports Hub"; - break; - } - - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const strings = await presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', + live: 'general.live', + }) + const vidArea = document.querySelector('.video__player-area') + const presenceData: PresenceData = { + largeImageKey: Logos.Paramount, + startTimestamp: browsingTimestamp, + } + const { pathname: path } = document.location + + switch (true) { + case pathIncludes(path, '/home'): + presenceData.details = 'Browsing' + presenceData.state = 'Viewing home page' + break + + case pathIncludes(path, '/search'): + presenceData.details = 'Searching' + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Searching' + break + + case pathIncludes(path, '/shows'): { + if (vidArea && pathIncludes(path, '/video')) { + const data = JSON.parse( + document.querySelector('[type="application/ld+json"]')?.textContent ?? '{}', + ) + + const video = document.querySelector('video')! + + const title = data.partOfSeries.name + + const seasonEpisode = `S${data.partOfSeason.seasonNumber}:E${data.episodeNumber} - ${data.name}` + + if (title) + presenceData.details = title + presenceData.state = seasonEpisode + + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? strings.pause + : strings.play + presenceData.largeImageKey = data.image || Logos.Paramount; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else if ( + !vidArea + && document.querySelector('[type="application/ld+json"]') !== null + ) { + presenceData.details = 'Viewing series' + presenceData.state = JSON.parse( + document.querySelector('[type="application/ld+json"]')?.textContent ?? '{}', + ).name + } + else { + presenceData.details = 'Browsing' + presenceData.state = 'Viewing Shows' + } + break + } + + case pathIncludes(path, '/movies'): + if ( + vidArea + && document.querySelector('video.marqueeVideo') + && !vidArea.querySelector('video') + ) { + presenceData.details = 'Previewing a movie' + presenceData.state = JSON.parse( + document.querySelector('[type="application/ld+json"]')?.textContent ?? '{}', + ).name + } + else if (vidArea && vidArea.querySelector('video')) { + const movData = JSON.parse( + document.querySelector('[type="application/ld+json"]')?.textContent ?? '{}', + ) + + const video = vidArea.querySelector('video')! + + if (movData.name) + presenceData.state = movData.name + presenceData.details = 'Watching a movie' + + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? strings.pause + : strings.play; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else { + presenceData.details = 'Browsing' + presenceData.state = 'Viewing Movies' + } + break + + case pathIncludes(path, '/live'): { + const liveTitle = document.querySelector( + '.video__metadata.padded-container > p', + )?.textContent + + presenceData.details = 'Watching Live TV' + presenceData.state = liveTitle + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = strings.live + break + } + case pathIncludes(path, '/brands'): + presenceData.details = 'Browsing Brands' + presenceData.state = 'Viewing Brands' + + if (pathIncludes(path, '/cbs/')) { + presenceData.details = 'Browsing Brand' + presenceData.state = 'CBS' + presenceData.largeImageKey = Logos.CBS + } + else if (pathIncludes(path, '/bet/')) { + presenceData.details = 'Browsing Brand' + presenceData.state = 'BET' + presenceData.largeImageKey = Logos.BET + } + else if (pathIncludes(path, '/comedy-central/')) { + presenceData.details = 'Browsing Brand' + presenceData.state = 'Comedy Central' + presenceData.largeImageKey = Logos.ComedyCentral + } + else if (pathIncludes(path, '/mtv/')) { + presenceData.details = 'Browsing Brand' + presenceData.state = 'MTV' + presenceData.largeImageKey = Logos.MTV + } + else if (pathIncludes(path, '/nickelodeon/')) { + presenceData.details = 'Browsing Brand' + presenceData.state = 'Nickelodeon' + presenceData.largeImageKey = Logos.Nickelodeon + } + else if (pathIncludes(path, '/smithsonian-channel/')) { + presenceData.details = 'Browsing Brand' + presenceData.state = 'Smithsonian Channel' + presenceData.largeImageKey = Logos.Smithsonian + } + + break + + case pathIncludes(path, '/my-list'): + presenceData.details = 'Browsing My List' + break + + case pathIncludes(path, '/news'): + presenceData.details = 'Browsing News' + break + + case pathIncludes(path, '/collections/sports-hub/'): + presenceData.details = 'Browsing Sports Hub' + break + } + + presence.setActivity(presenceData) +}) diff --git a/websites/P/Pastebin/metadata.json b/websites/P/Pastebin/metadata.json index 793d34b23cde..34ce6efeeac2 100644 --- a/websites/P/Pastebin/metadata.json +++ b/websites/P/Pastebin/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "thatdevjon", - "id": "570656255610191874" - }, - "service": "Pastebin", - "description": { - "en": "Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.", - "nl": "Pastebin.com is de nummer één plak tool sinds 2002. Pastebin is een website waar je tekst online kunt bewaren voor een bepaalde tijd." - }, - "url": [ - "pastebin.com", - "www.pastebin.com" - ], - "version": "1.3.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pastebin/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pastebin/assets/thumbnail.png", - "color": "#023859", - "category": "other", - "tags": [ - "text" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "thatdevjon", + "id": "570656255610191874" + }, + "service": "Pastebin", + "description": { + "en": "Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.", + "nl": "Pastebin.com is de nummer één plak tool sinds 2002. Pastebin is een website waar je tekst online kunt bewaren voor een bepaalde tijd." + }, + "url": [ + "pastebin.com", + "www.pastebin.com" + ], + "version": "1.3.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pastebin/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pastebin/assets/thumbnail.png", + "color": "#023859", + "category": "other", + "tags": [ + "text" + ] +} diff --git a/websites/P/Pastebin/presence.ts b/websites/P/Pastebin/presence.ts index c4947306e76e..1a290cd1ae42 100644 --- a/websites/P/Pastebin/presence.ts +++ b/websites/P/Pastebin/presence.ts @@ -1,30 +1,33 @@ const presence = new Presence({ - clientId: "630194809763790871", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '630194809763790871', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Pastebin/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - urlData = window.location.pathname.replace(/^\/([^/]*).*$/, "$1"); - let currentPage = document.title.slice(15); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Pastebin/assets/logo.png', + startTimestamp: browsingTimestamp, + } + // eslint-disable-next-line regexp/no-super-linear-backtracking + const urlData = window.location.pathname.replace(/^\/([^/]*).*$/, '$1') + let currentPage = document.title.slice(15) - if (urlData.length === 8) { - presenceData.details = "Viewing a paste"; - presenceData.state = `${document - .querySelector(".paste_box_line1") - .getAttribute("title")} | ${urlData}`; - } else { - presenceData.details = "Browsing pastebin"; + if (urlData.length === 8) { + presenceData.details = 'Viewing a paste' + presenceData.state = `${document + .querySelector('.paste_box_line1') + ?.getAttribute('title')} | ${urlData}` + } + else { + presenceData.details = 'Browsing pastebin' - if (currentPage === "#1 paste tool since 2002!") currentPage = "Homepage"; + if (currentPage === '#1 paste tool since 2002!') + currentPage = 'Homepage' - presenceData.state = currentPage; - } + presenceData.state = currentPage + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/Patreon/metadata.json b/websites/P/Patreon/metadata.json index f676d35e9911..5296888bc1f6 100644 --- a/websites/P/Patreon/metadata.json +++ b/websites/P/Patreon/metadata.json @@ -1,32 +1,32 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "RisingSunLight", - "id": "240521747852558347" - }, - "service": "Patreon", - "description": { - "en": "Patreon is the best place for creators to build memberships by providing exclusive access to their work and a deeper connection with their communities.", - "fr": "Patreon est le meilleur endroit pour les créateurs afin de créer de l'adhésion en fournissant des accès exclusifs à leur travail et une connexion plus profonde avec leur communauté." - }, - "url": "www.patreon.com", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Patreon/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Patreon/assets/thumbnail.png", - "color": "#F1465A", - "category": "other", - "tags": [ - "patreon", - "creator", - "patronage" - ], - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "RisingSunLight", + "id": "240521747852558347" + }, + "service": "Patreon", + "description": { + "en": "Patreon is the best place for creators to build memberships by providing exclusive access to their work and a deeper connection with their communities.", + "fr": "Patreon est le meilleur endroit pour les créateurs afin de créer de l'adhésion en fournissant des accès exclusifs à leur travail et une connexion plus profonde avec leur communauté." + }, + "url": "www.patreon.com", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Patreon/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Patreon/assets/thumbnail.png", + "color": "#F1465A", + "category": "other", + "tags": [ + "patreon", + "creator", + "patronage" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/P/Patreon/presence.ts b/websites/P/Patreon/presence.ts index df7beed99432..18211e8a9572 100644 --- a/websites/P/Patreon/presence.ts +++ b/websites/P/Patreon/presence.ts @@ -1,114 +1,123 @@ -const presence = new Presence({ clientId: "1013183483750907904" }), - browsingTimestamp = Math.floor(Date.now() / 1000), - statics: { - [name: string]: string; - } = { - "": "Viewing homepage", - pricing: "Comparing all plans", - explore: "Exploring Patreon", - home: "Viewing their feed", - login: "Log in Patreon", - }, - slideshow = presence.createSlideshow(); +const presence = new Presence({ clientId: '1013183483750907904' }) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const statics: { + [name: string]: string +} = { + '': 'Viewing homepage', + 'pricing': 'Comparing all plans', + 'explore': 'Exploring Patreon', + 'home': 'Viewing their feed', + 'login': 'Log in Patreon', +} +const slideshow = presence.createSlideshow() const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Patreon/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Patreon/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - startTimestamp: browsingTimestamp, - largeImageKey: Assets.Logo, - }, - presenceDataSlide: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - showButtons = await presence.getSetting("buttons"), - { pathname, href } = document.location, - pathArr = pathname.split("/"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + startTimestamp: browsingTimestamp, + largeImageKey: Assets.Logo, + } + const presenceDataSlide: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const showButtons = await presence.getSetting('buttons') + const { pathname, href } = document.location + const pathArr = pathname.split('/') - switch (pathArr[1]) { - case "product": - presenceData.details = "Viewing a plan"; - presenceData.state = `Plan: ${pathArr[2]}`; - break; - case "c": - presenceData.details = "Viewing a page for creators"; - presenceData.state = `For: ${ - { - podcasts: "podcasters", - video: "video creators", - music: "musicians", - visualartists: "visual artists", - communities: "community leaders", - writing: "writers & journalists", - gaming: "gaming creators", - nonprofits: "nonprofit organizations", - "tutorials-and-education": "education & tutorial creators", - "local-businesses": "local businesses", - }[pathArr[2]] - }`; - break; - case "apps": - if (pathArr.length === 2) presenceData.details = "Viewing apps available"; - else { - presenceData.details = "Viewing an app"; - presenceData.state = document.querySelector( - ".Text_variantDisplayTextLg__NwCo5" - ).textContent; - presenceData.buttons = [{ label: "View app", url: href }]; - } - break; - case "settings": - presenceData.details = "Editing their settings"; - presenceData.state = `Page: ${ - document.querySelectorAll('a[aria-current="page"]')[1].textContent - }`; - break; - case "search": - if (href.includes("?q=")) { - presenceData.details = "Searching"; - presenceData.state = `Query: ${document - .querySelector("input") - .getAttribute("value")}`; - presenceData.smallImageKey = Assets.Search; - } else presenceData.details = "On searching page"; - break; - case "posts": - presenceData.details = presenceDataSlide.details = "Viewing a post"; - presenceData.state = document.querySelector( - 'span[data-tag="post-title"]' - ).textContent; - presenceDataSlide.state = `From ${ - document.querySelector('div[data-tag="metadata-wrapper"] > div > div') - .textContent - }`; + switch (pathArr[1]) { + case 'product': + presenceData.details = 'Viewing a plan' + presenceData.state = `Plan: ${pathArr[2]}` + break + case 'c': + presenceData.details = 'Viewing a page for creators' + presenceData.state = `For: ${ + { + 'podcasts': 'podcasters', + 'video': 'video creators', + 'music': 'musicians', + 'visualartists': 'visual artists', + 'communities': 'community leaders', + 'writing': 'writers & journalists', + 'gaming': 'gaming creators', + 'nonprofits': 'nonprofit organizations', + 'tutorials-and-education': 'education & tutorial creators', + 'local-businesses': 'local businesses', + }[pathArr[2]] + }` + break + case 'apps': + if (pathArr.length === 2) { + presenceData.details = 'Viewing apps available' + } + else { + presenceData.details = 'Viewing an app' + presenceData.state = document.querySelector( + '.Text_variantDisplayTextLg__NwCo5', + )?.textContent + presenceData.buttons = [{ label: 'View app', url: href }] + } + break + case 'settings': + presenceData.details = 'Editing their settings' + presenceData.state = `Page: ${ + document.querySelectorAll('a[aria-current="page"]')[1].textContent + }` + break + case 'search': + if (href.includes('?q=')) { + presenceData.details = 'Searching' + presenceData.state = `Query: ${document + .querySelector('input') + ?.getAttribute('value')}` + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = 'On searching page' + } + break + case 'posts': + presenceData.details = presenceDataSlide.details = 'Viewing a post' + presenceData.state = document.querySelector( + 'span[data-tag="post-title"]', + )?.textContent + presenceDataSlide.state = `From ${ + document.querySelector('div[data-tag="metadata-wrapper"] > div > div') + ?.textContent + }` - presenceData.buttons = presenceDataSlide.buttons = [ - { label: "View Post", url: href }, - ]; + presenceData.buttons = presenceDataSlide.buttons = [ + { label: 'View Post', url: href }, + ] - slideshow.addSlide("slidePostName", presenceData, 5000); - slideshow.addSlide("slideCreatorName", presenceDataSlide, 5000); - break; - default: - if (Object.keys(statics).includes(pathArr[1])) - presenceData.details = statics[pathArr[1]]; - else if (pathArr[1].includes("messages")) - presenceData.details = "Reading their messages"; - else { - presenceData.details = "Viewing a creator"; - presenceData.state = document.querySelector("h1").textContent.trim(); - presenceData.buttons = [{ label: "View Creator", url: href }]; - } - } + slideshow.addSlide('slidePostName', presenceData, 5000) + slideshow.addSlide('slideCreatorName', presenceDataSlide, 5000) + break + default: + if (Object.keys(statics).includes(pathArr[1])) { + presenceData.details = statics[pathArr[1]] + } + else if (pathArr[1].includes('messages')) { + presenceData.details = 'Reading their messages' + } + else { + presenceData.details = 'Viewing a creator' + presenceData.state = document.querySelector('h1')?.textContent?.trim() + presenceData.buttons = [{ label: 'View Creator', url: href }] + } + } - if (!showButtons) { - delete presenceData.buttons; - delete presenceDataSlide.buttons; - } + if (!showButtons) { + delete presenceData.buttons + delete presenceDataSlide.buttons + } - 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/P/PcPartPicker/metadata.json b/websites/P/PcPartPicker/metadata.json index 8ddb2b466ee8..6fd246cd8c2b 100644 --- a/websites/P/PcPartPicker/metadata.json +++ b/websites/P/PcPartPicker/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "वाह्य", - "id": "819696394180100106" - }, - "service": "PcPartPicker", - "description": { - "en": "Pick parts. Build your PC. Compare and Share." - }, - "url": "pcpartpicker.com", - "regExp": "([a-z]{2}.|)pcpartpicker.com", - "version": "1.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PcPartPicker/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PcPartPicker/assets/thumbnail.png", - "color": "#c3a041", - "category": "other", - "tags": [ - "diy", - "pc-builder", - "building-guides" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "वाह्य", + "id": "819696394180100106" + }, + "service": "PcPartPicker", + "description": { + "en": "Pick parts. Build your PC. Compare and Share." + }, + "url": "pcpartpicker.com", + "regExp": "([a-z]{2}.|)pcpartpicker.com", + "version": "1.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PcPartPicker/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PcPartPicker/assets/thumbnail.png", + "color": "#c3a041", + "category": "other", + "tags": [ + "diy", + "pc-builder", + "building-guides" + ] +} diff --git a/websites/P/PcPartPicker/presence.ts b/websites/P/PcPartPicker/presence.ts index c3173da92cd2..e7d2e6398003 100644 --- a/websites/P/PcPartPicker/presence.ts +++ b/websites/P/PcPartPicker/presence.ts @@ -1,129 +1,142 @@ const presence = new Presence({ - clientId: "857912880947265566", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '857912880947265566', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PcPartPicker/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, href } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PcPartPicker/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, href } = document.location - if (pathname === "/") presenceData.details = "Browsing Home Page"; - else if (pathname.startsWith("/guide/")) { - const title: HTMLHeadingElement = document.querySelector( - "h1.pageTitle.guide__title" - ), - price: HTMLTableDataCellElement = document.querySelector( - "tr.tr__total.tr__total--final > td.td__price" - ); - presenceData.details = title - ? `Browsing ${title.textContent}` - : "Browsing Guide"; - if (price) presenceData.state = `Price: ${price.textContent}`; - presenceData.buttons = [ - { - label: "Browse Guide", - url: href, - }, - ]; - } else if (pathname.startsWith("/b/")) { - const build: HTMLHeadingElement = document.querySelector( - "h1.pageTitle.build__name" - ), - user: HTMLAnchorElement = document.querySelector("div.user > a"), - price: HTMLTableDataCellElement = document.querySelector( - "tr.tr__total.tr__total--grandtotal > td.td__price" - ); - if (build && user) - presenceData.details = `Viweing ${build.textContent} by ${user.textContent}`; - if (price) presenceData.state = `Price: ${price.textContent}`; - presenceData.buttons = [ - { - label: "View Build", - url: href, - }, - ]; - } else if (pathname.startsWith("/product/")) { - const productType: HTMLAnchorElement = document.querySelector( - "section.breadcrumb > ol.list-unstyled > li > a" - ), - productName: HTMLHeadingElement = document.querySelector("h1.pageTitle"); - if (productType) - presenceData.details = `Looking at ${productType.textContent}`; - if (productName) presenceData.state = productName.textContent; - presenceData.buttons = [ - { - label: "Look at product", - url: href, - }, - ]; - } else if (pathname.startsWith("/products/")) { - presenceData.details = - pathname === "/products/" - ? "Viewing All Product List" - : `Looking for ${pathname - .substring(10, pathname.lastIndexOf("/")) - .split("-") - .join(" ") - .replace(/\b\w/g, c => c.toUpperCase())}`; // Capitalize first char of every word - } else if (pathname.startsWith("/user/")) { - const section = pathname.split("'/")[3]; - presenceData.details = `Viewing ${pathname.split("/")[2]}'s ${ - section === "" ? "profile" : section - }`; - presenceData.buttons = [ - { - label: "View User", - url: href, - }, - ]; - } else if (pathname.startsWith("/list/")) { - const price: HTMLTableDataCellElement = document.querySelector( - "tr.tr__total.tr__total--final > td.td__price" - ), - link: HTMLInputElement = document.querySelector( - "div.actionBox.actionBox__permalink > input.text-input" - ); - presenceData.details = "Building System"; - presenceData.state = price ? `Price: ${price.textContent}` : "Price: $0"; - if (link) { - presenceData.buttons = [ - { - label: "View System", - url: link.value, - }, - ]; - } - } else if (pathname.startsWith("/forums/")) { - const topic: HTMLHeadingElement = document.querySelector("h1.pageTitle"); - presenceData.details = "Browsing Forums"; - if (topic) { - presenceData.state = topic.textContent; - presenceData.buttons = [ - { - label: "View Thread", - url: href, - }, - ]; - } - } else if (pathname.startsWith("/trends/")) { - presenceData.details = "Looking at price trends"; - if (pathname !== "/trends/") { - presenceData.state = `for ${ - document.querySelector("h1.pageTitle").textContent - }`; - } - presenceData.buttons = [ - { - label: "View Trends", - url: href, - }, - ]; - } else if (pathname.startsWith("/builds/")) - presenceData.details = "Viewing Completed Builds"; - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (pathname === '/') { + presenceData.details = 'Browsing Home Page' + } + else if (pathname.startsWith('/guide/')) { + const title = document.querySelector( + 'h1.pageTitle.guide__title', + ) + const price = document.querySelector( + 'tr.tr__total.tr__total--final > td.td__price', + ) + presenceData.details = title + ? `Browsing ${title.textContent}` + : 'Browsing Guide' + if (price) + presenceData.state = `Price: ${price.textContent}` + presenceData.buttons = [ + { + label: 'Browse Guide', + url: href, + }, + ] + } + else if (pathname.startsWith('/b/')) { + const build = document.querySelector( + 'h1.pageTitle.build__name', + ) + const user = document.querySelector('div.user > a') + const price = document.querySelector( + 'tr.tr__total.tr__total--grandtotal > td.td__price', + ) + if (build && user) + presenceData.details = `Viweing ${build.textContent} by ${user.textContent}` + if (price) + presenceData.state = `Price: ${price.textContent}` + presenceData.buttons = [ + { + label: 'View Build', + url: href, + }, + ] + } + else if (pathname.startsWith('/product/')) { + const productType = document.querySelector( + 'section.breadcrumb > ol.list-unstyled > li > a', + ) + const productName = document.querySelector('h1.pageTitle') + if (productType) + presenceData.details = `Looking at ${productType.textContent}` + if (productName) + presenceData.state = productName.textContent + presenceData.buttons = [ + { + label: 'Look at product', + url: href, + }, + ] + } + else if (pathname.startsWith('/products/')) { + presenceData.details = pathname === '/products/' + ? 'Viewing All Product List' + : `Looking for ${pathname + .substring(10, pathname.lastIndexOf('/')) + .split('-') + .join(' ') + .replace(/\b\w/g, c => c.toUpperCase())}` // Capitalize first char of every word + } + else if (pathname.startsWith('/user/')) { + const section = pathname.split('\'/')[3] + presenceData.details = `Viewing ${pathname.split('/')[2]}'s ${ + section === '' ? 'profile' : section + }` + presenceData.buttons = [ + { + label: 'View User', + url: href, + }, + ] + } + else if (pathname.startsWith('/list/')) { + const price = document.querySelector( + 'tr.tr__total.tr__total--final > td.td__price', + ) + const link = document.querySelector( + 'div.actionBox.actionBox__permalink > input.text-input', + ) + presenceData.details = 'Building System' + presenceData.state = price ? `Price: ${price.textContent}` : 'Price: $0' + if (link) { + presenceData.buttons = [ + { + label: 'View System', + url: link.value, + }, + ] + } + } + else if (pathname.startsWith('/forums/')) { + const topic = document.querySelector('h1.pageTitle') + presenceData.details = 'Browsing Forums' + if (topic) { + presenceData.state = topic.textContent + presenceData.buttons = [ + { + label: 'View Thread', + url: href, + }, + ] + } + } + else if (pathname.startsWith('/trends/')) { + presenceData.details = 'Looking at price trends' + if (pathname !== '/trends/') { + presenceData.state = `for ${ + document.querySelector('h1.pageTitle')?.textContent + }` + } + presenceData.buttons = [ + { + label: 'View Trends', + url: href, + }, + ] + } + else if (pathname.startsWith('/builds/')) { + presenceData.details = 'Viewing Completed Builds' + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/PeaceScans/metadata.json b/websites/P/PeaceScans/metadata.json index 4a4d4c8fdbd2..77296efe647b 100644 --- a/websites/P/PeaceScans/metadata.json +++ b/websites/P/PeaceScans/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "293803241110503426", - "name": "weemizo" - }, - "service": "PeaceScans", - "description": { - "en": "Read Manga Online For Free", - "pl": "Czytaj mangę online za darmo" - }, - "url": [ - "peacescans.life", - "www.peacescans.life" - ], - "version": "1.0.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PeaceScans/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PeaceScans/assets/thumbnail.png", - "color": "#154360", - "category": "anime", - "tags": [ - "manga" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "293803241110503426", + "name": "weemizo" + }, + "service": "PeaceScans", + "description": { + "en": "Read Manga Online For Free", + "pl": "Czytaj mangę online za darmo" + }, + "url": [ + "peacescans.life", + "www.peacescans.life" + ], + "version": "1.0.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PeaceScans/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PeaceScans/assets/thumbnail.png", + "color": "#154360", + "category": "anime", + "tags": [ + "manga" + ] +} diff --git a/websites/P/PeaceScans/presence.ts b/websites/P/PeaceScans/presence.ts index aad9cc5389c8..118ec7873485 100644 --- a/websites/P/PeaceScans/presence.ts +++ b/websites/P/PeaceScans/presence.ts @@ -1,43 +1,47 @@ const presence = new Presence({ - clientId: "1121489312370933780", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1121489312370933780', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PeaceScans/assets/0.png", - startTimestamp: browsingTimestamp, - }, - { pathname } = document.location, - site: { [key: string]: string } = { - "index.html": "Viewing homepage", - index: "Viewing homepage", // yes i really had to create three ways to read homepage - "": "Viewing homepage", - Recruitment: "Considering recruitment", - Donate: "Donating", - }, - animeCheckTitle = document.querySelector("body > section h3")?.textContent, - animeTitle = document.querySelector( - "body > section > div > div > div.anime__details__episodes > div > h5" - )?.textContent, - checkIfHomepage = document.querySelector( - "body > header > div > div.row > div.col-lg-8 > div > nav > ul > li.active > a" - ); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PeaceScans/assets/0.png', + startTimestamp: browsingTimestamp, + } + const { pathname } = document.location + const site: { [key: string]: string } = { + 'index.html': 'Viewing homepage', + 'index': 'Viewing homepage', // yes i really had to create three ways to read homepage + '': 'Viewing homepage', + 'Recruitment': 'Considering recruitment', + 'Donate': 'Donating', + } + const animeCheckTitle = document.querySelector('body > section h3')?.textContent + const animeTitle = document.querySelector( + 'body > section > div > div > div.anime__details__episodes > div > h5', + )?.textContent + const checkIfHomepage = document.querySelector( + 'body > header > div > div.row > div.col-lg-8 > div > nav > ul > li.active > a', + ) - if (document.querySelector("body > iframe") !== null) - presenceData.details = `Currently reading ${animeTitle}`; - else if (checkIfHomepage) - presenceData.details = site[pathname.split("/").at(-1)]; - else if ( - document.querySelector("body > section > div.container > div > div.row") - ) { - presenceData.details = - typeof animeCheckTitle !== "undefined" - ? `Checking "${animeCheckTitle}"` - : "Reading a manga"; - } else presenceData.details = "Viewing website"; + if (document.querySelector('body > iframe') !== null) { + presenceData.details = `Currently reading ${animeTitle}` + } + else if (checkIfHomepage) { + presenceData.details = site[pathname.split('/').at(-1)!] + } + else if ( + document.querySelector('body > section > div.container > div > div.row') + ) { + presenceData.details = typeof animeCheckTitle !== 'undefined' + ? `Checking "${animeCheckTitle}"` + : 'Reading a manga' + } + else { + presenceData.details = 'Viewing website' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/Peacock/metadata.json b/websites/P/Peacock/metadata.json index 13fa20d57257..3eaf00219ecd 100644 --- a/websites/P/Peacock/metadata.json +++ b/websites/P/Peacock/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kedi", - "id": "238668511222693888" - }, - "service": "Peacock", - "description": { - "en": "Watch TV shows and movies online with Peacock. Stream iconic shows and movies, exclusive Peacock originals, live news and sports and more.", - "nl": "Bekijk tv-programma's en films online met Peacock. Stream iconische shows en films, exclusieve Peacock-originelen, live nieuws en sport en meer." - }, - "url": [ - "www.peacocktv.com", - "peacocktv.com" - ], - "version": "1.0.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Peacock/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Peacock/assets/thumbnail.png", - "color": "#FCCC12", - "category": "videos", - "tags": [ - "video", - "tv", - "movies" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Kedi", + "id": "238668511222693888" + }, + "service": "Peacock", + "description": { + "en": "Watch TV shows and movies online with Peacock. Stream iconic shows and movies, exclusive Peacock originals, live news and sports and more.", + "nl": "Bekijk tv-programma's en films online met Peacock. Stream iconische shows en films, exclusieve Peacock-originelen, live nieuws en sport en meer." + }, + "url": [ + "www.peacocktv.com", + "peacocktv.com" + ], + "version": "1.0.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Peacock/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Peacock/assets/thumbnail.png", + "color": "#FCCC12", + "category": "videos", + "tags": [ + "video", + "tv", + "movies" + ] +} diff --git a/websites/P/Peacock/presence.ts b/websites/P/Peacock/presence.ts index 28c3b1401be5..6531ffde9b8b 100644 --- a/websites/P/Peacock/presence.ts +++ b/websites/P/Peacock/presence.ts @@ -1,87 +1,91 @@ const presence = new Presence({ - clientId: "767402228825980929", - }), - newStrings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - live: "general.live", - }), - elapsed = Math.floor(Date.now() / 1000); + clientId: '767402228825980929', +}) +const newStrings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', + live: 'general.live', +}) +const elapsed = Math.floor(Date.now() / 1000) -let strings: Awaited; +let strings: Awaited -presence.on("UpdateData", async () => { - let extra = "..."; +presence.on('UpdateData', async () => { + let extra = '...' - const path = window.location.pathname, - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Peacock/assets/logo.png", - startTimestamp: elapsed, - }; + const path = window.location.pathname + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Peacock/assets/logo.png', + startTimestamp: elapsed, + } - strings ??= await newStrings; + strings ??= await newStrings - if (path.includes("/movies/highlights")) extra = " Movies"; - else if (path.includes("/watch/tv/highlights")) extra = " TV Shows"; - else if (path.includes("/watch/kids/highlights")) extra = " Kids"; - else if (path.includes("/watch/sports/highlights")) extra = " Sports"; - else if (path.includes("/watch/latino/highlights")) extra = " Latino"; + if (path.includes('/movies/highlights')) + extra = ' Movies' + else if (path.includes('/watch/tv/highlights')) + extra = ' TV Shows' + else if (path.includes('/watch/kids/highlights')) + extra = ' Kids' + else if (path.includes('/watch/sports/highlights')) + extra = ' Sports' + else if (path.includes('/watch/latino/highlights')) + extra = ' Latino' - presenceData.details = `Browsing${extra}`; + presenceData.details = `Browsing${extra}` - if (path.includes("/watch/search")) presenceData.details = "Searching..."; + if (path.includes('/watch/search')) + presenceData.details = 'Searching...' - if (path.includes("/watch/playback") || path.includes("/watch/asset")) { - const video = document.querySelector( - ".video-player-component video" - ); - if (video) { - const title = - document.querySelector(".playback-header__title") || - document.querySelector(".playback-metadata__container-title"), - timestamps = presence.getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ), - live = timestamps[1] === Infinity, - desc = - document.querySelector( - ".playback-metadata__container-episode-metadata-info" - ) || - document.querySelector(".playback-metadata__container-description") || - document.querySelector( - ".swiper-slide-active .playlist-item-overlay__container-title" - ); + if (path.includes('/watch/playback') || path.includes('/watch/asset')) { + const video = document.querySelector( + '.video-player-component video', + ) + if (video) { + const title = document.querySelector('.playback-header__title') + || document.querySelector('.playback-metadata__container-title') + const timestamps = presence.getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) + const live = timestamps[1] === Infinity + const desc = document.querySelector( + '.playback-metadata__container-episode-metadata-info', + ) + || document.querySelector('.playback-metadata__container-description') + || document.querySelector( + '.swiper-slide-active .playlist-item-overlay__container-title', + ) - if (desc) presenceData.state = desc.textContent; + if (desc) + presenceData.state = desc.textContent - if (title) { - presenceData.details = title.textContent; - if (path.includes("/watch/playback/playlist")) - presenceData.details += " Playlist"; - } + if (title) { + presenceData.details = title.textContent + if (path.includes('/watch/playback/playlist')) + presenceData.details += ' Playlist' + } - presenceData.smallImageKey = live - ? Assets.Live - : video.paused - ? Assets.Pause - : Assets.Play; - presenceData.smallImageText = live - ? strings.live - : video.paused - ? strings.pause - : strings.play; + presenceData.smallImageKey = live + ? Assets.Live + : video.paused + ? Assets.Pause + : Assets.Play + presenceData.smallImageText = live + ? strings.live + : video.paused + ? strings.pause + : strings.play - if (!live) - [presenceData.startTimestamp, presenceData.endTimestamp] = timestamps; + if (!live) + [presenceData.startTimestamp, presenceData.endTimestamp] = timestamps - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } - } + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/Peario/metadata.json b/websites/P/Peario/metadata.json index efc39ce01eef..bb781a714b9f 100644 --- a/websites/P/Peario/metadata.json +++ b/websites/P/Peario/metadata.json @@ -1,42 +1,42 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dark_Ville", - "id": "638080361179512853" - }, - "service": "Peario", - "description": { - "nl": "Deel je streams. Peario zorgt er voor dat je Stremio-streams kunt delen met je vrienden.", - "en": "Share your streams. Peario allows you to watch Stremio streams with your friends." - }, - "url": "peario.xyz", - "version": "1.0.12", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Peario/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Peario/assets/thumbnail.png", - "color": "#BEFDEB", - "category": "videos", - "tags": [ - "streamio", - "peario", - "videos", - "streams" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "buttons", - "if": { - "privacy": false - }, - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dark_Ville", + "id": "638080361179512853" + }, + "service": "Peario", + "description": { + "nl": "Deel je streams. Peario zorgt er voor dat je Stremio-streams kunt delen met je vrienden.", + "en": "Share your streams. Peario allows you to watch Stremio streams with your friends." + }, + "url": "peario.xyz", + "version": "1.0.12", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Peario/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Peario/assets/thumbnail.png", + "color": "#BEFDEB", + "category": "videos", + "tags": [ + "streamio", + "peario", + "videos", + "streams" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "buttons", + "if": { + "privacy": false + }, + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/P/Peario/presence.ts b/websites/P/Peario/presence.ts index 38164062a9a2..c07251e0f64c 100644 --- a/websites/P/Peario/presence.ts +++ b/websites/P/Peario/presence.ts @@ -1,111 +1,137 @@ const presence = new Presence({ - clientId: "969204609845428234", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '969204609845428234', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) interface Data { - meta: { - name: string; - }[]; + meta: { + name: string + }[] } -let cached: Data; +let cached: Data async function fetchWithoutVideo() { - const split = window.location.href.split("/"); - if (!cached || !JSON.stringify(cached).includes(split[5])) { - if ( - document.querySelector( - "#app > div > div > div > div.loading > div > ion-icon" - ) - ) - return; - const fetched = await fetch( - `https://v3-cinemeta.strem.io/meta/${split[4]}/${split[5]}.json` - ).then(x => x.json()); - cached = fetched; - return fetched; - } else return cached; + const split = window.location.href.split('/') + if (!cached || !JSON.stringify(cached).includes(split[5])) { + if ( + document.querySelector( + '#app > div > div > div > div.loading > div > ion-icon', + ) + ) { + return + } + const fetched = await fetch( + `https://v3-cinemeta.strem.io/meta/${split[4]}/${split[5]}.json`, + ).then(x => x.json()) + cached = fetched + return fetched + } + else { + return cached + } } async function fetchWithVideo(video: HTMLMediaElement) { - if ( - !cached || - !JSON.stringify(cached).includes(window.location.href.split("/")[5]) - ) { - const fetched = await fetch( - `https://v3-cinemeta.strem.io/meta/movie/${ - video.getAttribute("poster").split("/")[5] - }.json` - ).then(x => x.json()); - cached = fetched; - return fetched; - } else return cached; + if ( + !cached + || !JSON.stringify(cached).includes(window.location.href.split('/')[5]) + ) { + const fetched = await fetch( + `https://v3-cinemeta.strem.io/meta/movie/${ + video.getAttribute('poster')?.split('/')[5] + }.json`, + ).then(x => x.json()) + cached = fetched + return fetched + } + else { + return cached + } } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Peario/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - video = document.querySelector( - "#app > div > div > div > div.player > video" - ), - page = window.location.pathname, - [privacy, buttons] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("buttons"), - ]); - if (privacy && !video) presenceData.details = "Browsing..."; - else if (privacy && video) presenceData.details = "Watching..."; - else if (document.querySelector("#addons")) presenceData.details = "Addons"; - else if ( - document.querySelector( - "#app > div.modal > div.inner > div.title.secondary > ion-icon" - ) - ) - presenceData.details = "Settings"; - else if (page.includes("search")) { - const search = document.querySelector( - "#app > div > div > div > div > input" - ); - if (search?.value) { - presenceData.details = "Searching for:"; - presenceData.state = search.value; - } else presenceData.details = "Browsing..."; - } else if (page.includes("stream") || page.includes("room")) { - presenceData.buttons = [ - { - label: "Join Room", - url: document.location.href, - }, - ]; - if ( - document.querySelector( - "#app > div > div > div > div.player > div.lock-screen > div > button" - ) - ) - presenceData.details = "Waiting..."; - else if (video) { - delete presenceData.startTimestamp; - const fetched = await fetchWithVideo(video); - if (fetched) presenceData.details = fetched.meta.name; - presenceData.smallImageText = `${ - document.querySelector("#app > div > div > div > div.users.show > div") - .textContent - } Viewers`; - if (video.paused || isNaN(video.duration)) { - delete presenceData.endTimestamp; - presenceData.smallImageKey = Assets.Pause; - } else { - presenceData.smallImageKey = Assets.Play; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - } - } else { - const fetched = await fetchWithoutVideo(); - if (fetched) presenceData.details = fetched.meta.name; - } - } else presenceData.details = "Browsing..."; - if (!buttons) delete presenceData.buttons; - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Peario/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const video = document.querySelector( + '#app > div > div > div > div.player > video', + ) + const page = window.location.pathname + const [privacy, buttons] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('buttons'), + ]) + if (privacy && !video) { + presenceData.details = 'Browsing...' + } + else if (privacy && video) { + presenceData.details = 'Watching...' + } + else if (document.querySelector('#addons')) { + presenceData.details = 'Addons' + } + else if ( + document.querySelector( + '#app > div.modal > div.inner > div.title.secondary > ion-icon', + ) + ) { + presenceData.details = 'Settings' + } + else if (page.includes('search')) { + const search = document.querySelector( + '#app > div > div > div > div > input', + ) + if (search?.value) { + presenceData.details = 'Searching for:' + presenceData.state = search.value + } + else { + presenceData.details = 'Browsing...' + } + } + else if (page.includes('stream') || page.includes('room')) { + presenceData.buttons = [ + { + label: 'Join Room', + url: document.location.href, + }, + ] + if ( + document.querySelector( + '#app > div > div > div > div.player > div.lock-screen > div > button', + ) + ) { + presenceData.details = 'Waiting...' + } + else if (video) { + delete presenceData.startTimestamp + const fetched = await fetchWithVideo(video) + if (fetched) + presenceData.details = fetched.meta.name + presenceData.smallImageText = `${ + document.querySelector('#app > div > div > div > div.users.show > div') + ?.textContent + } Viewers` + if (video.paused || Number.isNaN(video.duration)) { + delete presenceData.endTimestamp + presenceData.smallImageKey = Assets.Pause + } + else { + presenceData.smallImageKey = Assets.Play; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + } + } + else { + const fetched = await fetchWithoutVideo() + if (fetched) + presenceData.details = fetched.meta.name + } + } + else { + presenceData.details = 'Browsing...' + } + if (!buttons) + delete presenceData.buttons + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/Peloton/metadata.json b/websites/P/Peloton/metadata.json index 8f6f80e4ba8d..06dbd20e8e5b 100644 --- a/websites/P/Peloton/metadata.json +++ b/websites/P/Peloton/metadata.json @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "The Gamerzs", - "id": "730142125181894657" - }, - "service": "Peloton", - "description": { - "en": "Peloton is attractive, addictive, and seriously whips you into shape.", - "nl": "Peloton is aantrekkelijk, verslavend en brengt je serieus in vorm." - }, - "url": [ - "www.onepeloton.com", - "www.onepeloton.co.uk", - "www.onepeloton.ca", - "www.onepeloton.de" - ], - "regExp": "([a-z0-9-]+[.])*onepeloton([.][a-z]+)+[/]", - "version": "1.0.30", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Peloton/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Peloton/assets/thumbnail.jpg", - "color": "#f5f7f9", - "category": "other", - "tags": [ - "goals", - "classes", - "exercise", - "training" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "The Gamerzs", + "id": "730142125181894657" + }, + "service": "Peloton", + "description": { + "en": "Peloton is attractive, addictive, and seriously whips you into shape.", + "nl": "Peloton is aantrekkelijk, verslavend en brengt je serieus in vorm." + }, + "url": [ + "www.onepeloton.com", + "www.onepeloton.co.uk", + "www.onepeloton.ca", + "www.onepeloton.de" + ], + "regExp": "([a-z0-9-]+[.])*onepeloton([.][a-z]+)+[/]", + "version": "1.0.30", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Peloton/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Peloton/assets/thumbnail.jpg", + "color": "#f5f7f9", + "category": "other", + "tags": [ + "goals", + "classes", + "exercise", + "training" + ] +} diff --git a/websites/P/Peloton/presence.ts b/websites/P/Peloton/presence.ts index 8c0a51c9f5e6..93e55a2eb80a 100644 --- a/websites/P/Peloton/presence.ts +++ b/websites/P/Peloton/presence.ts @@ -1,257 +1,260 @@ const presence = new Presence({ - clientId: "712294190339588209", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '712294190339588209', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let path, strings, clipTitle, clipAuthor, clipTimeLeft; +let path, strings -presence.on("UpdateData", async () => { - strings = await presence.getStrings({ - live: "general.live", - play: "general.playing", - pause: "general.paused", - }); - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Peloton/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + strings = await presence.getStrings({ + live: 'general.live', + play: 'general.playing', + pause: 'general.paused', + }) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Peloton/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (window.location.hostname.includes("www.onepeloton")) { - switch (window.location.pathname) { - case "/": - presenceData.details = "Browsing the Home Page"; - break; - case "/bike": - presenceData.details = "Browsing the bikes"; - break; - case "/app": - presenceData.details = "Browsing the app"; - break; - case "/membership": - presenceData.details = "Browsing memberships"; - break; - case "/terms": - presenceData.details = "Browsing the terms of service"; - break; - case "/company": - presenceData.details = "Browsing Peloton's Mission"; - break; - case "/showrooms": - presenceData.details = "Browsing the showrooms"; - break; - case "/membership-terms": - presenceData.details = "Browsing the membership terms"; - break; - } - } else if (window.location.hostname.includes("support.onepeloton")) - presenceData.details = "Browsing the support pages"; - else if (window.location.hostname.includes("blog.onepeloton")) { - switch (window.location.pathname) { - case "/": - presenceData.details = "Browsing the blogs"; - break; - case "/category/community/": - presenceData.details = "Browsing the community blogs"; - break; - case "/category/lifestyle/": - presenceData.details = "Browsing the lifestyle blogs"; - break; - case "/category/news/": - presenceData.details = "Browsing the news blogs"; - break; - case "/category/tech/": - presenceData.details = "Browsing the tech blogs"; - break; - case "/category/wellness/": - presenceData.details = "Browsing the wellness blogs"; - break; - } - } else if (window.location.hostname.includes("members.onepeloton")) { - //Class categories - if (window.location.pathname === "/classes") - presenceData.details = "Browsing classes"; - else if (window.location.pathname.includes("/classes/")) { - //Class category - path = window.location.pathname.replace("/classes/", ""); - switch (path) { - case "strength": - presenceData.details = "Browsing strength classes"; - break; - case "yoga": - presenceData.details = "Browsing yoga classes"; - break; - case "meditation": - presenceData.details = "Browsing meditation classes"; - break; - case "cardio": - presenceData.details = "Browsing cardio classes"; - break; - case "stretching": - presenceData.details = "Browsing stretching classes"; - break; - case "cycling": - presenceData.details = "Browsing cycling classes"; - break; - case "outdoor": - presenceData.details = "Browsing outdoor classes"; - break; - case "running": - presenceData.details = "Browsing running classes"; - break; - case "walking": - presenceData.details = "Browsing walking classes"; - break; - case "bootcamp": - presenceData.details = "Browsing bootcamp classes"; - break; - default: - presenceData.details = "Browsing classes"; - } + if (window.location.hostname.includes('www.onepeloton')) { + switch (window.location.pathname) { + case '/': + presenceData.details = 'Browsing the Home Page' + break + case '/bike': + presenceData.details = 'Browsing the bikes' + break + case '/app': + presenceData.details = 'Browsing the app' + break + case '/membership': + presenceData.details = 'Browsing memberships' + break + case '/terms': + presenceData.details = 'Browsing the terms of service' + break + case '/company': + presenceData.details = 'Browsing Peloton\'s Mission' + break + case '/showrooms': + presenceData.details = 'Browsing the showrooms' + break + case '/membership-terms': + presenceData.details = 'Browsing the membership terms' + break + } + } + else if (window.location.hostname.includes('support.onepeloton')) { + presenceData.details = 'Browsing the support pages' + } + else if (window.location.hostname.includes('blog.onepeloton')) { + switch (window.location.pathname) { + case '/': + presenceData.details = 'Browsing the blogs' + break + case '/category/community/': + presenceData.details = 'Browsing the community blogs' + break + case '/category/lifestyle/': + presenceData.details = 'Browsing the lifestyle blogs' + break + case '/category/news/': + presenceData.details = 'Browsing the news blogs' + break + case '/category/tech/': + presenceData.details = 'Browsing the tech blogs' + break + case '/category/wellness/': + presenceData.details = 'Browsing the wellness blogs' + break + } + } + else if (window.location.hostname.includes('members.onepeloton')) { + // Class categories + if (window.location.pathname === '/classes') { + presenceData.details = 'Browsing classes' + } + else if (window.location.pathname.includes('/classes/')) { + // Class category + path = window.location.pathname.replace('/classes/', '') + switch (path) { + case 'strength': + presenceData.details = 'Browsing strength classes' + break + case 'yoga': + presenceData.details = 'Browsing yoga classes' + break + case 'meditation': + presenceData.details = 'Browsing meditation classes' + break + case 'cardio': + presenceData.details = 'Browsing cardio classes' + break + case 'stretching': + presenceData.details = 'Browsing stretching classes' + break + case 'cycling': + presenceData.details = 'Browsing cycling classes' + break + case 'outdoor': + presenceData.details = 'Browsing outdoor classes' + break + case 'running': + presenceData.details = 'Browsing running classes' + break + case 'walking': + presenceData.details = 'Browsing walking classes' + break + case 'bootcamp': + presenceData.details = 'Browsing bootcamp classes' + break + default: + presenceData.details = 'Browsing classes' + } - //Video - if (path.includes("player/")) { - const video: HTMLVideoElement = document.querySelector(".jw-video"); - clipTitle = document.querySelector( - ".jw-controlbar > div:nth-child(3) > div > div > div > h1" - ).textContent; - clipAuthor = document.querySelector( - ".jw-controlbar > div:nth-child(3) > div > div > div > p" - ).textContent; + // Video + if (path.includes('player/')) { + const video = document.querySelector('.jw-video')! + const clipTitle = document.querySelector( + '.jw-controlbar > div:nth-child(3) > div > div > div > h1', + )?.textContent + const clipAuthor = document.querySelector( + '.jw-controlbar > div:nth-child(3) > div > div > div > p', + )?.textContent - switch (!video.paused) { - case true: - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = strings.play; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - break; - case false: - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = strings.pause; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - break; - } - presenceData.details = clipTitle.replace("&", "&"); - presenceData.state = clipAuthor; - } - } + switch (!video.paused) { + case true: + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = strings.play; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + break + case false: + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = strings.pause; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + break + } + presenceData.details = clipTitle?.replace('&', '&') + presenceData.state = clipAuthor + } + } - //Live - if (window.location.pathname.includes("/player/live")) { - clipTitle = document.querySelector( - ".jw-controlbar > div:nth-child(3) > div > div > div > h1" - ).textContent; - clipAuthor = document.querySelector( - ".jw-controlbar > div:nth-child(3) > div > div > div > p" - ).textContent; - clipTimeLeft = document - .querySelector( - ".player-overlay-wrapper > div:nth-child(3) > button > div:nth-child(2) > div > div > p" - ) - .textContent.split(":") - .map(Number); + // Live + if (window.location.pathname.includes('/player/live')) { + const clipTitle = document.querySelector( + '.jw-controlbar > div:nth-child(3) > div > div > div > h1', + )?.textContent + const clipAuthor = document.querySelector( + '.jw-controlbar > div:nth-child(3) > div > div > div > p', + )?.textContent + const clipTimeLeft = document + .querySelector( + '.player-overlay-wrapper > div:nth-child(3) > button > div:nth-child(2) > div > div > p', + ) + ?.textContent + ?.split(':') + .map(Number) ?? [] - switch ( - !(document.querySelector(".jw-video") as HTMLVideoElement).paused - ) { - case true: - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = strings.live; - presenceData.endTimestamp = new Date( - Date.now() + (clipTimeLeft[0] * 1 + clipTimeLeft[1] * 1) * 10 - ).getTime(); - break; - case false: - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = strings.live; - break; - } - presenceData.details = clipTitle.replace("&", "&"); - presenceData.state = clipAuthor; - } + switch ( + !(document.querySelector('.jw-video') as HTMLVideoElement).paused + ) { + case true: + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = strings.live + presenceData.endTimestamp = new Date( + Date.now() + (clipTimeLeft[0] * 1 + clipTimeLeft[1] * 1) * 10, + ).getTime() + break + case false: + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = strings.live + break + } + presenceData.details = clipTitle?.replace('&', '&') + presenceData.state = clipAuthor + } - //schedule - if (window.location.pathname.includes("/schedule/")) { - path = window.location.pathname.replace("/schedule/", ""); - switch (path) { - case "strength": - presenceData.details = "Browsing strength schedule"; - break; - case "yoga": - presenceData.details = "Browsing yoga schedule"; - break; - case "meditation": - presenceData.details = "Browsing meditation schedule"; - break; - case "cardio": - presenceData.details = "Browsing cardio schedule"; - break; - case "stretching": - presenceData.details = "Browsing stretching schedule"; - break; - case "cycling": - presenceData.details = "Browsing cycling schedule"; - break; - case "running": - presenceData.details = "Browsing running schedule"; - break; - case "walking": - presenceData.details = "Browsing walking schedule"; - break; - case "bootcamp": - presenceData.details = "Browsing bootcamp schedule"; - break; - default: - presenceData.details = "Browsing schedule"; - break; - } - } + // schedule + if (window.location.pathname.includes('/schedule/')) { + path = window.location.pathname.replace('/schedule/', '') + switch (path) { + case 'strength': + presenceData.details = 'Browsing strength schedule' + break + case 'yoga': + presenceData.details = 'Browsing yoga schedule' + break + case 'meditation': + presenceData.details = 'Browsing meditation schedule' + break + case 'cardio': + presenceData.details = 'Browsing cardio schedule' + break + case 'stretching': + presenceData.details = 'Browsing stretching schedule' + break + case 'cycling': + presenceData.details = 'Browsing cycling schedule' + break + case 'running': + presenceData.details = 'Browsing running schedule' + break + case 'walking': + presenceData.details = 'Browsing walking schedule' + break + case 'bootcamp': + presenceData.details = 'Browsing bootcamp schedule' + break + default: + presenceData.details = 'Browsing schedule' + break + } + } - //Challenges - if (window.location.pathname.includes("/challenges/")) { - path = window.location.pathname.replace("/challenges/", ""); - switch (path) { - case "active": - presenceData.details = "Browsing active challenges"; - break; - case "upcoming": - presenceData.details = "Browsing upcoming challenges"; - break; - case "completed": - presenceData.details = "Browsing completed challenges"; - break; - default: - presenceData.details = "Browsing challenges"; - break; - } - } + // Challenges + if (window.location.pathname.includes('/challenges/')) { + path = window.location.pathname.replace('/challenges/', '') + switch (path) { + case 'active': + presenceData.details = 'Browsing active challenges' + break + case 'upcoming': + presenceData.details = 'Browsing upcoming challenges' + break + case 'completed': + presenceData.details = 'Browsing completed challenges' + break + default: + presenceData.details = 'Browsing challenges' + break + } + } - //Profile - if (window.location.pathname.includes("/profile/")) { - path = window.location.pathname.replace("/profile/", ""); - switch (path) { - case "overview": - presenceData.details = "Browsing their profile"; - break; - case "workouts": - presenceData.details = "Browsing their workouts"; - break; - case "completed": - presenceData.details = "Browsing their achievements"; - break; - default: - presenceData.details = "Browsing their profile"; - break; - } - } + // Profile + if (window.location.pathname.includes('/profile/')) { + path = window.location.pathname.replace('/profile/', '') + switch (path) { + case 'overview': + presenceData.details = 'Browsing their profile' + break + case 'workouts': + presenceData.details = 'Browsing their workouts' + break + case 'completed': + presenceData.details = 'Browsing their achievements' + break + default: + presenceData.details = 'Browsing their profile' + break + } + } - //Profile - if (window.location.pathname.includes("/preferences/")) - presenceData.details = "Browsing their profile"; - } + // Profile + if (window.location.pathname.includes('/preferences/')) + presenceData.details = 'Browsing their profile' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/Perplexity/metadata.json b/websites/P/Perplexity/metadata.json index 79c94c94613b..584532640462 100644 --- a/websites/P/Perplexity/metadata.json +++ b/websites/P/Perplexity/metadata.json @@ -1,46 +1,46 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "431524485548736535", - "name": "0x796935" - }, - "service": "Perplexity", - "description": { - "en": "Perplexity AI is an AI chat tool that acts as a powerful search engine." - }, - "url": "www.perplexity.ai", - "version": "1.0.7", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/thumbnail.png", - "color": "#202025", - "category": "other", - "tags": [ - "search", - "ai" - ], - "settings": [ - { - "id": "privacy", - "title": "Search Privacy (includes btns)", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "hideButtons", - "title": "Hide Buttons", - "icon": "fad fa-eye-slash", - "value": false - }, - { - "id": "iconType", - "title": "Icon", - "icon": "fad fa-images", - "value": 0, - "values": [ - "dark", - "light" - ] - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "431524485548736535", + "name": "0x796935" + }, + "service": "Perplexity", + "description": { + "en": "Perplexity AI is an AI chat tool that acts as a powerful search engine." + }, + "url": "www.perplexity.ai", + "version": "1.0.7", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/thumbnail.png", + "color": "#202025", + "category": "other", + "tags": [ + "search", + "ai" + ], + "settings": [ + { + "id": "privacy", + "title": "Search Privacy (includes btns)", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "hideButtons", + "title": "Hide Buttons", + "icon": "fad fa-eye-slash", + "value": false + }, + { + "id": "iconType", + "title": "Icon", + "icon": "fad fa-images", + "value": 0, + "values": [ + "dark", + "light" + ] + } + ] +} diff --git a/websites/P/Perplexity/presence.ts b/websites/P/Perplexity/presence.ts index 7478ea52591c..c09ff4846752 100644 --- a/websites/P/Perplexity/presence.ts +++ b/websites/P/Perplexity/presence.ts @@ -1,90 +1,92 @@ const presence = new Presence({ - clientId: "893871116945350726", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - threadExportRegex = /([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12})/i; -let recentSearchQuery: string = null; + clientId: '893871116945350726', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const threadExportRegex = /([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12})/i +let recentSearchQuery: string | null = null -presence.on("UpdateData", async () => { - const { href, pathname } = document.location, - [privacy, hideButtons, iconType] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("hideButtons"), - presence.getSetting("iconType"), - ]), - currentSearch = new URL(href).searchParams.get("q"), - pageInput = document.querySelector(".md\\:mb-md"), - currentPage = pathname.split("/")[1], - largeImage = - [ - "https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/logo.png", - "https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/0.png", - ][iconType] || - "https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/logo.png", - presenceData: PresenceData = { - largeImageKey: largeImage, - startTimestamp: browsingTimestamp, - }; - if (currentSearch && currentSearch !== recentSearchQuery) - recentSearchQuery = currentSearch; +presence.on('UpdateData', async () => { + const { href, pathname } = document.location + const [privacy, hideButtons, iconType] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('hideButtons'), + presence.getSetting('iconType'), + ]) + const currentSearch = new URL(href).searchParams.get('q') + const pageInput = document.querySelector('.md\\:mb-md') + const currentPage = pathname.split('/')[1] + const largeImage = [ + 'https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/logo.png', + 'https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/0.png', + ][iconType] + || 'https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/logo.png' + const presenceData: PresenceData = { + largeImageKey: largeImage, + startTimestamp: browsingTimestamp, + } + if (currentSearch && currentSearch !== recentSearchQuery) + recentSearchQuery = currentSearch - presenceData.details = "Home"; + presenceData.details = 'Home' - if (!currentPage) return presence.setActivity(presenceData); + if (!currentPage) + return presence.setActivity(presenceData) - switch (currentPage.toLowerCase()) { - case "search": - presenceData.details = privacy ? "Searching" : "Searching for"; - presenceData.smallImageKey = Assets.Search; + switch (currentPage.toLowerCase()) { + case 'search': + presenceData.details = privacy ? 'Searching' : 'Searching for' + presenceData.smallImageKey = Assets.Search - if (pathname.match(threadExportRegex)) { - presenceData.buttons = [ - { - label: "Open Thread", - url: href, - }, - ]; - } + if (pathname.match(threadExportRegex)) { + presenceData.buttons = [ + { + label: 'Open Thread', + url: href, + }, + ] + } - presenceData.state = recentSearchQuery; - if ( - pageInput && - pageInput.textContent && - pageInput.textContent !== recentSearchQuery - ) - presenceData.state = pageInput.textContent; - break; + presenceData.state = recentSearchQuery + if ( + pageInput + && pageInput.textContent + && pageInput.textContent !== recentSearchQuery + ) { + presenceData.state = pageInput.textContent + } + break - case "threads": - presenceData.details = "Searching threads"; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/1.png"; - break; + case 'threads': + presenceData.details = 'Searching threads' + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/P/Perplexity/assets/1.png' + break - case "about": - presenceData.details = "Reading about"; - break; + case 'about': + presenceData.details = 'Reading about' + break - case "blog": - presenceData.details = "Reading blog"; - break; + case 'blog': + presenceData.details = 'Reading blog' + break - case "privacy": - presenceData.details = "Reading privacy policy"; - break; + case 'privacy': + presenceData.details = 'Reading privacy policy' + break - case "tos": - presenceData.details = "Reading terms of service"; - break; + case 'tos': + presenceData.details = 'Reading terms of service' + break - default: - presenceData.details = "Browsing"; - presenceData.state = currentPage; - break; - } + default: + presenceData.details = 'Browsing' + presenceData.state = currentPage + break + } - if (privacy && presenceData.state) delete presenceData.state; - if (hideButtons && presenceData.buttons) delete presenceData.buttons; + if (privacy && presenceData.state) + delete presenceData.state + if (hideButtons && presenceData.buttons) + delete presenceData.buttons - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/Personality Database/metadata.json b/websites/P/Personality Database/metadata.json index 6f93341c4cfc..7cedefbc4cba 100644 --- a/websites/P/Personality Database/metadata.json +++ b/websites/P/Personality Database/metadata.json @@ -1,41 +1,41 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "JustArya", - "id": "281770836283883530" - }, - "service": "Personality Database", - "description": { - "en": "Personality Database (PDB) is a user-driven, social community based on analytical psychology typing methods as Jungian Cognitive Functions, Myers–Briggs Type Indicators (MBTI), Enneagram, Instinctual Variant, Tritype, Socionics, Big Five Personality Traits, Psychosophy (Attitudinal Psyche), and Temperaments." - }, - "url": "personality-database.com", - "regExp": "([a-z0-9-]+[.])*personality-database[.]com[/]", - "version": "1.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/thumbnail.png", - "color": "#2e96a5", - "category": "socials", - "tags": [ - "personality", - "psychology", - "database", - "mbti", - "socionics", - "enneagram" - ], - "settings": [ - { - "id": "useOnlyFirstPersonalityType", - "title": "Show only first type", - "icon": "fas fa-head-side-brain", - "value": true - }, - { - "id": "showUserNameInUserProfile", - "title": "Show user's names when visiting other user profile", - "icon": "fas fa-user", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "JustArya", + "id": "281770836283883530" + }, + "service": "Personality Database", + "description": { + "en": "Personality Database (PDB) is a user-driven, social community based on analytical psychology typing methods as Jungian Cognitive Functions, Myers–Briggs Type Indicators (MBTI), Enneagram, Instinctual Variant, Tritype, Socionics, Big Five Personality Traits, Psychosophy (Attitudinal Psyche), and Temperaments." + }, + "url": "personality-database.com", + "regExp": "([a-z0-9-]+[.])*personality-database[.]com[/]", + "version": "1.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/thumbnail.png", + "color": "#2e96a5", + "category": "socials", + "tags": [ + "personality", + "psychology", + "database", + "mbti", + "socionics", + "enneagram" + ], + "settings": [ + { + "id": "useOnlyFirstPersonalityType", + "title": "Show only first type", + "icon": "fas fa-head-side-brain", + "value": true + }, + { + "id": "showUserNameInUserProfile", + "title": "Show user's names when visiting other user profile", + "icon": "fas fa-user", + "value": false + } + ] +} diff --git a/websites/P/Personality Database/presence.ts b/websites/P/Personality Database/presence.ts index 26291265caed..a98bb0085e9d 100644 --- a/websites/P/Personality Database/presence.ts +++ b/websites/P/Personality Database/presence.ts @@ -1,112 +1,122 @@ const presence = new Presence({ - clientId: "909403157686288414", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '909403157686288414', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Group = "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/0.png", - Home = "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/1.png", - Notification = "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/2.png", - User = "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/3.png", - Star = "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/4.png", - List = "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/5.png", - Poll = "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/6.png", - PersonalityDatabase = "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/7.png", + Group = 'https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/0.png', + Home = 'https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/1.png', + Notification = 'https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/2.png', + User = 'https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/3.png', + Star = 'https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/4.png', + List = 'https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/5.png', + Poll = 'https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/6.png', + PersonalityDatabase = 'https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/7.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - useOnlyFirstPersonalityType = await presence.getSetting( - "useOnlyFirstPersonalityType" - ), - showUserNameInUserProfile = await presence.getSetting( - "showUserNameInUserProfile" - ); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Personality%20Database/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const useOnlyFirstPersonalityType = await presence.getSetting( + 'useOnlyFirstPersonalityType', + ) + const showUserNameInUserProfile = await presence.getSetting( + 'showUserNameInUserProfile', + ) - if (document.location.pathname.includes("/profile/")) { - const profileName: string = (( - document.querySelector( - "div.profile-description-basic > h1.profile-name" - ) - ))?.textContent, - profilePersonality: string = (( - document.querySelector( - "div.profile-description > div.profile-description-info > div.profile-description-basic > div.profile-personality" - ) - ))?.textContent, - profilePicture: string = (( - document.querySelector( - "div.profile-description > div.profile-description-info > div.profile-description-avatar img" - ) - ))?.getAttribute("src"); + if (document.location.pathname.includes('/profile/')) { + const profileName = document.querySelector( + 'div.profile-description-basic > h1.profile-name', + )?.textContent + const profilePersonality = document.querySelector( + 'div.profile-description > div.profile-description-info > div.profile-description-basic > div.profile-personality', + )?.textContent + const profilePicture = document.querySelector( + 'div.profile-description > div.profile-description-info > div.profile-description-avatar img', + )?.getAttribute('src') - if (profilePicture) presenceData.largeImageKey = profilePicture; - presenceData.smallImageKey = Assets.Poll; - presenceData.details = "Viewing:"; + if (profilePicture) + presenceData.largeImageKey = profilePicture + presenceData.smallImageKey = Assets.Poll + presenceData.details = 'Viewing:' - const firstType: string = profilePersonality?.split(" - ")[0]; + const firstType = profilePersonality?.split(' - ')[0] - if (firstType) { - if (useOnlyFirstPersonalityType) - presenceData.state = `${profileName} - ${firstType}`; - else { - presenceData.details = `Viewing: ${profileName}`; - presenceData.state = `${profilePersonality}`; - } - } else presenceData.state = profileName; + if (firstType) { + if (useOnlyFirstPersonalityType) { + presenceData.state = `${profileName} - ${firstType}` + } + else { + presenceData.details = `Viewing: ${profileName}` + presenceData.state = `${profilePersonality}` + } + } + else { + presenceData.state = profileName + } - presenceData.buttons = [ - { - label: "Visit profile", - url: document.location.href, - }, - ]; - } else if (document.location.pathname === "/search") { - const urlParams = new URLSearchParams(window.location.search); + presenceData.buttons = [ + { + label: 'Visit profile', + url: document.location.href, + }, + ] + } + else if (document.location.pathname === '/search') { + const urlParams = new URLSearchParams(window.location.search) - presenceData.smallImageKey = Assets.Search; - presenceData.details = "Searching:"; - presenceData.state = urlParams.get("keyword") || urlParams.get("q"); - } else if (document.location.pathname === "/vote") { - presenceData.smallImageKey = Assets.Home; - presenceData.details = "Viewing homepage"; - } else if (document.location.pathname.includes("/profile")) { - presenceData.smallImageKey = Assets.List; - presenceData.details = "Viewing category:"; - presenceData.state = document.title?.split(" | ")[0]; - } else if (document.location.pathname.includes("/community")) { - presenceData.smallImageKey = Assets.Group; - presenceData.details = "Viewing community feed"; - } else if (document.location.pathname.includes("/topic")) { - presenceData.smallImageKey = Assets.Star; - presenceData.details = "Viewing topic:"; - presenceData.state = document.title?.split(" | ")[0]; - } else if (document.location.pathname.includes("/notification")) { - presenceData.smallImageKey = Assets.Notification; - presenceData.details = "Viewing notification"; - } else if (document.location.pathname.includes("/user/")) { - if (showUserNameInUserProfile) { - const userName: string = document.title?.split(" | ")[0]; - presenceData.details = "Viewing user's profile:"; - presenceData.state = userName; + presenceData.smallImageKey = Assets.Search + presenceData.details = 'Searching:' + presenceData.state = urlParams.get('keyword') || urlParams.get('q') + } + else if (document.location.pathname === '/vote') { + presenceData.smallImageKey = Assets.Home + presenceData.details = 'Viewing homepage' + } + else if (document.location.pathname.includes('/profile')) { + presenceData.smallImageKey = Assets.List + presenceData.details = 'Viewing category:' + presenceData.state = document.title?.split(' | ')[0] + } + else if (document.location.pathname.includes('/community')) { + presenceData.smallImageKey = Assets.Group + presenceData.details = 'Viewing community feed' + } + else if (document.location.pathname.includes('/topic')) { + presenceData.smallImageKey = Assets.Star + presenceData.details = 'Viewing topic:' + presenceData.state = document.title?.split(' | ')[0] + } + else if (document.location.pathname.includes('/notification')) { + presenceData.smallImageKey = Assets.Notification + presenceData.details = 'Viewing notification' + } + else if (document.location.pathname.includes('/user/')) { + if (showUserNameInUserProfile) { + const userName: string = document.title?.split(' | ')[0] + presenceData.details = 'Viewing user\'s profile:' + presenceData.state = userName - presenceData.buttons = [ - { - label: `Visit ${userName}'s profile`, - url: document.location.href, - }, - ]; - } else presenceData.details = "Viewing user's profile"; - presenceData.smallImageKey = Assets.User; - } else { - presenceData.details = "Viewing page:"; - presenceData.state = document.title?.split(" | ")[0]; - } + presenceData.buttons = [ + { + label: `Visit ${userName}'s profile`, + url: document.location.href, + }, + ] + } + else { + presenceData.details = 'Viewing user\'s profile' + } + presenceData.smallImageKey = Assets.User + } + else { + presenceData.details = 'Viewing page:' + presenceData.state = document.title?.split(' | ')[0] + } - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/P/Philo/metadata.json b/websites/P/Philo/metadata.json index 36402bfb447c..8e2be53ddaf0 100644 --- a/websites/P/Philo/metadata.json +++ b/websites/P/Philo/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kedi", - "id": "238668511222693888" - }, - "service": "Philo", - "description": { - "en": "Live & on-demand TV. 60+ channels. Unlimited DVR. No contract.", - "nl": "Live en on-demand tv. 60+ kanalen. Onbeperkte DVR. Geen contract." - }, - "url": [ - "www.philo.com", - "philo.com" - ], - "version": "1.0.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Philo/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Philo/assets/thumbnail.jpg", - "color": "#0C93F2", - "category": "videos", - "tags": [ - "philo", - "video", - "media" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Kedi", + "id": "238668511222693888" + }, + "service": "Philo", + "description": { + "en": "Live & on-demand TV. 60+ channels. Unlimited DVR. No contract.", + "nl": "Live en on-demand tv. 60+ kanalen. Onbeperkte DVR. Geen contract." + }, + "url": [ + "www.philo.com", + "philo.com" + ], + "version": "1.0.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Philo/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Philo/assets/thumbnail.jpg", + "color": "#0C93F2", + "category": "videos", + "tags": [ + "philo", + "video", + "media" + ] +} diff --git a/websites/P/Philo/presence.ts b/websites/P/Philo/presence.ts index 1bc0aca88733..4c97df3241bd 100644 --- a/websites/P/Philo/presence.ts +++ b/websites/P/Philo/presence.ts @@ -1,85 +1,92 @@ const presence = new Presence({ - clientId: "770395849041248306", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - live: "general.live", - }); + clientId: '770395849041248306', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', + live: 'general.live', +}) -let elapsed: number, oldUrl: string; +let elapsed: number, oldUrl: string -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Philo/assets/logo.png", - }, - { href, pathname: path } = window.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Philo/assets/logo.png', + } + const { href, pathname: path } = window.location - if (href !== oldUrl) { - oldUrl = href; - elapsed = Math.floor(Date.now() / 1000); - } + if (href !== oldUrl) { + oldUrl = href + elapsed = Math.floor(Date.now() / 1000) + } - const video: HTMLVideoElement = document.querySelector("#player video"); + const video = document.querySelector('#player video') - if (video) { - const seriesEp = document.querySelector(".season-episode-format"), - live = document.querySelector(".flag.flag-live"), - state = seriesEp - ? `${seriesEp.textContent} ${ - document.querySelector(".player-controls-subtitle-text").textContent - }` - : live - ? "Watching Live" - : "Watching", - channel: HTMLImageElement = document.querySelector( - ".player-controls-subtitle img" - ); + if (video) { + const seriesEp = document.querySelector('.season-episode-format') + const live = document.querySelector('.flag.flag-live') + const state = seriesEp + ? `${seriesEp.textContent} ${ + document.querySelector('.player-controls-subtitle-text')?.textContent + }` + : live + ? 'Watching Live' + : 'Watching' + const channel = document.querySelector( + '.player-controls-subtitle img', + ) - (presenceData.details = document.querySelector( - ".player-controls-title" - )?.textContent), - (presenceData.state = state); - presenceData.smallImageKey = live - ? Assets.Live - : video.paused - ? Assets.Pause - : Assets.Play; - presenceData.smallImageText = live - ? (await strings).live - : video.paused - ? (await strings).pause - : (await strings).play; - if (!live) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - } else presenceData.startTimestamp = elapsed; + presenceData.details = document.querySelector( + '.player-controls-title', + )?.textContent + presenceData.state = state + presenceData.smallImageKey = live + ? Assets.Live + : video.paused + ? Assets.Pause + : Assets.Play + presenceData.smallImageText = live + ? (await strings).live + : video.paused + ? (await strings).pause + : (await strings).play + if (!live) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + } + else { + presenceData.startTimestamp = elapsed + } - if (live) delete presenceData.endTimestamp; + if (live) + delete presenceData.endTimestamp - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } - if (!presenceData.endTimestamp) delete presenceData.endTimestamp; + if (!presenceData.endTimestamp) + delete presenceData.endTimestamp - if (presenceData.details && presenceData.state.trim()) { - if (channel && channel.getAttribute("alt")) - presenceData.state += ` on ${channel.getAttribute("alt")}`; + if (presenceData.details && presenceData.state.trim()) { + if (channel && channel.getAttribute('alt')) + presenceData.state += ` on ${channel.getAttribute('alt')}` - presence.setActivity(presenceData, !video.paused); - } - } else { - presenceData.details = "Browsing..."; - if (path.includes("/guide")) presenceData.details = "Browsing Guide"; + presence.setActivity(presenceData, !video.paused) + } + } + else { + presenceData.details = 'Browsing...' + if (path.includes('/guide')) + presenceData.details = 'Browsing Guide' - if (path.includes("/saved")) presenceData.details = "Browsing Saved"; + if (path.includes('/saved')) + presenceData.details = 'Browsing Saved' - if (path.includes("/search")) presenceData.details = "Searching..."; + if (path.includes('/search')) + presenceData.details = 'Searching...' - presenceData.startTimestamp = elapsed; - presence.setActivity(presenceData); - } -}); + presenceData.startTimestamp = elapsed + presence.setActivity(presenceData) + } +}) diff --git a/websites/P/Phira/metadata.json b/websites/P/Phira/metadata.json index 3f09ac053144..721d51ae5d93 100644 --- a/websites/P/Phira/metadata.json +++ b/websites/P/Phira/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "205984221859151873", - "name": "joerkig" - }, - "service": "Phira", - "description": { - "en": "Phigros Fanmade Community" - }, - "url": "phira.moe", - "version": "1.0.1", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Phira/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Phira/assets/thumbnail.png", - "color": "#6419e6", - "category": "games", - "tags": [ - "leaderboards", - "phigros", - "charts" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "205984221859151873", + "name": "joerkig" + }, + "service": "Phira", + "description": { + "en": "Phigros Fanmade Community" + }, + "url": "phira.moe", + "version": "1.0.1", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Phira/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Phira/assets/thumbnail.png", + "color": "#6419e6", + "category": "games", + "tags": [ + "leaderboards", + "phigros", + "charts" + ] +} diff --git a/websites/P/Phira/presence.ts b/websites/P/Phira/presence.ts index 826bde314a28..37a969801691 100644 --- a/websites/P/Phira/presence.ts +++ b/websites/P/Phira/presence.ts @@ -1,75 +1,82 @@ const presence = new Presence({ - clientId: "1328129220655972412", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1328129220655972412', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Phira/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Phira/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname, href } = document.location, - pathArr = pathname.split("/"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname, href } = document.location + const pathArr = pathname.split('/') - switch (pathArr[1]) { - case "": { - presenceData.details = "Viewing homepage"; - break; - } - case "chart": { - if (!pathArr[2]) { - const selector = document.querySelector(".select"); - presenceData.details = "Browsing charts"; - presenceData.state = - selector?.options[selector?.options.selectedIndex].textContent; - if (!presenceData.state) return; - } else { - presenceData.details = document.querySelector("h1.text-5xl"); - presenceData.state = document.querySelector("h1"); - presenceData.largeImageKey = document - .querySelector(".illustration") - ?.style.backgroundImage.slice(5, -2); - presenceData.buttons = [ - { - label: "View Page", - url: href, - }, - { - label: "View Uploader", - url: document.querySelector("a[href*='/user/']") - ?.href, - }, - ]; - if (!presenceData.details) return; - } - break; - } - case "user": { - if (!pathArr[2]) presenceData.details = "Browsing users"; - else { - presenceData.details = "Viewing profile"; - presenceData.state = document.querySelector("span.text-3xl > span"); - presenceData.largeImageKey = - document.querySelector(".mask-squircle img"); - presenceData.buttons = [ - { - label: "View Page", - url: href, - }, - ]; - if (!presenceData.state) return; - } - break; - } - default: { - presenceData.details = `Viewing ${document.querySelector("h1")}`; - if (!document.querySelector("h1")) return; - } - } + switch (pathArr[1]) { + case '': { + presenceData.details = 'Viewing homepage' + break + } + case 'chart': { + if (!pathArr[2]) { + const selector = document.querySelector('.select') + presenceData.details = 'Browsing charts' + presenceData.state = selector?.options[selector?.options.selectedIndex].textContent + if (!presenceData.state) + return + } + else { + presenceData.details = document.querySelector('h1.text-5xl') + presenceData.state = document.querySelector('h1') + presenceData.largeImageKey = document + .querySelector('.illustration') + ?.style + .backgroundImage + .slice(5, -2) + presenceData.buttons = [ + { + label: 'View Page', + url: href, + }, + { + label: 'View Uploader', + url: document.querySelector('a[href*=\'/user/\']') + ?.href ?? '', + }, + ] + if (!presenceData.details) + return + } + break + } + case 'user': { + if (!pathArr[2]) { + presenceData.details = 'Browsing users' + } + else { + presenceData.details = 'Viewing profile' + presenceData.state = document.querySelector('span.text-3xl > span') + presenceData.largeImageKey = document.querySelector('.mask-squircle img') + presenceData.buttons = [ + { + label: 'View Page', + url: href, + }, + ] + if (!presenceData.state) + return + } + break + } + default: { + presenceData.details = `Viewing ${document.querySelector('h1')}` + if (!document.querySelector('h1')) + return + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/Photopea/metadata.json b/websites/P/Photopea/metadata.json index 3602b75c21aa..5cd3dc0b5323 100644 --- a/websites/P/Photopea/metadata.json +++ b/websites/P/Photopea/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Jake.", - "id": "480407581085532180" - }, - "service": "Photopea", - "description": { - "en": "Photopea online image editor is a free Photoshop clone with advanced tools", - "nl": "Photopea online afbeeldingseditor is een gratis Photoshop-kloon met geavanceerde tools" - }, - "url": "www.photopea.com", - "version": "1.4.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Photopea/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Photopea/assets/thumbnail.jpg", - "color": "#42b3f5", - "category": "other", - "tags": [ - "photo-editing", - "free", - "image-editor" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Jake.", + "id": "480407581085532180" + }, + "service": "Photopea", + "description": { + "en": "Photopea online image editor is a free Photoshop clone with advanced tools", + "nl": "Photopea online afbeeldingseditor is een gratis Photoshop-kloon met geavanceerde tools" + }, + "url": "www.photopea.com", + "version": "1.4.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Photopea/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Photopea/assets/thumbnail.jpg", + "color": "#42b3f5", + "category": "other", + "tags": [ + "photo-editing", + "free", + "image-editor" + ] +} diff --git a/websites/P/Photopea/presence.ts b/websites/P/Photopea/presence.ts index d9067f635eba..bbc95f0c4307 100644 --- a/websites/P/Photopea/presence.ts +++ b/websites/P/Photopea/presence.ts @@ -1,56 +1,61 @@ const presence = new Presence({ - clientId: "685559589625659492", -}); + clientId: '685559589625659492', +}) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Photopea/assets/logo.png", - }, - Path = document.location.pathname; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Photopea/assets/logo.png', + } + const Path = document.location.pathname + presenceData.startTimestamp = Math.floor(Date.now() / 1000) - if (Path.startsWith("/learn")) { - presenceData.details = "Learning new cool tricks :"; - presenceData.state = `${ - Path.replace("/learn/", "").length < 1 - ? "Main Section" - : `${Path.replace("/learn/", "").toUpperCase()} Section` - }`; - } else if (Path === "/") { - switch ( - document.querySelector( - "body > div[class='flexrow app'] > div:nth-child(1) > div.flexrow > div.panelblock.mainblock > div > div.panelhead" - ).children.length - ) { - case 0: - presenceData.details = "Viewing the home page "; - break; - default: { - const name = document.querySelector("div.active > span").textContent; - presenceData.details = `Editing a ${ - name.split(".").length > 1 - ? name.split(".")[name.split(".").length - 1] - : name.split(".")[1] - } file :`; - presenceData.state = name; - } - } - } else if (Path.startsWith("/api")) { - presenceData.details = "Consulting the api docs :"; - presenceData.state = `${ - Path.replace("/api/", "").length < 1 - ? "Main Section" - : `${Path.replace("/api/", "").toUpperCase()} Section` - }`; - } else if (Path.startsWith("/tuts")) { - presenceData.details = "Consulting the tutorials :"; - presenceData.state = `${ - Path.replace("/tuts/", "").length < 1 - ? "Main Section" - : `${document.querySelector("#post-396 > h1").textContent}` - }`; - } else presenceData.details = "Browsing the site "; + if (Path.startsWith('/learn')) { + presenceData.details = 'Learning new cool tricks :' + presenceData.state = `${ + Path.replace('/learn/', '').length < 1 + ? 'Main Section' + : `${Path.replace('/learn/', '').toUpperCase()} Section` + }` + } + else if (Path === '/') { + switch ( + document.querySelector( + 'body > div[class=\'flexrow app\'] > div:nth-child(1) > div.flexrow > div.panelblock.mainblock > div > div.panelhead', + )?.children.length + ) { + case 0: + presenceData.details = 'Viewing the home page ' + break + default: { + const name = document.querySelector('div.active > span')?.textContent + presenceData.details = `Editing a ${ + name && name.split('.').length > 1 + ? name.split('.')[name.split('.').length - 1] + : name?.split('.')[1] + } file :` + presenceData.state = name + } + } + } + else if (Path.startsWith('/api')) { + presenceData.details = 'Consulting the api docs :' + presenceData.state = `${ + Path.replace('/api/', '').length < 1 + ? 'Main Section' + : `${Path.replace('/api/', '').toUpperCase()} Section` + }` + } + else if (Path.startsWith('/tuts')) { + presenceData.details = 'Consulting the tutorials :' + presenceData.state = `${ + Path.replace('/tuts/', '').length < 1 + ? 'Main Section' + : `${document.querySelector('#post-396 > h1')?.textContent}` + }` + } + else { + presenceData.details = 'Browsing the site ' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/Physics Wallah/metadata.json b/websites/P/Physics Wallah/metadata.json index ef98f7ead6c6..7bd69c104b22 100644 --- a/websites/P/Physics Wallah/metadata.json +++ b/websites/P/Physics Wallah/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "847084634294059018", - "name": ".infinite_." - }, - "service": "Physics Wallah", - "description": { - "en": "Physics Wallah is India's top online ed-tech platform that provides affordable and comprehensive learning experience to students of classes 6 to 12 and those preparing for JEE and NEET exams." - }, - "url": "www.pw.live", - "version": "1.1.1", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/thumbnail.png", - "color": "#2596be", - "category": "videos", - "tags": [ - "video", - "media" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "847084634294059018", + "name": ".infinite_." + }, + "service": "Physics Wallah", + "description": { + "en": "Physics Wallah is India's top online ed-tech platform that provides affordable and comprehensive learning experience to students of classes 6 to 12 and those preparing for JEE and NEET exams." + }, + "url": "www.pw.live", + "version": "1.1.1", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/thumbnail.png", + "color": "#2596be", + "category": "videos", + "tags": [ + "video", + "media" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + } + ] +} diff --git a/websites/P/Physics Wallah/presence.ts b/websites/P/Physics Wallah/presence.ts index fbc394f64383..99cc5efebcec 100644 --- a/websites/P/Physics Wallah/presence.ts +++ b/websites/P/Physics Wallah/presence.ts @@ -1,123 +1,133 @@ const presence = new Presence({ - clientId: "1134044987277975616", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1134044987277975616', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - HomePage = "https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/0.png", - Scrolling = "https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/1.png", - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/logo.png", + HomePage = 'https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/0.png', + Scrolling = 'https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/1.png', + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Physics%20Wallah/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - type: ActivityType.Watching, - }, - { pathname, href } = document.location, - privacyMode = await presence.getSetting("privacy"), - jsonobj = JSON.parse(sessionStorage.getItem("batches_urls")); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + type: ActivityType.Watching, + } + const { pathname, href } = document.location + const privacyMode = await presence.getSetting('privacy') + const jsonobj = JSON.parse(sessionStorage.getItem('batches_urls')!) - if (pathname === "/") { - presenceData.details = "Home"; - presenceData.state = "Browsing..."; - presenceData.smallImageKey = Assets.HomePage; - presenceData.smallImageText = "Browsing Home Page"; - } else if (pathname.startsWith("/study")) { - presenceData.details = "Browsing..."; - presenceData.state = "In website"; - presenceData.smallImageKey = Assets.Scrolling; - presenceData.smallImageText = "Browsing the website"; + if (pathname === '/') { + presenceData.details = 'Home' + presenceData.state = 'Browsing...' + presenceData.smallImageKey = Assets.HomePage + presenceData.smallImageText = 'Browsing Home Page' + } + else if (pathname.startsWith('/study')) { + presenceData.details = 'Browsing...' + presenceData.state = 'In website' + presenceData.smallImageKey = Assets.Scrolling + presenceData.smallImageText = 'Browsing the website' - if (pathname.endsWith("/my-batches")) { - presenceData.details = "Studying..."; - presenceData.state = "My Batches"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Studying"; - } - if (href.includes("batch-overview")) { - presenceData.details = "Studying..."; - presenceData.state = `Viewing ${ - JSON.parse(localStorage.getItem("BATCH_DETAILS")).name - }`; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Studying"; - presenceData.buttons = [{ label: "View Batch", url: href }]; - } else if (href.includes("subject-topics")) { - if (href.includes("chapterId")) { - const urlsobj = new URL(jsonobj[3].value, "https://www.pw.live"); - presenceData.details = urlsobj.searchParams.get("subject"); - presenceData.state = urlsobj.searchParams.get("topic"); - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Browsing Resources"; - } else if (!href.includes("chapterId")) { - presenceData.details = new URL( - jsonobj[2].value, - "https://www.pw.live" - ).searchParams.get("subject"); - presenceData.state = "Browsing Resources..."; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Browsing Resources"; - } - } else if (href.includes("open-pdf")) { - const urlsobj = new URL(jsonobj[3].value, "https://www.pw.live"); - presenceData.details = `Solving DPP (PDF) | ${urlsobj.searchParams.get( - "subject" - )}`; - if (!privacyMode) presenceData.state = urlsobj.searchParams.get("topic"); - else presenceData.state = "Improving skills"; + if (pathname.endsWith('/my-batches')) { + presenceData.details = 'Studying...' + presenceData.state = 'My Batches' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Studying' + } + if (href.includes('batch-overview')) { + presenceData.details = 'Studying...' + presenceData.state = `Viewing ${ + JSON.parse(localStorage.getItem('BATCH_DETAILS')!).name + }` + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Studying' + presenceData.buttons = [{ label: 'View Batch', url: href }] + } + else if (href.includes('subject-topics')) { + if (href.includes('chapterId')) { + const urlsobj = new URL(jsonobj[3].value, 'https://www.pw.live') + presenceData.details = urlsobj.searchParams.get('subject') + presenceData.state = urlsobj.searchParams.get('topic') + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Browsing Resources' + } + else if (!href.includes('chapterId')) { + presenceData.details = new URL( + jsonobj[2].value, + 'https://www.pw.live', + ).searchParams.get('subject') + presenceData.state = 'Browsing Resources...' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Browsing Resources' + } + } + else if (href.includes('open-pdf')) { + const urlsobj = new URL(jsonobj[3].value, 'https://www.pw.live') + presenceData.details = `Solving DPP (PDF) | ${urlsobj.searchParams.get( + 'subject', + )}` + if (!privacyMode) + presenceData.state = urlsobj.searchParams.get('topic') + else presenceData.state = 'Improving skills' - presenceData.startTimestamp = browsingTimestamp; - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = "Viewing DPP"; - } - } else if (pathname.startsWith("/watch")) { - const deta = JSON.parse(localStorage.getItem("SCHEDULE_DETAILS")); - let detal = ""; - if (deta.subject === null) detal = ""; - else detal = ` | ${deta.subject.name}`; - if (!privacyMode) { - presenceData.details = `Watching Lecture${detal}`; + presenceData.startTimestamp = browsingTimestamp + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = 'Viewing DPP' + } + } + else if (pathname.startsWith('/watch')) { + const deta = JSON.parse(localStorage.getItem('SCHEDULE_DETAILS')!) + let detal = '' + if (deta.subject === null) + detal = '' + else detal = ` | ${deta.subject.name}` + if (!privacyMode) { + presenceData.details = `Watching Lecture${detal}` - presenceData.state = `${deta.topic}`; + presenceData.state = `${deta.topic}` - presenceData.buttons = [{ label: "Watch Lecture", url: href }]; - } else { - presenceData.details = "Watching a lecture"; - presenceData.state = `Subject: ${deta.subject.name}`; - } - if (document.querySelectorAll(".vjs-paused").length < 1) { - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Watching a lecture"; - [presenceData.startTimestamp, presenceData.endTimestamp] = - updateVideoTimestamps(); - } else { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = "Paused"; - } - } else if (pathname.startsWith("/practice")) { - const urlsobj = new URL(jsonobj[3].value, "https://www.pw.live"); - presenceData.details = `Solving DPP (MCQ) | ${urlsobj.searchParams.get( - "subject" - )}`; - if (!privacyMode) presenceData.state = urlsobj.searchParams.get("topic"); - else presenceData.state = "Improving skills"; + presenceData.buttons = [{ label: 'Watch Lecture', url: href }] + } + else { + presenceData.details = 'Watching a lecture' + presenceData.state = `Subject: ${deta.subject.name}` + } + if (document.querySelectorAll('.vjs-paused').length < 1) { + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Watching a lecture'; + [presenceData.startTimestamp, presenceData.endTimestamp] = updateVideoTimestamps() + } + else { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Paused' + } + } + else if (pathname.startsWith('/practice')) { + const urlsobj = new URL(jsonobj[3].value, 'https://www.pw.live') + presenceData.details = `Solving DPP (MCQ) | ${urlsobj.searchParams.get( + 'subject', + )}` + if (!privacyMode) + presenceData.state = urlsobj.searchParams.get('topic') + else presenceData.state = 'Improving skills' - presenceData.startTimestamp = browsingTimestamp; - presenceData.smallImageKey = Assets.Viewing; - presenceData.smallImageText = "Viewing DPP"; - } - presence.setActivity(presenceData); -}); + presenceData.startTimestamp = browsingTimestamp + presenceData.smallImageKey = Assets.Viewing + presenceData.smallImageText = 'Viewing DPP' + } + presence.setActivity(presenceData) +}) function updateVideoTimestamps() { - return presence.getTimestamps( - presence.timestampFromFormat( - document.querySelector(".vjs-current-time-display").textContent - ), - presence.timestampFromFormat( - document.querySelector(".vjs-duration-display").textContent - ) - ); + return presence.getTimestamps( + presence.timestampFromFormat( + document.querySelector('.vjs-current-time-display')?.textContent ?? '', + ), + presence.timestampFromFormat( + document.querySelector('.vjs-duration-display')?.textContent ?? '', + ), + ) } diff --git a/websites/P/Picarto/metadata.json b/websites/P/Picarto/metadata.json index 315a633bb57b..6de59db0dee8 100644 --- a/websites/P/Picarto/metadata.json +++ b/websites/P/Picarto/metadata.json @@ -1,22 +1,22 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "TheSlowly", - "id": "505071508851523599" - }, - "service": "Picarto", - "description": { - "en": "Picarto is the world’s leading live streaming platform for creative minds. Come join us and watch artists from all over the world during their creative process!", - "nl": "Picarto is 's werelds toonaangevende live streamingplatform voor creatieve geesten. Doe mee en kijk naar artiesten van over de hele wereld tijdens hun creatieve proces!" - }, - "url": "picarto.tv", - "version": "1.2.27", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Picarto/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Picarto/assets/thumbnail.png", - "color": "#35A775", - "category": "videos", - "tags": [ - "video" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "TheSlowly", + "id": "505071508851523599" + }, + "service": "Picarto", + "description": { + "en": "Picarto is the world’s leading live streaming platform for creative minds. Come join us and watch artists from all over the world during their creative process!", + "nl": "Picarto is 's werelds toonaangevende live streamingplatform voor creatieve geesten. Doe mee en kijk naar artiesten van over de hele wereld tijdens hun creatieve proces!" + }, + "url": "picarto.tv", + "version": "1.2.27", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Picarto/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Picarto/assets/thumbnail.png", + "color": "#35A775", + "category": "videos", + "tags": [ + "video" + ] +} diff --git a/websites/P/Picarto/presence.ts b/websites/P/Picarto/presence.ts index 2987a443a16d..ad6cd83a91f8 100644 --- a/websites/P/Picarto/presence.ts +++ b/websites/P/Picarto/presence.ts @@ -1,48 +1,47 @@ const presence = new Presence({ - clientId: "630771716058120192", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Picarto/assets/logo.png", - }, - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '630771716058120192', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) +const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Picarto/assets/logo.png', +} +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const video = document.querySelector(".mistvideo-video"); - if (video && !isNaN(video.duration)) { - const title = document.querySelector( - ".styled__StreamTitle-sc-sf47ty-9" - ), - uploader = document.querySelector( - ".ChannelToolbarTitle__ChannelTitle-sc-146631g-3" - ); - presenceData.details = title ? title.textContent : "Title not found..."; - presenceData.state = uploader - ? uploader.textContent - : "Uploader not found..."; - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/P/Picarto/assets/logo.png"; - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? (await strings).pause - : (await strings).play; - presenceData.startTimestamp = browsingTimestamp; +presence.on('UpdateData', async () => { + const video = document.querySelector('.mistvideo-video') + if (video && !Number.isNaN(video.duration)) { + const title = document.querySelector( + '.styled__StreamTitle-sc-sf47ty-9', + ) + const uploader = document.querySelector( + '.ChannelToolbarTitle__ChannelTitle-sc-146631g-3', + ) + presenceData.details = title ? title.textContent : 'Title not found...' + presenceData.state = uploader + ? uploader.textContent + : 'Uploader not found...' + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/P/Picarto/assets/logo.png' + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? (await strings).pause + : (await strings).play + presenceData.startTimestamp = browsingTimestamp - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } - if (title && uploader) presence.setActivity(presenceData, !video.paused); - } else { - presence.setActivity({ - details: "Browsing..", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Picarto/assets/logo.png", - }); - } -}); + if (title && uploader) + presence.setActivity(presenceData, !video.paused) + } + else { + presence.setActivity({ + details: 'Browsing..', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Picarto/assets/logo.png', + }) + } +}) diff --git a/websites/P/PikiDiary/metadata.json b/websites/P/PikiDiary/metadata.json index 903e24dbfad4..96a67ad51ad9 100644 --- a/websites/P/PikiDiary/metadata.json +++ b/websites/P/PikiDiary/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "302505485519683585", - "name": "darkitxu84" - }, - "service": "PikiDiary", - "description": { - "en": "PikiDiary is a microblogging platform where you can record fun memories and share them with everyone!" - }, - "url": "pikidiary.lol", - "version": "1.0.0", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PikiDiary/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PikiDiary/assets/thumbnail.png", - "color": "#ABD022", - "category": "socials", - "tags": [ - "social", - "media", - "pikidiary" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "302505485519683585", + "name": "darkitxu84" + }, + "service": "PikiDiary", + "description": { + "en": "PikiDiary is a microblogging platform where you can record fun memories and share them with everyone!" + }, + "url": "pikidiary.lol", + "version": "1.0.0", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PikiDiary/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PikiDiary/assets/thumbnail.png", + "color": "#ABD022", + "category": "socials", + "tags": [ + "social", + "media", + "pikidiary" + ] +} diff --git a/websites/P/PikiDiary/presence.ts b/websites/P/PikiDiary/presence.ts index c18f581f25bf..c1815cf58e5a 100644 --- a/websites/P/PikiDiary/presence.ts +++ b/websites/P/PikiDiary/presence.ts @@ -1,107 +1,116 @@ const presence = new Presence({ - clientId: "1327078556802482206", - }), - getElement = (query: string): string | undefined => { - return document.querySelector(query)?.textContent; - }, - browsingTimestamp = Math.floor(Date.now() / 1000), - BROWSING_TEXTS = new Map([ - ["following", "their following posts..."], - ["me", "their own posts..."], - ["explore", "users posts..."], - ["tagged", "their tagged posts..."], - ]); + clientId: '1327078556802482206', +}) +function getElement(query: string): string | undefined { + return document.querySelector(query)?.textContent ?? undefined +} +const browsingTimestamp = Math.floor(Date.now() / 1000) +const BROWSING_TEXTS = new Map([ + ['following', 'their following posts...'], + ['me', 'their own posts...'], + ['explore', 'users posts...'], + ['tagged', 'their tagged posts...'], +]) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/PikiDiary/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/PikiDiary/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - name: "PikiDiary", - type: ActivityType.Playing, - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname, search, href } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + name: 'PikiDiary', + type: ActivityType.Playing, + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname, search, href } = document.location - if (pathname === "/") presenceData.details = "Viewing home page"; - else if (pathname.includes("@")) { - // the @ means that we're in a user page - if (!document.querySelector(".info > a")) { - presenceData.details = `Viewing ${getElement(".info > span")} profile`; - presenceData.largeImageKey = - document.querySelector(".bar > div > img") ?? - Assets.Logo; - presenceData.buttons = [ - { - label: "View Profile", - url: href, - }, - ]; - } else { - // self profile - let slicedSearch = ""; - search ? (slicedSearch = search.slice(5)) : (slicedSearch = "following"); - presenceData.details = "Browsing through"; - presenceData.state = BROWSING_TEXTS.get(slicedSearch); - } - } else if (pathname.includes("live")) { - if (pathname.includes("studio")) { - const viewCount = getElement("#view-count"); - if (viewCount === "0") { - // not streaming yet - presenceData.details = "Managing their live..."; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Setting up..."; - } else { - presenceData.details = - document.querySelector("#title-text").textContent; - presenceData.state = `Live on PikiDiary // ${viewCount} viewers`; - presenceData.largeImageKey = - document.querySelector(".avatar-small") ?? - Assets.Logo; // user avatar - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = "Live"; - presenceData.buttons = [ - { - label: "Watch Live", - url: getElement("#share-link"), - }, - ]; - } - } else { - (presenceData as PresenceData).type = ActivityType.Watching; - presenceData.details = getElement("#title-text"); // live name - presenceData.state = document.querySelectorAll("a")[4].textContent; // user name - presenceData.largeImageKey = - document.querySelector(".avatar-small") ?? - Assets.Logo; // user avatar - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = "Live"; - presenceData.buttons = [ - { - label: "Watch Live", - url: href, - }, - ]; - } - } else if (pathname.includes("settings")) { - presenceData.details = "Setting up"; - presenceData.state = "their profile"; - } else if (pathname.includes("posts")) { - presenceData.details = `Reading a post of ${getElement(".post-name")}`; - presenceData.state = `${getElement(".like-count")} likes // ${ - document.querySelectorAll(".post-button")[1].textContent - } replys`; - presenceData.buttons = [ - { - label: "View Post", - url: href, - }, - ]; - } else if (pathname.includes("login")) presenceData.details = "Logging in"; - else if (pathname.includes("signup")) presenceData.details = "Signing up"; + if (pathname === '/') { + presenceData.details = 'Viewing home page' + } + else if (pathname.includes('@')) { + // the @ means that we're in a user page + if (!document.querySelector('.info > a')) { + presenceData.details = `Viewing ${getElement('.info > span')} profile` + presenceData.largeImageKey = document.querySelector('.bar > div > img') + ?? Assets.Logo + presenceData.buttons = [ + { + label: 'View Profile', + url: href, + }, + ] + } + else { + // self profile + let slicedSearch = '' + search ? (slicedSearch = search.slice(5)) : (slicedSearch = 'following') + presenceData.details = 'Browsing through' + presenceData.state = BROWSING_TEXTS.get(slicedSearch) + } + } + else if (pathname.includes('live')) { + if (pathname.includes('studio')) { + const viewCount = getElement('#view-count') + if (viewCount === '0') { + // not streaming yet + presenceData.details = 'Managing their live...' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Setting up...' + } + else { + presenceData.details = document.querySelector('#title-text')?.textContent + presenceData.state = `Live on PikiDiary // ${viewCount} viewers` + presenceData.largeImageKey = document.querySelector('.avatar-small') + ?? Assets.Logo // user avatar + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = 'Live' + presenceData.buttons = [ + { + label: 'Watch Live', + url: getElement('#share-link') ?? '', + }, + ] + } + } + else { + (presenceData as PresenceData).type = ActivityType.Watching + presenceData.details = getElement('#title-text') // live name + presenceData.state = document.querySelectorAll('a')[4].textContent // user name + presenceData.largeImageKey = document.querySelector('.avatar-small') + ?? Assets.Logo // user avatar + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = 'Live' + presenceData.buttons = [ + { + label: 'Watch Live', + url: href, + }, + ] + } + } + else if (pathname.includes('settings')) { + presenceData.details = 'Setting up' + presenceData.state = 'their profile' + } + else if (pathname.includes('posts')) { + presenceData.details = `Reading a post of ${getElement('.post-name')}` + presenceData.state = `${getElement('.like-count')} likes // ${ + document.querySelectorAll('.post-button')[1].textContent + } replys` + presenceData.buttons = [ + { + label: 'View Post', + url: href, + }, + ] + } + else if (pathname.includes('login')) { + presenceData.details = 'Logging in' + } + else if (pathname.includes('signup')) { + presenceData.details = 'Signing up' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/Pinterest/metadata.json b/websites/P/Pinterest/metadata.json index 637a449f0e83..4722449a57b5 100644 --- a/websites/P/Pinterest/metadata.json +++ b/websites/P/Pinterest/metadata.json @@ -1,38 +1,38 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "contributors": [ - { - "name": "Dark_Ville", - "id": "638080361179512853" - } - ], - "service": "Pinterest", - "description": { - "en": "Discover recipes, home ideas, style inspiration and other ideas to try.", - "nl": "Ontdek recepten, huisideeën, stijlinspiratie en andere ideeën om uit te proberen.", - "vi_VN": "Khám phá các công thức, ý tưởng cải tiến nhà, cảm hứng và các ý tưởng khác." - }, - "url": "www.pinterest.com", - "regExp": "([a-z0-9-]+[.])*pinterest([.][a-z]+)+[/]", - "version": "1.4.5", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pinterest/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pinterest/assets/thumbnail.jpg", - "color": "#cc2127", - "category": "other", - "tags": [ - "pinterest" - ], - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "contributors": [ + { + "name": "Dark_Ville", + "id": "638080361179512853" + } + ], + "service": "Pinterest", + "description": { + "en": "Discover recipes, home ideas, style inspiration and other ideas to try.", + "nl": "Ontdek recepten, huisideeën, stijlinspiratie en andere ideeën om uit te proberen.", + "vi_VN": "Khám phá các công thức, ý tưởng cải tiến nhà, cảm hứng và các ý tưởng khác." + }, + "url": "www.pinterest.com", + "regExp": "([a-z0-9-]+[.])*pinterest([.][a-z]+)+[/]", + "version": "1.4.5", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pinterest/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pinterest/assets/thumbnail.jpg", + "color": "#cc2127", + "category": "other", + "tags": [ + "pinterest" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/P/Pinterest/presence.ts b/websites/P/Pinterest/presence.ts index 4e4bd792546c..4ddb2a49faeb 100644 --- a/websites/P/Pinterest/presence.ts +++ b/websites/P/Pinterest/presence.ts @@ -1,139 +1,140 @@ const presence = new Presence({ - clientId: "629428243061145640", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '629428243061145640', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Likes = "https://cdn.rcd.gg/PreMiD/websites/P/Pinterest/assets/0.png", - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Pinterest/assets/logo.png", - Loading = "https://i.imgur.com/6s5f2TA\u002egif", + Likes = 'https://cdn.rcd.gg/PreMiD/websites/P/Pinterest/assets/0.png', + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Pinterest/assets/logo.png', + Loading = 'https://i.imgur.com/6s5f2TA\u002Egif', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname, hostname, href } = document.location, - buttons = await presence.getSetting("buttons"), - ideasHubPage = - document.querySelector('[data-test-id="ideas-hub-page-header"]') || - document.querySelector('[data-test-id="control-ideas-redesign-header"]'), - search = document.querySelector( - 'input[aria-label="Search"],input[aria-label="search"]' - ), - video = document.querySelector("video"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname, hostname, href } = document.location + const buttons = await presence.getSetting('buttons') + const ideasHubPage = document.querySelector('[data-test-id="ideas-hub-page-header"]') + || document.querySelector('[data-test-id="control-ideas-redesign-header"]') + const search = document.querySelector( + 'input[aria-label="Search"],input[aria-label="search"]', + ) + const video = document.querySelector('video') - if (hostname === "help.pinterest.com") { - presenceData.details = "Viewing the help center"; - presence.setActivity(presenceData); - return; - } - switch (true) { - case document.readyState !== "complete": { - presenceData.details = "Loading"; - presenceData.smallImageKey = Assets.Loading; - break; - } - case !!search?.value: { - presenceData.details = !pathname.includes("/search/") - ? "Searching for" - : "Viewing search results for"; - presenceData.state = search.value; - presenceData.smallImageKey = Assets.Search; - break; - } - case !!document.querySelector( - '[data-layout-shift-boundary-id="ProfilePageContainer"]' - ): { - presenceData.details = "Viewing profile of"; - presenceData.state = document.querySelector( - '[data-test-id="profile-name"]' - )?.textContent; - presenceData.buttons = [{ label: "View Profile", url: href }]; - break; - } + if (hostname === 'help.pinterest.com') { + presenceData.details = 'Viewing the help center' + presence.setActivity(presenceData) + return + } + switch (true) { + case document.readyState !== 'complete': { + presenceData.details = 'Loading' + presenceData.smallImageKey = Assets.Loading + break + } + case !!search?.value: { + presenceData.details = !pathname.includes('/search/') + ? 'Searching for' + : 'Viewing search results for' + presenceData.state = search.value + presenceData.smallImageKey = Assets.Search + break + } + case !!document.querySelector( + '[data-layout-shift-boundary-id="ProfilePageContainer"]', + ): { + presenceData.details = 'Viewing profile of' + presenceData.state = document.querySelector( + '[data-test-id="profile-name"]', + )?.textContent + presenceData.buttons = [{ label: 'View Profile', url: href }] + break + } - case pathname.includes("/pin/"): { - const creatorProfile = document - .querySelector('[data-test-id="official-user-attribution"]') - ?.querySelector("a")?.href, - likesEl = document.querySelector( - '[data-test-id="Reaction"]' - )?.textContent; - presenceData.details = - JSON.parse( - document.querySelector('[data-test-id="leaf-snippet"]')?.textContent - )?.headline ?? "Viewing a pin"; + case pathname.includes('/pin/'): { + const creatorProfile = document + .querySelector('[data-test-id="official-user-attribution"]') + ?.querySelector('a') + ?.href + const likesEl = document.querySelector( + '[data-test-id="Reaction"]', + )?.textContent + presenceData.details = JSON.parse( + document.querySelector('[data-test-id="leaf-snippet"]')?.textContent ?? '{}', + )?.headline ?? 'Viewing a pin' - if (!isNaN(video?.duration)) { - delete presenceData.startTimestamp; - if (!video.paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - } - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused ? "Paused" : "Playing back"; - presenceData.state = `Viewing a video pin by: ${ - document.querySelector( - '[data-test-id="creator-profile-name"],[data-test-id="username"]' - )?.textContent - }`; - presenceData.buttons = creatorProfile - ? [ - { label: "Watch Video Pin", url: href }, - { - label: "View Creator's Profile", - url: creatorProfile, - }, - ] - : [{ label: "Watch Video Pin", url: href }]; - } else { - if (likesEl) { - presenceData.smallImageKey = Assets.Likes; - presenceData.smallImageText = `${likesEl} likes`; - } - presenceData.state = `Viewing pin by: ${ - document.querySelector( - '[data-test-id="creator-profile-name"],[data-test-id="username"]' - )?.textContent - }`; - presenceData.buttons = creatorProfile - ? [ - { label: "View Pin", url: href }, - { - label: "View Creator's Profile", - url: creatorProfile, - }, - ] - : [{ label: "View Pin", url: href }]; - } - break; - } - case pathname.includes("/ideas/") && - !!pathname.match(/[0-9]{12}/gm)?.length: { - presenceData.details = `Browsing through ideas about: ${ideasHubPage?.textContent}`; - presenceData.state = Array.from( - document.querySelectorAll('[data-test-id="breadcrumb"]') || [] - ) - .map(x => x?.textContent) - .join(" => "); - presenceData.buttons = [{ label: "Browse Through Ideas", url: href }]; - break; - } - case pathname.includes("/videos/"): { - presenceData.details = "Browsing through videos"; - break; - } - case pathname === "/": { - presenceData.details = "Viewing the homepage"; - break; - } - default: { - presenceData.details = "Viewing an unknown page"; - } - } + if (video && !Number.isNaN(video.duration)) { + delete presenceData.startTimestamp + if (!video.paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + } + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused ? 'Paused' : 'Playing back' + presenceData.state = `Viewing a video pin by: ${ + document.querySelector( + '[data-test-id="creator-profile-name"],[data-test-id="username"]', + )?.textContent + }` + presenceData.buttons = creatorProfile + ? [ + { label: 'Watch Video Pin', url: href }, + { + label: 'View Creator\'s Profile', + url: creatorProfile, + }, + ] + : [{ label: 'Watch Video Pin', url: href }] + } + else { + if (likesEl) { + presenceData.smallImageKey = Assets.Likes + presenceData.smallImageText = `${likesEl} likes` + } + presenceData.state = `Viewing pin by: ${ + document.querySelector( + '[data-test-id="creator-profile-name"],[data-test-id="username"]', + )?.textContent + }` + presenceData.buttons = creatorProfile + ? [ + { label: 'View Pin', url: href }, + { + label: 'View Creator\'s Profile', + url: creatorProfile, + }, + ] + : [{ label: 'View Pin', url: href }] + } + break + } + case pathname.includes('/ideas/') + && !!pathname.match(/\d{12}/g)?.length: { + presenceData.details = `Browsing through ideas about: ${ideasHubPage?.textContent}` + presenceData.state = Array.from( + document.querySelectorAll('[data-test-id="breadcrumb"]') || [], + ) + .map(x => x?.textContent) + .join(' => ') + presenceData.buttons = [{ label: 'Browse Through Ideas', url: href }] + break + } + case pathname.includes('/videos/'): { + presenceData.details = 'Browsing through videos' + break + } + case pathname === '/': { + presenceData.details = 'Viewing the homepage' + break + } + default: { + presenceData.details = 'Viewing an unknown page' + } + } - if (!buttons && presenceData.buttons) delete presenceData.buttons; - if (presenceData.details) presence.setActivity(presenceData); -}); + if (!buttons && presenceData.buttons) + delete presenceData.buttons + if (presenceData.details) + presence.setActivity(presenceData) +}) diff --git a/websites/P/Pixelmon Mod/metadata.json b/websites/P/Pixelmon Mod/metadata.json index b2b7501dc77f..d983186d0c6c 100644 --- a/websites/P/Pixelmon Mod/metadata.json +++ b/websites/P/Pixelmon Mod/metadata.json @@ -1,36 +1,36 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dark_Ville", - "id": "638080361179512853" - }, - "service": "Pixelmon Mod", - "description": { - "en": "Pixelmon adds many aspects of Pokémon into Minecraft, including the Pokémon themselves, battling, trading, and breeding.", - "nl": "Pixelmon voegt veel aspecten van Pokémon toe aan Minecraft, zoals Pokémon zelf, vechten, ruilen en fokken." - }, - "url": "pixelmonmod.com", - "version": "2.0.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pixelmon%20Mod/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pixelmon%20Mod/assets/thumbnail.jpg", - "color": "#F27635", - "category": "games", - "tags": [ - "pixelmon", - "pokemon" - ], - "settings": [ - { - "id": "image", - "title": "Image Size", - "icon": "fad fa-images", - "value": 0, - "values": [ - "Use as Large Image", - "Use as Small Image", - "Disable" - ] - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dark_Ville", + "id": "638080361179512853" + }, + "service": "Pixelmon Mod", + "description": { + "en": "Pixelmon adds many aspects of Pokémon into Minecraft, including the Pokémon themselves, battling, trading, and breeding.", + "nl": "Pixelmon voegt veel aspecten van Pokémon toe aan Minecraft, zoals Pokémon zelf, vechten, ruilen en fokken." + }, + "url": "pixelmonmod.com", + "version": "2.0.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pixelmon%20Mod/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pixelmon%20Mod/assets/thumbnail.jpg", + "color": "#F27635", + "category": "games", + "tags": [ + "pixelmon", + "pokemon" + ], + "settings": [ + { + "id": "image", + "title": "Image Size", + "icon": "fad fa-images", + "value": 0, + "values": [ + "Use as Large Image", + "Use as Small Image", + "Disable" + ] + } + ] +} diff --git a/websites/P/Pixelmon Mod/presence.ts b/websites/P/Pixelmon Mod/presence.ts index 8a98bbe6cb6a..a0ff7307a62d 100644 --- a/websites/P/Pixelmon Mod/presence.ts +++ b/websites/P/Pixelmon Mod/presence.ts @@ -1,141 +1,143 @@ const presence = new Presence({ - clientId: "976435781486911509", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '976435781486911509', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Pixelmon%20Mod/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Pixelmon%20Mod/assets/logo.png', } const timestampCheck: { - hash: string; - timestamp: number; + hash: string + timestamp: number } = { - hash: "", - timestamp: Math.floor(Date.now() / 1000), -}; + hash: '', + timestamp: Math.floor(Date.now() / 1000), +} function fullURL(host: string, url: string) { - if (url === Assets.Logo) return Assets.Logo; - else if (url && host) return `https://${host}${url}`; + if (url === Assets.Logo) + return Assets.Logo + else if (url && host) + return `https://${host}${url}` } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - image = await presence.getSetting("image"), - { pathname, hostname, href } = document.location, - title = - document.querySelector('[class="side-segment"]') ?? - document.querySelector( - "#page-body > main > div > div.col-md-9 > div.side-segment > h3" - ), - firstChild = document.querySelector( - "#content > div.contentHeader" - )?.firstElementChild, - search = document.querySelector("#searchInput"), - hash: string = href; - if (timestampCheck.hash !== hash) { - timestampCheck.hash = hash; - timestampCheck.timestamp = Math.floor(Date.now() / 1000); - } - switch (true) { - case !!search?.value: { - presenceData.smallImageKey = Assets.Search; - presenceData.details = "Searching for"; - presenceData.state = search.value; - break; - } - case !!document.querySelector("#firstHeading-h2csdq87lb"): { - presenceData.details = "Search results for"; - presenceData.state = document.querySelector("#ooui-php-1").textContent; - break; - } - case document.querySelector("#siteSub")?.textContent.includes("Wiki"): { - if (firstChild.className.includes("firstHeading")) { - presenceData.state = firstChild.textContent; - presenceData.smallImageKey = Assets.Reading; - presenceData.details = "Reading wiki page"; - const matchingElement = document.evaluate( - "//b[contains(text(),'#')]", - document, - null, - XPathResult.FIRST_ORDERED_NODE_TYPE, - null - )?.singleNodeValue?.textContent, - img = matchingElement - ? `https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/${ - Number(matchingElement?.split("#")[1].at(0)) === 0 - ? matchingElement?.split("#")[1].slice(1) - : matchingElement?.split("#")[1] - }.png` - : fullURL( - hostname, - document - .querySelector('[class="image"] > img') - ?.getAttribute("src") ?? Assets.Logo - ); - presenceData.largeImageKey = image === 0 ? img : Assets.Logo; - presenceData.smallImageKey = - image === 0 || image === 2 ? Assets.Reading : img ?? Assets.Reading; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const image = await presence.getSetting('image') + const { pathname, hostname, href } = document.location + const title = document.querySelector('[class="side-segment"]') + ?? document.querySelector( + '#page-body > main > div > div.col-md-9 > div.side-segment > h3', + ) + const firstChild = document.querySelector( + '#content > div.contentHeader', + )?.firstElementChild + const search = document.querySelector('#searchInput') + const hash: string = href + if (timestampCheck.hash !== hash) { + timestampCheck.hash = hash + timestampCheck.timestamp = Math.floor(Date.now() / 1000) + } + switch (true) { + case !!search?.value: { + presenceData.smallImageKey = Assets.Search + presenceData.details = 'Searching for' + presenceData.state = search.value + break + } + case !!document.querySelector('#firstHeading-h2csdq87lb'): { + presenceData.details = 'Search results for' + presenceData.state = document.querySelector('#ooui-php-1')?.textContent + break + } + case document.querySelector('#siteSub')?.textContent?.includes('Wiki'): { + if (firstChild?.className.includes('firstHeading')) { + presenceData.state = firstChild.textContent + presenceData.smallImageKey = Assets.Reading + presenceData.details = 'Reading wiki page' + const matchingElement = document.evaluate( + '//b[contains(text(),\'#\')]', + document, + null, + XPathResult.FIRST_ORDERED_NODE_TYPE, + null, + )?.singleNodeValue?.textContent + const img = matchingElement + ? `https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/${ + Number(matchingElement?.split('#')[1].at(0)) === 0 + ? matchingElement?.split('#')[1].slice(1) + : matchingElement?.split('#')[1] + }.png` + : fullURL( + hostname, + document + .querySelector('[class="image"] > img') + ?.getAttribute('src') ?? Assets.Logo, + ) + presenceData.largeImageKey = image === 0 ? img : Assets.Logo + presenceData.smallImageKey = image === 0 || image === 2 ? Assets.Reading : img ?? Assets.Reading - presenceData.buttons = [{ label: "Read Wiki Page", url: href }]; - } else presenceData.details = "Reading the wiki"; - break; - } - case pathname.includes("index.php"): { - presenceData.details = "Viewing the forum"; - break; - } - case pathname.includes("viewforum.php"): { - presenceData.details = `${title.textContent} Forum`; - break; - } - case pathname.includes("viewtopic.php"): { - presenceData.details = "Viewing post"; - presenceData.state = title.textContent; - presenceData.buttons = [{ label: "Read Post", url: href }]; - break; - } - case pathname.includes("team.php"): { - presenceData.details = `Pixelmon's ${ - document.querySelector("li[class='team-nav-active']").textContent - } Team`; - break; - } - case pathname.includes("ucp.php?mode="): { - presenceData.details = title.textContent; - presenceData.smallImageKey = Assets.Reading; - break; - } - case pathname.includes("downloads.php"): { - presenceData.details = "Viewing all available downloads"; - break; - } - case pathname.includes("donation.php"): { - presenceData.details = "Viewing the donations page"; - break; - } - case pathname.includes("tracker.php"): { - presenceData.details = - title?.textContent === "Bugs" - ? "Viewing known bugs" - : title.textContent; - presenceData.state = - document.querySelectorAll('[class="side-segment"]')?.[1]?.textContent ?? - ""; - presenceData.buttons = [{ label: "View Bug Report", url: href }]; - break; - } - case !!document.querySelector( - "#page-body > main > div > div.col-sm-8 > div:nth-child(2)" - ): { - presenceData.details = "Viewing the homepage"; - break; - } - } + presenceData.buttons = [{ label: 'Read Wiki Page', url: href }] + } + else { + presenceData.details = 'Reading the wiki' + } + break + } + case pathname.includes('index.php'): { + presenceData.details = 'Viewing the forum' + break + } + case pathname.includes('viewforum.php'): { + presenceData.details = `${title?.textContent} Forum` + break + } + case pathname.includes('viewtopic.php'): { + presenceData.details = 'Viewing post' + presenceData.state = title?.textContent + presenceData.buttons = [{ label: 'Read Post', url: href }] + break + } + case pathname.includes('team.php'): { + presenceData.details = `Pixelmon's ${ + document.querySelector('li[class=\'team-nav-active\']')?.textContent + } Team` + break + } + case pathname.includes('ucp.php?mode='): { + presenceData.details = title?.textContent + presenceData.smallImageKey = Assets.Reading + break + } + case pathname.includes('downloads.php'): { + presenceData.details = 'Viewing all available downloads' + break + } + case pathname.includes('donation.php'): { + presenceData.details = 'Viewing the donations page' + break + } + case pathname.includes('tracker.php'): { + presenceData.details = title?.textContent === 'Bugs' + ? 'Viewing known bugs' + : title?.textContent + presenceData.state = document.querySelectorAll('[class="side-segment"]')?.[1]?.textContent + ?? '' + presenceData.buttons = [{ label: 'View Bug Report', url: href }] + break + } + case !!document.querySelector( + '#page-body > main > div > div.col-sm-8 > div:nth-child(2)', + ): { + presenceData.details = 'Viewing the homepage' + break + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/Pixlr/metadata.json b/websites/P/Pixlr/metadata.json index 2f315f4dc571..a1e575f899eb 100644 --- a/websites/P/Pixlr/metadata.json +++ b/websites/P/Pixlr/metadata.json @@ -1,22 +1,22 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Lavenderleaff", - "id": "988801425196867644" - }, - "service": "Pixlr", - "description": { - "en": "Welcome to Pixlr, the No 1 in photo editing and design tools. Edit photos and create stunning designs right in your browser, on your phone or desktop for free. Start from an empty canvas, a photo, a video or select one of our professionally crafted templates." - }, - "url": "pixlr.com", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/thumbnail.png", - "color": "#2596be", - "category": "other", - "tags": [ - "photo", - "editing" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Lavenderleaff", + "id": "988801425196867644" + }, + "service": "Pixlr", + "description": { + "en": "Welcome to Pixlr, the No 1 in photo editing and design tools. Edit photos and create stunning designs right in your browser, on your phone or desktop for free. Start from an empty canvas, a photo, a video or select one of our professionally crafted templates." + }, + "url": "pixlr.com", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/thumbnail.png", + "color": "#2596be", + "category": "other", + "tags": [ + "photo", + "editing" + ] +} diff --git a/websites/P/Pixlr/presence.ts b/websites/P/Pixlr/presence.ts index f17982831b43..6f263cbc8cf8 100644 --- a/websites/P/Pixlr/presence.ts +++ b/websites/P/Pixlr/presence.ts @@ -1,65 +1,81 @@ const presence = new Presence({ - clientId: "995363603261702234", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '995363603261702234', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - startTimestamp: browsingTimestamp, - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/logo.jpg", - }; - if (document.location.pathname === "/") - presenceData.details = "Viewing the home page"; - else if (document.location.pathname.includes("remove-background")) { - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/0.png"; - presenceData.details = "Using Remove Background"; - } else if (document.location.pathname.includes("mobile")) { - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/1.png"; - presenceData.details = "Viewing Pixlr Stories"; - } else if (document.location.pathname.includes("myaccount")) - presenceData.details = "Editing account settings"; - else if (document.location.pathname.startsWith("/photomash/")) { - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/2.png"; - if (document.location.hash.endsWith("#editor")) - presenceData.details = "Editing a photo in Photomash"; - else presenceData.details = "Browing Photomash"; - } else if (document.location.pathname.startsWith("/x/")) { - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/3.png"; - if (document.location.hash.endsWith("#editor")) { - presenceData.details = `Editing a photo at ${ - document.querySelector("#zoom-level").textContent - } zoom...`; - } else if (document.location.hash.endsWith("template")) - presenceData.details = "Browsing templates"; - else if (document.location.hash.endsWith("search")) - presenceData.details = "Searching for stock images"; - else if (document.location.hash.endsWith("home")) - presenceData.details = "Browsing Pixlr X"; - else if (document.location.hash.endsWith("history")) - presenceData.details = "Viewing their history"; - else presenceData.details = "Browsing Pixlr X"; - } else if (document.location.pathname.startsWith("/e/")) { - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/4.png"; - if (document.location.hash.endsWith("#editor")) { - presenceData.details = "Editing a photo in"; - presenceData.state = `${ - document.querySelector("#horizontal-image-info").textContent - }.`; - } else if (document.location.hash.endsWith("template")) - presenceData.details = "Browsing templates"; - else if (document.location.hash.endsWith("search")) - presenceData.details = "Searching for stock images"; - else if (document.location.hash.endsWith("home")) - presenceData.details = "Browsing Pixlr E"; - else if (document.location.hash.endsWith("history")) - presenceData.details = "Viewing their history"; - else presenceData.details = "Browsing Pixlr E"; - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + startTimestamp: browsingTimestamp, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/logo.jpg', + } + if (document.location.pathname === '/') { + presenceData.details = 'Viewing the home page' + } + else if (document.location.pathname.includes('remove-background')) { + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/0.png' + presenceData.details = 'Using Remove Background' + } + else if (document.location.pathname.includes('mobile')) { + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/1.png' + presenceData.details = 'Viewing Pixlr Stories' + } + else if (document.location.pathname.includes('myaccount')) { + presenceData.details = 'Editing account settings' + } + else if (document.location.pathname.startsWith('/photomash/')) { + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/2.png' + if (document.location.hash.endsWith('#editor')) + presenceData.details = 'Editing a photo in Photomash' + else presenceData.details = 'Browing Photomash' + } + else if (document.location.pathname.startsWith('/x/')) { + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/3.png' + if (document.location.hash.endsWith('#editor')) { + presenceData.details = `Editing a photo at ${ + document.querySelector('#zoom-level')?.textContent + } zoom...` + } + else if (document.location.hash.endsWith('template')) { + presenceData.details = 'Browsing templates' + } + else if (document.location.hash.endsWith('search')) { + presenceData.details = 'Searching for stock images' + } + else if (document.location.hash.endsWith('home')) { + presenceData.details = 'Browsing Pixlr X' + } + else if (document.location.hash.endsWith('history')) { + presenceData.details = 'Viewing their history' + } + else { + presenceData.details = 'Browsing Pixlr X' + } + } + else if (document.location.pathname.startsWith('/e/')) { + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/P/Pixlr/assets/4.png' + if (document.location.hash.endsWith('#editor')) { + presenceData.details = 'Editing a photo in' + presenceData.state = `${ + document.querySelector('#horizontal-image-info')?.textContent + }.` + } + else if (document.location.hash.endsWith('template')) { + presenceData.details = 'Browsing templates' + } + else if (document.location.hash.endsWith('search')) { + presenceData.details = 'Searching for stock images' + } + else if (document.location.hash.endsWith('home')) { + presenceData.details = 'Browsing Pixlr E' + } + else if (document.location.hash.endsWith('history')) { + presenceData.details = 'Viewing their history' + } + else { + presenceData.details = 'Browsing Pixlr E' + } + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/Planet Minecraft/metadata.json b/websites/P/Planet Minecraft/metadata.json index 50c7d81daff0..af031322c987 100644 --- a/websites/P/Planet Minecraft/metadata.json +++ b/websites/P/Planet Minecraft/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "283380624687890433", - "name": "cardinalsystem" - }, - "service": "Planet Minecraft", - "description": { - "en": "Planet Minecraft is a family friendly community that shares and respects the creative works and interests of others. They have a variety of entertaining ways to explore and upload content, socialize and find like minded creative members from around the world that love the game of Minecraft." - }, - "url": "www.planetminecraft.com", - "version": "1.0.5", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Planet%20Minecraft/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Planet%20Minecraft/assets/thumbnail.jpg", - "color": "#014E96", - "category": "games", - "tags": [ - "planetminecraft", - "minecraft", - "games" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "283380624687890433", + "name": "cardinalsystem" + }, + "service": "Planet Minecraft", + "description": { + "en": "Planet Minecraft is a family friendly community that shares and respects the creative works and interests of others. They have a variety of entertaining ways to explore and upload content, socialize and find like minded creative members from around the world that love the game of Minecraft." + }, + "url": "www.planetminecraft.com", + "version": "1.0.5", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Planet%20Minecraft/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Planet%20Minecraft/assets/thumbnail.jpg", + "color": "#014E96", + "category": "games", + "tags": [ + "planetminecraft", + "minecraft", + "games" + ] +} diff --git a/websites/P/Planet Minecraft/presence.ts b/websites/P/Planet Minecraft/presence.ts index 7a9df71af373..0162285fcfca 100644 --- a/websites/P/Planet Minecraft/presence.ts +++ b/websites/P/Planet Minecraft/presence.ts @@ -1,342 +1,366 @@ const presence = new Presence({ - clientId: "1193411747898458132", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - stateless = "stateless"; + clientId: '1193411747898458132', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const stateless = 'stateless' async function getStrings() { - return presence.getStrings({ - viewHome: "general.viewHome", - viewMember: "general.viewMember", - viewChannel: "general.viewChannel", - readingThread: "general.readingThread", - browsing: "general.browsing", - reading: "general.reading", - }); + return presence.getStrings({ + viewHome: 'general.viewHome', + viewMember: 'general.viewMember', + viewChannel: 'general.viewChannel', + readingThread: 'general.readingThread', + browsing: 'general.browsing', + reading: 'general.reading', + }) } -let strings: Awaited>; +let strings: Awaited> -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - details: "Viewing page:", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Planet%20Minecraft/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + details: 'Viewing page:', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Planet%20Minecraft/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (!strings) strings = await getStrings(); + if (!strings) + strings = await getStrings() - const pathname = document.location.pathname.replaceAll(/\/$/g, ""); + const pathname = document.location.pathname.replaceAll(/\/$/g, '') - if (pathname === "") { - presenceData.state = strings.viewHome; - delete presenceData.details; - } else { - const url = `${document.location.protocol}//${document.location.host}${document.location.pathname}`; - if (pathname.startsWith("/member")) - memberActivity(presenceData, pathname, url); - else if ( - pathname.startsWith("/account/manage") && - pathname.endsWith("/new") - ) { - presenceData.details = "Managing Submissions"; - presenceData.state = document.querySelector("#manage_header").textContent; - } else { - switch (pathname) { - case "/projects": { - genericFeed(presenceData, "Maps", url); - break; - } - case "/texture-packs": { - genericFeed(presenceData, "Resource Packs", url); - break; - } - case "/skins": { - genericFeed(presenceData, "Skins", url); - break; - } - case "/mob-skins": { - genericFeed(presenceData, "Mob Skins", url); - break; - } - case "/data-packs": { - genericFeed(presenceData, "Data Packs", url); - break; - } - case "/mods": { - genericFeed(presenceData, "Mods", url); - break; - } - case "/blogs": { - genericFeed(presenceData, "Blogs", url); - break; - } - case "/servers": { - genericFeed(presenceData, "Servers", url); - break; - } - case "/bedrock-servers": { - genericFeed(presenceData, "Bedrock Servers", url); - break; - } - case "/collections": { - genericFeed(presenceData, "Collections", url); - break; - } - default: { - if (pathname.startsWith("/mod")) { - presenceData.details = "Viewing mod:"; - genericSubmission(presenceData, "Mod", url); - } else if (pathname.startsWith("/blog")) { - presenceData.details = `${strings.reading} a blog:`; - genericSubmission(presenceData, "Blog", url); - } else if (pathname.startsWith("/project")) { - presenceData.details = "Viewing map:"; - genericSubmission(presenceData, "Map", url); - } else if (pathname.startsWith("/texture-pack")) { - presenceData.details = "Viewing a resource pack:"; - genericSubmission(presenceData, "Resource Pack", url); - } else if (pathname.startsWith("/skin")) { - presenceData.details = "Viewing skin:"; - genericSubmission(presenceData, "Skin", url); - } else if (pathname.startsWith("/mob-skin")) { - presenceData.details = "Viewing mob skin:"; - genericSubmission(presenceData, "Mob Skin", url); - } else if (pathname.startsWith("/data-pack")) { - presenceData.details = "Viewing data pack:"; - genericSubmission(presenceData, "Data Pack", url); - } else if (pathname.startsWith("/server")) { - presenceData.details = "Viewing server:"; - genericSubmission(presenceData, "Server", url); - } else if (pathname.startsWith("/bedrock-server")) { - presenceData.details = "Viewing bedrock server:"; - genericSubmission(presenceData, "Server", url); - } else if (/\/tickets\/\d+/.test(pathname)) { - presenceData.details = `${strings.reading} ticket:`; - presenceData.state = - document.querySelector("#ticket_view > h1").textContent; - genericButton(presenceData, "Ticket", url); - } else if (pathname.startsWith("/rules")) { - presenceData.details = `${strings.reading} the rules.`; - presenceData.buttons = [ - { - label: "Read Rules", - url, - }, - ]; - } else if (pathname.startsWith("/chat")) { - presenceData.details = strings.viewChannel; - presenceData.state = - document.querySelector("span.channel_name").textContent; - presenceData.buttons = [ - { - label: "Open Chat", - url, - }, - ]; - } else if (pathname.startsWith("/forums")) { - if (pathname.endsWith("/new")) { - presenceData.details = "Writing a thread..."; - presenceData.state = stateless; - } else { - const parentElement = document.querySelector( - "#content_graphic_header > *:first-child" - ), - { length } = parentElement.children; + if (pathname === '') { + presenceData.state = strings.viewHome + delete presenceData.details + } + else { + const url = `${document.location.protocol}//${document.location.host}${document.location.pathname}` + if (pathname.startsWith('/member')) { + memberActivity(presenceData, pathname, url) + } + else if ( + pathname.startsWith('/account/manage') + && pathname.endsWith('/new') + ) { + presenceData.details = 'Managing Submissions' + presenceData.state = document.querySelector('#manage_header')?.textContent + } + else { + switch (pathname) { + case '/projects': { + genericFeed(presenceData, 'Maps', url) + break + } + case '/texture-packs': { + genericFeed(presenceData, 'Resource Packs', url) + break + } + case '/skins': { + genericFeed(presenceData, 'Skins', url) + break + } + case '/mob-skins': { + genericFeed(presenceData, 'Mob Skins', url) + break + } + case '/data-packs': { + genericFeed(presenceData, 'Data Packs', url) + break + } + case '/mods': { + genericFeed(presenceData, 'Mods', url) + break + } + case '/blogs': { + genericFeed(presenceData, 'Blogs', url) + break + } + case '/servers': { + genericFeed(presenceData, 'Servers', url) + break + } + case '/bedrock-servers': { + genericFeed(presenceData, 'Bedrock Servers', url) + break + } + case '/collections': { + genericFeed(presenceData, 'Collections', url) + break + } + default: { + if (pathname.startsWith('/mod')) { + presenceData.details = 'Viewing mod:' + genericSubmission(presenceData, 'Mod', url) + } + else if (pathname.startsWith('/blog')) { + presenceData.details = `${strings.reading} a blog:` + genericSubmission(presenceData, 'Blog', url) + } + else if (pathname.startsWith('/project')) { + presenceData.details = 'Viewing map:' + genericSubmission(presenceData, 'Map', url) + } + else if (pathname.startsWith('/texture-pack')) { + presenceData.details = 'Viewing a resource pack:' + genericSubmission(presenceData, 'Resource Pack', url) + } + else if (pathname.startsWith('/skin')) { + presenceData.details = 'Viewing skin:' + genericSubmission(presenceData, 'Skin', url) + } + else if (pathname.startsWith('/mob-skin')) { + presenceData.details = 'Viewing mob skin:' + genericSubmission(presenceData, 'Mob Skin', url) + } + else if (pathname.startsWith('/data-pack')) { + presenceData.details = 'Viewing data pack:' + genericSubmission(presenceData, 'Data Pack', url) + } + else if (pathname.startsWith('/server')) { + presenceData.details = 'Viewing server:' + genericSubmission(presenceData, 'Server', url) + } + else if (pathname.startsWith('/bedrock-server')) { + presenceData.details = 'Viewing bedrock server:' + genericSubmission(presenceData, 'Server', url) + } + else if (/\/tickets\/\d+/.test(pathname)) { + presenceData.details = `${strings.reading} ticket:` + presenceData.state = document.querySelector('#ticket_view > h1')?.textContent + genericButton(presenceData, 'Ticket', url) + } + else if (pathname.startsWith('/rules')) { + presenceData.details = `${strings.reading} the rules.` + presenceData.buttons = [ + { + label: 'Read Rules', + url, + }, + ] + } + else if (pathname.startsWith('/chat')) { + presenceData.details = strings.viewChannel + presenceData.state = document.querySelector('span.channel_name')?.textContent + presenceData.buttons = [ + { + label: 'Open Chat', + url, + }, + ] + } + else if (pathname.startsWith('/forums')) { + if (pathname.endsWith('/new')) { + presenceData.details = 'Writing a thread...' + presenceData.state = stateless + } + else { + const parentElement = document.querySelector( + '#content_graphic_header > *:first-child', + )! + const { length } = parentElement.children - if (parentElement.lastChild.nodeType === Node.TEXT_NODE) { - presenceData.state = parentElement.lastChild.textContent; - genericFeed(presenceData, "Forums", url); - } else if ( - (parentElement.lastChild as HTMLElement).getAttribute( - "href" - ) === "#current" - ) { - let text; - if (length < 1) text = parentElement.textContent; - else { - text = ""; - for (let i = 0; i < length; i++) { - const childElement = parentElement.children[i]; - if (childElement.tagName.toLowerCase() !== "i") { - const { childNodes } = childElement; - for (const childNode of childNodes) { - if (childNode.nodeType === Node.TEXT_NODE) - text += (i > 0 ? " > " : "") + childNode.textContent; - } - } - } - } + if (parentElement.lastChild?.nodeType === Node.TEXT_NODE) { + presenceData.state = parentElement.lastChild?.textContent + genericFeed(presenceData, 'Forums', url) + } + else if ( + (parentElement.lastChild as HTMLElement).getAttribute( + 'href', + ) === '#current' + ) { + let text + if (length < 1) { + text = parentElement.textContent + } + else { + text = '' + for (let i = 0; i < length; i++) { + const childElement = parentElement.children[i] + if (childElement.tagName.toLowerCase() !== 'i') { + const { childNodes } = childElement + for (const childNode of childNodes) { + if (childNode.nodeType === Node.TEXT_NODE) + text += (i > 0 ? ' > ' : '') + childNode.textContent + } + } + } + } - presenceData.state = text; - genericFeed(presenceData, "Forums", url); - } else { - presenceData.details = strings.readingThread; - presenceData.state = document.querySelector("head > title"); - genericButton(presenceData, "Thread", url); - } - } - } - } - } - } - } + presenceData.state = text + genericFeed(presenceData, 'Forums', url) + } + else { + presenceData.details = strings.readingThread + presenceData.state = document.querySelector('head > title') + genericButton(presenceData, 'Thread', url) + } + } + } + } + } + } + } - if (!presenceData.state) - presenceData.state = document.querySelector("head > title").textContent; - else if (presenceData.state === stateless) delete presenceData.state; + if (!presenceData.state) + presenceData.state = document.querySelector('head > title')?.textContent + else if (presenceData.state === stateless) + delete presenceData.state - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) function memberActivity( - presenceData: PresenceData, - pathname: string, - url: string + presenceData: PresenceData, + pathname: string, + url: string, ) { - let profileUrl = (pathname.match(/\/member\/\w+/) || [pathname])[0]; - const remainingPathname = pathname - .substring(profileUrl.length) - .replaceAll(/\/(?=$)/gi, ""); - profileUrl = `${document.location.protocol}//${document.location.host}${profileUrl}`; + let profileUrl = (pathname.match(/\/member\/\w+/) || [pathname])[0] + const remainingPathname = pathname + .substring(profileUrl.length) + .replaceAll(/\/$/g, '') + profileUrl = `${document.location.protocol}//${document.location.host}${profileUrl}` - presenceData.buttons = [ - { - label: "View Profile", - url: profileUrl, - }, - ]; + presenceData.buttons = [ + { + label: 'View Profile', + url: profileUrl, + }, + ] - if (remainingPathname) { - presenceData.largeImageKey = document - .querySelector("#avatar > img") - .getAttribute("src"); - presenceData.state = document - .querySelector("#member-title-primary > a") - .getAttribute("title"); - } + if (remainingPathname) { + presenceData.largeImageKey = document + .querySelector('#avatar > img') + ?.getAttribute('src') + presenceData.state = document + .querySelector('#member-title-primary > a') + ?.getAttribute('title') + } - switch (remainingPathname) { - case "/submissions": { - presenceData.details = "Viewing submissions by:"; - genericButton(presenceData, "Submissions", url); + switch (remainingPathname) { + case '/submissions': { + presenceData.details = 'Viewing submissions by:' + genericButton(presenceData, 'Submissions', url) - break; - } - case "/guestbook": { - presenceData.details = `${strings.reading} guest book of:`; - genericButton(presenceData, "Guest Book", url); + break + } + case '/guestbook': { + presenceData.details = `${strings.reading} guest book of:` + genericButton(presenceData, 'Guest Book', url) - break; - } - case "/jams": { - presenceData.details = "Viewing jam activity of:"; - genericButton(presenceData, "Jams", url); + break + } + case '/jams': { + presenceData.details = 'Viewing jam activity of:' + genericButton(presenceData, 'Jams', url) - break; - } - case "/forum": { - presenceData.details = "Viewing threads by:"; - genericButton(presenceData, "Threads", url); + break + } + case '/forum': { + presenceData.details = 'Viewing threads by:' + genericButton(presenceData, 'Threads', url) - break; - } - case "/subscribers": { - presenceData.details = "Viewing subscribers of:"; - genericButton(presenceData, "Subscribers", url); + break + } + case '/subscribers': { + presenceData.details = 'Viewing subscribers of:' + genericButton(presenceData, 'Subscribers', url) - break; - } - case "/subscriptions": { - presenceData.details = "Viewing subscriptions of:"; - genericButton(presenceData, "Subscriptions", url); + break + } + case '/subscriptions': { + presenceData.details = 'Viewing subscriptions of:' + genericButton(presenceData, 'Subscriptions', url) - break; - } - case "/awards": { - presenceData.details = "Viewing trophies of:"; - genericButton(presenceData, "Trophies", url); + break + } + case '/awards': { + presenceData.details = 'Viewing trophies of:' + genericButton(presenceData, 'Trophies', url) - break; - } - case "/upvoted": { - presenceData.details = "Viewing diamonds of:"; - genericButton(presenceData, "Diamonds", url); + break + } + case '/upvoted': { + presenceData.details = 'Viewing diamonds of:' + genericButton(presenceData, 'Diamonds', url) - break; - } - case "/favorites": { - presenceData.details = "Viewing favorites of:"; - genericButton(presenceData, "Favorites", url); + break + } + case '/favorites': { + presenceData.details = 'Viewing favorites of:' + genericButton(presenceData, 'Favorites', url) - break; - } - case "/feed": { - presenceData.details = "Viewing feed of:"; - genericButton(presenceData, "Feed", url); + break + } + case '/feed': { + presenceData.details = 'Viewing feed of:' + genericButton(presenceData, 'Feed', url) - break; - } - case "/activity": { - presenceData.details = "Viewing activity of:"; - genericButton(presenceData, "Activity", url); + break + } + case '/activity': { + presenceData.details = 'Viewing activity of:' + genericButton(presenceData, 'Activity', url) - break; - } - default: { - if (remainingPathname.startsWith("/post")) { - presenceData.details = `${strings.reading} custom post:`; - presenceData.state = document - .querySelector('meta[name="description"]') - .getAttribute("content"); - genericButton(presenceData, "Post", url); - } else if (remainingPathname.startsWith("/wall")) { - if (/\/post\/\d+/.test(remainingPathname)) { - presenceData.details = `${strings.reading} wall post by:`; - genericButton(presenceData, "Post", url); - } else { - presenceData.details = `${strings.reading} wall posts by:`; - genericButton(presenceData, "Wall", url); - } - } else { - presenceData.details = strings.viewMember; - presenceData.state = document - .querySelector('meta[name="og:profile:username"]') - .getAttribute("content"); - presenceData.largeImageKey = document - .querySelector('meta[name="og:image:secure_url"]') - .getAttribute("content"); - } - } - } + break + } + default: { + if (remainingPathname.startsWith('/post')) { + presenceData.details = `${strings.reading} custom post:` + presenceData.state = document + .querySelector('meta[name="description"]') + ?.getAttribute('content') + genericButton(presenceData, 'Post', url) + } + else if (remainingPathname.startsWith('/wall')) { + if (/\/post\/\d+/.test(remainingPathname)) { + presenceData.details = `${strings.reading} wall post by:` + genericButton(presenceData, 'Post', url) + } + else { + presenceData.details = `${strings.reading} wall posts by:` + genericButton(presenceData, 'Wall', url) + } + } + else { + presenceData.details = strings.viewMember + presenceData.state = document + .querySelector('meta[name="og:profile:username"]') + ?.getAttribute('content') + presenceData.largeImageKey = document + .querySelector('meta[name="og:image:secure_url"]') + ?.getAttribute('content') + } + } + } } function genericFeed(presenceData: PresenceData, type: string, url: string) { - presenceData.details = strings.browsing; - if (!presenceData.state) presenceData.state = type; - genericButton(presenceData, type, url); + presenceData.details = strings.browsing + if (!presenceData.state) + presenceData.state = type + genericButton(presenceData, type, url) } function genericSubmission( - presenceData: PresenceData, - type: string, - url: string + presenceData: PresenceData, + type: string, + url: string, ) { - presenceData.state = document.querySelector( - "#resource-title-text > h1" - ).textContent; - presenceData.largeImageKey = document - .querySelector('link[rel="image_src"]') - .getAttribute("href"); - genericButton(presenceData, type, url); + presenceData.state = document.querySelector( + '#resource-title-text > h1', + )?.textContent + presenceData.largeImageKey = document + .querySelector('link[rel="image_src"]') + ?.getAttribute('href') + genericButton(presenceData, type, url) } function genericButton(presenceData: PresenceData, type: string, url: string) { - const button = { - label: `View ${type}`, - url, - }; + const button = { + label: `View ${type}`, + url, + } - if (presenceData.buttons) presenceData.buttons.unshift(button); - else presenceData.buttons = [button]; + if (presenceData.buttons) + presenceData.buttons.unshift(button) + else presenceData.buttons = [button] } diff --git a/websites/P/PlanetXO/metadata.json b/websites/P/PlanetXO/metadata.json index 0fd825694643..e35e0b9239a1 100644 --- a/websites/P/PlanetXO/metadata.json +++ b/websites/P/PlanetXO/metadata.json @@ -1,40 +1,40 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "850028897118584843", - "name": "kieranl29" - }, - "service": "PlanetXO", - "description": { - "en": "PlanetXO - Small Regional Radio Stations localised to regions of the UK." - }, - "url": [ - "planetxo.uk", - "panel.planetxo.uk", - "api.planetxo.uk", - "staff.planetxo.uk" - ], - "version": "1.0.6", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PlanetXO/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PlanetXO/assets/thumbnail.jpg", - "color": "#8c52ff", - "category": "other", - "tags": [ - "bot", - "discord", - "radio", - "online", - "hiring", - "socials", - "gossuip", - "news", - "hitstation", - "localised", - "uk", - "unitedkingdom", - "socialise", - "regulated", - "kaneproductions" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "850028897118584843", + "name": "kieranl29" + }, + "service": "PlanetXO", + "description": { + "en": "PlanetXO - Small Regional Radio Stations localised to regions of the UK." + }, + "url": [ + "planetxo.uk", + "panel.planetxo.uk", + "api.planetxo.uk", + "staff.planetxo.uk" + ], + "version": "1.0.6", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PlanetXO/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PlanetXO/assets/thumbnail.jpg", + "color": "#8c52ff", + "category": "other", + "tags": [ + "bot", + "discord", + "radio", + "online", + "hiring", + "socials", + "gossuip", + "news", + "hitstation", + "localised", + "uk", + "unitedkingdom", + "socialise", + "regulated", + "kaneproductions" + ] +} diff --git a/websites/P/PlanetXO/presence.ts b/websites/P/PlanetXO/presence.ts index 2a656c9674c1..25f61c220c4d 100644 --- a/websites/P/PlanetXO/presence.ts +++ b/websites/P/PlanetXO/presence.ts @@ -1,163 +1,162 @@ const presence = new Presence({ - clientId: "1260572178068406282", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1260572178068406282', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PlanetXO/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PlanetXO/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (document.location.hostname === "planetxo.uk") { - switch (document.location.href.split("/").slice(0, -1).join("/")) { - case "https://planetxo.uk": { - presenceData.details = "Viewing the map"; - break; - } - case "https://planetxo.uk/xoradio": { - presenceData.details = "Viewing XO Radio"; - presenceData.buttons = [ - { - label: "Listen Along!", - url: "https://planetxo.uk/xoradio", - }, - ]; - break; - } - case "https://planetxo.uk/panel/planetxo": { - presenceData.details = "Viewing the PlanetXO Global Panel"; - break; - } - case "https://planetxo.uk/panel/admin": { - presenceData.details = - "Viewing the PlanetXO System Administrator Panel"; - break; - } - case "https://planetxo.uk/blastradio": { - presenceData.details = "Viewing Blast Radio"; - presenceData.buttons = [ - { - label: "Listen Along!", - url: "https://planetxo.uk/blastradio", - }, - ]; - break; - } - case "https://planetxo.uk/qtfm": { - presenceData.details = "Viewing QTFM"; - presenceData.buttons = [ - { - label: "Listen Along!", - url: "https://planetxo.uk/qtfm", - }, - ]; - break; - } - case "https://planetxo.uk/lushradio": { - presenceData.details = "Viewing Lush Radio"; - presenceData.buttons = [ - { - label: "Listen Along!", - url: "https://planetxo.uk/lushradio", - }, - ]; - break; - } - case "https://planetxo.uk/everyradio": { - presenceData.details = "Viewing Every Radio"; - presenceData.buttons = [ - { - label: "Listen Along!", - url: "https://planetxo.uk/everyradio", - }, - ]; - break; - } - case "https://planetxo.uk/player": { - presenceData.details = "Viewing Player"; - presenceData.buttons = [ - { - label: "Listen Along!", - url: "https://planetxo.uk/player", - }, - ]; - break; - } - case "https://planetxo.uk/panel": { - presenceData.details = "Viewing PlanetXO Panel"; - presenceData.buttons = [ - { - label: "Join the Team?", - url: "https://planetxo.uk/vacancies.php", - }, - ]; - break; - } - case "https://planetxo.uk/panel/xoradio": { - presenceData.details = "Viewing the Panel for XO Radio"; - presenceData.buttons = [ - { - label: "Listen Along!", - url: "https://planetxo.uk/xoradio", - }, - ]; - break; - } - case "https://planetxo.uk/panel/blastradio": { - presenceData.details = "Viewing the Panel for Blast Radio"; - presenceData.buttons = [ - { - label: "Listen Along!", - url: "https://planetxo.uk/blastradio", - }, - ]; - break; - } - case "https://planetxo.uk/panel/qtfm": { - presenceData.details = "Viewing the Panel for QTFM"; - presenceData.buttons = [ - { - label: "Listen Along!", - url: "https://planetxo.uk/qtfm", - }, - ]; - break; - } - case "https://planetxo.uk/panel/lushradio": { - presenceData.details = "Viewing the Panel for Lush Radio"; - presenceData.buttons = [ - { - label: "Listen Along!", - url: "https://planetxo.uk/lushradio", - }, - ]; - break; - } - case "https://planetxo.uk/panel/everyradio": { - presenceData.details = "Viewing the Panel for Every Radio"; - presenceData.buttons = [ - { - label: "Listen Along!", - url: "https://planetxo.uk/everyradio", - }, - ]; - break; - } - default: - if (document.location.hostname === "planetxo.uk") - presenceData.details = "Viewing PlanetXO"; - break; - } - } + if (document.location.hostname === 'planetxo.uk') { + switch (document.location.href.split('/').slice(0, -1).join('/')) { + case 'https://planetxo.uk': { + presenceData.details = 'Viewing the map' + break + } + case 'https://planetxo.uk/xoradio': { + presenceData.details = 'Viewing XO Radio' + presenceData.buttons = [ + { + label: 'Listen Along!', + url: 'https://planetxo.uk/xoradio', + }, + ] + break + } + case 'https://planetxo.uk/panel/planetxo': { + presenceData.details = 'Viewing the PlanetXO Global Panel' + break + } + case 'https://planetxo.uk/panel/admin': { + presenceData.details = 'Viewing the PlanetXO System Administrator Panel' + break + } + case 'https://planetxo.uk/blastradio': { + presenceData.details = 'Viewing Blast Radio' + presenceData.buttons = [ + { + label: 'Listen Along!', + url: 'https://planetxo.uk/blastradio', + }, + ] + break + } + case 'https://planetxo.uk/qtfm': { + presenceData.details = 'Viewing QTFM' + presenceData.buttons = [ + { + label: 'Listen Along!', + url: 'https://planetxo.uk/qtfm', + }, + ] + break + } + case 'https://planetxo.uk/lushradio': { + presenceData.details = 'Viewing Lush Radio' + presenceData.buttons = [ + { + label: 'Listen Along!', + url: 'https://planetxo.uk/lushradio', + }, + ] + break + } + case 'https://planetxo.uk/everyradio': { + presenceData.details = 'Viewing Every Radio' + presenceData.buttons = [ + { + label: 'Listen Along!', + url: 'https://planetxo.uk/everyradio', + }, + ] + break + } + case 'https://planetxo.uk/player': { + presenceData.details = 'Viewing Player' + presenceData.buttons = [ + { + label: 'Listen Along!', + url: 'https://planetxo.uk/player', + }, + ] + break + } + case 'https://planetxo.uk/panel': { + presenceData.details = 'Viewing PlanetXO Panel' + presenceData.buttons = [ + { + label: 'Join the Team?', + url: 'https://planetxo.uk/vacancies.php', + }, + ] + break + } + case 'https://planetxo.uk/panel/xoradio': { + presenceData.details = 'Viewing the Panel for XO Radio' + presenceData.buttons = [ + { + label: 'Listen Along!', + url: 'https://planetxo.uk/xoradio', + }, + ] + break + } + case 'https://planetxo.uk/panel/blastradio': { + presenceData.details = 'Viewing the Panel for Blast Radio' + presenceData.buttons = [ + { + label: 'Listen Along!', + url: 'https://planetxo.uk/blastradio', + }, + ] + break + } + case 'https://planetxo.uk/panel/qtfm': { + presenceData.details = 'Viewing the Panel for QTFM' + presenceData.buttons = [ + { + label: 'Listen Along!', + url: 'https://planetxo.uk/qtfm', + }, + ] + break + } + case 'https://planetxo.uk/panel/lushradio': { + presenceData.details = 'Viewing the Panel for Lush Radio' + presenceData.buttons = [ + { + label: 'Listen Along!', + url: 'https://planetxo.uk/lushradio', + }, + ] + break + } + case 'https://planetxo.uk/panel/everyradio': { + presenceData.details = 'Viewing the Panel for Every Radio' + presenceData.buttons = [ + { + label: 'Listen Along!', + url: 'https://planetxo.uk/everyradio', + }, + ] + break + } + default: + if (document.location.hostname === 'planetxo.uk') + presenceData.details = 'Viewing PlanetXO' + break + } + } - if (document.location.hostname === "panel.planetxo.uk") - presenceData.details = "Viewing the Panel for PlanetXO"; + if (document.location.hostname === 'panel.planetxo.uk') + presenceData.details = 'Viewing the Panel for PlanetXO' - if (document.location.hostname === "staff.planetxo.uk") - presenceData.details = "Viewing the Emails for PlanetXO"; + if (document.location.hostname === 'staff.planetxo.uk') + presenceData.details = 'Viewing the Emails for PlanetXO' - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/Platzi/metadata.json b/websites/P/Platzi/metadata.json index 849e37c49e58..cff989de75f9 100644 --- a/websites/P/Platzi/metadata.json +++ b/websites/P/Platzi/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Brunooh", - "id": "698582921887481889" - }, - "service": "Platzi", - "description": { - "es": "Platzi es una de las mejores plataformas de estudio online hispanas, te ayuda a perfeccionar, mejorar y estar informado de las nuevas tendencias de tu carrera.", - "en": "Platzi is one of the best online spanish study platforms, it helps you to improve and be informed of new trends in your career.", - "nl": "Platzi is een van de beste Spaanse online studieplatforms, het helpt je te verbeteren en op de hoogte te blijven van nieuwe trends in je carrière." - }, - "url": "platzi.com", - "version": "1.0.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Platzi/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Platzi/assets/thumbnail.png", - "color": "#98CA3F", - "category": "videos", - "tags": [ - "courses", - "learning", - "platzi" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Brunooh", + "id": "698582921887481889" + }, + "service": "Platzi", + "description": { + "es": "Platzi es una de las mejores plataformas de estudio online hispanas, te ayuda a perfeccionar, mejorar y estar informado de las nuevas tendencias de tu carrera.", + "en": "Platzi is one of the best online spanish study platforms, it helps you to improve and be informed of new trends in your career.", + "nl": "Platzi is een van de beste Spaanse online studieplatforms, het helpt je te verbeteren en op de hoogte te blijven van nieuwe trends in je carrière." + }, + "url": "platzi.com", + "version": "1.0.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Platzi/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Platzi/assets/thumbnail.png", + "color": "#98CA3F", + "category": "videos", + "tags": [ + "courses", + "learning", + "platzi" + ] +} diff --git a/websites/P/Platzi/presence.ts b/websites/P/Platzi/presence.ts index 703472d39fbb..c68be4f6e063 100644 --- a/websites/P/Platzi/presence.ts +++ b/websites/P/Platzi/presence.ts @@ -1,333 +1,369 @@ const presence = new Presence({ - clientId: "834628404233240628", - }), - estimatedTime = Math.floor(Date.now() / 1000); + clientId: '834628404233240628', +}) +const estimatedTime = Math.floor(Date.now() / 1000) -let categoriesEventListener = false, - activeCategory = ""; +let categoriesEventListener = false +let activeCategory = '' -const stripPlatziProfileFlags = (url: string) => { - return url - .replace("https://static.platzi.com/media/flags/", "") - .replace(".png", ""); - }, - setPresenceFromEvent = (learningPath: string) => { - activeCategory = learningPath; - }; +function stripPlatziProfileFlags(url: string) { + return url + .replace('https://static.platzi.com/media/flags/', '') + .replace('.png', '') +} +function setPresenceFromEvent(learningPath: string) { + activeCategory = learningPath +} -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Platzi/assets/logo.jpg", - }, - { pathname } = document.location, - pathNameSplit = pathname.split("/").filter(Boolean); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Platzi/assets/logo.jpg', + } + const { pathname } = document.location + const pathNameSplit = pathname.split('/').filter(Boolean) - if (pathname.includes("/home")) { - const inputValues = [ - ...document.querySelectorAll(".SearchBar input"), - ] - .map(input => input.value) - .filter(Boolean); + if (pathname.includes('/home')) { + const inputValues = [ + ...document.querySelectorAll('.SearchBar input'), + ] + .map(input => input.value) + .filter(Boolean) - presenceData.state = "Página de inicio"; + presenceData.state = 'Página de inicio' - if (inputValues.length > 0) { - presenceData.state = "Página de inicio"; + if (inputValues.length > 0) { + presenceData.state = 'Página de inicio' - if (inputValues[0].replace(/[ ]/gi, "") !== "") { - presenceData.details = "Página de inicio"; - presenceData.state = `Buscando: ${inputValues[0]}`; - } - } - } else if (pathname.includes("/blog/buscar")) { - const input = document.querySelector(".Search-input"), - blogPage = document.querySelector( - "a.Pagination-number.is-current" - ); + if (inputValues[0].replace(/ /g, '') !== '') { + presenceData.details = 'Página de inicio' + presenceData.state = `Buscando: ${inputValues[0]}` + } + } + } + else if (pathname.includes('/blog/buscar')) { + const input = document.querySelector('.Search-input') + const blogPage = document.querySelector( + 'a.Pagination-number.is-current', + ) - presenceData.details = "Viendo el Blog"; + presenceData.details = 'Viendo el Blog' - if (input.value) { - presenceData.state = "Viendo el Blog"; + if (input?.value) { + presenceData.state = 'Viendo el Blog' - if (blogPage) presenceData.state = `Página ${blogPage.textContent}`; + if (blogPage) + presenceData.state = `Página ${blogPage.textContent}` - if (input.value.replace(/[ ]/gi, "") !== "") { - presenceData.state = `Buscando: ${input.value}${ - blogPage ? ` [Pagina ${blogPage.textContent}]` : "" - }`; - } - } else if (blogPage) presenceData.state = `Página ${blogPage.textContent}`; - } else if (pathname.startsWith("/blog/")) { - presenceData.details = "Viendo el Blog"; + if (input.value.replace(/ /g, '') !== '') { + presenceData.state = `Buscando: ${input.value}${ + blogPage ? ` [Pagina ${blogPage.textContent}]` : '' + }` + } + } + else if (blogPage) { + presenceData.state = `Página ${blogPage.textContent}` + } + } + else if (pathname.startsWith('/blog/')) { + presenceData.details = 'Viendo el Blog' - if (pathNameSplit.length > 1) { - presenceData.details = `Blog: ${ - document.querySelector(".Discussion-title h1") - .textContent - }`; - presenceData.state = `de ${ - document.querySelector(".DiscussionInfo-user a") - .textContent - } [${ - document.querySelector(".DiscussionInfo span") - .textContent - } pts] ${ - document.querySelector(".DiscussionInfo-time") - .textContent - }`; - presenceData.buttons = [ - { label: "Ver el Artículo", url: `https://platzi.com${pathname}` }, - ]; - } - } else if (pathname.startsWith("/foro/")) { - const input = document.querySelector( - ".CustomSearchInput-search-input" - ), - forumPage = document.querySelector( - ".Paginator-number.is-current" - ); + if (pathNameSplit.length > 1) { + presenceData.details = `Blog: ${ + document.querySelector('.Discussion-title h1') + ?.textContent + }` + presenceData.state = `de ${ + document.querySelector('.DiscussionInfo-user a') + ?.textContent + } [${ + document.querySelector('.DiscussionInfo span') + ?.textContent + } pts] ${ + document.querySelector('.DiscussionInfo-time') + ?.textContent + }` + presenceData.buttons = [ + { label: 'Ver el Artículo', url: `https://platzi.com${pathname}` }, + ] + } + } + else if (pathname.startsWith('/foro/')) { + const input = document.querySelector( + '.CustomSearchInput-search-input', + ) + const forumPage = document.querySelector( + '.Paginator-number.is-current', + ) - presenceData.details = "Viendo el Foro"; + presenceData.details = 'Viendo el Foro' - if (input.value) { - presenceData.state = "Viendo el Foro"; + if (input?.value) { + presenceData.state = 'Viendo el Foro' - if (forumPage) presenceData.state = `Página ${forumPage.textContent}`; + if (forumPage) + presenceData.state = `Página ${forumPage.textContent}` - if (input.value.replace(/[ ]/gi, "") !== "") { - presenceData.state = `Buscando: ${input.value}${ - forumPage ? ` [Pagina ${forumPage.textContent}]` : "" - }`; - } - } else if (forumPage) - presenceData.state = `Página ${forumPage.textContent}`; - } else if (pathname.startsWith("/precios/")) - presenceData.state = "Viendo los planes de compra"; - else if (pathname.startsWith("/empresas/")) - presenceData.state = "Viendo el plan para empresas"; - else if (pathname.startsWith("/comprar/")) { - presenceData.details = "Comprando un plan..."; - presenceData.state = document.querySelector(".Details-name").textContent; - } else if (pathname.startsWith("/clases/notificaciones/")) { - presenceData.details = "Viendo sus notificaciones"; + if (input.value.replace(/ /g, '') !== '') { + presenceData.state = `Buscando: ${input.value}${ + forumPage ? ` [Pagina ${forumPage.textContent}]` : '' + }` + } + } + else if (forumPage) { + presenceData.state = `Página ${forumPage.textContent}` + } + } + else if (pathname.startsWith('/precios/')) { + presenceData.state = 'Viendo los planes de compra' + } + else if (pathname.startsWith('/empresas/')) { + presenceData.state = 'Viendo el plan para empresas' + } + else if (pathname.startsWith('/comprar/')) { + presenceData.details = 'Comprando un plan...' + presenceData.state = document.querySelector('.Details-name')?.textContent + } + else if (pathname.startsWith('/clases/notificaciones/')) { + presenceData.details = 'Viendo sus notificaciones' - const notificationPage = document.querySelector( - ".Paginator-number.is-current" - ); + const notificationPage = document.querySelector( + '.Paginator-number.is-current', + ) - if (notificationPage) - presenceData.state = `Página ${notificationPage.textContent}`; - } else if (pathname.startsWith("/p/")) { - const userFlag = document.querySelector( - "div.ProfileHeader-username > figure > img" - ), - userLink = document.querySelector(".UserUrl-link"); + if (notificationPage) + presenceData.state = `Página ${notificationPage.textContent}` + } + else if (pathname.startsWith('/p/')) { + const userFlag = document.querySelector( + 'div.ProfileHeader-username > figure > img', + ) + const userLink = document.querySelector('.UserUrl-link') - let finalString = ` ${ - document.querySelector(".ProfileHeader-name").textContent - } `; - if (userFlag) { - finalString += ` ${stripPlatziProfileFlags( - userFlag.getAttribute("src") - )} `; - } + let finalString = ` ${ + document.querySelector('.ProfileHeader-name')?.textContent + } ` + if (userFlag) { + finalString += ` ${stripPlatziProfileFlags( + userFlag.getAttribute('src') ?? '', + )} ` + } - finalString += ` [${ - document.querySelector(".ProfileScore-number.is-green") - .textContent - } pts] `; + finalString += ` [${ + document.querySelector('.ProfileScore-number.is-green') + ?.textContent + } pts] ` - if (userLink) { - presenceData.buttons = [ - { label: "Link personal", url: `${userLink.href}` }, - ]; - } + if (userLink) { + presenceData.buttons = [ + { label: 'Link personal', url: `${userLink.href}` }, + ] + } - presenceData.details = "Viendo el perfil de"; + presenceData.details = 'Viendo el perfil de' - if ( - [...document.querySelectorAll(".SingleTab")].find( - tab => tab.textContent === "Mi Portafolio" - ) - ) - presenceData.details = "Viendo su perfil"; + if ( + [...document.querySelectorAll('.SingleTab')].find( + tab => tab.textContent === 'Mi Portafolio', + ) + ) { + presenceData.details = 'Viendo su perfil' + } - presenceData.state = finalString; - } else if (pathname === "/agenda/") presenceData.state = "Viendo la Agenda"; - else if (pathname === "/live/") { - presenceData.state = "Viendo Platzi Live"; - presenceData.startTimestamp = estimatedTime; - presenceData.buttons = [ - { label: "Ver Live", url: `https://platzi.com${pathname}` }, - ]; - } else if (pathname.includes("/clases/") && pathNameSplit.length === 2) { - presenceData.state = `de ${ - document.querySelector(".TeacherList-full-name") - .textContent - }`; - presenceData.details = document.querySelector( - ".CourseDetail-left-title" - ).textContent; - presenceData.buttons = [ - { - label: "Ver curso", - url: `https://platzi.com${pathname}`, - }, - ]; - } else if ( - pathname.includes("/clases/") && - pathNameSplit.length > 2 && - !pathname.includes("examen") - ) { - const course = document.querySelector( - ".Header-course-info-content a" - ), - video = document.querySelector(".vjs-tech"), - [actualEpisode, finalEpisode] = document - .querySelector(".Header-class-title span") - .textContent.split("/"); + presenceData.state = finalString + } + else if (pathname === '/agenda/') { + presenceData.state = 'Viendo la Agenda' + } + else if (pathname === '/live/') { + presenceData.state = 'Viendo Platzi Live' + presenceData.startTimestamp = estimatedTime + presenceData.buttons = [ + { label: 'Ver Live', url: `https://platzi.com${pathname}` }, + ] + } + else if (pathname.includes('/clases/') && pathNameSplit.length === 2) { + presenceData.state = `de ${ + document.querySelector('.TeacherList-full-name') + ?.textContent + }` + presenceData.details = document.querySelector( + '.CourseDetail-left-title', + )?.textContent + presenceData.buttons = [ + { + label: 'Ver curso', + url: `https://platzi.com${pathname}`, + }, + ] + } + else if ( + pathname.includes('/clases/') + && pathNameSplit.length > 2 + && !pathname.includes('examen') + ) { + const course = document.querySelector( + '.Header-course-info-content a', + ) + const video = document.querySelector('.vjs-tech') + const [actualEpisode, finalEpisode] = document + .querySelector('.Header-class-title span') + ?.textContent + ?.split('/') ?? [] - presenceData.details = `${ - document.querySelector(".Header-class-title h1") - .textContent - } [${actualEpisode}/ ${finalEpisode}]`; - presenceData.state = `${course.children[0].textContent}`; - presenceData.buttons = [ - { - label: "Ver Curso", - url: `https://platzi.com${course.getAttribute("href")}`, - }, - { label: "Ver Clase", url: `https://platzi.com${pathname}` }, - ]; + presenceData.details = `${ + document.querySelector('.Header-class-title h1') + ?.textContent + } [${actualEpisode}/ ${finalEpisode}]` + presenceData.state = `${course?.children[0].textContent}` + presenceData.buttons = [ + { + label: 'Ver Curso', + url: `https://platzi.com${course?.getAttribute('href')}`, + }, + { label: 'Ver Clase', url: `https://platzi.com${pathname}` }, + ] - if ( - video && - !isNaN(video.duration) && - document - .querySelector(".VideoPlayer > div") - .className.includes("vjs-playing") - ) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - } - } else if (pathname.includes("/cursos/")) { - //NEW UI, SAME PRESENCE /CLASES/ - if (pathNameSplit.length >= 2) { - presenceData.state = `de ${ - document.querySelector(".Hero-teacher-name strong") - .textContent - }`; - presenceData.details = document.querySelector( - ".Hero-content-title" - ).textContent; - } else { - presenceData.state = "Buscando cursos..."; - presenceData.startTimestamp = estimatedTime; - } - } else if (pathname.includes("/categorias/")) { - if (pathNameSplit.length >= 2) { - const learningPaths = - document.querySelectorAll(".LearningPathItem"); - presenceData.state = document.querySelector( - ".HeroCoursesItem-title span" - ).textContent; - presenceData.details = activeCategory; + if ( + video + && !Number.isNaN(video.duration) + && document + .querySelector('.VideoPlayer > div') + ?.className + .includes('vjs-playing') + ) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + } + } + else if (pathname.includes('/cursos/')) { + // NEW UI, SAME PRESENCE /CLASES/ + if (pathNameSplit.length >= 2) { + presenceData.state = `de ${ + document.querySelector('.Hero-teacher-name strong') + ?.textContent + }` + presenceData.details = document.querySelector( + '.Hero-content-title', + )?.textContent + } + else { + presenceData.state = 'Buscando cursos...' + presenceData.startTimestamp = estimatedTime + } + } + else if (pathname.includes('/categorias/')) { + if (pathNameSplit.length >= 2) { + const learningPaths = document.querySelectorAll('.LearningPathItem') + presenceData.state = document.querySelector( + '.HeroCoursesItem-title span', + )?.textContent + presenceData.details = activeCategory - if (activeCategory !== "") presenceData.details = activeCategory; + if (activeCategory !== '') + presenceData.details = activeCategory - if (!categoriesEventListener) { - for (const learningPath of learningPaths) { - learningPath.addEventListener("mouseover", () => - setPresenceFromEvent(learningPath.querySelector("h2").textContent) - ); - } - categoriesEventListener = true; - } - } - } else if (pathname.includes("/tutoriales/")) { - presenceData.details = document.querySelector( - ".Breadcrumb-desktop span:nth-child(2) a" - ).textContent; - presenceData.state = "Viendo un tutorial..."; - } else if (pathNameSplit.includes("examen")) { - if (pathname.includes("tomar_examen")) { - presenceData.details = document.querySelector( - ".ExamProgress-top-title" - ).textContent; - presenceData.state = `${ - document.querySelector(".QuestionSelector-title") - .textContent - } [${document - .querySelector(".ExamProgress-top-count > span") - .textContent.replace(/de /gi, "") - .split(" ") - .join("-")}]`; - } else if (pathname.includes("review")) { - presenceData.details = document.querySelector( - ".ExamProgress-top-title" - ).textContent; - presenceData.state = "Revisando sus respuestas..."; - } else if (pathname.includes("resultados")) { - const score = parseFloat( - document.querySelector(".ExamResults-score-grade").textContent - ); - presenceData.details = - document.querySelector( - ".CourseRow-title" - ).textContent; - presenceData.state = `Examen ${ - score >= 9 ? "aprobado" : "no aprobado" - }. [${score} en ${ - document - .querySelector(".ExamResults-score-answers") - .textContent.split("/")[1] - } preguntas]`; - } else { - presenceData.details = document.querySelector( - ".StartExamOverview-course-title" - ).textContent; - presenceData.state = `Empezando el examen [${ - document.querySelector( - ".StartExamOverview-list-item:nth-child(2) > strong" - ).textContent - }]`; - } - } else if (pathname.startsWith("/direct-messages/u/soporte-platzi")) - presenceData.state = "Hablando con el Soporte Platzi"; - else if (pathname.startsWith("/mensajes-directos/")) - presenceData.state = "Viendo sus Mensajes"; - else if (pathname.startsWith("/empleos/")) - presenceData.state = "Viendo la lista de Empleos"; - else if (pathname.startsWith("/mi-suscripcion/beneficiario/")) - presenceData.state = "Viendo su Beneficiario"; - else if (pathname.startsWith("/mi-suscripcion/facturas/")) { - presenceData.details = `Viendo sus ${ - document.querySelector(".InvoicesList-title") - .textContent - }`; - presenceData.state = `${ - document.querySelector(".ProfileMenu-name").textContent - } [${ - document.querySelector(".ProfileMenu-rank").textContent - }]`; - } else if (pathname.startsWith("/mi-suscripcion/referidos/")) { - presenceData.state = "Viendo sus referidos"; - presenceData.buttons = [ - { - label: "Referido", - url: `${ - document.querySelector("#copyUrl").textContent - }`, - }, - ]; - } else if (pathname.startsWith("/mi--suscripcion/")) { - presenceData.details = "Viendo su suscripción"; - presenceData.state = `${ - document.querySelector(".CurrentPlan-name").textContent - }`; - } + if (!categoriesEventListener) { + for (const learningPath of learningPaths) { + learningPath.addEventListener('mouseover', () => + setPresenceFromEvent(learningPath.querySelector('h2')?.textContent ?? '')) + } + categoriesEventListener = true + } + } + } + else if (pathname.includes('/tutoriales/')) { + presenceData.details = document.querySelector( + '.Breadcrumb-desktop span:nth-child(2) a', + )?.textContent + presenceData.state = 'Viendo un tutorial...' + } + else if (pathNameSplit.includes('examen')) { + if (pathname.includes('tomar_examen')) { + presenceData.details = document.querySelector( + '.ExamProgress-top-title', + )?.textContent + presenceData.state = `${ + document.querySelector('.QuestionSelector-title') + ?.textContent + } [${document + .querySelector('.ExamProgress-top-count > span') + ?.textContent + ?.replace(/de /gi, '') + ?.split(' ') + ?.join('-')}]` + } + else if (pathname.includes('review')) { + presenceData.details = document.querySelector( + '.ExamProgress-top-title', + )?.textContent + presenceData.state = 'Revisando sus respuestas...' + } + else if (pathname.includes('resultados')) { + const score = Number.parseFloat( + document.querySelector('.ExamResults-score-grade')?.textContent ?? '', + ) + presenceData.details = document.querySelector( + '.CourseRow-title', + )?.textContent + presenceData.state = `Examen ${ + score >= 9 ? 'aprobado' : 'no aprobado' + }. [${score} en ${ + document + .querySelector('.ExamResults-score-answers') + ?.textContent + ?.split('/')[1] + } preguntas]` + } + else { + presenceData.details = document.querySelector( + '.StartExamOverview-course-title', + )?.textContent + presenceData.state = `Empezando el examen [${ + document.querySelector( + '.StartExamOverview-list-item:nth-child(2) > strong', + )?.textContent + }]` + } + } + else if (pathname.startsWith('/direct-messages/u/soporte-platzi')) { + presenceData.state = 'Hablando con el Soporte Platzi' + } + else if (pathname.startsWith('/mensajes-directos/')) { + presenceData.state = 'Viendo sus Mensajes' + } + else if (pathname.startsWith('/empleos/')) { + presenceData.state = 'Viendo la lista de Empleos' + } + else if (pathname.startsWith('/mi-suscripcion/beneficiario/')) { + presenceData.state = 'Viendo su Beneficiario' + } + else if (pathname.startsWith('/mi-suscripcion/facturas/')) { + presenceData.details = `Viendo sus ${ + document.querySelector('.InvoicesList-title') + ?.textContent + }` + presenceData.state = `${ + document.querySelector('.ProfileMenu-name')?.textContent + } [${ + document.querySelector('.ProfileMenu-rank')?.textContent + }]` + } + else if (pathname.startsWith('/mi-suscripcion/referidos/')) { + presenceData.state = 'Viendo sus referidos' + presenceData.buttons = [ + { + label: 'Referido', + url: `${ + document.querySelector('#copyUrl')?.textContent + }`, + }, + ] + } + else if (pathname.startsWith('/mi--suscripcion/')) { + presenceData.details = 'Viendo su suscripción' + presenceData.state = `${ + document.querySelector('.CurrentPlan-name')?.textContent + }` + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/PlayScrabble/metadata.json b/websites/P/PlayScrabble/metadata.json index a3db7f9c3653..90eeccfbf238 100644 --- a/websites/P/PlayScrabble/metadata.json +++ b/websites/P/PlayScrabble/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "PlayScrabble", - "description": { - "en": "Play your favorite game of Scrabble with friends and family or practice against the computer in real-time. Play Scrabble online for free now!" - }, - "url": [ - "www.playscrabble.com", - "playscrabble.com" - ], - "version": "1.0.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PlayScrabble/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PlayScrabble/assets/thumbnail.png", - "color": "#F04930", - "category": "games", - "tags": [ - "real-time", - "computer", - "scrabble" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "PlayScrabble", + "description": { + "en": "Play your favorite game of Scrabble with friends and family or practice against the computer in real-time. Play Scrabble online for free now!" + }, + "url": [ + "www.playscrabble.com", + "playscrabble.com" + ], + "version": "1.0.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PlayScrabble/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PlayScrabble/assets/thumbnail.png", + "color": "#F04930", + "category": "games", + "tags": [ + "real-time", + "computer", + "scrabble" + ] +} diff --git a/websites/P/PlayScrabble/presence.ts b/websites/P/PlayScrabble/presence.ts index aeb4fff82eed..2b574091f603 100644 --- a/websites/P/PlayScrabble/presence.ts +++ b/websites/P/PlayScrabble/presence.ts @@ -1,139 +1,148 @@ const presence = new Presence({ - clientId: "1115852112224604160", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1115852112224604160', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/PlayScrabble/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/PlayScrabble/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname, href } = document.location, - pathList = pathname.split("/").filter(Boolean); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname, href } = document.location + const pathList = pathname.split('/').filter(Boolean) - switch (pathList[0] ?? "") { - case "": { - presenceData.details = "Browsing the homepage"; - break; - } - case "play": { - const gameElement = document.querySelector( - "[class*='ScrabbleGame_rightGamePanel'] > div > div:nth-child(2)" - ); - if (gameElement) { - if ( - document.querySelector( - "[src*='roundSummaryBackground']" - ) - ) - presenceData.details = "Viewing round summary"; - else { - presenceData.details = `Playing ${gameElement.textContent.replace( - /\s{2}/, - "" - )}`; - presenceData.state = `My score: ${ - document.querySelector(".game_player_score_block") - .textContent - } | My time remaining: ${ - document.querySelector(".game_player_timer_block") - .textContent - }`; - presenceData.smallImageKey = document.querySelector( - "[class*='switched_active'] [class*='Avatar'] img" - ).src; - presenceData.smallImageText = `Current player: ${ - document.querySelector( - ".game_player_info.switched_active_text" - ).textContent - }`; - } - } else { - presenceData.details = "Setting up a game"; - switch (pathList[1]) { - case "ai": - presenceData.state = "Playing against AI"; - break; - case "friend": - presenceData.state = "Playing with friends"; - break; - case "online": - presenceData.state = "Playing online"; - break; - } - } - break; - } - case "dictionary": { - const input = - document.querySelector(".dictionary-input"); - if (input.value) { - presenceData.details = `Checking if ${input.value} is a word`; - if ( - document.querySelector("[class*='Dictionary'] [class*='IcoMoon'].sad") - ) - presenceData.state = "It's not a word"; - else { - const definition = document.querySelector( - "[class*='Dictionary'] > div:nth-child(2) > div > div > div:nth-child(2) > div > div:nth-child(2) [class*='Textstyle']" - ).textContent; - presenceData.state = "It's a word"; - presenceData.smallImageKey = Assets.Question; - presenceData.smallImageText = - definition.length < 256 - ? definition - : `${definition.slice(0, 253)}...`; - } - } else presenceData.details = "Viewing the dictionary"; - break; - } - case "word-finder": { - presenceData.details = "Finding words"; - presenceData.state = `Letters: ${ - document.querySelector("[class*='WordFinderSearch']") - .value || "(none)" - }`; - break; - } - case "news-blog": { - if (pathList[1] === "category") { - presenceData.details = "Viewing blog category"; - presenceData.state = document.querySelector( - "[class*='NewsBlogHeader'] [class*='CategoryContent'] span:nth-child(2)" - ).textContent; - } else if (pathList[1] === "author") { - presenceData.details = "Viewing blog author"; - presenceData.state = document.querySelector( - "[class*='NewsBlogHeader'] [class*='AuthorContent'] span:nth-child(2)" - ).textContent; - } else if (pathList[1]) { - const image = document.querySelector( - "[class*='AuthorBlogAvatar']" - ); - presenceData.details = "Reading a blog post"; - presenceData.state = - document.querySelector( - ".individual-title" - ).textContent; - presenceData.smallImageKey = image.src; - presenceData.smallImageText = image.nextElementSibling.textContent; - presenceData.buttons = [{ label: "Read Post", url: href }]; - } else presenceData.details = "Viewing the blog"; - break; - } - case "user": { - presenceData.details = "Viewing a user's profile"; - presenceData.state = document.querySelector("h1").textContent; - presenceData.smallImageKey = document.querySelector( - "#profile-component [class*='Avatar'] img" - ).src; - } - } + switch (pathList[0] ?? '') { + case '': { + presenceData.details = 'Browsing the homepage' + break + } + case 'play': { + const gameElement = document.querySelector( + '[class*=\'ScrabbleGame_rightGamePanel\'] > div > div:nth-child(2)', + ) + if (gameElement) { + if ( + document.querySelector( + '[src*=\'roundSummaryBackground\']', + ) + ) { + presenceData.details = 'Viewing round summary' + } + else { + presenceData.details = `Playing ${gameElement.textContent?.replace( + /\s{2}/, + '', + )}` + presenceData.state = `My score: ${ + document.querySelector('.game_player_score_block') + ?.textContent + } | My time remaining: ${ + document.querySelector('.game_player_timer_block') + ?.textContent + }` + presenceData.smallImageKey = document.querySelector( + '[class*=\'switched_active\'] [class*=\'Avatar\'] img', + )?.src + presenceData.smallImageText = `Current player: ${ + document.querySelector( + '.game_player_info.switched_active_text', + )?.textContent + }` + } + } + else { + presenceData.details = 'Setting up a game' + switch (pathList[1]) { + case 'ai': + presenceData.state = 'Playing against AI' + break + case 'friend': + presenceData.state = 'Playing with friends' + break + case 'online': + presenceData.state = 'Playing online' + break + } + } + break + } + case 'dictionary': { + const input = document.querySelector('.dictionary-input') + if (input?.value) { + presenceData.details = `Checking if ${input.value} is a word` + if ( + document.querySelector('[class*=\'Dictionary\'] [class*=\'IcoMoon\'].sad') + ) { + presenceData.state = 'It\'s not a word' + } + else { + const definition = document.querySelector( + '[class*=\'Dictionary\'] > div:nth-child(2) > div > div > div:nth-child(2) > div > div:nth-child(2) [class*=\'Textstyle\']', + )?.textContent + presenceData.state = 'It\'s a word' + presenceData.smallImageKey = Assets.Question + presenceData.smallImageText = definition && definition.length < 256 + ? definition + : `${definition?.slice(0, 253)}...` + } + } + else { + presenceData.details = 'Viewing the dictionary' + } + break + } + case 'word-finder': { + presenceData.details = 'Finding words' + presenceData.state = `Letters: ${ + document.querySelector('[class*=\'WordFinderSearch\']') + ?.value || '(none)' + }` + break + } + case 'news-blog': { + if (pathList[1] === 'category') { + presenceData.details = 'Viewing blog category' + presenceData.state = document.querySelector( + '[class*=\'NewsBlogHeader\'] [class*=\'CategoryContent\'] span:nth-child(2)', + )?.textContent + } + else if (pathList[1] === 'author') { + presenceData.details = 'Viewing blog author' + presenceData.state = document.querySelector( + '[class*=\'NewsBlogHeader\'] [class*=\'AuthorContent\'] span:nth-child(2)', + )?.textContent + } + else if (pathList[1]) { + const image = document.querySelector( + '[class*=\'AuthorBlogAvatar\']', + ) + presenceData.details = 'Reading a blog post' + presenceData.state = document.querySelector( + '.individual-title', + )?.textContent + presenceData.smallImageKey = image?.src + presenceData.smallImageText = image?.nextElementSibling?.textContent + presenceData.buttons = [{ label: 'Read Post', url: href }] + } + else { + presenceData.details = 'Viewing the blog' + } + break + } + case 'user': { + presenceData.details = 'Viewing a user\'s profile' + presenceData.state = document.querySelector('h1')?.textContent + presenceData.smallImageKey = document.querySelector( + '#profile-component [class*=\'Avatar\'] img', + )?.src + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/Playerbros/metadata.json b/websites/P/Playerbros/metadata.json index d6a398722324..662df33cf393 100644 --- a/websites/P/Playerbros/metadata.json +++ b/websites/P/Playerbros/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "EGGSY", - "id": "162969778699501569" - }, - "service": "Playerbros", - "description": { - "en": "Playerbros is a Turkish e-sport news website.", - "tr": "Playerbros, Türkçe espor haberleri ve bu konuda özel videolar oluşturan bir internet sitesidir.", - "nl": "Playerbros is een Turkse nieuwswebsite over e-sport." - }, - "url": "playerbros.com", - "version": "1.1.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/thumbnail.png", - "color": "#f15a22", - "category": "other", - "tags": [ - "playerbros", - "esport", - "news", - "turkish" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "EGGSY", + "id": "162969778699501569" + }, + "service": "Playerbros", + "description": { + "en": "Playerbros is a Turkish e-sport news website.", + "tr": "Playerbros, Türkçe espor haberleri ve bu konuda özel videolar oluşturan bir internet sitesidir.", + "nl": "Playerbros is een Turkse nieuwswebsite over e-sport." + }, + "url": "playerbros.com", + "version": "1.1.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/thumbnail.png", + "color": "#f15a22", + "category": "other", + "tags": [ + "playerbros", + "esport", + "news", + "turkish" + ] +} diff --git a/websites/P/Playerbros/presence.ts b/websites/P/Playerbros/presence.ts index d2d32bc7033f..9fe7190e8ae6 100644 --- a/websites/P/Playerbros/presence.ts +++ b/websites/P/Playerbros/presence.ts @@ -1,119 +1,116 @@ const presence = new Presence({ - clientId: "643848955586805770", - }), - pages: { - [name: string]: string; - } = { - "/": "Ana Sayfa", - "/espor": "Espor Haberleri", - "/video-konusu": "Video Konuları", - "/roportaj": "Röportajlar", - "/testler": "Testler", - "/lol": "LoL Haberleri", - "/csgo": "CS:GO Haberleri", - "/fortnite": "Fortnite Haberleri", - "/pubg": "PUBG Haberleri", - "/fifa": "FIFA Haberleri", - "/zula": "Zula Haberleri", - "/register": "Kayıt Ol", - "/login": "Giriş Yap", - "/hakkinda": "Hakkımızda", - "/kunye": "Künye", - "/iletisim": "İletişim", - "/wp-admin/profile.php": "Profil", // -_- wp-admin? really? - }; + clientId: '643848955586805770', +}) +const pages: { + [name: string]: string +} = { + '/': 'Ana Sayfa', + '/espor': 'Espor Haberleri', + '/video-konusu': 'Video Konuları', + '/roportaj': 'Röportajlar', + '/testler': 'Testler', + '/lol': 'LoL Haberleri', + '/csgo': 'CS:GO Haberleri', + '/fortnite': 'Fortnite Haberleri', + '/pubg': 'PUBG Haberleri', + '/fifa': 'FIFA Haberleri', + '/zula': 'Zula Haberleri', + '/register': 'Kayıt Ol', + '/login': 'Giriş Yap', + '/hakkinda': 'Hakkımızda', + '/kunye': 'Künye', + '/iletisim': 'İletişim', + '/wp-admin/profile.php': 'Profil', // -_- wp-admin? really? +} -presence.on("UpdateData", async () => { - const page = document.location.pathname, - postTitle = document.querySelector("#mvp-article-head > h1"), - date = document.querySelector( - "#mvp-article-head > div > ul > li > span > p > time" - ), - author = document.querySelector("#mvp-author-box-head > span > a"), - _author = document.querySelector("#mvp-author-top-right > h1"); +presence.on('UpdateData', async () => { + const page = document.location.pathname + const postTitle = document.querySelector('#mvp-article-head > h1') + const date = document.querySelector( + '#mvp-article-head > div > ul > li > span > p > time', + ) + const author = document.querySelector('#mvp-author-box-head > span > a') + const _author = document.querySelector('#mvp-author-top-right > h1') - if ( - postTitle && - author && - date && - postTitle.textContent !== "" && - author.textContent !== "" && - date.textContent !== "" - ) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png", - details: postTitle.textContent || "Belirsiz", - state: `Yazar: ${author.textContent} (${date.textContent})`, - smallImageKey: Assets.Reading, - smallImageText: "Bir gönderi okuyor...", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if ( - page.includes("/author/") && - _author && - _author.textContent !== "" - ) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png", - details: "Bir yazara göz atıyor:", - state: _author.textContent, - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (page.includes("/etiket/")) { - const tag = document.querySelector( - "#mvp-main-body > div > div > div > div.mvp-main-body-in2 > div > h1 > span" - ); + if ( + postTitle + && author + && date + && postTitle.textContent !== '' + && author.textContent !== '' + && date.textContent !== '' + ) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png', + details: postTitle.textContent || 'Belirsiz', + state: `Yazar: ${author.textContent} (${date.textContent})`, + smallImageKey: Assets.Reading, + smallImageText: 'Bir gönderi okuyor...', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if ( + page.includes('/author/') + && _author + && _author.textContent !== '' + ) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png', + details: 'Bir yazara göz atıyor:', + state: _author.textContent, + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (page.includes('/etiket/')) { + const tag = document.querySelector( + '#mvp-main-body > div > div > div > div.mvp-main-body-in2 > div > h1 > span', + ) - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png", - details: "Bir etikete göz atıyor:", - state: - tag && tag.textContent !== "" - ? tag.textContent - .split(" ") - [tag.textContent.split(" ").length - 1].replaceAll('"', "") - : null || "Belirsiz", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (document.location.search.includes("?s=")) { - const searchingFor = document.querySelector( - "#mvp-main-body > div > div > div > div.mvp-main-body-in2 > div > h1 > span" - ); + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png', + details: 'Bir etikete göz atıyor:', + state: tag && tag.textContent + ? tag.textContent + .split(' ')[tag.textContent.split(' ').length - 1] + .replaceAll('"', '') + : 'Belirsiz', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (document.location.search.includes('?s=')) { + const searchingFor = document.querySelector( + '#mvp-main-body > div > div > div > div.mvp-main-body-in2 > div > h1 > span', + ) - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png", - details: "Bir şey arıyor:", - state: - searchingFor && searchingFor.textContent !== "" - ? searchingFor.textContent - .split(" ") - [searchingFor.textContent.split(" ").length - 1].replaceAll( - '"', - "" - ) - : null || "Belirsiz", - smallImageKey: Assets.Search, - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (pages[page] || pages[page.slice(0, -1)]) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png", - details: "Bir sayfaya göz atıyor:", - state: pages[page] || pages[page.slice(0, -1)], - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png", - details: "Bir sayfaya göz atıyor:", - state: "Ana Sayfa", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } -}); + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png', + details: 'Bir şey arıyor:', + state: searchingFor && searchingFor.textContent + ? searchingFor.textContent + .split(' ')[searchingFor.textContent.split(' ').length - 1] + .replaceAll( + '"', + '', + ) + : 'Belirsiz', + smallImageKey: Assets.Search, + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (pages[page] || pages[page.slice(0, -1)]) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png', + details: 'Bir sayfaya göz atıyor:', + state: pages[page] || pages[page.slice(0, -1)], + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Playerbros/assets/logo.png', + details: 'Bir sayfaya göz atıyor:', + state: 'Ana Sayfa', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } +}) diff --git a/websites/P/Plex/metadata.json b/websites/P/Plex/metadata.json index 03e66bae1a43..bec775a5920c 100644 --- a/websites/P/Plex/metadata.json +++ b/websites/P/Plex/metadata.json @@ -1,39 +1,39 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "Plex", - "description": { - "en": "Plex allows you to manage, curate, and stream your personal media along with premium content. Enjoy your own content on all your devices wherever you are with Plex.", - "nl": "Met Plex kunt u uw persoonlijke media beheren, samenstellen en streamen samen met premium inhoud. Geniet van uw eigen inhoud op al uw apparaten waar u ook bent met Plex.", - "de": "Mit Plex können Sie Ihre persönlichen Medien zusammen mit Premium-Inhalten verwalten und streamen. Genießen Sie Ihre eigenen Inhalte auf all Ihren Geräten, wo immer Sie mit Plex unterwegs sind." - }, - "url": "www.plex.tv", - "regExp": "(([a-z0-9-]+[.])*plex[.]tv[/])|( *[/]web[/]index[.]html#)", - "version": "1.10.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Plex/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Plex/assets/thumbnail.png", - "color": "#d78c14", - "category": "videos", - "tags": [ - "video", - "music" - ], - "settings": [ - { - "id": "cover", - "title": "Show Cover", - "icon": "fad fa-images", - "value": true - }, - { - "id": "usePresenceName", - "title": "Show Title as Presence", - "icon": "fad fa-user-edit", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "Plex", + "description": { + "en": "Plex allows you to manage, curate, and stream your personal media along with premium content. Enjoy your own content on all your devices wherever you are with Plex.", + "nl": "Met Plex kunt u uw persoonlijke media beheren, samenstellen en streamen samen met premium inhoud. Geniet van uw eigen inhoud op al uw apparaten waar u ook bent met Plex.", + "de": "Mit Plex können Sie Ihre persönlichen Medien zusammen mit Premium-Inhalten verwalten und streamen. Genießen Sie Ihre eigenen Inhalte auf all Ihren Geräten, wo immer Sie mit Plex unterwegs sind." + }, + "url": "www.plex.tv", + "regExp": "(([a-z0-9-]+[.])*plex[.]tv[/])|( *[/]web[/]index[.]html#)", + "version": "1.10.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Plex/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Plex/assets/thumbnail.png", + "color": "#d78c14", + "category": "videos", + "tags": [ + "video", + "music" + ], + "settings": [ + { + "id": "cover", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true + }, + { + "id": "usePresenceName", + "title": "Show Title as Presence", + "icon": "fad fa-user-edit", + "value": false + } + ] +} diff --git a/websites/P/Plex/presence.ts b/websites/P/Plex/presence.ts index 86cab45762b6..7edc90979aa1 100644 --- a/websites/P/Plex/presence.ts +++ b/websites/P/Plex/presence.ts @@ -1,347 +1,371 @@ const presence = new Presence({ - clientId: "645028677033132033", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - { language } = window.navigator; //Make this change-able with presence settings -//en = English -//nl = Nederlands -//Language list can be found here: https://api.premid.app/v2/langFile/list + clientId: '645028677033132033', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const { language } = window.navigator // Make this change-able with presence settings +// en = English +// nl = Nederlands +// Language list can be found here: https://api.premid.app/v2/langFile/list /** * Get Translation * @param stringName Name of string you want to get */ function getTranslation(stringName: string): string { - switch (stringName) { - case "HomePage": - switch (language) { - case "nl": - return "Bekijkt de startpagina"; - case "de": - return "Ist auf der Startseite"; - case "sv": - return "Kollar på startsidan"; - default: - return "Viewing home page"; - } - case "News": - switch (language) { - case "nl": - return "Bladeren door het niews"; - case "de": - return "Sieht sich News an"; - case "sv": - return "Bläddrar igenom nyheter"; - default: - return "Browsing news"; - } - case "WebShows": - switch (language) { - case "nl": - return "Bladeren door alle web shows"; - case "de": - return "Sieht sich Web-Shows an"; - case "sv": - return "Bläddrar igenom web shows"; - default: - return "Browsing web shows"; - } - case "Podcasts": - switch (language) { - case "nl": - return "Bladeren door podcasts"; - case "de": - return "Sieht sich Podcasts an"; - case "sv": - return "Bläddrar igenom podcasts"; - default: - return "Browsing podcasts"; - } - case "Music": - switch (language) { - case "nl": - return "Bladeren door muziek"; - case "de": - return "Sieht sich Musik an"; - case "sv": - return "Bläddrar igenom musik"; - default: - return "Browsing music"; - } - case "Search": - switch (language) { - case "nl": - return "Zoekt naar:"; - case "de": - return "Sucht nach:"; - case "sv": - return "Söker efter:"; - default: - return "Searching for:"; - } - case "Library": - switch (language) { - case "nl": - return "Bekijkt bibliotheek:"; - case "de": - return "Ist in der Bibliothek:"; - case "sv": - return "Kollar på bibliotek:"; - default: - return "Viewing library:"; - } - break; - case "Collection": - switch (language) { - case "nl": - return "Bekijkt collectie:"; - case "de": - return "Ist in der Kollektion"; - case "sv": - return "Kollar på samling:"; - default: - return "Viewing collection:"; - } + switch (stringName) { + case 'HomePage': + switch (language) { + case 'nl': + return 'Bekijkt de startpagina' + case 'de': + return 'Ist auf der Startseite' + case 'sv': + return 'Kollar på startsidan' + default: + return 'Viewing home page' + } + case 'News': + switch (language) { + case 'nl': + return 'Bladeren door het niews' + case 'de': + return 'Sieht sich News an' + case 'sv': + return 'Bläddrar igenom nyheter' + default: + return 'Browsing news' + } + case 'WebShows': + switch (language) { + case 'nl': + return 'Bladeren door alle web shows' + case 'de': + return 'Sieht sich Web-Shows an' + case 'sv': + return 'Bläddrar igenom web shows' + default: + return 'Browsing web shows' + } + case 'Podcasts': + switch (language) { + case 'nl': + return 'Bladeren door podcasts' + case 'de': + return 'Sieht sich Podcasts an' + case 'sv': + return 'Bläddrar igenom podcasts' + default: + return 'Browsing podcasts' + } + case 'Music': + switch (language) { + case 'nl': + return 'Bladeren door muziek' + case 'de': + return 'Sieht sich Musik an' + case 'sv': + return 'Bläddrar igenom musik' + default: + return 'Browsing music' + } + case 'Search': + switch (language) { + case 'nl': + return 'Zoekt naar:' + case 'de': + return 'Sucht nach:' + case 'sv': + return 'Söker efter:' + default: + return 'Searching for:' + } + case 'Library': + switch (language) { + case 'nl': + return 'Bekijkt bibliotheek:' + case 'de': + return 'Ist in der Bibliothek:' + case 'sv': + return 'Kollar på bibliotek:' + default: + return 'Viewing library:' + } + break + case 'Collection': + switch (language) { + case 'nl': + return 'Bekijkt collectie:' + case 'de': + return 'Ist in der Kollektion' + case 'sv': + return 'Kollar på samling:' + default: + return 'Viewing collection:' + } - case "Playlist": - switch (language) { - case "nl": - return "Bekijkt afspeellijst:"; - case "de": - return "Ist in der Playlist"; - case "sv": - return "Kollar på spellista:"; - default: - return "Viewing playlist:"; - } - case "Vod": - switch (language) { - case "nl": - return "Bekijkt Film/TV Show/VOD:"; - case "de": - return "Schaut Film/TV-Sendung/VOD:"; - case "sv": - return "Kollar på Film/TV Show/VOD:"; - default: - return "Viewing Movie/TV Show/VOD:"; - } - default: - presence.error( - "Unknown StringName please contact the Developer of this presence!\nYou can contact him/her in the PreMiD Discord (discord.premid.app)" - ); - return "Unknown stringName"; - } + case 'Playlist': + switch (language) { + case 'nl': + return 'Bekijkt afspeellijst:' + case 'de': + return 'Ist in der Playlist' + case 'sv': + return 'Kollar på spellista:' + default: + return 'Viewing playlist:' + } + case 'Vod': + switch (language) { + case 'nl': + return 'Bekijkt Film/TV Show/VOD:' + case 'de': + return 'Schaut Film/TV-Sendung/VOD:' + case 'sv': + return 'Kollar på Film/TV Show/VOD:' + default: + return 'Viewing Movie/TV Show/VOD:' + } + default: + presence.error( + 'Unknown StringName please contact the Developer of this presence!\nYou can contact him/her in the PreMiD Discord (discord.premid.app)', + ) + return 'Unknown stringName' + } } -let isUploading = false; +let isUploading = false const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Plex/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Plex/assets/logo.png', } -const uploadedImages: Record = {}; +const uploadedImages: Record = {} async function uploadImage(urlToUpload: string): Promise { - if (isUploading) return "plex"; + if (isUploading) + return 'plex' - if (uploadedImages[urlToUpload]) return uploadedImages[urlToUpload]; - isUploading = true; + if (uploadedImages[urlToUpload]) + return uploadedImages[urlToUpload] + isUploading = true - const file = await fetch(urlToUpload).then(x => x.blob()), - formData = new FormData(); + const file = await fetch(urlToUpload).then(x => x.blob()) + const formData = new FormData() - formData.append("file", file, "file"); + formData.append('file', file, 'file') - const response = await fetch("https://pd.premid.app/create/image", { - method: "POST", - body: formData, - }), - responseUrl = await response.text(); + const response = await fetch('https://pd.premid.app/create/image', { + method: 'POST', + body: formData, + }) + const responseUrl = await response.text() - isUploading = false; - uploadedImages[urlToUpload] = responseUrl; - return responseUrl; + isUploading = false + uploadedImages[urlToUpload] = responseUrl + return responseUrl } function isPrivateIp(ip = location.hostname) { - return /^(?:(?:10|127|192(\.|-)168|172(\.|-)(?:1[6-9]|2\d|3[01]))(\.|-)|localhost)/.test( - ip - ); + return /^(?:(?:10|127|192(?:\.|-)168|172(?:\.|-)(?:1[6-9]|2\d|3[01]))(?:\.|-)|localhost)/.test( + ip, + ) } -const shortenedURLs: Record = {}; +const shortenedURLs: Record = {} async function getShortURL(url: string) { - if (url && isPrivateIp(new URL(url).hostname)) return await uploadImage(url); - if (!url || url.length < 256) return url; + if (url && isPrivateIp(new URL(url).hostname)) + return await uploadImage(url) + if (!url || url.length < 256) + return url - if (shortenedURLs[url]) return shortenedURLs[url]; - try { - const pdURL = await ( - await fetch(`https://pd.premid.app/create/${url}`) - ).text(); - shortenedURLs[url] = pdURL; - return pdURL; - } catch (err) { - presence.error(err); - return url; - } + if (shortenedURLs[url]) + return shortenedURLs[url] + try { + const pdURL = await ( + await fetch(`https://pd.premid.app/create/${url}`) + ).text() + shortenedURLs[url] = pdURL + return pdURL + } + catch (err) { + presence.error(err as string) + return url + } } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname, href } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } as PresenceData + const { pathname, href } = document.location - if (document.querySelector("#plex")) { - if (document.querySelector("#plex > div:nth-child(4) > div")) { - const media = document.querySelector( - "#plex > div:nth-child(4) > div > div:nth-child(1) > :is(video, audio)" - ), - [cover, titlePresenceName] = await Promise.all([ - presence.getSetting("cover"), - presence.getSetting("usePresenceName"), - ]); + if (document.querySelector('#plex')) { + if (document.querySelector('#plex > div:nth-child(4) > div')) { + const media = document.querySelector( + '#plex > div:nth-child(4) > div > div:nth-child(1) > :is(video, audio)', + )! + const [cover, titlePresenceName] = await Promise.all([ + presence.getSetting('cover'), + presence.getSetting('usePresenceName'), + ]) - if ( - document.querySelector("[class^=PlayerControls-buttonGroupCenter]") - .children.length > 1 - ) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(media); - } else { - const formatTimestamps = document - .querySelector('[data-testid="mediaDuration"]') - ?.textContent.split(" "); + if ( + document.querySelector('[class^=PlayerControls-buttonGroupCenter]')! + .children + .length > 1 + ) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(media) + } + else { + const formatTimestamps = document + .querySelector('[data-testid="mediaDuration"]') + ?.textContent + ?.split(' '); - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - presence.timestampFromFormat(formatTimestamps?.[0]), - presence.timestampFromFormat(formatTimestamps?.[1]) - ); - } + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + presence.timestampFromFormat(formatTimestamps?.[0] ?? ''), + presence.timestampFromFormat(formatTimestamps?.[1] ?? ''), + ) + } - if (cover && navigator.mediaSession.metadata?.artwork[0].src) { - const art = navigator.mediaSession.metadata.artwork?.[0]?.src; - presenceData.largeImageKey = art?.match( - /(\d+)(? node.textContent) - .join(" "); + const title = document.querySelector( + '[class^=PlayerControlsMetadata] [data-testid="metadataTitleLink"]', + )?.textContent + const subTitle = Array.from( + document.querySelector( + '[class^=PlayerControlsMetadata] :is([data-testid="metadataTitleLink"] + span, [data-testid="metadataTitleLink"] + div)', + )?.childNodes ?? [], + ) + .map(node => node.textContent) + .join(' ') - if (!titlePresenceName) presenceData.details = title; - else presenceData.name = title; + if (!titlePresenceName) + presenceData.details = title + else presenceData.name = title! - presenceData.state = subTitle; + presenceData.state = subTitle - if ( - (!navigator.mediaSession.metadata.artist && - !navigator.mediaSession.metadata.album) || - !!document.querySelector(".application.show-video-player") - ) - presenceData.type = ActivityType.Watching; - else presenceData.type = ActivityType.Listening; + if ( + (!navigator.mediaSession?.metadata?.artist + && !navigator.mediaSession?.metadata?.album) + || !!document.querySelector('.application.show-video-player') + ) { + presenceData.type = ActivityType.Watching + } + else { + presenceData.type = ActivityType.Listening + } - if (media.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else if (href.includes("/tv.plex.provider.webshows")) { - presenceData.details = getTranslation("WebShows"); - const title = document.querySelector( - "#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(2) > div > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span" - ); - if (title) { - presenceData.details = "Viewing webshow:"; - presenceData.state = title.textContent; - } - } else if (href.includes("/tv.plex.provider.news")) - presenceData.details = getTranslation("News"); - else if (href.includes("/tv.plex.provider.podcasts")) { - presenceData.details = getTranslation("Podcasts"); - const title = document.querySelector( - "#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(2) > div > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span" - ); - if (title) { - presenceData.details = "Viewing podcast:"; - presenceData.state = title.textContent; - } - } else if (href.includes("/tv.plex.provider.music")) { - presenceData.details = getTranslation("Music"); - const title = document.querySelector( - "#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(2) > div > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > span" - ); - if (title) { - presenceData.details = "Viewing album:"; - presenceData.state = title.textContent; - } - } else if (href.includes("/search")) { - const search = document.querySelector( - "#plex > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(2) > span" - ); + if (media.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else if (href.includes('/tv.plex.provider.webshows')) { + presenceData.details = getTranslation('WebShows') + const title = document.querySelector( + '#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(2) > div > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span', + ) + if (title) { + presenceData.details = 'Viewing webshow:' + presenceData.state = title.textContent + } + } + else if (href.includes('/tv.plex.provider.news')) { + presenceData.details = getTranslation('News') + } + else if (href.includes('/tv.plex.provider.podcasts')) { + presenceData.details = getTranslation('Podcasts') + const title = document.querySelector( + '#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(2) > div > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span', + ) + if (title) { + presenceData.details = 'Viewing podcast:' + presenceData.state = title.textContent + } + } + else if (href.includes('/tv.plex.provider.music')) { + presenceData.details = getTranslation('Music') + const title = document.querySelector( + '#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(2) > div > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > span', + ) + if (title) { + presenceData.details = 'Viewing album:' + presenceData.state = title.textContent + } + } + else if (href.includes('/search')) { + const search = document.querySelector( + '#plex > div:nth-child(3) > div > div:nth-child(2) > div > div:nth-child(2) > span', + ) - presenceData.details = getTranslation("Search"); - presenceData.state = search.textContent.split('"')[1].replace('"', ""); - presenceData.smallImageKey = Assets.Search; - } else if (href.includes("/com.plexapp.plugins.library")) { - presenceData.details = getTranslation("Library"); - presenceData.state = document.querySelector( - "#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > a > div:nth-child(1)" - ).textContent; - } else if (href.includes("content.collections")) { - presenceData.details = getTranslation("Collection"); - presenceData.state = document.querySelector( - "#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > span" - ).textContent; - } else if ( - href.includes("content.playlists") && - document.querySelector( - "#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > span" - ) - ) { - presenceData.details = getTranslation("Playlist"); - presenceData.state = document.querySelector( - "#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > span" - ).textContent; - } else if (href.includes("tv.plex.provider.vod")) { - presenceData.details = getTranslation("Vod"); - presenceData.state = document.querySelector( - "#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(2) > div > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div > span" - ).textContent; - } else if (href.includes("/server/")) { - presenceData.details = getTranslation("Vod"); - presenceData.state = document.querySelector( - "#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(2) > div > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div > span" - ).textContent; - } else if ( - href === "https://app.plex.tv/" || - href === "https://app.plex.tv/desktop" || - href === "https://app.plex.tv/desktop#" || - href === "https://app.plex.tv/desktop/#!/" || - pathname === "/web/index.html" || - pathname === "/web/index.html#" - ) - presenceData.details = getTranslation("HomePage"); + presenceData.details = getTranslation('Search') + presenceData.state = search?.textContent?.split('"')[1].replace('"', '') + presenceData.smallImageKey = Assets.Search + } + else if (href.includes('/com.plexapp.plugins.library')) { + presenceData.details = getTranslation('Library') + presenceData.state = document.querySelector( + '#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > a > div:nth-child(1)', + )?.textContent + } + else if (href.includes('content.collections')) { + presenceData.details = getTranslation('Collection') + presenceData.state = document.querySelector( + '#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > span', + )?.textContent + } + else if ( + href.includes('content.playlists') + && document.querySelector( + '#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > span', + ) + ) { + presenceData.details = getTranslation('Playlist') + presenceData.state = document.querySelector( + '#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > span', + )?.textContent + } + else if (href.includes('tv.plex.provider.vod')) { + presenceData.details = getTranslation('Vod') + presenceData.state = document.querySelector( + '#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(2) > div > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div > span', + )?.textContent + } + else if (href.includes('/server/')) { + presenceData.details = getTranslation('Vod') + presenceData.state = document.querySelector( + '#plex > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(2) > div > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div > span', + )?.textContent + } + else if ( + href === 'https://app.plex.tv/' + || href === 'https://app.plex.tv/desktop' + || href === 'https://app.plex.tv/desktop#' + || href === 'https://app.plex.tv/desktop/#!/' + || pathname === '/web/index.html' + || pathname === '/web/index.html#' + ) { + presenceData.details = getTranslation('HomePage') + } - if (!presenceData.details && !presenceData.name) presence.setActivity(); - else presence.setActivity(presenceData); - } -}); + if (!presenceData.details && !presenceData.name) + presence.setActivity() + else presence.setActivity(presenceData) + } +}) diff --git a/websites/P/PlutoTV/metadata.json b/websites/P/PlutoTV/metadata.json index 91bc850dafab..e97b1a4caa11 100644 --- a/websites/P/PlutoTV/metadata.json +++ b/websites/P/PlutoTV/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "PlutoTV", - "description": { - "en": "It’s Free TV.", - "nl": "Het is gratis TV." - }, - "url": "pluto.tv", - "regExp": "([a-z0-9-]+[.])*pluto[.]tv[/]", - "version": "1.3.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PlutoTV/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PlutoTV/assets/thumbnail.png", - "color": "#ffffff", - "category": "videos", - "tags": [ - "tv", - "live" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "PlutoTV", + "description": { + "en": "It’s Free TV.", + "nl": "Het is gratis TV." + }, + "url": "pluto.tv", + "regExp": "([a-z0-9-]+[.])*pluto[.]tv[/]", + "version": "1.3.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PlutoTV/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PlutoTV/assets/thumbnail.png", + "color": "#ffffff", + "category": "videos", + "tags": [ + "tv", + "live" + ] +} diff --git a/websites/P/PlutoTV/presence.ts b/websites/P/PlutoTV/presence.ts index 157ec80555e3..81d448e7ef84 100644 --- a/websites/P/PlutoTV/presence.ts +++ b/websites/P/PlutoTV/presence.ts @@ -1,129 +1,129 @@ const presence = new Presence({ - clientId: "640292045117980713", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '640292045117980713', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let title: HTMLElement, - playing: boolean, - paused: boolean, - progress: string | HTMLStyleElement | number, - lastState: string | null, - oldTitle: string | null, - currentTime: number, - duration: number, - video: HTMLVideoElement; +let playing: boolean, + paused: boolean, + progress: number | undefined, + lastState: string | null | undefined, + oldTitle: string | null | undefined -lastState = null; -oldTitle = null; +lastState = null +oldTitle = null -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PlutoTV/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PlutoTV/assets/logo.png', + } - if (document.location.hostname === "pluto.tv") { - if (document.location.pathname.includes("/live-tv/")) { - progress = document.querySelector( - "#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.VideoControls__videoControls-irCOHX.frYEBe > div.VideoControls__bottomPanel-gpACgQ.jiJGDj > div > div > div > div" - ); - progress = progress.style.cssText - .replace("width: ", "") - .replace("%;", ""); + if (document.location.hostname === 'pluto.tv') { + if (document.location.pathname.includes('/live-tv/')) { + const newProgress = document.querySelector( + '#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.VideoControls__videoControls-irCOHX.frYEBe > div.VideoControls__bottomPanel-gpACgQ.jiJGDj > div > div > div > div', + )?.style.cssText.replace('width: ', '').replace('%;', '') - if (lastState === progress && progress !== "0" && progress !== "100") { - playing = true; - paused = true; - } else if (progress === "0" || progress === "100") { - playing = false; - paused = true; - } else { - lastState = progress; - playing = true; - paused = false; - } - progress = Number(progress); - progress = Math.round(progress); - } + if (lastState === newProgress && newProgress !== '0' && newProgress !== '100') { + playing = true + paused = true + } + else if (newProgress === '0' || newProgress === '100') { + playing = false + paused = true + } + else { + lastState = newProgress + playing = true + paused = false + } + progress = Math.round(Number(newProgress)) + } - if (playing === true && paused === false) { - title = document.querySelector( - "#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.NnGyI" - ); - presenceData.details = title.textContent; - presenceData.state = `${progress}% progressed`; - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Playing"; - } else if (playing === true && paused === true) { - title = document.querySelector( - "#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.NnGyI" - ); - presenceData.details = title.textContent; - presenceData.state = `${progress}% progressed`; - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Playing"; - } else if (document.location.pathname.includes("/on-demand/movies/")) { - video = document.querySelector( - "#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.Player__VideoWrapper-iChBud.eNibdw > div > div:nth-child(1) > div > div.container.chromeless.pointer-enabled > video" - ); - ({ currentTime, duration, paused } = video); + if (playing === true && paused === false) { + const title = document.querySelector( + '#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.NnGyI', + ) + presenceData.details = title?.textContent + presenceData.state = `${progress}% progressed` + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Playing' + } + else if (playing === true && paused === true) { + const title = document.querySelector( + '#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.NnGyI', + ) + presenceData.details = title?.textContent + presenceData.state = `${progress}% progressed` + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Playing' + } + else if (document.location.pathname.includes('/on-demand/movies/')) { + const video = document.querySelector( + '#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.Player__VideoWrapper-iChBud.eNibdw > div > div:nth-child(1) > div > div.container.chromeless.pointer-enabled > video', + )! + const { currentTime, duration, paused } = video; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(Math.floor(currentTime), Math.floor(duration)); - if (!isNaN(duration)) { - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = paused - ? (await strings).pause - : (await strings).play; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(Math.floor(currentTime), Math.floor(duration)) + if (!Number.isNaN(duration)) { + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = paused + ? (await strings).pause + : (await strings).play - title = document.querySelector( - "#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.ktRSHs > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.krcxuL" - ); - title ??= document.querySelector( - "#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.krcxuL" - ); + const title = document.querySelector( + '#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.ktRSHs > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.krcxuL', + ) ?? document.querySelector( + '#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.krcxuL', + ) - if (!title && oldTitle) presenceData.details = oldTitle; - else { - presenceData.details = title.textContent; - oldTitle = title.textContent; - } + if (!title && oldTitle) { + presenceData.details = oldTitle + } + else { + presenceData.details = title?.textContent + oldTitle = title?.textContent + } - if (paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else if (isNaN(duration)) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Looking at: "; - title = document.querySelector( - "#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.ktRSHs > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.krcxuL" - ); - title ??= document.querySelector( - "#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.krcxuL" - ); - if (!title && oldTitle) presenceData.details = oldTitle; - else { - presenceData.details = title.textContent; - oldTitle = title.textContent; - } + if (paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else if (Number.isNaN(duration)) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Looking at: ' + const title = document.querySelector( + '#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.ktRSHs > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.krcxuL', + ) ?? document.querySelector( + '#root > div.jss1.withHeader.withGuide > div.Player__Wrapper-kxPlPT.cCxNsj > div > div > div > div.PlayerOverlay__Wrapper-kMDJbl.dZAJEx > div > div > div.Overlay__copyWrapper-cCOfPR.dWHpCz > div.Overlay__title-kcjStc.krcxuL', + ) + if (!title && oldTitle) { + presenceData.details = oldTitle + } + else { + presenceData.details = title?.textContent + oldTitle = title?.textContent + } - presenceData.smallImageKey = Assets.Reading; - } - } else if (document.location.pathname.includes("/trending")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing what's trending"; - } else if (document.location.pathname.includes("/on-demand")) { - presenceData.details = "Browsing on"; - presenceData.state = "demand shows..."; - presenceData.startTimestamp = browsingTimestamp; - } - } + presenceData.smallImageKey = Assets.Reading + } + } + else if (document.location.pathname.includes('/trending')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing what\'s trending' + } + else if (document.location.pathname.includes('/on-demand')) { + presenceData.details = 'Browsing on' + presenceData.state = 'demand shows...' + 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/P/Pocket Casts/metadata.json b/websites/P/Pocket Casts/metadata.json index d8b7570b2b33..ee0927d31da6 100644 --- a/websites/P/Pocket Casts/metadata.json +++ b/websites/P/Pocket Casts/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "ry", - "id": "421371986824921109" - }, - "service": "Pocket Casts", - "description": { - "en": "All the features you need in a podcasting app without any of the bloat. Podcast listening turned up to 11.", - "nl": "Alle functies die je nodig hebt in een podcasting-app zonder een opgeblazen gevoel. Podcast luisteren is op 11 gezet." - }, - "url": "play.pocketcasts.com", - "version": "1.2.26", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pocket%20Casts/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pocket%20Casts/assets/thumbnail.png", - "color": "#F43E37", - "category": "other", - "tags": [ - "podcasts", - "media" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "ry", + "id": "421371986824921109" + }, + "service": "Pocket Casts", + "description": { + "en": "All the features you need in a podcasting app without any of the bloat. Podcast listening turned up to 11.", + "nl": "Alle functies die je nodig hebt in een podcasting-app zonder een opgeblazen gevoel. Podcast luisteren is op 11 gezet." + }, + "url": "play.pocketcasts.com", + "version": "1.2.26", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pocket%20Casts/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pocket%20Casts/assets/thumbnail.png", + "color": "#F43E37", + "category": "other", + "tags": [ + "podcasts", + "media" + ] +} diff --git a/websites/P/Pocket Casts/presence.ts b/websites/P/Pocket Casts/presence.ts index a7299f687c96..cf79cbae135d 100644 --- a/websites/P/Pocket Casts/presence.ts +++ b/websites/P/Pocket Casts/presence.ts @@ -1,97 +1,101 @@ const presence = new Presence({ - clientId: "661889916635971616", -}); + clientId: '661889916635971616', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Pocket%20Casts/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Pocket%20Casts/assets/logo.png', + } - if (document.querySelector(".controls").ariaLabel.includes("Playing")) { - presenceData.details = document.querySelector("div.episode").textContent; - presenceData.state = document.querySelector( - ".player_podcast_title" - ).textContent; + if (document.querySelector('.controls')?.ariaLabel?.includes('Playing')) { + presenceData.details = document.querySelector('div.episode')?.textContent + presenceData.state = document.querySelector( + '.player_podcast_title', + )?.textContent - const time = document - .querySelector( - ".TimeTextstyled__TimeTextWrapper-sc-1yzkn0m-0.lmVDeu.current-time" - ) - .textContent.split(":") - .map(Number); - presenceData.smallImageKey = Assets.Play; - if (time.length === 3) { - presenceData.startTimestamp = - Date.now() - (time[0] * 3600 + time[1] * 60 + time[2]) * 1000; - } else { - presenceData.startTimestamp = - Date.now() - (time[0] * 60 + time[1]) * 1000; - } - } else if (document.querySelector(".controls").ariaLabel.includes("Paused")) { - presenceData.details = document.querySelector("div.episode").textContent; - presenceData.state = document.querySelector( - ".player_podcast_title" - ).textContent; - presenceData.smallImageKey = Assets.Pause; - delete presenceData.startTimestamp; - } - if (document.querySelector(".controls").ariaLabel.includes("Paused")) { - if (document.location.pathname === "/podcasts") - presenceData.details = "Viewing subscriptions"; - else if ( - document.location.pathname.startsWith("/podcasts/") || - document.location.pathname.startsWith("/discover/podcast/") - ) { - presenceData.details = "Viewing podcast"; - presenceData.state = document.querySelector( - "*[class*='PodcastTitle-sc']" - ).textContent; - } else if (document.location.pathname === "/discover") - presenceData.details = "Viewing discover page"; - else if (document.location.pathname.startsWith("/discover/list/")) { - presenceData.details = "Viewing discover page"; - presenceData.state = document.querySelectorAll("h1")[0].textContent; - } else { - switch (document.location.pathname) { - case "/new-releases": { - presenceData.details = "Viewing new releases"; - break; - } - case "/in-progress": { - presenceData.details = "Viewing in-progress episodes"; - break; - } - case "/starred": { - presenceData.details = "Viewing starred episodes"; - break; - } - case "/profile": { - presenceData.details = "Viewing profile"; - break; - } - case "/uploaded-files": { - presenceData.details = "Viewing uploaded files"; - break; - } - case "/history": { - presenceData.details = "Viewing listening history"; - break; - } - case "/stats": { - presenceData.details = "Viewing listening stats"; - presenceData.state = `Listened for ${ - document.querySelectorAll(".styled__TimeListened-sc-1nd51k4-2")[0] - .textContent - }`; + const time = document + .querySelector( + '.TimeTextstyled__TimeTextWrapper-sc-1yzkn0m-0.lmVDeu.current-time', + ) + ?.textContent + ?.split(':') + .map(Number) ?? [] + presenceData.smallImageKey = Assets.Play + if (time.length === 3) { + presenceData.startTimestamp = Date.now() - (time[0] * 3600 + time[1] * 60 + time[2]) * 1000 + } + else { + presenceData.startTimestamp = Date.now() - (time[0] * 60 + time[1]) * 1000 + } + } + else if (document.querySelector('.controls')?.ariaLabel?.includes('Paused')) { + presenceData.details = document.querySelector('div.episode')?.textContent + presenceData.state = document.querySelector( + '.player_podcast_title', + )?.textContent + presenceData.smallImageKey = Assets.Pause + delete presenceData.startTimestamp + } + if (document.querySelector('.controls')?.ariaLabel?.includes('Paused')) { + if (document.location.pathname === '/podcasts') { + presenceData.details = 'Viewing subscriptions' + } + else if ( + document.location.pathname.startsWith('/podcasts/') + || document.location.pathname.startsWith('/discover/podcast/') + ) { + presenceData.details = 'Viewing podcast' + presenceData.state = document.querySelector( + '*[class*=\'PodcastTitle-sc\']', + )?.textContent + } + else if (document.location.pathname === '/discover') { + presenceData.details = 'Viewing discover page' + } + else if (document.location.pathname.startsWith('/discover/list/')) { + presenceData.details = 'Viewing discover page' + presenceData.state = document.querySelectorAll('h1')[0].textContent + } + else { + switch (document.location.pathname) { + case '/new-releases': { + presenceData.details = 'Viewing new releases' + break + } + case '/in-progress': { + presenceData.details = 'Viewing in-progress episodes' + break + } + case '/starred': { + presenceData.details = 'Viewing starred episodes' + break + } + case '/profile': { + presenceData.details = 'Viewing profile' + break + } + case '/uploaded-files': { + presenceData.details = 'Viewing uploaded files' + break + } + case '/history': { + presenceData.details = 'Viewing listening history' + break + } + case '/stats': { + presenceData.details = 'Viewing listening stats' + presenceData.state = `Listened for ${ + document.querySelectorAll('.styled__TimeListened-sc-1nd51k4-2')[0] + .textContent + }` - break; - } - default: - if (document.location.pathname.startsWith("/settings/")) - presenceData.details = "Changing settings"; - } - } - } - presence.setActivity(presenceData); -}); + break + } + default: + if (document.location.pathname.startsWith('/settings/')) + presenceData.details = 'Changing settings' + } + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/P/PodcastAddict/metadata.json b/websites/P/PodcastAddict/metadata.json index 610d2bfc487d..4c35172a490f 100644 --- a/websites/P/PodcastAddict/metadata.json +++ b/websites/P/PodcastAddict/metadata.json @@ -1,32 +1,32 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Harold", - "id": "141206144264699904" - }, - "contributors": [ - { - "name": "Noah", - "id": "272450405525356546" - } - ], - "service": "PodcastAddict", - "description": { - "en": "Podcast Addict is Android #1 podcast app with over 10M downloads, 500K reviews and an average rating of 4.7/5", - "nl": "Podcast Addict is Android's #1 podcast app met meer dan 10M downloads, 500K reviews en een gemiddelde waardering van 4.7/5" - }, - "url": [ - "podcastaddict.com", - "www.podcastaddict.com" - ], - "version": "1.1.17", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PodcastAddict/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PodcastAddict/assets/thumbnail.jpg", - "color": "#f48529", - "category": "music", - "tags": [ - "podcast", - "music" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Harold", + "id": "141206144264699904" + }, + "contributors": [ + { + "name": "Noah", + "id": "272450405525356546" + } + ], + "service": "PodcastAddict", + "description": { + "en": "Podcast Addict is Android #1 podcast app with over 10M downloads, 500K reviews and an average rating of 4.7/5", + "nl": "Podcast Addict is Android's #1 podcast app met meer dan 10M downloads, 500K reviews en een gemiddelde waardering van 4.7/5" + }, + "url": [ + "podcastaddict.com", + "www.podcastaddict.com" + ], + "version": "1.1.17", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PodcastAddict/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PodcastAddict/assets/thumbnail.jpg", + "color": "#f48529", + "category": "music", + "tags": [ + "podcast", + "music" + ] +} diff --git a/websites/P/PodcastAddict/presence.ts b/websites/P/PodcastAddict/presence.ts index 9c381a1a2869..faf4d9f536a1 100644 --- a/websites/P/PodcastAddict/presence.ts +++ b/websites/P/PodcastAddict/presence.ts @@ -1,70 +1,85 @@ const presence = new Presence({ - clientId: "835652520637890620", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '835652520637890620', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PodcastAddict/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, search } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PodcastAddict/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, search } = document.location - if (pathname === "/" && search.substr(0, 2) === "?q") { - presenceData.details = "Searching:"; - presenceData.state = document.querySelector(".caption").textContent; - presenceData.smallImageKey = Assets.Search; - } else if (pathname === "/") presenceData.details = "Viewing the homepage"; - else if (pathname.startsWith("/app")) - presenceData.details = "Reading the app page"; - else if (pathname.startsWith("/ads")) - presenceData.details = "Reading the ads page"; - else if (pathname.startsWith("/privacy")) - presenceData.details = "Reading the privacy policy & ToS page"; - else if (pathname.startsWith("/submit")) - presenceData.details = "Reading the podcast submission page"; - else if (pathname.startsWith("/podcasters")) - presenceData.details = "Reading the podcasters page"; - else if (pathname.startsWith("/premium")) - presenceData.details = "Reading the premium page"; - else if (pathname.startsWith("/faq")) - presenceData.details = "Reading the FAQ page"; - else if (pathname.startsWith("/changelog")) - presenceData.details = "Reading the changelog page"; - else if (pathname.startsWith("/contact")) - presenceData.details = "Reading the contact page"; - else if (pathname.startsWith("/podcast")) { - presenceData.details = "Viewing:"; - presenceData.state = document.querySelector(".caption").textContent; - presenceData.smallImageKey = Assets.Viewing; - presenceData.buttons = [ - { label: "View Podcast", url: window.location.href }, - ]; - } else if (pathname.startsWith("/episode")) { - const elapsedTime = presence.timestampFromFormat( - document.querySelector("#elapsedTime").textContent - ); + if (pathname === '/' && search.substr(0, 2) === '?q') { + presenceData.details = 'Searching:' + presenceData.state = document.querySelector('.caption')?.textContent + presenceData.smallImageKey = Assets.Search + } + else if (pathname === '/') { + presenceData.details = 'Viewing the homepage' + } + else if (pathname.startsWith('/app')) { + presenceData.details = 'Reading the app page' + } + else if (pathname.startsWith('/ads')) { + presenceData.details = 'Reading the ads page' + } + else if (pathname.startsWith('/privacy')) { + presenceData.details = 'Reading the privacy policy & ToS page' + } + else if (pathname.startsWith('/submit')) { + presenceData.details = 'Reading the podcast submission page' + } + else if (pathname.startsWith('/podcasters')) { + presenceData.details = 'Reading the podcasters page' + } + else if (pathname.startsWith('/premium')) { + presenceData.details = 'Reading the premium page' + } + else if (pathname.startsWith('/faq')) { + presenceData.details = 'Reading the FAQ page' + } + else if (pathname.startsWith('/changelog')) { + presenceData.details = 'Reading the changelog page' + } + else if (pathname.startsWith('/contact')) { + presenceData.details = 'Reading the contact page' + } + else if (pathname.startsWith('/podcast')) { + presenceData.details = 'Viewing:' + presenceData.state = document.querySelector('.caption')?.textContent + presenceData.smallImageKey = Assets.Viewing + presenceData.buttons = [ + { label: 'View Podcast', url: window.location.href }, + ] + } + else if (pathname.startsWith('/episode')) { + const elapsedTime = presence.timestampFromFormat( + document.querySelector('#elapsedTime')?.textContent ?? '', + ) - presenceData.buttons = [ - { label: "Listen Along", url: window.location.href }, - ]; - presenceData.details = document.querySelector(".pure-button").textContent; - presenceData.state = document.querySelector(".title").textContent; - if ( - !document - .querySelector("#play-pause-button") - .classList.contains("fa-play-circle") - ) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - elapsedTime, - presence.timestampFromFormat( - document.querySelector("#remainingTime").textContent.substr(1) - ) + elapsedTime - ); - presenceData.smallImageKey = Assets.Play; - } else presenceData.smallImageKey = Assets.Pause; - } - presence.setActivity(presenceData); -}); + presenceData.buttons = [ + { label: 'Listen Along', url: window.location.href }, + ] + presenceData.details = document.querySelector('.pure-button')?.textContent + presenceData.state = document.querySelector('.title')?.textContent + if ( + !document + .querySelector('#play-pause-button') + ?.classList + .contains('fa-play-circle') + ) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + elapsedTime, + presence.timestampFromFormat( + document.querySelector('#remainingTime')?.textContent?.substr(1) ?? '', + ) + elapsedTime, + ) + presenceData.smallImageKey = Assets.Play + } + else { + presenceData.smallImageKey = Assets.Pause + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/P/Podurama/metadata.json b/websites/P/Podurama/metadata.json index c4ad9b2ae450..d809f8951a57 100644 --- a/websites/P/Podurama/metadata.json +++ b/websites/P/Podurama/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "358402930191106049", - "name": "ion606" - }, - "service": "Podurama", - "description": { - "en": "Best free podcast player to listen to free podcasts, add custom rss feeds or upload your private files on mobile and desktop devices. Discover over 2M podcasts and millions of episodes." - }, - "url": "podurama.com", - "version": "1.0.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Podurama/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Podurama/assets/thumbnail.png", - "color": "#4B5458", - "category": "other", - "tags": [ - "podurama" - ], - "settings": [ - { - "id": "usetimeleft", - "title": "Use time left", - "icon": "fad fa-stopwatch", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "358402930191106049", + "name": "ion606" + }, + "service": "Podurama", + "description": { + "en": "Best free podcast player to listen to free podcasts, add custom rss feeds or upload your private files on mobile and desktop devices. Discover over 2M podcasts and millions of episodes." + }, + "url": "podurama.com", + "version": "1.0.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Podurama/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Podurama/assets/thumbnail.png", + "color": "#4B5458", + "category": "other", + "tags": [ + "podurama" + ], + "settings": [ + { + "id": "usetimeleft", + "title": "Use time left", + "icon": "fad fa-stopwatch", + "value": true + } + ] +} diff --git a/websites/P/Podurama/presence.ts b/websites/P/Podurama/presence.ts index af3a02b82e49..403cddcddcf9 100644 --- a/websites/P/Podurama/presence.ts +++ b/websites/P/Podurama/presence.ts @@ -1,124 +1,127 @@ const presence = new Presence({ - clientId: "1234257543467892826", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1234257543467892826', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Podurama/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Podurama/assets/logo.png', } const enum Pages { - home = "home", - podcast = "podcast", - episode = "episode", - bookmarks = "bookmarks", - recent = "recently-played", - Trending = "top-charts", - myPodcasts = "subscribed-podcasts", - newEps = "new-episodes", - myFiles = "my-files", - favorites = "favourites", - tags = "tags", - Bookmarks = "bookmarks", - followed = "followed-playlists", + home = 'home', + podcast = 'podcast', + episode = 'episode', + bookmarks = 'bookmarks', + recent = 'recently-played', + Trending = 'top-charts', + myPodcasts = 'subscribed-podcasts', + newEps = 'new-episodes', + myFiles = 'my-files', + favorites = 'favourites', + tags = 'tags', + // eslint-disable-next-line ts/no-duplicate-enum-values + Bookmarks = 'bookmarks', + followed = 'followed-playlists', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - [, sect, subsect] = document.location.pathname.split("/"), - player = document.querySelector(".audio-player"), - useTimeLeft = await presence.getSetting("usetimeleft"); - - if (player) { - const audioEl = document.querySelector("audio"), - [startTS, endTS] = presence.getTimestampsfromMedia(audioEl); - presenceData.details = "Listening to a Podcast"; - presenceData.state = player.querySelector(".episode-title").textContent; - - if (audioEl.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } else if (useTimeLeft) { - [presenceData.startTimestamp, presenceData.endTimestamp] = [ - startTS, - endTS, - ]; - } else presenceData.startTimestamp = startTS; - - presenceData.smallImageKey = audioEl.paused ? Assets.Pause : Assets.Play; - presenceData.largeImageKey = player - ?.querySelector(".episode-details") - ?.querySelector("img")?.src; - } else { - switch (sect) { - case Pages.podcast: - { - const header = document.querySelector("header"); - presenceData.details = "Viewing Podcast Page"; - presenceData.state = header.querySelector("h1").textContent; - presenceData.largeImageKey = header.querySelector("img").src; - } - break; - - case Pages.episode: - { - presenceData.details = "Viewing Podcast Page"; - presenceData.state = - document.querySelector(".episode-title").textContent; - presenceData.largeImageKey = - document.querySelector(".main-img-loc").src; - } - break; - - case Pages.bookmarks: - presenceData.details = "Browsing Bookmarks"; - break; - - case Pages.Trending: - { - presenceData.details = "Browsing Trending Podcasts!"; - presenceData.state = `In the '${subsect.replaceAll( - "-", - " " - )}' category`; - } - break; - - case Pages.favorites: - presenceData.details = "Browsing Favorite Episodes!"; - break; - - case Pages.followed: - presenceData.details = "Browsing Followed Podcasts!"; - break; - - case Pages.myFiles: - presenceData.details = "Browsing My Files!"; - break; - - case Pages.myPodcasts: - presenceData.details = "Browsing Subcribed Podcasts!"; - break; - - case Pages.newEps: - presenceData.details = "Searching for New Episodes!"; - break; - - case Pages.recent: - presenceData.details = "Browsing Recently Played!"; - break; - - case Pages.tags: - presenceData.details = "Browsing Collections!"; - break; - - default: - presenceData.details = "Browsing the Site"; - } - } - - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const [, sect, subsect] = document.location.pathname.split('/') + const player = document.querySelector('.audio-player') + const useTimeLeft = await presence.getSetting('usetimeleft') + + if (player) { + const audioEl = document.querySelector('audio')! + const [startTS, endTS] = presence.getTimestampsfromMedia(audioEl) + presenceData.details = 'Listening to a Podcast' + presenceData.state = player.querySelector('.episode-title')?.textContent + + if (audioEl.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + else if (useTimeLeft) { + [presenceData.startTimestamp, presenceData.endTimestamp] = [ + startTS, + endTS, + ] + } + else { + presenceData.startTimestamp = startTS + } + + presenceData.smallImageKey = audioEl.paused ? Assets.Pause : Assets.Play + presenceData.largeImageKey = player + ?.querySelector('.episode-details') + ?.querySelector('img') + ?.src + } + else { + switch (sect) { + case Pages.podcast: + { + const header = document.querySelector('header') + presenceData.details = 'Viewing Podcast Page' + presenceData.state = header?.querySelector('h1')?.textContent + presenceData.largeImageKey = header?.querySelector('img')?.src + } + break + + case Pages.episode: { + presenceData.details = 'Viewing Podcast Page' + presenceData.state = document.querySelector('.episode-title')?.textContent + presenceData.largeImageKey = document.querySelector('.main-img-loc')?.src + break + } + + case Pages.bookmarks: + presenceData.details = 'Browsing Bookmarks' + break + + case Pages.Trending: { + presenceData.details = 'Browsing Trending Podcasts!' + presenceData.state = `In the '${subsect.replaceAll( + '-', + ' ', + )}' category` + break + } + + case Pages.favorites: + presenceData.details = 'Browsing Favorite Episodes!' + break + + case Pages.followed: + presenceData.details = 'Browsing Followed Podcasts!' + break + + case Pages.myFiles: + presenceData.details = 'Browsing My Files!' + break + + case Pages.myPodcasts: + presenceData.details = 'Browsing Subcribed Podcasts!' + break + + case Pages.newEps: + presenceData.details = 'Searching for New Episodes!' + break + + case Pages.recent: + presenceData.details = 'Browsing Recently Played!' + break + + case Pages.tags: + presenceData.details = 'Browsing Collections!' + break + + default: + presenceData.details = 'Browsing the Site' + } + } + + presence.setActivity(presenceData) +}) diff --git a/websites/P/Poke/metadata.json b/websites/P/Poke/metadata.json index 65f7054ca488..d6c61091cd1c 100644 --- a/websites/P/Poke/metadata.json +++ b/websites/P/Poke/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "ashley", - "id": "396571938081865741" - }, - "service": "Poke", - "description": { - "en": "Watch Silly videos or search the interwebs while being anonymous on poke!" - }, - "url": [ - "poketube.fun", - "poke.ggtyler.dev", - "poke.vern.cc" - ], - "version": "1.0.6", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Poke/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Poke/assets/thumbnail.png", - "color": "#414161", - "category": "videos", - "tags": [ - "video", - "media" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "ashley", + "id": "396571938081865741" + }, + "service": "Poke", + "description": { + "en": "Watch Silly videos or search the interwebs while being anonymous on poke!" + }, + "url": [ + "poketube.fun", + "poke.ggtyler.dev", + "poke.vern.cc" + ], + "version": "1.0.6", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Poke/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Poke/assets/thumbnail.png", + "color": "#414161", + "category": "videos", + "tags": [ + "video", + "media" + ] +} diff --git a/websites/P/Poke/presence.ts b/websites/P/Poke/presence.ts index 269b5244c86f..4a7e1deb6468 100644 --- a/websites/P/Poke/presence.ts +++ b/websites/P/Poke/presence.ts @@ -1,66 +1,65 @@ const presence = new Presence({ - clientId: "1188371319776100463", -}); + clientId: '1188371319776100463', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/P/Poke/assets/logo.png", - }; - let clear = false; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Poke/assets/logo.png', + } + let clear = false - switch (document.location.pathname.replace("/feed", "").split("/")[1]) { - case "": - case "app": - presenceData.details = "Browsing trending videos"; - break; + switch (document.location.pathname.replace('/feed', '').split('/')[1]) { + case '': + case 'app': + presenceData.details = 'Browsing trending videos' + break - case "my-acc": - presenceData.details = "Browsing subscriptions"; - break; + case 'my-acc': + presenceData.details = 'Browsing subscriptions' + break - case "license": - case "privacy": - presenceData.details = "Managing preferences"; - break; + case 'license': + case 'privacy': + presenceData.details = 'Managing preferences' + break - case "watch": { - presenceData.smallImageKey = - document.querySelector("video") && - !document.querySelector("video").paused - ? Assets.Play - : Assets.Pause; - const videoTitleElement = document.querySelector(".video-title.t"); - presenceData.details = videoTitleElement - ? videoTitleElement.textContent.trim() - : "No Title Available"; + case 'watch': { + presenceData.smallImageKey = document.querySelector('video') + && !document.querySelector('video')?.paused + ? Assets.Play + : Assets.Pause + const videoTitleElement = document.querySelector('.video-title.t') + presenceData.details = videoTitleElement + ? videoTitleElement.textContent?.trim() + : 'No Title Available' - const channelNameElement = document.querySelector( - ".video-info-pill-channelname" - ); - presenceData.state = channelNameElement - ? channelNameElement.textContent.trim() - : "No Channel Name Available"; - const videoPlayer = document.querySelector("video"); + const channelNameElement = document.querySelector( + '.video-info-pill-channelname', + ) + presenceData.state = channelNameElement + ? channelNameElement.textContent?.trim() + : 'No Channel Name Available' + const videoPlayer = document.querySelector('video') - if (videoPlayer && !videoPlayer.paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(document.querySelector("video")); - } - break; - } - case "channel": { - const nameElement = document.querySelector(".name p"); - presenceData.details = "Viewing channel"; - presenceData.state = nameElement - ? nameElement.textContent.trim() - : "No Name Available"; - break; - } - default: - clear = true; - break; - } + if (videoPlayer && !videoPlayer.paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(document.querySelector('video')!) + } + break + } + case 'channel': { + const nameElement = document.querySelector('.name p') + presenceData.details = 'Viewing channel' + presenceData.state = nameElement + ? nameElement.textContent?.trim() + : 'No Name Available' + break + } + default: + clear = true + break + } - if (clear) presence.setActivity(); - else presence.setActivity(presenceData); -}); + if (clear) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/P/PokeRogue/metadata.json b/websites/P/PokeRogue/metadata.json index dc0c9e86d9fc..ea8eb07a96b6 100644 --- a/websites/P/PokeRogue/metadata.json +++ b/websites/P/PokeRogue/metadata.json @@ -1,49 +1,49 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "638080361179512853", - "name": "dark_ville" - }, - "service": "PokeRogue", - "description": { - "en": "A Pokémon fangame heavily inspired by the roguelite genre. Battle endlessly while gathering stacking items, exploring many different biomes, and reaching Pokémon stats you never thought possible." - }, - "url": [ - "pokerogue.net", - "127.0.0.1" - ], - "version": "1.0.6", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PokeRogue/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PokeRogue/assets/thumbnail.png", - "color": "#6b5a73", - "category": "games", - "tags": [ - "poke", - "pokemon", - "rogue", - "run" - ], - "settings": [ - { - "id": "timePer", - "title": "Reset timestamp after each wave", - "icon": "fad fa-stopwatch", - "value": false - }, - { - "id": "gameDetail", - "title": "Game Details row1", - "icon": "fas fa-comment-alt-edit", - "value": "%biome% %wave%", - "placeholder": "Use %wave% %biome% %playtime% %mode%" - }, - { - "id": "gameState", - "title": "Game Details row2", - "icon": "fas fa-comment-alt-edit", - "value": "%mode% %playtime%", - "placeholder": "same like row1 or use {0} to delete the row completely" - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "638080361179512853", + "name": "dark_ville" + }, + "service": "PokeRogue", + "description": { + "en": "A Pokémon fangame heavily inspired by the roguelite genre. Battle endlessly while gathering stacking items, exploring many different biomes, and reaching Pokémon stats you never thought possible." + }, + "url": [ + "pokerogue.net", + "127.0.0.1" + ], + "version": "1.0.6", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PokeRogue/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PokeRogue/assets/thumbnail.png", + "color": "#6b5a73", + "category": "games", + "tags": [ + "poke", + "pokemon", + "rogue", + "run" + ], + "settings": [ + { + "id": "timePer", + "title": "Reset timestamp after each wave", + "icon": "fad fa-stopwatch", + "value": false + }, + { + "id": "gameDetail", + "title": "Game Details row1", + "icon": "fas fa-comment-alt-edit", + "value": "%biome% %wave%", + "placeholder": "Use %wave% %biome% %playtime% %mode%" + }, + { + "id": "gameState", + "title": "Game Details row2", + "icon": "fas fa-comment-alt-edit", + "value": "%mode% %playtime%", + "placeholder": "same like row1 or use {0} to delete the row completely" + } + ] +} diff --git a/websites/P/PokeRogue/presence.ts b/websites/P/PokeRogue/presence.ts index b3afece84c0e..2b25470614b6 100644 --- a/websites/P/PokeRogue/presence.ts +++ b/websites/P/PokeRogue/presence.ts @@ -1,57 +1,59 @@ const presence = new Presence({ - clientId: "1238090575924826114", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1238090575924826114', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/PokeRogue/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/PokeRogue/assets/logo.png', } -type gameInfo = { - gameInfo: { - playTime: 0; - gameMode: ""; - biome: ""; - wave: 0; - }; -}; -let prevWave: number; +interface gameInfo { + gameInfo: { + playTime: 0 + gameMode: '' + biome: '' + wave: 0 + } +} +let prevWave: number function replacePlaceholders(str: string, data: gameInfo) { - return str - .replace("%wave%", `Wave: ${data.gameInfo.wave} |`) - .replace("%biome%", `Biome: ${data.gameInfo.biome} |`) - .replace("%playtime%", `Playtime: ${data.gameInfo.playTime} min |`) - .replace("%mode%", `Mode: ${data.gameInfo.gameMode} |`) - .slice(0, -2); + return str + .replace('%wave%', `Wave: ${data.gameInfo.wave} |`) + .replace('%biome%', `Biome: ${data.gameInfo.biome} |`) + .replace('%playtime%', `Playtime: ${data.gameInfo.playTime} min |`) + .replace('%mode%', `Mode: ${data.gameInfo.gameMode} |`) + .slice(0, -2) } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - [timePer, gameDetails, gameStates] = await Promise.all([ - presence.getSetting("timePer"), - presence.getSetting("gameDetail"), - presence.getSetting("gameState"), - ]), - data: gameInfo = await presence.getPageVariable("gameInfo"); - - if (!data) return; - if (!data.gameInfo.biome || (!gameDetails && !gameStates)) { - presenceData.details = "Browsing..."; - return presence.setActivity(presenceData); - } - - presenceData.details = replacePlaceholders(gameDetails, data); - - if (gameStates !== "{0}") - presenceData.state = replacePlaceholders(gameStates, data); - - if (timePer && !prevWave) prevWave = data.gameInfo.wave; - else if (timePer && prevWave !== data.gameInfo.wave) - delete presenceData.startTimestamp; - - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const [timePer, gameDetails, gameStates] = await Promise.all([ + presence.getSetting('timePer'), + presence.getSetting('gameDetail'), + presence.getSetting('gameState'), + ]) + const data: gameInfo = await presence.getPageVariable('gameInfo') + + if (!data) + return + if (!data.gameInfo.biome || (!gameDetails && !gameStates)) { + presenceData.details = 'Browsing...' + return presence.setActivity(presenceData) + } + + presenceData.details = replacePlaceholders(gameDetails, data) + + if (gameStates !== '{0}') + presenceData.state = replacePlaceholders(gameStates, data) + + if (timePer && !prevWave) + prevWave = data.gameInfo.wave + else if (timePer && prevWave !== data.gameInfo.wave) + delete presenceData.startTimestamp + + presence.setActivity(presenceData) +}) diff --git "a/websites/P/Pok\303\251flix/iframe.ts" "b/websites/P/Pok\303\251flix/iframe.ts" index 828e201ece20..496a38b96396 100644 --- "a/websites/P/Pok\303\251flix/iframe.ts" +++ "b/websites/P/Pok\303\251flix/iframe.ts" @@ -1,14 +1,14 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", async () => { - if (document.querySelector("video")) { - const video = document.querySelector("video"); - if (!isNaN(video?.duration)) { - iframe.send({ - 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({ + duration: video.duration, + currentTime: video.currentTime, + paused: video.paused, + }) + } + } +}) diff --git "a/websites/P/Pok\303\251flix/metadata.json" "b/websites/P/Pok\303\251flix/metadata.json" index d6714e4ecc2f..5d4931ebb256 100644 --- "a/websites/P/Pok\303\251flix/metadata.json" +++ "b/websites/P/Pok\303\251flix/metadata.json" @@ -1,56 +1,56 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "257151906038677504", - "name": "SHISEN" - }, - "service": "Pokéflix", - "description": { - "en": "Watch all of your favourite Pokémon movies, episodes and specials for free online, right here on Pokéflix." - }, - "url": "www.pokeflix.tv", - "version": "1.0.13", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9flix/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9flix/assets/thumbnail.png", - "color": "#222", - "category": "videos", - "tags": [ - "pokeflix", - "movie", - "video", - "media" - ], - "iframe": true, - "iFrameRegExp": ".*", - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "time", - "if": { - "privacy": false - }, - "title": "Show timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "buttons", - "if": { - "privacy": false - }, - "title": "Show buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "257151906038677504", + "name": "SHISEN" + }, + "service": "Pokéflix", + "description": { + "en": "Watch all of your favourite Pokémon movies, episodes and specials for free online, right here on Pokéflix." + }, + "url": "www.pokeflix.tv", + "version": "1.0.13", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9flix/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9flix/assets/thumbnail.png", + "color": "#222", + "category": "videos", + "tags": [ + "pokeflix", + "movie", + "video", + "media" + ], + "iframe": true, + "iFrameRegExp": ".*", + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "privacy", + "title": "Privacy", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "time", + "if": { + "privacy": false + }, + "title": "Show timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "buttons", + "if": { + "privacy": false + }, + "title": "Show buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git "a/websites/P/Pok\303\251flix/presence.ts" "b/websites/P/Pok\303\251flix/presence.ts" index 47fedf31410a..b1675a479b0b 100644 --- "a/websites/P/Pok\303\251flix/presence.ts" +++ "b/websites/P/Pok\303\251flix/presence.ts" @@ -1,117 +1,121 @@ const presence = new Presence({ - clientId: "1055612773419196476", -}); + clientId: '1055612773419196476', +}) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9flix/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9flix/assets/logo.png', } async function getStrings() { - return presence.getStrings( - { - viewHome: "general.viewHome", - viewing: "general.viewing", - search: "general.search", - searchFor: "general.searchFor", - play: "general.watchingVid", - pause: "general.paused", - searchSomething: "general.searchSomething", - watchVideoButton: "general.buttonWatchVideo", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + viewHome: 'general.viewHome', + viewing: 'general.viewing', + search: 'general.search', + searchFor: 'general.searchFor', + play: 'general.watchingVid', + pause: 'general.paused', + searchSomething: 'general.searchSomething', + watchVideoButton: 'general.buttonWatchVideo', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } let video = { - duration: 0, - currentTime: 0, - paused: true, - }, - strings: Awaited>; + duration: 0, + currentTime: 0, + paused: true, +} +let strings: Awaited> function textContent(tags: string) { - return document.querySelector(tags)?.textContent?.trim(); + return document.querySelector(tags)?.textContent?.trim() } function capitalizeFirstLetter(string: string) { - return string.trim().charAt(0).toUpperCase() + string.trim().slice(1); + return string.trim().charAt(0).toUpperCase() + string.trim().slice(1) } presence.on( - "iFrameData", - (data: { duration: number; currentTime: number; paused: boolean }) => { - video = data; - } -); + 'iFrameData', + (data: unknown) => { + video = data as typeof video + }, +) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - details: "Somewhere on the site", - largeImageKey: Assets.Logo, - }, - [privacy, time, buttons] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("time"), - presence.getSetting("buttons"), - ]), - { pathname, href } = document.location, - path = pathname.split("/")[1]; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + details: 'Somewhere on the site', + largeImageKey: Assets.Logo, + } + const [privacy, time, buttons] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('time'), + presence.getSetting('buttons'), + ]) + const { pathname, href } = document.location + const path = pathname.split('/')[1] - if (!strings) strings = await getStrings(); + if (!strings) + strings = await getStrings() - switch (path) { - case "": - presenceData.details = strings.viewHome; - break; + switch (path) { + case '': + presenceData.details = strings.viewHome + break - case "browse": - case "upcoming": - case "movies": - case "specials": - presenceData.details = !privacy - ? strings.searchFor - : strings.searchSomething; - presenceData.state = - path === "movies" || path === "specials" - ? capitalizeFirstLetter(path) - : textContent(".container h2"); - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = strings.search; - break; + case 'browse': + case 'upcoming': + case 'movies': + case 'specials': + presenceData.details = !privacy + ? strings.searchFor + : strings.searchSomething + presenceData.state = path === 'movies' || path === 'specials' + ? capitalizeFirstLetter(path) + : textContent('.container h2') + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = strings.search + break - case "v": - case "video": - presenceData.details = !privacy - ? `${strings.viewing} ${document - .querySelector(".fluid-container h2") - .firstChild?.textContent?.trim()}` - : strings.play; - presenceData.state = textContent(".fluid-container h2 p"); + case 'v': + case 'video': + presenceData.details = !privacy + ? `${strings.viewing} ${document + .querySelector('.fluid-container h2') + ?.firstChild + ?.textContent + ?.trim()}` + : strings.play + presenceData.state = textContent('.fluid-container h2 p') - if (!privacy && video.currentTime > 0) { - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? strings.pause - : strings.play; - presenceData.buttons = [ - { - label: strings.watchVideoButton, - url: href, - }, - ]; + if (!privacy && video.currentTime > 0) { + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? strings.pause + : strings.play + presenceData.buttons = [ + { + label: strings.watchVideoButton, + url: href, + }, + ] - if (video.paused || !time) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } else { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(video.currentTime, video.duration); - } - } - break; - } + if (video.paused || !time) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + else { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(video.currentTime, video.duration) + } + } + break + } - if (privacy) delete presenceData.state; - if (privacy || !buttons) delete presenceData.buttons; - presence.setActivity(presenceData); -}); + if (privacy) + delete presenceData.state + if (privacy || !buttons) + delete presenceData.buttons + presence.setActivity(presenceData) +}) diff --git "a/websites/P/Pok\303\251mon Showdown/metadata.json" "b/websites/P/Pok\303\251mon Showdown/metadata.json" index 90ae44558853..88c384101125 100644 --- "a/websites/P/Pok\303\251mon Showdown/metadata.json" +++ "b/websites/P/Pok\303\251mon Showdown/metadata.json" @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Striker", - "id": "215509157837537280" - }, - "service": "Pokémon Showdown", - "altnames": [ - "Pokemon Showdown" - ], - "description": { - "en": "Pokémon Showdown is a Pokémon battle simulator. Play Pokémon battles online! Play with randomly generated teams, or build your own! Fully animated!", - "nl": "Pokémon Showdown is een Pokémon-vechtsimulator. Speel Pokémon-gevechten online! Speel met willekeurig gegenereerde teams, of bouw je eigen team! Volledig geanimeerd!" - }, - "url": [ - "pokemonshowdown.com", - "play.pokemonshowdown.com" - ], - "version": "1.1.28", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon%20Showdown/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon%20Showdown/assets/thumbnail.png", - "color": "#FFF942", - "category": "games", - "tags": [ - "pokémon-showdown", - "pokémon", - "games" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Striker", + "id": "215509157837537280" + }, + "service": "Pokémon Showdown", + "altnames": [ + "Pokemon Showdown" + ], + "description": { + "en": "Pokémon Showdown is a Pokémon battle simulator. Play Pokémon battles online! Play with randomly generated teams, or build your own! Fully animated!", + "nl": "Pokémon Showdown is een Pokémon-vechtsimulator. Speel Pokémon-gevechten online! Speel met willekeurig gegenereerde teams, of bouw je eigen team! Volledig geanimeerd!" + }, + "url": [ + "pokemonshowdown.com", + "play.pokemonshowdown.com" + ], + "version": "1.1.28", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon%20Showdown/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon%20Showdown/assets/thumbnail.png", + "color": "#FFF942", + "category": "games", + "tags": [ + "pokémon-showdown", + "pokémon", + "games" + ] +} diff --git "a/websites/P/Pok\303\251mon Showdown/presence.ts" "b/websites/P/Pok\303\251mon Showdown/presence.ts" index b449e46701c0..12c0fde1878a 100644 --- "a/websites/P/Pok\303\251mon Showdown/presence.ts" +++ "b/websites/P/Pok\303\251mon Showdown/presence.ts" @@ -1,42 +1,45 @@ const presence = new Presence({ - clientId: "808762003476709406", -}); + clientId: '808762003476709406', +}) -let elapsed = Math.floor(Date.now() / 1000); +let elapsed: number | null = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon%20Showdown/assets/logo.png", - }, - path = document.location.pathname; - if (path === "/") { - presenceData.details = "Viewing Homepage"; - elapsed = null; - } else if (path.startsWith("/teambuilder")) { - presenceData.details = "Building a Team"; - elapsed = null; - } else if (path.startsWith("/ladder")) { - presenceData.details = "Viewing a Ladder"; - elapsed = null; - } else if (path.includes("battle")) { - presenceData.details = - document.querySelector("a.roomtab i.text").textContent; - presenceData.state = document.querySelector( - "a.roomtab.button.cur span" - ).textContent; - presenceData.buttons = [ - { - label: "Spectate", - url: document.baseURI, - }, - ]; - if (elapsed === null) elapsed = Math.floor(Date.now() / 1000); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon%20Showdown/assets/logo.png', + } + const path = document.location.pathname + if (path === '/') { + presenceData.details = 'Viewing Homepage' + elapsed = null + } + else if (path.startsWith('/teambuilder')) { + presenceData.details = 'Building a Team' + elapsed = null + } + else if (path.startsWith('/ladder')) { + presenceData.details = 'Viewing a Ladder' + elapsed = null + } + else if (path.includes('battle')) { + presenceData.details = document.querySelector('a.roomtab i.text')?.textContent + presenceData.state = document.querySelector( + 'a.roomtab.button.cur span', + )?.textContent + presenceData.buttons = [ + { + label: 'Spectate', + url: document.baseURI, + }, + ] + if (elapsed === null) + elapsed = Math.floor(Date.now() / 1000) - presenceData.startTimestamp = elapsed; - } else { - presenceData.details = "Somewhere on-site"; - elapsed = null; - } - presence.setActivity(presenceData); -}); + presenceData.startTimestamp = elapsed + } + else { + presenceData.details = 'Somewhere on-site' + elapsed = null + } + presence.setActivity(presenceData) +}) diff --git "a/websites/P/Pok\303\251mon/metadata.json" "b/websites/P/Pok\303\251mon/metadata.json" index ac0bb6171c5c..b5a8683cfbff 100644 --- "a/websites/P/Pok\303\251mon/metadata.json" +++ "b/websites/P/Pok\303\251mon/metadata.json" @@ -1,40 +1,40 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "Pokémon", - "altnames": [ - "Pokemon", - "포켓몬스터", - "宝可梦", - "精靈寶可夢", - "ポケモン", - "ポケットモンスター" - ], - "description": { - "en": "Pokémon are creatures of all shapes and sizes who live in the wild or alongside humans. For the most part, Pokémon do not speak except to utter their names. There are currently more than 700 creatures that inhabit the Pokémon universe.", - "nl": "Pokémon zijn wezens in alle soorten en maten die in het wild of naast mensen leven. Voor het grootste deel spreken Pokémon niet, behalve om hun namen uit te spreken. Er zijn momenteel meer dan 700 wezens die het Pokémon-universum bewonen." - }, - "url": "www.pokemon.com", - "regExp": "([a-z0-9-]+[.])*(pokemon|portal-pokemon|pokemontcg|pokemoncenter|pokemoncenter-online|pokemon-cafe|pokemonkorea|pokemoncard|pokemonstore|pokemon-movie|pokemon-card)([.][a-z]+)+[/]", - "version": "1.1.30", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/thumbnail.jpg", - "color": "#ffcb05", - "category": "games", - "tags": [ - "pokémon", - "pokémontv" - ], - "settings": [ - { - "id": "pdexID", - "title": "Pokédex - Show Pokémon ID", - "icon": "fas fa-info", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "Pokémon", + "altnames": [ + "Pokemon", + "포켓몬스터", + "宝可梦", + "精靈寶可夢", + "ポケモン", + "ポケットモンスター" + ], + "description": { + "en": "Pokémon are creatures of all shapes and sizes who live in the wild or alongside humans. For the most part, Pokémon do not speak except to utter their names. There are currently more than 700 creatures that inhabit the Pokémon universe.", + "nl": "Pokémon zijn wezens in alle soorten en maten die in het wild of naast mensen leven. Voor het grootste deel spreken Pokémon niet, behalve om hun namen uit te spreken. Er zijn momenteel meer dan 700 wezens die het Pokémon-universum bewonen." + }, + "url": "www.pokemon.com", + "regExp": "([a-z0-9-]+[.])*(pokemon|portal-pokemon|pokemontcg|pokemoncenter|pokemoncenter-online|pokemon-cafe|pokemonkorea|pokemoncard|pokemonstore|pokemon-movie|pokemon-card)([.][a-z]+)+[/]", + "version": "1.1.30", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/thumbnail.jpg", + "color": "#ffcb05", + "category": "games", + "tags": [ + "pokémon", + "pokémontv" + ], + "settings": [ + { + "id": "pdexID", + "title": "Pokédex - Show Pokémon ID", + "icon": "fas fa-info", + "value": true + } + ] +} diff --git "a/websites/P/Pok\303\251mon/presence.ts" "b/websites/P/Pok\303\251mon/presence.ts" index e45fa8e11621..4c27334b224e 100644 --- "a/websites/P/Pok\303\251mon/presence.ts" +++ "b/websites/P/Pok\303\251mon/presence.ts" @@ -1,884 +1,1064 @@ const presence = new Presence({ - clientId: "684885381728043048", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }); + clientId: '684885381728043048', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) function settingSetter(): void { - if (document.location.pathname.includes("/pokedex")) - presence.showSetting("pdexID"); - else presence.hideSetting("pdexID"); + if (document.location.pathname.includes('/pokedex')) + presence.showSetting('pdexID') + else presence.hideSetting('pdexID') } -const browsingTimestamp = Math.floor(Date.now() / 1000); +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Pokemontv = "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/0.png", - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/logo.png", - Pokemonplay = "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/1.png", - Pokeball = "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/2.png", - Tcg = "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/3.png", - Store = "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/4.png", - Storejp = "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/5.png", - Cafe = "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/6.png", - Sweets = "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/7.png", - Storekr = "https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/8.png", + Pokemontv = 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/0.png', + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/logo.png', + Pokemonplay = 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/1.png', + Pokeball = 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/2.png', + Tcg = 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/3.png', + Store = 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/4.png', + Storejp = 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/5.png', + Cafe = 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/6.png', + Sweets = 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/7.png', + Storekr = 'https://cdn.rcd.gg/PreMiD/websites/P/Pok%C3%A9mon/assets/8.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }; - - settingSetter(); - - switch (document.location.host) { - case "www.pokemon.com": { - if ( - document.location.pathname.includes("/pokemon-news/") || - document.location.pathname.includes("/actus-pokemon/") || - document.location.pathname.includes("/novita-pokemon/") || - document.location.pathname.includes("/pokemon-nieuws/") || - document.location.pathname.includes("/pokemon-nyheter/") || - document.location.pathname.includes("/noticias-pokemon/") - ) { - const title = document.querySelector(".full-article > h1"); - if (title) { - presenceData.details = "Reading article:"; - presenceData.state = title.textContent; - presenceData.smallImageKey = Assets.Reading; - } else { - presenceData.details = "Pokémon News"; - presenceData.state = "Browsing..."; - } - } else if (document.location.pathname.includes("/play-pokemon/")) { - presenceData.largeImageKey = Assets.Pokemonplay; - const title = document.querySelector(".full-article > h1"); - if (title) { - presenceData.details = "Reading article:"; - presenceData.state = title.textContent; - presenceData.smallImageKey = Assets.Reading; - } else { - presenceData.details = "Play! Pokémon"; - presenceData.state = "Browsing..."; - } - } else if (document.location.pathname.includes("/pokedex/")) { - presenceData.smallImageKey = Assets.Pokeball; - presenceData.smallImageText = "Pokédex"; - const search = document.querySelector("#searchInput"); - - if ( - document.querySelector(".pokedex-pokemon-pagination-title > div") !== - null - ) { - const pdexID = await presence.getSetting("pdexID"); - let name = document.querySelector( - ".pokedex-pokemon-pagination-title > div" - ).textContent, - number = document.querySelector( - ".pokedex-pokemon-pagination-title > div > span" - ).textContent; - name = name.replace(number, "").trim(); - number = number.replace(/\D+/g, ""); - - presenceData.details = "Viewing Pokémon:"; - if (pdexID) presenceData.state = `${name} (#${number})`; - else presenceData.state = name; - } else if (search && search.value !== "") { - if (search.value.length > 2) { - presenceData.details = "Pokédex - Searching for:"; - presenceData.state = search.value; - } else { - presenceData.details = "Pokédex"; - presenceData.state = "Searching something up..."; - } - presenceData.largeImageKey = Assets.Pokeball; - presenceData.smallImageKey = Assets.Search; - } else { - presenceData.details = "Pokédex"; - presenceData.state = "Browsing..."; - } - } else if (document.location.pathname.includes("/app")) { - const title = document.querySelector(".full-article > h1"); - if (title) { - presenceData.details = "Viewing app:"; - presenceData.state = title.textContent; - presenceData.smallImageKey = Assets.Reading; - } else presenceData.details = "Viewing Pokémon Apps"; - } else if ( - document.location.pathname.includes("/pokemon-video-games") || - document.location.pathname.includes("/pokemon-videospiele") || - document.location.pathname.includes("/jeux-video-pokemon") || - document.location.pathname.includes("/videogiochi") || - document.location.pathname.includes("/videojuegos-pokemon") - ) { - const title = document.querySelector(".full-article > h1"); - presenceData.smallImageKey = Assets.Reading; - if (title) { - presenceData.details = "Reading about game:"; - presenceData.state = title.textContent; - } else if ( - document.location.pathname.includes("/all-pokemon-games") || - document.location.pathname.includes("/alle-pokemon-spiele") || - document.location.pathname.includes("/todos-los-juegos-pokemon") - ) { - presenceData.details = "Viewing all"; - presenceData.state = "Pokémon games"; - } else { - presenceData.details = "Browsing through"; - presenceData.state = "Pokémon's games"; - } - } else if ( - document.querySelector( - "body > nav > div.content-wrapper > ul > li.home > a" - ) && - document.querySelector( - "body > nav > div.content-wrapper > ul > li.home > a" - ).href === document.URL - ) - presenceData.details = "Viewing the homepage..."; - else if ( - document.location.pathname.includes("/pokemon-tcg") || - document.location.pathname.includes("/pokemon-sammelkartenspiel") || - document.location.pathname.includes("/jcc-pokemon") || - document.location.pathname.includes("/pokemon-estampas-ilustradas") || - document.location.pathname.includes("/gcc") - ) { - presenceData.largeImageKey = Assets.Tcg; - presenceData.smallImageKey = Assets.Reading; - - if ( - document.location.pathname.includes("/pokemon-cards") || - document.location.pathname.includes("/pokemon-karten") || - document.location.pathname.includes("/cartas-pokemon") || - document.location.pathname.includes("/cartes-pokemon") || - document.location.pathname.includes("/archivio-carte") - ) { - presenceData.details = "Viewing card:"; - presenceData.state = document.querySelector( - ".card-description > div > h1" - ).textContent; - } else if ( - document.location.pathname.includes("/product-gallery") || - document.location.pathname.includes("/Produktgalerie") - ) { - const title = document.querySelector(".full-article > h1"); - if (title) { - presenceData.details = "Viewing product:"; - presenceData.state = title.textContent; - } else { - presenceData.details = "Viewing Pokémon Card Game"; - presenceData.state = "product galery"; - } - } else if (document.location.pathname.includes("/leaderboards")) { - presenceData.details = "Viewing Trading Card Game"; - presenceData.state = "Online leadersboards"; - } else { - presenceData.details = "Reading about Pokémon's"; - presenceData.state = "Trading Card Game"; - } - } else if ( - document.location.pathname.includes("/pokemon-episodes") || - document.location.pathname.includes("/pokemon-folgen") || - document.location.pathname.includes("/episodios-pokemon") || - document.location.pathname.includes("/pokemon-afsnit") || - document.location.pathname.includes("/pokemon-jaksot") || - document.location.pathname.includes("/episodes-pokemon") || - document.location.pathname.includes("/episodi-tv") || - document.location.pathname.includes("/pokemon-afleveringen") || - document.location.pathname.includes("/pokemon-episoder") || - document.location.pathname.includes("/pokemon-avsnitt") - ) { - presenceData.largeImageKey = Assets.Pokemontv; - presenceData.details = "Viewing PokémonTV"; - } else if ( - document.location.pathname.includes("/country-region") || - document.location.pathname.includes("/land-region") || - document.location.pathname.includes("/pais-region") || - document.location.pathname.includes("/pais-regiao") || - document.location.pathname.includes("/maa-alue") || - document.location.pathname.includes("/pays-region") || - document.location.pathname.includes("/seleziona-paese-regione") || - document.location.pathname.includes("/land-regio") - ) - presenceData.details = "Changing region"; - - break; - } - case "tcg.pokemon.com": { - presenceData.largeImageKey = Assets.Tcg; - if (document.location.pathname.includes("/how-to-play/")) - presenceData.details = "Learning how to play"; - else if (document.location.pathname.includes("/expansions/")) { - presenceData.details = "Viewing expansion:"; - presenceData.state = document.title.split("|")[1].trim(); - } else if (document.location.pathname.includes("/galleries/")) { - presenceData.details = "Viewing cards of expansion:"; - presenceData.state = document.title.split("|")[1].trim(); - } else if (document.location.pathname.includes("/parents-guide/")) - presenceData.details = "Viewing parents guide"; - else if (document.location.pathname.includes("/where-to-buy/")) - presenceData.details = "Viewing where to buy"; - - break; - } - case "forums.pokemontcg.com": { - presenceData.largeImageKey = Assets.Tcg; - if (document.location.pathname.includes("/topic")) { - presenceData.details = "Reading thread:"; - presenceData.state = document - .querySelector(".ipsType_pageTitle") - .textContent.trim(); - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/forum")) { - presenceData.details = "Viewing category:"; - presenceData.state = document - .querySelector(".ipsType_pageTitle") - .textContent.trim(); - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/leaderboard")) - presenceData.details = "Viewing the leaderboards"; - else if (document.location.pathname.includes("/pastleaders")) - presenceData.details = "Viewing the pastleaders"; - else if (document.location.pathname.includes("/topmembers")) - presenceData.details = "Viewing the topmembers"; - else if (document.location.pathname.includes("/discover")) - presenceData.details = "Viewing the recent activity"; - else if (document.location.pathname.includes("/search")) { - presenceData.details = "Searching for:"; - - presenceData.state = - document.querySelector("#elMainSearchInput").value; - presenceData.smallImageKey = Assets.Search; - } else presenceData.details = "Browsing the forums"; - - break; - } - case "www.pokemoncenter.com": { - presenceData.largeImageKey = Assets.Store; - if (document.querySelector(".main_header")) { - presenceData.details = "Viewing product:"; - presenceData.state = document.querySelector(".main_header").textContent; - } else if (document.querySelector(".row > div > div > h1")) { - presenceData.details = "Viewing category:"; - presenceData.state = document - .querySelector(".row > div > div > h1") - .textContent.trim(); - } else if ( - document.location.pathname.includes("/AjaxOrderItemDisplayView") - ) - presenceData.details = "Viewing their cart"; - else presenceData.details = "Browsing through the store"; - - break; - } - case "www.pokemoncenter-online.com": { - presenceData.largeImageKey = Assets.Storejp; - if (document.location.pathname.includes("/cafe")) { - presenceData.largeImageKey = Assets.Cafe; - if (document.location.pathname.includes("/pikachu_sweets")) { - presenceData.largeImageKey = Assets.Sweets; - presenceData.details = "Viewing the"; - presenceData.state = "Pikachu Sweets Cafe"; - } else if (document.location.pathname.includes("/menu")) - presenceData.details = "Viewing the menu"; - else if (document.location.pathname.includes("/goods")) - presenceData.details = "Viewing the goods"; - else if (document.location.pathname.includes("/news")) { - if ( - document.querySelector( - "#mainContent > section > div > div > div.boxStyle03 > div > h3" - ) - ) { - presenceData.details = "Reading article:"; - presenceData.state = document.querySelector( - "#mainContent > section > div > div > div.boxStyle03 > div > h3" - ).textContent; - presenceData.smallImageKey = Assets.Reading; - } else presenceData.details = "Viewing the articles"; - } else if (document.URL.includes("access")) - presenceData.details = "Viewing the access points"; - else if (document.location.pathname.includes("/faq")) - presenceData.details = "Viewing the FAQs"; - else if (document.location.pathname.includes("/reservation")) - presenceData.details = "Making a reservation"; - } else if ( - document.querySelector( - "#contents > section > div.item_detail > article > h1" - ) - ) { - presenceData.details = "Viewing product:"; - presenceData.state = document.querySelector( - "#contents > section > div.item_detail > article > h1" - ).textContent; - } else if ( - document.querySelector( - "#contents > div.topic_path > ul > li:nth-child(2) > span" - ) - ) { - presenceData.details = "Viewing category:"; - presenceData.state = document.querySelector( - "#contents > div.topic_path > ul > li:nth-child(2) > span" - ).textContent; - } else if (document.URL.includes("shopping_cart")) - presenceData.details = "Viewing their cart"; - else presenceData.details = "Browsing through the store"; - - break; - } - default: - if ( - document.location.host.match( - "([a-z0-9]+)[.]pokemon-cafe[.]([a-z0-9]+)([.]([a-z0-9]+))?" - ) - ) { - presenceData.largeImageKey = Assets.Cafe; - presenceData.details = "Making a reservation"; - } else { - switch (document.location.host) { - case "watch.pokemon.com": { - presenceData.largeImageKey = Assets.Pokemontv; - if (document.location.pathname.includes("/player")) { - const video = document.querySelector("video"); - - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Play; - presenceData.smallImageText = video.paused - ? (await strings).pause - : (await strings).play; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - - const title = document - .querySelector(".header-bar-small > span:nth-child(4)") - .textContent.split(" - ")[1] - .trim(); - presenceData.details = `${document - .querySelector(".header-bar-small > span:nth-child(2)") - .textContent.trim()} - ${document - .querySelector(".header-bar-small > span:nth-child(4)") - .textContent.split(" - ")[0] - .trim()}`; - presenceData.state = title; - - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else if (document.location.pathname.includes("/season")) { - presenceData.details = "Viewing season:"; - presenceData.state = - document.querySelector("#lbl_season_title").textContent; - } else presenceData.details = "Browsing PokémonTV"; - - break; - } - case "pokemonkorea.co.kr": { - if (document.location.pathname.includes("/news/")) { - presenceData.smallImageKey = Assets.Reading; - presenceData.details = "Reading article:"; - - const title = document.querySelector(".section-title"), - tag = document.querySelector(".section-title > span"), - publish = document.querySelector(".section-title > small"); - if (tag) { - presenceData.state = title.textContent - .replace(tag.textContent, "") - .replace(publish.textContent, ""); - } else { - presenceData.state = title.textContent.replace( - publish.textContent, - "" - ); - } - } else if (document.location.pathname.includes("/news")) { - presenceData.details = "Viewing the recent"; - presenceData.state = "News and Announcements"; - } else if (document.location.pathname.includes("/game/")) { - const title = document.querySelector(".medium-title"); - if (title) { - presenceData.details = "Viewing game:"; - presenceData.state = title.textContent; - } else if (document.location.pathname.includes("/category/")) { - presenceData.details = "Viewing category:"; - presenceData.state = - document.querySelector(".section-title").textContent; - } - } else if (document.location.pathname.includes("/game")) - presenceData.details = "Viewing Pokémon's games"; - else if (document.location.pathname.includes("/pokedex")) { - presenceData.smallImageKey = Assets.Pokeball; - presenceData.smallImageText = "Pokédex"; - const search = - document.querySelector("#word.form-control"); - if ( - document.querySelector( - "body > div.single_header_wrap > div > h1" - ) !== null - ) { - const pdexID = await presence.getSetting("pdexID"); - let name = document - .querySelector("body > div.single_header_wrap > div > h1") - .textContent.trim(), - number = document.querySelector( - "body > div.single_header_wrap > div > h1 > span" - ).textContent; - name = name.replace(number, ""); - number = number.replace("No. ", ""); - - presenceData.details = "Viewing Pokémon:"; - if (pdexID) presenceData.state = `${name} (#${number})`; - else presenceData.state = name; - } else if (search && search.value !== "") { - if (search.value.length > 2) { - presenceData.details = "Pokédex - Searching for:"; - presenceData.state = search.textContent; - } else { - presenceData.details = "Pokédex"; - presenceData.state = "Searching something up..."; - } - presenceData.largeImageKey = Assets.Pokeball; - presenceData.smallImageKey = Assets.Search; - } else { - presenceData.details = "Pokédex"; - presenceData.state = "Browsing..."; - } - } else if (document.location.pathname.includes("/animation")) { - const title = document.querySelector(".medium-title"); - if (title) { - presenceData.details = "Reading about animation:"; - presenceData.state = title.textContent; - presenceData.smallImageKey = Assets.Reading; - } else presenceData.details = "Viewing Pokémon's animations"; - } else if (document.location.pathname.includes("/product")) { - presenceData.largeImageKey = Assets.Storekr; - const title = document.querySelector(".medium-title"); - if (title) { - presenceData.details = "Viewing product:"; - presenceData.state = title.textContent; - } else { - presenceData.details = "Browsing through"; - presenceData.state = "Pokémon's products"; - } - } - - break; - } - case "pokemoncard.co.kr": { - presenceData.largeImageKey = Assets.Tcg; - if (document.location.pathname.includes("/main")) - presenceData.details = "Browsing..."; - else if (document.location.pathname.includes("/news/")) { - presenceData.smallImageKey = Assets.Reading; - presenceData.details = "Reading article:"; - - const title = document.querySelector(".section-title"), - tag = document.querySelector(".section-title > span"), - publish = document.querySelector(".section-title > small"); - if (tag) { - presenceData.state = title.textContent - .replace(tag.textContent, "") - .replace(publish.textContent, ""); - } else { - presenceData.state = title.textContent.replace( - publish.textContent, - "" - ); - } - } else if (document.location.pathname.includes("/news")) { - presenceData.details = "Viewing the recent"; - presenceData.state = "News and Announcements"; - } else if (document.location.pathname.includes("/card")) { - if (document.location.pathname.includes("/category")) { - if (document.location.pathname.includes("/event")) - presenceData.details = "Viewing upcoming events"; - else { - presenceData.details = "Viewing category:"; - presenceData.state = document - .querySelector("#partners > div > div > ul > li.active") - .textContent.trim(); - } - } else if (document.location.pathname.includes("/play")) - presenceData.details = "Learning how to play"; - else if ( - document - .querySelector( - "#header-top-menu > li.active > a" - ) - .href.includes("/event") - ) { - presenceData.details = "Viewing event:"; - presenceData.state = - document.querySelector(".medium-title").textContent; - } else if (document.location.pathname.includes("/cards")) { - const input = - document.querySelector("#search_text"); - if (document.location.pathname.includes("/detail")) { - presenceData.details = "Viewing card:"; - presenceData.state = - document.querySelector(".card-hp.title").textContent; - } else if (input.value !== "") { - if (input.value.length > 2) { - presenceData.details = "Searching for:"; - presenceData.state = input.value; - } else presenceData.details = "Searching up something..."; - - presenceData.smallImageKey = Assets.Search; - } else presenceData.details = "Browsing through the cards"; - } else if (document.querySelector(".medium-title")) { - presenceData.details = "Viewing card:"; - presenceData.state = - document.querySelector(".medium-title").textContent; - } else presenceData.details = "Browsing through the cards"; - } else if (document.location.pathname.includes("/players")) - presenceData.details = "Viewing players"; - - break; - } - case "www.pokemonstore.co.kr": { - presenceData.largeImageKey = Assets.Storekr; - if (document.location.pathname.includes("/goods_view")) { - presenceData.details = "Viewing product:"; - presenceData.state = document - .querySelector(".goods-header > div.top > div") - .textContent.trim(); - } else if (document.location.pathname.includes("/goods_list")) { - presenceData.details = "Viewing category:"; - presenceData.state = document.querySelector( - "#content > div > div > div.cg-main > h2" - ).textContent; - } else if (document.location.pathname.includes("/main")) - presenceData.details = "Browsing..."; - else if (document.location.pathname.includes("/board/list")) - presenceData.details = "Viewing product reviews"; - else if (document.location.pathname.includes("/board/view")) { - presenceData.details = "Viewing review of product:"; - presenceData.state = - document.querySelector(".itemorder-name").textContent; - } else if ( - document.location.pathname.includes("/mypage/order_list") - ) - presenceData.details = "Viewing their orders"; - else if (document.location.pathname.includes("/mypage/wish_list")) - presenceData.details = "Viewing their wish list"; - else if (document.location.pathname.includes("/mypage/index")) - presenceData.details = "Viewing their page"; - else if (document.location.pathname.includes("/order/cart")) - presenceData.details = "Viewing their cart"; - - break; - } - case "www.pokemon.co.jp": { - if (document.location.pathname.includes("/app")) - presenceData.details = "Viewing Pokémon Apps"; - else if (document.location.pathname.includes("/game")) - presenceData.details = "Viewing Pokémon Games"; - else if (document.location.pathname.includes("/ex/")) { - presenceData.details = "Viewing game:"; - presenceData.state = document.title; - } else if (document.location.pathname.includes("/card")) - presenceData.details = "Viewing Pokémon Cards"; - else if (document.location.pathname.includes("/event")) - presenceData.details = "Viewing Pokémon Events"; - else if (document.location.pathname.includes("/anime")) { - presenceData.largeImageKey = Assets.Pokemontv; - const title = - document.querySelector(".m-ttl-top") || - document.querySelector(".m-ttl-dot"); - if (title) { - presenceData.details = "Viewing show:"; - presenceData.state = title.textContent; - } else presenceData.details = "Viewing Pokémon TV/Movies"; - } else if (document.location.pathname.includes("/gp")) { - const title = document.querySelector(".m-ttl-top"); - if (title && title.textContent.includes("ポケモンセンタ")) { - presenceData.details = "Viewing Pokémon Center:"; - presenceData.state = title.textContent - .replace("ポケモンセンター", "") - .trim(); - } else if ( - title && - title.textContent.includes("ポケモンストア") - ) { - presenceData.details = "Viewing Pokémon Store:"; - presenceData.state = title.textContent - .replace("ポケモンストア", "") - .trim(); - } else presenceData.details = "Viewing Pokémon Centers"; - } else if (document.location.pathname.includes("/sp")) { - const title = document.querySelector(".m-ttl-top"); - if (title) { - presenceData.details = "Viewing Upcoming Pokémon Center:"; - presenceData.state = title.textContent - .split("、")[0] - .replace("ポケモンセンター", "") - .trim(); - } else presenceData.details = "Viewing Upcoming Pokémon Centers"; - } else if (document.location.pathname.includes("/goods")) { - presenceData.smallImageKey = Assets.Storejp; - const title = document.querySelector(".m-ttl-hd"); - if (title) { - presenceData.details = "Viewing Pokémon Goods"; - presenceData.state = `in category: ${title.textContent}`; - } else presenceData.details = "Viewing Pokémon Goods"; - } - - break; - } - case "www.pokemon-movie.jp": { - presenceData.largeImageKey = Assets.Pokemontv; - if (document.location.pathname.includes("/news/")) { - if (document.URL.includes("?p=")) { - presenceData.smallImageKey = Assets.Reading; - presenceData.details = "Reading article:"; - presenceData.state = document.querySelector( - "#pagemain_newbig > div > div.entry_header > h2 > a" - ).textContent; - } else presenceData.details = "Viewing the recent articles"; - } else if (document.location.pathname === "/") { - presenceData.details = "Pokémon Movie"; - presenceData.state = "Browsing..."; - } else if (document.location.pathname.includes("/chara/")) { - presenceData.details = "Pokémon Movie"; - presenceData.state = "Viewing the characters"; - } else if (document.location.pathname.includes("/story/")) { - presenceData.smallImageKey = Assets.Reading; - presenceData.details = "Pokémon Movies"; - presenceData.state = "Reading the story"; - } else if (document.location.pathname.includes("/tickets/")) { - presenceData.details = "Pokémon Movies"; - presenceData.state = "Getting tickets"; - } else if (document.location.pathname.includes("/playground/")) { - presenceData.details = "Pokémon Movies"; - presenceData.state = "Viewing the playground"; - } else if (document.location.pathname.includes("/history/")) { - if (document.querySelector("#main > h1 > img")) { - presenceData.details = "Viewing history of:"; - presenceData.state = - document.querySelector( - "#main > h1 > img" - ).alt; - } else { - presenceData.details = "Pokémon Movies"; - presenceData.state = "Viewing the history"; - } - } else if (document.location.pathname.includes("/melmaga/form")) { - presenceData.details = "Pokémon Movies"; - presenceData.state = "Signing up for the magazine"; - } - - break; - } - case "www.pokemon-card.com": { - presenceData.largeImageKey = Assets.Tcg; - if (document.location.pathname.includes("/about")) - presenceData.details = "Viewing the tutorial"; - else if (document.location.pathname.includes("/rules")) { - if (document.location.pathname.includes("/regulation")) - presenceData.details = "Viewing the regulation"; - else presenceData.details = "Viewing the Q&A"; - } else if (document.location.pathname.includes("/products")) { - if (document.location.pathname.includes("/products/s")) { - presenceData.details = "Viewing product:"; - presenceData.state = document.querySelector( - ".MainArea > div > nav > ul > li.current" - ).textContent; - } else presenceData.details = "Viewing products"; - } else if (document.location.pathname.includes("/ex")) { - presenceData.details = "Viewing extension pack:"; - [, presenceData.state] = document.title - .split("」 | ")[0] - .split("「"); - } else if (document.location.pathname.includes("/event")) { - if ( - document.querySelector( - ".detailCalenderEventArea > section:nth-child(1) > ul > li:nth-child(1) > div > div.List_body" - ) - ) { - let title = document.querySelector( - ".detailCalenderEventArea > section:nth-child(1) > ul > li:nth-child(1) > div > div.List_body" - ).textContent; - const tags = document.querySelector( - ".detailCalenderEventArea > section:nth-child(1) > ul > li:nth-child(1) > div > div.List_body > ul" - ), - warning = document.querySelector( - ".detailCalenderEventArea > section:nth-child(1) > ul > li:nth-child(1) > div > div.List_body > div" - ); - - if (tags) title = title.replace(tags.textContent, ""); - - if (warning) title = title.replace(warning.textContent, ""); - - presenceData.details = "Viewing event:"; - presenceData.state = title; - } else { - presenceData.details = "Browsing through the"; - presenceData.state = "upcoming events"; - } - } else if (document.location.pathname.includes("/card-search/")) { - if (document.location.pathname.includes("/card/")) { - presenceData.details = "Viewing card:"; - presenceData.state = document.querySelector( - "body > div > div.PopupMain > section.Section > h1" - ).textContent; - } else { - presenceData.details = "Searching through"; - presenceData.state = "the cards..."; - presenceData.smallImageKey = Assets.Search; - } - } else if (document.location.pathname.includes("/info/")) { - presenceData.details = "Reading article:"; - presenceData.state = document.querySelector( - "body > div.WrapperArea > div.MainArea > div > section > h1" - ).textContent; - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/deck/")) - presenceData.details = "Browsing decks..."; - - break; - } - case "map.pokemon-card.com": { - presenceData.largeImageKey = Assets.Tcg; - presenceData.details = "Viewing the map"; - - break; - } - case "www.portal-pokemon.com": { - presenceData.details = "Changing region"; - break; - } - default: - if ( - document.location.host.match( - "(([a-z0-9]+)[.])?portal-pokemon[.]com" - ) - ) { - if (document.location.pathname.includes("/anime")) { - presenceData.largeImageKey = Assets.Pokemontv; - if (document.location.pathname.includes("/series")) { - presenceData.details = "Viewing serie:"; - presenceData.state = document.querySelector( - ".article-detail__title" - ).textContent; - } else presenceData.details = "Viewing ongoing series"; - } else if (document.location.pathname.includes("/topics")) { - if (document.location.pathname.includes("/movie")) { - presenceData.smallImageKey = Assets.Reading; - presenceData.details = "Reading about movie:"; - presenceData.state = document.querySelector( - ".article-detail__title" - ).textContent; - } else if (document.location.pathname.includes("/apps")) { - presenceData.smallImageKey = Assets.Reading; - presenceData.details = "Reading about app:"; - presenceData.state = document.querySelector( - ".article-detail__title" - ).textContent; - } else if (document.location.pathname.includes("/game")) { - presenceData.smallImageKey = Assets.Reading; - presenceData.details = "Reading about game:"; - presenceData.state = document.querySelector( - ".article-detail__title" - ).textContent; - } else if (document.location.pathname.includes("/event")) { - presenceData.smallImageKey = Assets.Reading; - presenceData.details = "Reading about event:"; - presenceData.state = document.querySelector( - ".article-detail__title" - ).textContent; - } - } else if (document.location.pathname.includes("/movie")) - presenceData.details = "Viewing Pokémon's movies"; - else if (document.location.pathname.includes("/goods")) { - if (document.querySelector(".article-detail__title")) { - presenceData.details = "Viewing product:"; - presenceData.state = document.querySelector( - ".article-detail__title" - ).textContent; - } else if ( - document.querySelector(".category-list__element--current") && - document.querySelector(".category-list__element--current") - .textContent !== - document.querySelector(".category-list__element") - .textContent - ) { - presenceData.details = "Goods - Viewing category:"; - presenceData.state = document.querySelector( - ".category-list__element--current" - ).textContent; - } else { - presenceData.details = "Browsing through"; - presenceData.state = "Pokémon's goods"; - } - } else if (document.location.pathname.includes("/apps")) - presenceData.details = "Viewing Pokémon Apps"; - else if (document.location.pathname.includes("/game")) - presenceData.details = "Viewing Pokémon Games"; - else if (document.location.pathname.includes("/event")) - presenceData.details = "Viewing Pokémon Events"; - else if (document.location.pathname.includes("/pokedex")) { - presenceData.smallImageKey = Assets.Pokeball; - presenceData.smallImageText = "Pokédex"; - const search = - document.querySelector("#search_input"); - - if (document.querySelector(".pokemon-detail__profile")) { - const pdexID = await presence.getSetting("pdexID"), - name = document.querySelector( - ".pokemon-slider__main-name" - ).textContent; - - presenceData.details = "Viewing Pokémon:"; - if (pdexID) { - presenceData.state = `${name} (#${ - document.querySelector(".pokemon-slider__main-no") - .textContent - })`; - } else presenceData.state = name; - } else if (search && search.textContent !== "") { - if (search.textContent.length > 2) { - presenceData.details = "Pokédex - Searching for:"; - presenceData.state = search.textContent; - } else { - presenceData.details = "Pokédex"; - presenceData.state = "Searching something up..."; - } - presenceData.largeImageKey = Assets.Pokeball; - presenceData.smallImageKey = Assets.Search; - } else { - presenceData.details = "Pokédex"; - presenceData.state = "Browsing..."; - } - } else if (document.location.pathname.includes("/card")) { - presenceData.largeImageKey = Assets.Tcg; - if (document.querySelector(".article-detail__title")) { - presenceData.details = "Viewing extension pack:"; - presenceData.state = document.querySelector( - ".article-detail__title" - ).textContent; - } else if (document.location.pathname.includes("/map")) - presenceData.details = "Viewing the map"; - else { - presenceData.details = "Reading about the"; - presenceData.state = "Trading Card Game"; - presenceData.smallImageKey = Assets.Reading; - } - } else if ( - document.location.pathname.includes("/pokemoncenter") - ) { - presenceData.details = "Reading about the"; - presenceData.state = "Pokémon Center"; - presenceData.smallImageKey = Assets.Reading; - } - } - } - } - } - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + + settingSetter() + + switch (document.location.host) { + case 'www.pokemon.com': { + if ( + document.location.pathname.includes('/pokemon-news/') + || document.location.pathname.includes('/actus-pokemon/') + || document.location.pathname.includes('/novita-pokemon/') + || document.location.pathname.includes('/pokemon-nieuws/') + || document.location.pathname.includes('/pokemon-nyheter/') + || document.location.pathname.includes('/noticias-pokemon/') + ) { + const title = document.querySelector('.full-article > h1') + if (title) { + presenceData.details = 'Reading article:' + presenceData.state = title.textContent + presenceData.smallImageKey = Assets.Reading + } + else { + presenceData.details = 'Pokémon News' + presenceData.state = 'Browsing...' + } + } + else if (document.location.pathname.includes('/play-pokemon/')) { + presenceData.largeImageKey = Assets.Pokemonplay + const title = document.querySelector('.full-article > h1') + if (title) { + presenceData.details = 'Reading article:' + presenceData.state = title.textContent + presenceData.smallImageKey = Assets.Reading + } + else { + presenceData.details = 'Play! Pokémon' + presenceData.state = 'Browsing...' + } + } + else if (document.location.pathname.includes('/pokedex/')) { + presenceData.smallImageKey = Assets.Pokeball + presenceData.smallImageText = 'Pokédex' + const search = document.querySelector('#searchInput') + + if ( + document.querySelector('.pokedex-pokemon-pagination-title > div') + !== null + ) { + const pdexID = await presence.getSetting('pdexID') + let name = document.querySelector( + '.pokedex-pokemon-pagination-title > div', + )?.textContent + let number = document.querySelector( + '.pokedex-pokemon-pagination-title > div > span', + )?.textContent + name = name?.replace(number ?? '', '').trim() + number = number?.replace(/\D+/g, '') + + presenceData.details = 'Viewing Pokémon:' + if (pdexID) + presenceData.state = `${name} (#${number})` + else presenceData.state = name + } + else if (search && search.value !== '') { + if (search.value.length > 2) { + presenceData.details = 'Pokédex - Searching for:' + presenceData.state = search.value + } + else { + presenceData.details = 'Pokédex' + presenceData.state = 'Searching something up...' + } + presenceData.largeImageKey = Assets.Pokeball + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = 'Pokédex' + presenceData.state = 'Browsing...' + } + } + else if (document.location.pathname.includes('/app')) { + const title = document.querySelector('.full-article > h1') + if (title) { + presenceData.details = 'Viewing app:' + presenceData.state = title.textContent + presenceData.smallImageKey = Assets.Reading + } + else { + presenceData.details = 'Viewing Pokémon Apps' + } + } + else if ( + document.location.pathname.includes('/pokemon-video-games') + || document.location.pathname.includes('/pokemon-videospiele') + || document.location.pathname.includes('/jeux-video-pokemon') + || document.location.pathname.includes('/videogiochi') + || document.location.pathname.includes('/videojuegos-pokemon') + ) { + const title = document.querySelector('.full-article > h1') + presenceData.smallImageKey = Assets.Reading + if (title) { + presenceData.details = 'Reading about game:' + presenceData.state = title.textContent + } + else if ( + document.location.pathname.includes('/all-pokemon-games') + || document.location.pathname.includes('/alle-pokemon-spiele') + || document.location.pathname.includes('/todos-los-juegos-pokemon') + ) { + presenceData.details = 'Viewing all' + presenceData.state = 'Pokémon games' + } + else { + presenceData.details = 'Browsing through' + presenceData.state = 'Pokémon\'s games' + } + } + else if ( + document.querySelector( + 'body > nav > div.content-wrapper > ul > li.home > a', + ) + && document.querySelector( + 'body > nav > div.content-wrapper > ul > li.home > a', + )?.href === document.URL + ) { + presenceData.details = 'Viewing the homepage...' + } + else if ( + document.location.pathname.includes('/pokemon-tcg') + || document.location.pathname.includes('/pokemon-sammelkartenspiel') + || document.location.pathname.includes('/jcc-pokemon') + || document.location.pathname.includes('/pokemon-estampas-ilustradas') + || document.location.pathname.includes('/gcc') + ) { + presenceData.largeImageKey = Assets.Tcg + presenceData.smallImageKey = Assets.Reading + + if ( + document.location.pathname.includes('/pokemon-cards') + || document.location.pathname.includes('/pokemon-karten') + || document.location.pathname.includes('/cartas-pokemon') + || document.location.pathname.includes('/cartes-pokemon') + || document.location.pathname.includes('/archivio-carte') + ) { + presenceData.details = 'Viewing card:' + presenceData.state = document.querySelector( + '.card-description > div > h1', + )?.textContent + } + else if ( + document.location.pathname.includes('/product-gallery') + || document.location.pathname.includes('/Produktgalerie') + ) { + const title = document.querySelector('.full-article > h1') + if (title) { + presenceData.details = 'Viewing product:' + presenceData.state = title.textContent + } + else { + presenceData.details = 'Viewing Pokémon Card Game' + presenceData.state = 'product galery' + } + } + else if (document.location.pathname.includes('/leaderboards')) { + presenceData.details = 'Viewing Trading Card Game' + presenceData.state = 'Online leadersboards' + } + else { + presenceData.details = 'Reading about Pokémon\'s' + presenceData.state = 'Trading Card Game' + } + } + else if ( + document.location.pathname.includes('/pokemon-episodes') + || document.location.pathname.includes('/pokemon-folgen') + || document.location.pathname.includes('/episodios-pokemon') + || document.location.pathname.includes('/pokemon-afsnit') + || document.location.pathname.includes('/pokemon-jaksot') + || document.location.pathname.includes('/episodes-pokemon') + || document.location.pathname.includes('/episodi-tv') + || document.location.pathname.includes('/pokemon-afleveringen') + || document.location.pathname.includes('/pokemon-episoder') + || document.location.pathname.includes('/pokemon-avsnitt') + ) { + presenceData.largeImageKey = Assets.Pokemontv + presenceData.details = 'Viewing PokémonTV' + } + else if ( + document.location.pathname.includes('/country-region') + || document.location.pathname.includes('/land-region') + || document.location.pathname.includes('/pais-region') + || document.location.pathname.includes('/pais-regiao') + || document.location.pathname.includes('/maa-alue') + || document.location.pathname.includes('/pays-region') + || document.location.pathname.includes('/seleziona-paese-regione') + || document.location.pathname.includes('/land-regio') + ) { + presenceData.details = 'Changing region' + } + + break + } + case 'tcg.pokemon.com': { + presenceData.largeImageKey = Assets.Tcg + if (document.location.pathname.includes('/how-to-play/')) { + presenceData.details = 'Learning how to play' + } + else if (document.location.pathname.includes('/expansions/')) { + presenceData.details = 'Viewing expansion:' + presenceData.state = document.title.split('|')[1].trim() + } + else if (document.location.pathname.includes('/galleries/')) { + presenceData.details = 'Viewing cards of expansion:' + presenceData.state = document.title.split('|')[1].trim() + } + else if (document.location.pathname.includes('/parents-guide/')) { + presenceData.details = 'Viewing parents guide' + } + else if (document.location.pathname.includes('/where-to-buy/')) { + presenceData.details = 'Viewing where to buy' + } + + break + } + case 'forums.pokemontcg.com': { + presenceData.largeImageKey = Assets.Tcg + if (document.location.pathname.includes('/topic')) { + presenceData.details = 'Reading thread:' + presenceData.state = document + .querySelector('.ipsType_pageTitle') + ?.textContent + ?.trim() + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/forum')) { + presenceData.details = 'Viewing category:' + presenceData.state = document + .querySelector('.ipsType_pageTitle') + ?.textContent + ?.trim() + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/leaderboard')) { + presenceData.details = 'Viewing the leaderboards' + } + else if (document.location.pathname.includes('/pastleaders')) { + presenceData.details = 'Viewing the pastleaders' + } + else if (document.location.pathname.includes('/topmembers')) { + presenceData.details = 'Viewing the topmembers' + } + else if (document.location.pathname.includes('/discover')) { + presenceData.details = 'Viewing the recent activity' + } + else if (document.location.pathname.includes('/search')) { + presenceData.details = 'Searching for:' + + presenceData.state = document.querySelector('#elMainSearchInput')?.value + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = 'Browsing the forums' + } + + break + } + case 'www.pokemoncenter.com': { + presenceData.largeImageKey = Assets.Store + if (document.querySelector('.main_header')) { + presenceData.details = 'Viewing product:' + presenceData.state = document.querySelector('.main_header')?.textContent + } + else if (document.querySelector('.row > div > div > h1')) { + presenceData.details = 'Viewing category:' + presenceData.state = document + .querySelector('.row > div > div > h1') + ?.textContent + ?.trim() + } + else if ( + document.location.pathname.includes('/AjaxOrderItemDisplayView') + ) { + presenceData.details = 'Viewing their cart' + } + else { + presenceData.details = 'Browsing through the store' + } + + break + } + case 'www.pokemoncenter-online.com': { + presenceData.largeImageKey = Assets.Storejp + if (document.location.pathname.includes('/cafe')) { + presenceData.largeImageKey = Assets.Cafe + if (document.location.pathname.includes('/pikachu_sweets')) { + presenceData.largeImageKey = Assets.Sweets + presenceData.details = 'Viewing the' + presenceData.state = 'Pikachu Sweets Cafe' + } + else if (document.location.pathname.includes('/menu')) { + presenceData.details = 'Viewing the menu' + } + else if (document.location.pathname.includes('/goods')) { + presenceData.details = 'Viewing the goods' + } + else if (document.location.pathname.includes('/news')) { + if ( + document.querySelector( + '#mainContent > section > div > div > div.boxStyle03 > div > h3', + ) + ) { + presenceData.details = 'Reading article:' + presenceData.state = document.querySelector( + '#mainContent > section > div > div > div.boxStyle03 > div > h3', + )?.textContent + presenceData.smallImageKey = Assets.Reading + } + else { + presenceData.details = 'Viewing the articles' + } + } + else if (document.URL.includes('access')) { + presenceData.details = 'Viewing the access points' + } + else if (document.location.pathname.includes('/faq')) { + presenceData.details = 'Viewing the FAQs' + } + else if (document.location.pathname.includes('/reservation')) { + presenceData.details = 'Making a reservation' + } + } + else if ( + document.querySelector( + '#contents > section > div.item_detail > article > h1', + ) + ) { + presenceData.details = 'Viewing product:' + presenceData.state = document.querySelector( + '#contents > section > div.item_detail > article > h1', + )?.textContent + } + else if ( + document.querySelector( + '#contents > div.topic_path > ul > li:nth-child(2) > span', + ) + ) { + presenceData.details = 'Viewing category:' + presenceData.state = document.querySelector( + '#contents > div.topic_path > ul > li:nth-child(2) > span', + )?.textContent + } + else if (document.URL.includes('shopping_cart')) { + presenceData.details = 'Viewing their cart' + } + else { + presenceData.details = 'Browsing through the store' + } + + break + } + default: + if ( + document.location.host.match( + '([a-z0-9]+)[.]pokemon-cafe[.]([a-z0-9]+)([.]([a-z0-9]+))?', + ) + ) { + presenceData.largeImageKey = Assets.Cafe + presenceData.details = 'Making a reservation' + } + else { + switch (document.location.host) { + case 'watch.pokemon.com': { + presenceData.largeImageKey = Assets.Pokemontv + if (document.location.pathname.includes('/player')) { + const video = document.querySelector('video')! + + presenceData.smallImageKey = video.paused + ? Assets.Pause + : Assets.Play + presenceData.smallImageText = video.paused + ? (await strings).pause + : (await strings).play; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + + const title = document + .querySelector('.header-bar-small > span:nth-child(4)') + ?.textContent + ?.split(' - ')[1] + .trim() + presenceData.details = `${document + .querySelector('.header-bar-small > span:nth-child(2)') + ?.textContent + ?.trim()} - ${document + .querySelector('.header-bar-small > span:nth-child(4)') + ?.textContent + ?.split(' - ')[0] + .trim()}` + presenceData.state = title + + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else if (document.location.pathname.includes('/season')) { + presenceData.details = 'Viewing season:' + presenceData.state = document.querySelector('#lbl_season_title')?.textContent + } + else { + presenceData.details = 'Browsing PokémonTV' + } + + break + } + case 'pokemonkorea.co.kr': { + if (document.location.pathname.includes('/news/')) { + presenceData.smallImageKey = Assets.Reading + presenceData.details = 'Reading article:' + + const title = document.querySelector('.section-title') + const tag = document.querySelector('.section-title > span') + const publish = document.querySelector('.section-title > small') + if (tag) { + presenceData.state = title?.textContent + ?.replace(tag.textContent ?? '', '') + ?.replace(publish?.textContent ?? '', '') + } + else { + presenceData.state = title?.textContent?.replace( + publish?.textContent ?? '', + '', + ) + } + } + else if (document.location.pathname.includes('/news')) { + presenceData.details = 'Viewing the recent' + presenceData.state = 'News and Announcements' + } + else if (document.location.pathname.includes('/game/')) { + const title = document.querySelector('.medium-title') + if (title) { + presenceData.details = 'Viewing game:' + presenceData.state = title.textContent + } + else if (document.location.pathname.includes('/category/')) { + presenceData.details = 'Viewing category:' + presenceData.state = document.querySelector('.section-title')?.textContent + } + } + else if (document.location.pathname.includes('/game')) { + presenceData.details = 'Viewing Pokémon\'s games' + } + else if (document.location.pathname.includes('/pokedex')) { + presenceData.smallImageKey = Assets.Pokeball + presenceData.smallImageText = 'Pokédex' + const search = document.querySelector('#word.form-control') + if ( + document.querySelector( + 'body > div.single_header_wrap > div > h1', + ) !== null + ) { + const pdexID = await presence.getSetting('pdexID') + let name = document + .querySelector('body > div.single_header_wrap > div > h1') + ?.textContent + ?.trim() + let number = document.querySelector( + 'body > div.single_header_wrap > div > h1 > span', + )?.textContent + name = name?.replace(number ?? '', '') + number = number?.replace('No. ', '') + + presenceData.details = 'Viewing Pokémon:' + if (pdexID) + presenceData.state = `${name} (#${number})` + else presenceData.state = name + } + else if (search && search.value !== '') { + if (search.value.length > 2) { + presenceData.details = 'Pokédex - Searching for:' + presenceData.state = search.textContent + } + else { + presenceData.details = 'Pokédex' + presenceData.state = 'Searching something up...' + } + presenceData.largeImageKey = Assets.Pokeball + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = 'Pokédex' + presenceData.state = 'Browsing...' + } + } + else if (document.location.pathname.includes('/animation')) { + const title = document.querySelector('.medium-title') + if (title) { + presenceData.details = 'Reading about animation:' + presenceData.state = title.textContent + presenceData.smallImageKey = Assets.Reading + } + else { + presenceData.details = 'Viewing Pokémon\'s animations' + } + } + else if (document.location.pathname.includes('/product')) { + presenceData.largeImageKey = Assets.Storekr + const title = document.querySelector('.medium-title') + if (title) { + presenceData.details = 'Viewing product:' + presenceData.state = title.textContent + } + else { + presenceData.details = 'Browsing through' + presenceData.state = 'Pokémon\'s products' + } + } + + break + } + case 'pokemoncard.co.kr': { + presenceData.largeImageKey = Assets.Tcg + if (document.location.pathname.includes('/main')) { + presenceData.details = 'Browsing...' + } + else if (document.location.pathname.includes('/news/')) { + presenceData.smallImageKey = Assets.Reading + presenceData.details = 'Reading article:' + + const title = document.querySelector('.section-title') + const tag = document.querySelector('.section-title > span') + const publish = document.querySelector('.section-title > small') + if (tag) { + presenceData.state = title?.textContent + ?.replace(tag.textContent ?? '', '') + ?.replace(publish?.textContent ?? '', '') + } + else { + presenceData.state = title?.textContent?.replace( + publish?.textContent ?? '', + '', + ) + } + } + else if (document.location.pathname.includes('/news')) { + presenceData.details = 'Viewing the recent' + presenceData.state = 'News and Announcements' + } + else if (document.location.pathname.includes('/card')) { + if (document.location.pathname.includes('/category')) { + if (document.location.pathname.includes('/event')) { + presenceData.details = 'Viewing upcoming events' + } + else { + presenceData.details = 'Viewing category:' + presenceData.state = document + .querySelector('#partners > div > div > ul > li.active') + ?.textContent + ?.trim() + } + } + else if (document.location.pathname.includes('/play')) { + presenceData.details = 'Learning how to play' + } + else if ( + document + .querySelector( + '#header-top-menu > li.active > a', + ) + ?.href + .includes('/event') + ) { + presenceData.details = 'Viewing event:' + presenceData.state = document.querySelector('.medium-title')?.textContent + } + else if (document.location.pathname.includes('/cards')) { + const input = document.querySelector('#search_text') + if (document.location.pathname.includes('/detail')) { + presenceData.details = 'Viewing card:' + presenceData.state = document.querySelector('.card-hp.title')?.textContent + } + else if (input && input.value !== '') { + if (input.value.length > 2) { + presenceData.details = 'Searching for:' + presenceData.state = input.value + } + else { + presenceData.details = 'Searching up something...' + } + + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = 'Browsing through the cards' + } + } + else if (document.querySelector('.medium-title')) { + presenceData.details = 'Viewing card:' + presenceData.state = document.querySelector('.medium-title')?.textContent + } + else { + presenceData.details = 'Browsing through the cards' + } + } + else if (document.location.pathname.includes('/players')) { + presenceData.details = 'Viewing players' + } + + break + } + case 'www.pokemonstore.co.kr': { + presenceData.largeImageKey = Assets.Storekr + if (document.location.pathname.includes('/goods_view')) { + presenceData.details = 'Viewing product:' + presenceData.state = document + .querySelector('.goods-header > div.top > div') + ?.textContent + ?.trim() + } + else if (document.location.pathname.includes('/goods_list')) { + presenceData.details = 'Viewing category:' + presenceData.state = document.querySelector( + '#content > div > div > div.cg-main > h2', + )?.textContent + } + else if (document.location.pathname.includes('/main')) { + presenceData.details = 'Browsing...' + } + else if (document.location.pathname.includes('/board/list')) { + presenceData.details = 'Viewing product reviews' + } + else if (document.location.pathname.includes('/board/view')) { + presenceData.details = 'Viewing review of product:' + presenceData.state = document.querySelector('.itemorder-name')?.textContent + } + else if ( + document.location.pathname.includes('/mypage/order_list') + ) { + presenceData.details = 'Viewing their orders' + } + else if (document.location.pathname.includes('/mypage/wish_list')) { + presenceData.details = 'Viewing their wish list' + } + else if (document.location.pathname.includes('/mypage/index')) { + presenceData.details = 'Viewing their page' + } + else if (document.location.pathname.includes('/order/cart')) { + presenceData.details = 'Viewing their cart' + } + + break + } + case 'www.pokemon.co.jp': { + if (document.location.pathname.includes('/app')) { + presenceData.details = 'Viewing Pokémon Apps' + } + else if (document.location.pathname.includes('/game')) { + presenceData.details = 'Viewing Pokémon Games' + } + else if (document.location.pathname.includes('/ex/')) { + presenceData.details = 'Viewing game:' + presenceData.state = document.title + } + else if (document.location.pathname.includes('/card')) { + presenceData.details = 'Viewing Pokémon Cards' + } + else if (document.location.pathname.includes('/event')) { + presenceData.details = 'Viewing Pokémon Events' + } + else if (document.location.pathname.includes('/anime')) { + presenceData.largeImageKey = Assets.Pokemontv + const title = document.querySelector('.m-ttl-top') + || document.querySelector('.m-ttl-dot') + if (title) { + presenceData.details = 'Viewing show:' + presenceData.state = title.textContent + } + else { + presenceData.details = 'Viewing Pokémon TV/Movies' + } + } + else if (document.location.pathname.includes('/gp')) { + const title = document.querySelector('.m-ttl-top') + if (title && title.textContent?.includes('ポケモンセンタ')) { + presenceData.details = 'Viewing Pokémon Center:' + presenceData.state = title.textContent + .replace('ポケモンセンター', '') + .trim() + } + else if ( + title + && title.textContent?.includes('ポケモンストア') + ) { + presenceData.details = 'Viewing Pokémon Store:' + presenceData.state = title.textContent + .replace('ポケモンストア', '') + .trim() + } + else { + presenceData.details = 'Viewing Pokémon Centers' + } + } + else if (document.location.pathname.includes('/sp')) { + const title = document.querySelector('.m-ttl-top') + if (title) { + presenceData.details = 'Viewing Upcoming Pokémon Center:' + presenceData.state = title.textContent + ?.split('、')[0] + .replace('ポケモンセンター', '') + .trim() + } + else { + presenceData.details = 'Viewing Upcoming Pokémon Centers' + } + } + else if (document.location.pathname.includes('/goods')) { + presenceData.smallImageKey = Assets.Storejp + const title = document.querySelector('.m-ttl-hd') + if (title) { + presenceData.details = 'Viewing Pokémon Goods' + presenceData.state = `in category: ${title.textContent}` + } + else { + presenceData.details = 'Viewing Pokémon Goods' + } + } + + break + } + case 'www.pokemon-movie.jp': { + presenceData.largeImageKey = Assets.Pokemontv + if (document.location.pathname.includes('/news/')) { + if (document.URL.includes('?p=')) { + presenceData.smallImageKey = Assets.Reading + presenceData.details = 'Reading article:' + presenceData.state = document.querySelector( + '#pagemain_newbig > div > div.entry_header > h2 > a', + )?.textContent + } + else { + presenceData.details = 'Viewing the recent articles' + } + } + else if (document.location.pathname === '/') { + presenceData.details = 'Pokémon Movie' + presenceData.state = 'Browsing...' + } + else if (document.location.pathname.includes('/chara/')) { + presenceData.details = 'Pokémon Movie' + presenceData.state = 'Viewing the characters' + } + else if (document.location.pathname.includes('/story/')) { + presenceData.smallImageKey = Assets.Reading + presenceData.details = 'Pokémon Movies' + presenceData.state = 'Reading the story' + } + else if (document.location.pathname.includes('/tickets/')) { + presenceData.details = 'Pokémon Movies' + presenceData.state = 'Getting tickets' + } + else if (document.location.pathname.includes('/playground/')) { + presenceData.details = 'Pokémon Movies' + presenceData.state = 'Viewing the playground' + } + else if (document.location.pathname.includes('/history/')) { + if (document.querySelector('#main > h1 > img')) { + presenceData.details = 'Viewing history of:' + presenceData.state = document.querySelector( + '#main > h1 > img', + )?.alt + } + else { + presenceData.details = 'Pokémon Movies' + presenceData.state = 'Viewing the history' + } + } + else if (document.location.pathname.includes('/melmaga/form')) { + presenceData.details = 'Pokémon Movies' + presenceData.state = 'Signing up for the magazine' + } + + break + } + case 'www.pokemon-card.com': { + presenceData.largeImageKey = Assets.Tcg + if (document.location.pathname.includes('/about')) { + presenceData.details = 'Viewing the tutorial' + } + else if (document.location.pathname.includes('/rules')) { + if (document.location.pathname.includes('/regulation')) + presenceData.details = 'Viewing the regulation' + else presenceData.details = 'Viewing the Q&A' + } + else if (document.location.pathname.includes('/products')) { + if (document.location.pathname.includes('/products/s')) { + presenceData.details = 'Viewing product:' + presenceData.state = document.querySelector( + '.MainArea > div > nav > ul > li.current', + )?.textContent + } + else { + presenceData.details = 'Viewing products' + } + } + else if (document.location.pathname.includes('/ex')) { + presenceData.details = 'Viewing extension pack:'; + [, presenceData.state] = document.title + .split('」 | ')[0] + .split('「') + } + else if (document.location.pathname.includes('/event')) { + if ( + document.querySelector( + '.detailCalenderEventArea > section:nth-child(1) > ul > li:nth-child(1) > div > div.List_body', + ) + ) { + let title = document.querySelector( + '.detailCalenderEventArea > section:nth-child(1) > ul > li:nth-child(1) > div > div.List_body', + )?.textContent + const tags = document.querySelector( + '.detailCalenderEventArea > section:nth-child(1) > ul > li:nth-child(1) > div > div.List_body > ul', + ) + const warning = document.querySelector( + '.detailCalenderEventArea > section:nth-child(1) > ul > li:nth-child(1) > div > div.List_body > div', + ) + + if (tags) + title = title?.replace(tags.textContent ?? '', '') + + if (warning) + title = title?.replace(warning.textContent ?? '', '') + + presenceData.details = 'Viewing event:' + presenceData.state = title + } + else { + presenceData.details = 'Browsing through the' + presenceData.state = 'upcoming events' + } + } + else if (document.location.pathname.includes('/card-search/')) { + if (document.location.pathname.includes('/card/')) { + presenceData.details = 'Viewing card:' + presenceData.state = document.querySelector( + 'body > div > div.PopupMain > section.Section > h1', + )?.textContent + } + else { + presenceData.details = 'Searching through' + presenceData.state = 'the cards...' + presenceData.smallImageKey = Assets.Search + } + } + else if (document.location.pathname.includes('/info/')) { + presenceData.details = 'Reading article:' + presenceData.state = document.querySelector( + 'body > div.WrapperArea > div.MainArea > div > section > h1', + )?.textContent + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/deck/')) { + presenceData.details = 'Browsing decks...' + } + + break + } + case 'map.pokemon-card.com': { + presenceData.largeImageKey = Assets.Tcg + presenceData.details = 'Viewing the map' + + break + } + case 'www.portal-pokemon.com': { + presenceData.details = 'Changing region' + break + } + default: + if ( + document.location.host.match( + '(([a-z0-9]+)[.])?portal-pokemon[.]com', + ) + ) { + if (document.location.pathname.includes('/anime')) { + presenceData.largeImageKey = Assets.Pokemontv + if (document.location.pathname.includes('/series')) { + presenceData.details = 'Viewing serie:' + presenceData.state = document.querySelector( + '.article-detail__title', + )?.textContent + } + else { + presenceData.details = 'Viewing ongoing series' + } + } + else if (document.location.pathname.includes('/topics')) { + if (document.location.pathname.includes('/movie')) { + presenceData.smallImageKey = Assets.Reading + presenceData.details = 'Reading about movie:' + presenceData.state = document.querySelector( + '.article-detail__title', + )?.textContent + } + else if (document.location.pathname.includes('/apps')) { + presenceData.smallImageKey = Assets.Reading + presenceData.details = 'Reading about app:' + presenceData.state = document.querySelector( + '.article-detail__title', + )?.textContent + } + else if (document.location.pathname.includes('/game')) { + presenceData.smallImageKey = Assets.Reading + presenceData.details = 'Reading about game:' + presenceData.state = document.querySelector( + '.article-detail__title', + )?.textContent + } + else if (document.location.pathname.includes('/event')) { + presenceData.smallImageKey = Assets.Reading + presenceData.details = 'Reading about event:' + presenceData.state = document.querySelector( + '.article-detail__title', + )?.textContent + } + } + else if (document.location.pathname.includes('/movie')) { + presenceData.details = 'Viewing Pokémon\'s movies' + } + else if (document.location.pathname.includes('/goods')) { + if (document.querySelector('.article-detail__title')) { + presenceData.details = 'Viewing product:' + presenceData.state = document.querySelector( + '.article-detail__title', + )?.textContent + } + else if ( + document.querySelector('.category-list__element--current') + && document.querySelector('.category-list__element--current') + ?.textContent + !== document.querySelector('.category-list__element') + ?.textContent + ) { + presenceData.details = 'Goods - Viewing category:' + presenceData.state = document.querySelector( + '.category-list__element--current', + )?.textContent + } + else { + presenceData.details = 'Browsing through' + presenceData.state = 'Pokémon\'s goods' + } + } + else if (document.location.pathname.includes('/apps')) { + presenceData.details = 'Viewing Pokémon Apps' + } + else if (document.location.pathname.includes('/game')) { + presenceData.details = 'Viewing Pokémon Games' + } + else if (document.location.pathname.includes('/event')) { + presenceData.details = 'Viewing Pokémon Events' + } + else if (document.location.pathname.includes('/pokedex')) { + presenceData.smallImageKey = Assets.Pokeball + presenceData.smallImageText = 'Pokédex' + const search = document.querySelector('#search_input') + + if (document.querySelector('.pokemon-detail__profile')) { + const pdexID = await presence.getSetting('pdexID') + const name = document.querySelector( + '.pokemon-slider__main-name', + )?.textContent + + presenceData.details = 'Viewing Pokémon:' + if (pdexID) { + presenceData.state = `${name} (#${ + document.querySelector('.pokemon-slider__main-no') + ?.textContent + })` + } + else { + presenceData.state = name + } + } + else if (search && search.textContent) { + if (search.textContent.length > 2) { + presenceData.details = 'Pokédex - Searching for:' + presenceData.state = search.textContent + } + else { + presenceData.details = 'Pokédex' + presenceData.state = 'Searching something up...' + } + presenceData.largeImageKey = Assets.Pokeball + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = 'Pokédex' + presenceData.state = 'Browsing...' + } + } + else if (document.location.pathname.includes('/card')) { + presenceData.largeImageKey = Assets.Tcg + if (document.querySelector('.article-detail__title')) { + presenceData.details = 'Viewing extension pack:' + presenceData.state = document.querySelector( + '.article-detail__title', + )?.textContent + } + else if (document.location.pathname.includes('/map')) { + presenceData.details = 'Viewing the map' + } + else { + presenceData.details = 'Reading about the' + presenceData.state = 'Trading Card Game' + presenceData.smallImageKey = Assets.Reading + } + } + else if ( + document.location.pathname.includes('/pokemoncenter') + ) { + presenceData.details = 'Reading about the' + presenceData.state = 'Pokémon Center' + presenceData.smallImageKey = Assets.Reading + } + } + } + } + } + + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/PonyvilleFM/metadata.json b/websites/P/PonyvilleFM/metadata.json index 30d3ef9bdef2..688c5611f8d8 100644 --- a/websites/P/PonyvilleFM/metadata.json +++ b/websites/P/PonyvilleFM/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "sks316", - "id": "226098403304538122" - }, - "service": "PonyvilleFM", - "description": { - "en": "PonyvilleFM is one of the oldest Brony and Pony EDM Radio Station with Live Mixes and Performances from our very talented line-up of DJs.", - "nl": "PonyvilleFM is een van de oudste Brony en Pony EDM-radiostations met live mixen en optredens van onze zeer getalenteerde line-up van dj's." - }, - "url": "ponyvillefm.com", - "version": "1.2.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/thumbnail.png", - "color": "#4D0F80", - "category": "music", - "tags": [ - "music", - "radio" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "sks316", + "id": "226098403304538122" + }, + "service": "PonyvilleFM", + "description": { + "en": "PonyvilleFM is one of the oldest Brony and Pony EDM Radio Station with Live Mixes and Performances from our very talented line-up of DJs.", + "nl": "PonyvilleFM is een van de oudste Brony en Pony EDM-radiostations met live mixen en optredens van onze zeer getalenteerde line-up van dj's." + }, + "url": "ponyvillefm.com", + "version": "1.2.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/thumbnail.png", + "color": "#4D0F80", + "category": "music", + "tags": [ + "music", + "radio" + ] +} diff --git a/websites/P/PonyvilleFM/presence.ts b/websites/P/PonyvilleFM/presence.ts index 574bc5ee6d31..c71b28f1a9f8 100644 --- a/websites/P/PonyvilleFM/presence.ts +++ b/websites/P/PonyvilleFM/presence.ts @@ -1,131 +1,128 @@ const presence = new Presence({ - clientId: "613628090219757599", - }), - timeElapsed = Math.floor(Date.now() / 1000); -let otherListeners: HTMLElement, - stationStatus, - listeningCheck: boolean, - onAir: HTMLElement; + clientId: '613628090219757599', +}) +const timeElapsed = Math.floor(Date.now() / 1000) +let stationStatus, + listeningCheck: boolean -presence.on("UpdateData", async () => { - switch (document.location.pathname) { - case "/player": { - otherListeners = document.querySelector( - "html > body > #playerContent > #about > div > div.col-sm-12 > h4 > small" - ); - if ( - !document.querySelector( - "html > body > #playerContent > #about > div.row > div.col-sm-12 > div.sm2-bar-ui.textured.full-width.playing" - ) - ) { - stationStatus = "Paused on PVFM One"; - listeningCheck = false; - } else { - stationStatus = `Listening on PVFM One with${otherListeners.textContent} others`; - listeningCheck = true; - } - onAir = document.querySelector( - "html > body > div#playerContent.content > div#about.container.ng-scope > div.row > div.col-sm-12 > h3#mane_onair.ng-binding" - ); - if (!listeningCheck) { - presence.setActivity({ - details: stationStatus, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png", - smallImageKey: Assets.Pause, - }); - } else { - const presenceData: PresenceData = { - details: stationStatus, - state: `On air: ${onAir.textContent}`, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png", - smallImageKey: Assets.Play, - startTimestamp: timeElapsed, - }; - presence.setActivity(presenceData); - } +presence.on('UpdateData', async () => { + switch (document.location.pathname) { + case '/player': { + const otherListeners = document.querySelector( + 'html > body > #playerContent > #about > div > div.col-sm-12 > h4 > small', + ) + if ( + !document.querySelector( + 'html > body > #playerContent > #about > div.row > div.col-sm-12 > div.sm2-bar-ui.textured.full-width.playing', + ) + ) { + stationStatus = 'Paused on PVFM One' + listeningCheck = false + } + else { + stationStatus = `Listening on PVFM One with${otherListeners?.textContent} others` + listeningCheck = true + } + const onAir = document.querySelector( + 'html > body > div#playerContent.content > div#about.container.ng-scope > div.row > div.col-sm-12 > h3#mane_onair.ng-binding', + ) + if (!listeningCheck) { + presence.setActivity({ + details: stationStatus, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png', + smallImageKey: Assets.Pause, + }) + } + else { + const presenceData: PresenceData = { + details: stationStatus, + state: `On air: ${onAir?.textContent}`, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png', + smallImageKey: Assets.Play, + startTimestamp: timeElapsed, + } + presence.setActivity(presenceData) + } - break; - } - case "/player/two": { - otherListeners = document.querySelector( - "html > body > #playerContent > #about > div > div.col-sm-12 > h4 > small" - ); - if ( - !document.querySelector( - "html > body > #playerContent > #about > div.row > div.col-sm-12 > div.sm2-bar-ui.textured.full-width.playing" - ) - ) { - stationStatus = "Paused on PVFM Two"; - listeningCheck = false; - } else { - stationStatus = `Listening on PVFM Two with${otherListeners.textContent} others`; - listeningCheck = true; - } - onAir = document.querySelector( - "html > body > div#playerContent.content > div#about.container.ng-scope > div.row > div.col-sm-12 > h3" - ); - if (!listeningCheck) { - presence.setActivity({ - details: stationStatus, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png", - smallImageKey: Assets.Pause, - }); - } else { - const presenceData: PresenceData = { - details: stationStatus, - state: `On air: ${onAir.textContent}`, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png", - smallImageKey: Assets.Play, - startTimestamp: timeElapsed, - }; - presence.setActivity(presenceData); - } + break + } + case '/player/two': { + const otherListeners = document.querySelector( + 'html > body > #playerContent > #about > div > div.col-sm-12 > h4 > small', + ) + if ( + !document.querySelector( + 'html > body > #playerContent > #about > div.row > div.col-sm-12 > div.sm2-bar-ui.textured.full-width.playing', + ) + ) { + stationStatus = 'Paused on PVFM Two' + listeningCheck = false + } + else { + stationStatus = `Listening on PVFM Two with${otherListeners?.textContent} others` + listeningCheck = true + } + const onAir = document.querySelector( + 'html > body > div#playerContent.content > div#about.container.ng-scope > div.row > div.col-sm-12 > h3', + ) + if (!listeningCheck) { + presence.setActivity({ + details: stationStatus, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png', + smallImageKey: Assets.Pause, + }) + } + else { + const presenceData: PresenceData = { + details: stationStatus, + state: `On air: ${onAir?.textContent}`, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png', + smallImageKey: Assets.Play, + startTimestamp: timeElapsed, + } + presence.setActivity(presenceData) + } - break; - } - case "/player/free": { - otherListeners = document.querySelector( - "html > body > #playerContent > #about > div > div.col-sm-12 > h4 > small" - ); - if ( - !document.querySelector( - "html > body > #playerContent > #about > div.row > div.col-sm-12 > div.sm2-bar-ui.textured.full-width.playing" - ) - ) { - stationStatus = "Paused on PVFM Free"; - listeningCheck = false; - } else { - stationStatus = `Listening on PVFM Free with${otherListeners.textContent} others`; - listeningCheck = true; - } - onAir = document.querySelector( - "html > body > div#playerContent.content > div#about.container.ng-scope > div.row > div.col-sm-12 > h3" - ); - if (!listeningCheck) { - presence.setActivity({ - details: stationStatus, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png", - smallImageKey: Assets.Pause, - }); - } else { - const presenceData: PresenceData = { - details: stationStatus, - state: `On air: ${onAir.textContent}`, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png", - smallImageKey: Assets.Play, - startTimestamp: timeElapsed, - }; - presence.setActivity(presenceData); - } + break + } + case '/player/free': { + const otherListeners = document.querySelector( + 'html > body > #playerContent > #about > div > div.col-sm-12 > h4 > small', + ) + if ( + !document.querySelector( + 'html > body > #playerContent > #about > div.row > div.col-sm-12 > div.sm2-bar-ui.textured.full-width.playing', + ) + ) { + stationStatus = 'Paused on PVFM Free' + listeningCheck = false + } + else { + stationStatus = `Listening on PVFM Free with${otherListeners?.textContent} others` + listeningCheck = true + } + const onAir = document.querySelector( + 'html > body > div#playerContent.content > div#about.container.ng-scope > div.row > div.col-sm-12 > h3', + ) + if (!listeningCheck) { + presence.setActivity({ + details: stationStatus, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png', + smallImageKey: Assets.Pause, + }) + } + else { + const presenceData: PresenceData = { + details: stationStatus, + state: `On air: ${onAir?.textContent}`, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PonyvilleFM/assets/logo.png', + smallImageKey: Assets.Play, + startTimestamp: timeElapsed, + } + presence.setActivity(presenceData) + } - break; - } - // No default - } -}); + break + } + } +}) diff --git a/websites/P/Poolsuite FM/metadata.json b/websites/P/Poolsuite FM/metadata.json index bd54f03c3c8d..57c9f2e13c4a 100644 --- a/websites/P/Poolsuite FM/metadata.json +++ b/websites/P/Poolsuite FM/metadata.json @@ -1,21 +1,21 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "197422681530957824", - "name": "6co" - }, - "service": "Poolsuite FM", - "description": { - "en": "Poolsuite FM is an 80s-themed music website bringing summer vibes year-round." - }, - "url": "poolsuite.net", - "version": "1.0.6", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Poolsuite%20FM/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Poolsuite%20FM/assets/thumbnail.png", - "color": "#03cafc", - "category": "music", - "tags": [ - "music" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "197422681530957824", + "name": "6co" + }, + "service": "Poolsuite FM", + "description": { + "en": "Poolsuite FM is an 80s-themed music website bringing summer vibes year-round." + }, + "url": "poolsuite.net", + "version": "1.0.6", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Poolsuite%20FM/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Poolsuite%20FM/assets/thumbnail.png", + "color": "#03cafc", + "category": "music", + "tags": [ + "music" + ] +} diff --git a/websites/P/Poolsuite FM/presence.ts b/websites/P/Poolsuite FM/presence.ts index 98f5c7641a75..78f59d577e6c 100644 --- a/websites/P/Poolsuite FM/presence.ts +++ b/websites/P/Poolsuite FM/presence.ts @@ -1,63 +1,64 @@ const presence = new Presence({ - clientId: "1174478441450573924", -}); + clientId: '1174478441450573924', +}) // Function to convert the site's duration timer to raw seconds function convertToSeconds(duration: string): number { - const [minutes, seconds] = duration.split(":").map(Number); - return minutes * 60 + seconds; + const [minutes, seconds] = duration.split(':').map(Number) + return minutes * 60 + seconds } const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Poolsuite%20FM/assets/logo.jpg", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Poolsuite%20FM/assets/logo.jpg', } -let details: string, state: string, artist: string; -presence.on("UpdateData", async () => { - // Grab channel and artist name - details = `Channel: ${ - document.querySelector(".select-wrapper").lastChild.textContent - }`; - artist = document.querySelector(".current-track").lastChild.textContent; +let details: string, state: string, artist: string +presence.on('UpdateData', async () => { + // Grab channel and artist name + details = `Channel: ${ + document.querySelector('.select-wrapper')?.lastChild?.textContent + }` + artist = document.querySelector('.current-track')?.lastChild?.textContent ?? '' - // If next track is loading, replace current track text with "Tuning..." instead of track - if (artist === "We'll be right back") state = "Tuning..."; - else { - state = `${artist} - ${ - document.querySelector(".current-track").firstChild.nextSibling - .textContent - }`; - } - if (document.querySelector(".middle").firstChild.textContent === "Pause") { - // Set presence data for a playing song - const elapsed = Math.floor(Date.now() / 1000), - presenceData: PresenceData = { - details, - state, - largeImageKey: Assets.Logo, - startTimestamp: elapsed, - endTimestamp: - elapsed + - (convertToSeconds( - document.querySelector(".timer").lastChild.textContent - ) - - convertToSeconds( - document.querySelector(".timer").firstChild.textContent - )), - smallImageKey: Assets.Play, - smallImageText: "Playing", - }; - presence.setActivity(presenceData); - } else { - // Set presence data for a paused song - const presenceData: PresenceData = { - details, - state, - largeImageKey: Assets.Logo, - endTimestamp: 0, - smallImageKey: Assets.Pause, - smallImageText: "Paused", - }; - presence.setActivity(presenceData); - } -}); + // If next track is loading, replace current track text with "Tuning..." instead of track + if (artist === 'We\'ll be right back') { + state = 'Tuning...' + } + else { + state = `${artist} - ${ + document.querySelector('.current-track')?.firstChild?.nextSibling?.textContent + }` + } + if (document.querySelector('.middle')?.firstChild?.textContent === 'Pause') { + // Set presence data for a playing song + const elapsed = Math.floor(Date.now() / 1000) + const presenceData: PresenceData = { + details, + state, + largeImageKey: Assets.Logo, + startTimestamp: elapsed, + endTimestamp: elapsed + + (convertToSeconds( + document.querySelector('.timer')?.lastChild?.textContent ?? '', + ) + - convertToSeconds( + document.querySelector('.timer')?.firstChild?.textContent ?? '', + )), + smallImageKey: Assets.Play, + smallImageText: 'Playing', + } + presence.setActivity(presenceData) + } + else { + // Set presence data for a paused song + const presenceData: PresenceData = { + details, + state, + largeImageKey: Assets.Logo, + endTimestamp: 0, + smallImageKey: Assets.Pause, + smallImageText: 'Paused', + } + presence.setActivity(presenceData) + } +}) diff --git a/websites/P/Prambors Radio/metadata.json b/websites/P/Prambors Radio/metadata.json index 812e1d7fae8b..b846d8e244b9 100644 --- a/websites/P/Prambors Radio/metadata.json +++ b/websites/P/Prambors Radio/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "allvzx", - "id": "369507341973979136" - }, - "service": "Prambors Radio", - "description": { - "en": "Prambors FM is a commercial radio network based in Jakarta, Indonesia. Launched on March 18, 1971 in Jakarta, the purpose of station was to play pop music with their target audience being teenagers and young adults. Prambors is known as a teen icon in Indonesia throughout the 80's and 90's. It is owned and operated by Masima Radio Network", - "nl": "Prambors FM is een commercieel radionetwerk gevestigd in Jakarta, Indonesië. Het station werd gelanceerd op 18 maart 1971 in Jakarta en het doel van het station was om popmuziek te spelen met als doelgroep tieners en jonge volwassenen. Prambors staat in de jaren 80 en 90 bekend als een tienericoon in Indonesië. Het is eigendom van en wordt beheerd door Masima Radio Network" - }, - "url": [ - "www.pramborsfm.com", - "live.pramborsfm.com", - "streaming.pramborsfm.com" - ], - "version": "1.3.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Prambors%20Radio/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Prambors%20Radio/assets/thumbnail.png", - "color": "#ffc925", - "category": "music", - "tags": [ - "prambors", - "music", - "radio" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "allvzx", + "id": "369507341973979136" + }, + "service": "Prambors Radio", + "description": { + "en": "Prambors FM is a commercial radio network based in Jakarta, Indonesia. Launched on March 18, 1971 in Jakarta, the purpose of station was to play pop music with their target audience being teenagers and young adults. Prambors is known as a teen icon in Indonesia throughout the 80's and 90's. It is owned and operated by Masima Radio Network", + "nl": "Prambors FM is een commercieel radionetwerk gevestigd in Jakarta, Indonesië. Het station werd gelanceerd op 18 maart 1971 in Jakarta en het doel van het station was om popmuziek te spelen met als doelgroep tieners en jonge volwassenen. Prambors staat in de jaren 80 en 90 bekend als een tienericoon in Indonesië. Het is eigendom van en wordt beheerd door Masima Radio Network" + }, + "url": [ + "www.pramborsfm.com", + "live.pramborsfm.com", + "streaming.pramborsfm.com" + ], + "version": "1.3.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Prambors%20Radio/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Prambors%20Radio/assets/thumbnail.png", + "color": "#ffc925", + "category": "music", + "tags": [ + "prambors", + "music", + "radio" + ] +} diff --git a/websites/P/Prambors Radio/presence.ts b/websites/P/Prambors Radio/presence.ts index c6694e280335..0e1d6709f864 100644 --- a/websites/P/Prambors Radio/presence.ts +++ b/websites/P/Prambors Radio/presence.ts @@ -1,77 +1,80 @@ const presence = new Presence({ - clientId: "630428033966276612", - }), - strings = presence.getStrings({ - pause: "general.paused", - }), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Prambors%20Radio/assets/logo.png", - }; + clientId: '630428033966276612', +}) +const strings = presence.getStrings({ + pause: 'general.paused', +}) +const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Prambors%20Radio/assets/logo.png', +} -let timestamp: number; +let timestamp: number | null = null -presence.on("UpdateData", async () => { - const { pause } = await strings; - if ( - ["streaming.pramborsfm.com", "live.pramborsfm.com"].includes( - document.location.hostname - ) - ) { - presenceData.buttons = [ - { - label: "Listen to Prambors", - url: "https://live.pramborsfm.com", - }, - ]; - timestamp ??= Date.now(); - switch (document.location.hostname) { - case "streaming.pramborsfm.com": { - const status = document.querySelector("#playerBtn")?.className; - if (status === "stopped") { - timestamp = null; - delete presenceData.startTimestamp; - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = pause; - } else if (status === "playing") { - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = "Listening"; - presenceData.startTimestamp = timestamp; - } - presenceData.state = document - .querySelectorAll("span[data-radium=true]") - .item(3).textContent; - presenceData.details = document - .querySelectorAll("span[data-radium=true]") - .item(2).textContent; - break; - } - case "live.pramborsfm.com": { - const buttonAction = [ - ...[...document.querySelectorAll("button")].pop().classList, - ] - .pop() - .split("--") - .pop(); - if (buttonAction === "play") { - timestamp = null; - delete presenceData.startTimestamp; - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = pause; - } else if (buttonAction === "pause") { - presenceData.smallImageKey = Assets.Live; - presenceData.smallImageText = "Listening"; - presenceData.startTimestamp = timestamp; - } - presenceData.state = document.querySelector( - ".td-player-vertical__track-info__artist-name" - ).textContent; - presenceData.details = document.querySelector( - ".td-player-vertical__track-info__cue-title" - ).textContent; - break; - } - } - } - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const { pause } = await strings + if ( + ['streaming.pramborsfm.com', 'live.pramborsfm.com'].includes( + document.location.hostname, + ) + ) { + presenceData.buttons = [ + { + label: 'Listen to Prambors', + url: 'https://live.pramborsfm.com', + }, + ] + timestamp ??= Date.now() + switch (document.location.hostname) { + case 'streaming.pramborsfm.com': { + const status = document.querySelector('#playerBtn')?.className + if (status === 'stopped') { + timestamp = null + delete presenceData.startTimestamp + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = pause + } + else if (status === 'playing') { + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = 'Listening' + presenceData.startTimestamp = timestamp + } + presenceData.state = document + .querySelectorAll('span[data-radium=true]') + .item(3) + .textContent + presenceData.details = document + .querySelectorAll('span[data-radium=true]') + .item(2) + .textContent + break + } + case 'live.pramborsfm.com': { + const buttonAction = [ + ...[...document.querySelectorAll('button')].pop()!.classList, + ] + .pop() + ?.split('--') + .pop() + if (buttonAction === 'play') { + timestamp = null + delete presenceData.startTimestamp + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = pause + } + else if (buttonAction === 'pause') { + presenceData.smallImageKey = Assets.Live + presenceData.smallImageText = 'Listening' + presenceData.startTimestamp = timestamp + } + presenceData.state = document.querySelector( + '.td-player-vertical__track-info__artist-name', + )?.textContent + presenceData.details = document.querySelector( + '.td-player-vertical__track-info__cue-title', + )?.textContent + break + } + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/P/PreMiD/metadata.json b/websites/P/PreMiD/metadata.json index f19d8e42dd8d..021e6dc88517 100644 --- a/websites/P/PreMiD/metadata.json +++ b/websites/P/PreMiD/metadata.json @@ -1,75 +1,75 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "contributors": [ - { - "name": "DooMlorD", - "id": "465105167751315471" - }, - { - "name": "Timeraa", - "id": "223238938716798978" - }, - { - "name": "TheDrop.", - "id": "293828021134295040" - }, - { - "name": "Callum", - "id": "506899274748133376" - }, - { - "name": "EGGSY", - "id": "162969778699501569" - } - ], - "service": "PreMiD", - "description": { - "en": "PreMiD adds Discord Rich Presence support to a lot of services you use and love.", - "nl": "PreMiD voegt ondersteuning voor Discord Rich Presence toe aan veel services die u gebruikt en waar u van houdt.", - "ga_IE": "Cuireann PreMiD tacaíocht Discord Rich Presence ar fáil do go leor seirbhísí a úsáideann tú agus a bhfuil grá agat dóibh.", - "de": "PreMiD ergänzt viele Dienste, die du nutzt und liebst, um die Unterstützung von Discord Rich Presence.", - "fr": "PreMiD ajoute le support de Discord Rich Presence à de nombreux services que vous utilisez et aimez.", - "tr": "PreMiD, kullandığınız internet servisleri için Discord profilinize Rich Presence bilgisi ekler.", - "vi_VN": "PreMiD thêm hỗ trợ Discord Rich Presence cho các dịch vụ bạn yêu thích và sử dụng.", - "ko_KR": "PreMiD는 당신이 사용하고 좋아하는 많은 서비스에 Discord Rich Presence 지원을 추가시킵니다." - }, - "url": [ - "premid.app", - "docs.premid.app", - "beta.premid.app", - "status.premid.app" - ], - "version": "3.1.15", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PreMiD/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PreMiD/assets/thumbnail.png", - "color": "#7289DA", - "category": "other", - "tags": [ - "discord", - "web-service", - "inception" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "time", - "title": "Show timestamps", - "icon": "fad fa-stopwatch", - "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": "Bas950", + "id": "241278257335500811" + }, + "contributors": [ + { + "name": "DooMlorD", + "id": "465105167751315471" + }, + { + "name": "Timeraa", + "id": "223238938716798978" + }, + { + "name": "TheDrop.", + "id": "293828021134295040" + }, + { + "name": "Callum", + "id": "506899274748133376" + }, + { + "name": "EGGSY", + "id": "162969778699501569" + } + ], + "service": "PreMiD", + "description": { + "en": "PreMiD adds Discord Rich Presence support to a lot of services you use and love.", + "nl": "PreMiD voegt ondersteuning voor Discord Rich Presence toe aan veel services die u gebruikt en waar u van houdt.", + "ga_IE": "Cuireann PreMiD tacaíocht Discord Rich Presence ar fáil do go leor seirbhísí a úsáideann tú agus a bhfuil grá agat dóibh.", + "de": "PreMiD ergänzt viele Dienste, die du nutzt und liebst, um die Unterstützung von Discord Rich Presence.", + "fr": "PreMiD ajoute le support de Discord Rich Presence à de nombreux services que vous utilisez et aimez.", + "tr": "PreMiD, kullandığınız internet servisleri için Discord profilinize Rich Presence bilgisi ekler.", + "vi_VN": "PreMiD thêm hỗ trợ Discord Rich Presence cho các dịch vụ bạn yêu thích và sử dụng.", + "ko_KR": "PreMiD는 당신이 사용하고 좋아하는 많은 서비스에 Discord Rich Presence 지원을 추가시킵니다." + }, + "url": [ + "premid.app", + "docs.premid.app", + "beta.premid.app", + "status.premid.app" + ], + "version": "3.1.15", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PreMiD/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PreMiD/assets/thumbnail.png", + "color": "#7289DA", + "category": "other", + "tags": [ + "discord", + "web-service", + "inception" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "time", + "title": "Show timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "showButtons", + "title": "Show buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/P/PreMiD/presence.ts b/websites/P/PreMiD/presence.ts index d9ecd7e88e1f..db73bfc8dc64 100644 --- a/websites/P/PreMiD/presence.ts +++ b/websites/P/PreMiD/presence.ts @@ -1,279 +1,278 @@ const presence = new Presence({ - clientId: "792735245488488458", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '792735245488488458', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) // checkmate javascript function pathIncludes(string: string): boolean { - return document.location.pathname.toLowerCase().includes(string); + return document.location.pathname.toLowerCase().includes(string) } async function getStrings() { - return presence.getStrings( - { - browsing: "general.browsing", - reading: "general.reading", - viewPage: "general.viewPage", - viewUser: "general.viewUser", - viewPresence: "premid.viewPresence", - docs: "premid.docs", - home: "premid.pageHome", - contributors: "premid.pageContributors", - downloads: "premid.pageDownloads", - store: "premid.pageStore", - cookies: "general.cookie", - privacy: "general.privacy", - terms: "general.terms", - about: "premid.pageAbout", - sysreq: "premid.pageSysReq", - install: "premid.pageInstall", - installFor: "premid.pageInstallFor", - yikes: "premid.pageTroubleshooting", - start: "premid.pageStart", - api: "premid.pageApi", - apiPage: "premid.pageApiVersion", - presenceDev: "premid.pagePresenceDev", - presenceGuide: "premid.pagePresenceGuide", - partners: "premid.partners", - viewing: "general.viewing", - incident: "general.incidentHistory", - uptime: "general.uptimeHistory", - class: "premid.pagePresenceClass", - slideshow: "premid.pageSlideshowClass", - iframe: "premid.pageIframe", - metadata: "premid.pageMetadata", - ts: "premid.pageTs", - btnViewPage: "general.buttonViewPage", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + browsing: 'general.browsing', + reading: 'general.reading', + viewPage: 'general.viewPage', + viewUser: 'general.viewUser', + viewPresence: 'premid.viewPresence', + docs: 'premid.docs', + home: 'premid.pageHome', + contributors: 'premid.pageContributors', + downloads: 'premid.pageDownloads', + store: 'premid.pageStore', + cookies: 'general.cookie', + privacy: 'general.privacy', + terms: 'general.terms', + about: 'premid.pageAbout', + sysreq: 'premid.pageSysReq', + install: 'premid.pageInstall', + installFor: 'premid.pageInstallFor', + yikes: 'premid.pageTroubleshooting', + start: 'premid.pageStart', + api: 'premid.pageApi', + apiPage: 'premid.pageApiVersion', + presenceDev: 'premid.pagePresenceDev', + presenceGuide: 'premid.pagePresenceGuide', + partners: 'premid.partners', + viewing: 'general.viewing', + incident: 'general.incidentHistory', + uptime: 'general.uptimeHistory', + class: 'premid.pagePresenceClass', + slideshow: 'premid.pageSlideshowClass', + iframe: 'premid.pageIframe', + metadata: 'premid.pageMetadata', + ts: 'premid.pageTs', + btnViewPage: 'general.buttonViewPage', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } -let strings: Awaited>, - oldLang: string = null, - host: string; +let strings: Awaited> +let oldLang: string | null = null +let host: string -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PreMiD/assets/logo.png", - }, - [newLang, time, showButtons] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("time"), - presence.getSetting("showButtons"), - ]); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PreMiD/assets/logo.png', + } + const [newLang, time, showButtons] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('time'), + presence.getSetting('showButtons'), + ]) - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - if (showButtons) { - presenceData.buttons = [ - { - label: strings.btnViewPage, - url: window.location.href, - }, - ]; - } + if (showButtons) { + presenceData.buttons = [ + { + label: strings.btnViewPage, + url: window.location.href, + }, + ] + } - if (time) presenceData.startTimestamp = browsingTimestamp; + if (time) + presenceData.startTimestamp = browsingTimestamp - host = document.location.hostname; + host = document.location.hostname - switch (host) { - case "premid.app": - case "beta.premid.app": { - host.includes("beta") - ? (presenceData.smallImageText = `BETA | ${strings.browsing}`) - : (presenceData.smallImageText = strings.browsing); - presenceData.smallImageKey = Assets.Search; + switch (host) { + case 'premid.app': + case 'beta.premid.app': { + host.includes('beta') + ? (presenceData.smallImageText = `BETA | ${strings.browsing}`) + : (presenceData.smallImageText = strings.browsing) + presenceData.smallImageKey = Assets.Search - let icon; + let icon - switch (true) { - case pathIncludes("/downloads"): - presenceData.details = strings.viewPage; - presenceData.state = strings.downloads; - break; - case pathIncludes("/contributors"): - presenceData.details = strings.viewPage; - presenceData.state = strings.contributors; - break; - case pathIncludes("/beta"): - presenceData.details = strings.viewPage; - presenceData.state = "BETA"; - break; - case pathIncludes("/partner"): - presenceData.details = strings.viewPage; - presenceData.state = strings.partners; - break; - case pathIncludes("/cookies"): - presenceData.details = strings.viewPage; - presenceData.state = strings.cookies; - break; - case pathIncludes("/privacy"): - presenceData.details = strings.viewPage; - presenceData.state = strings.privacy; - break; - case pathIncludes("/tos"): - presenceData.details = strings.viewPage; - presenceData.state = strings.terms; - break; - case pathIncludes("/users/"): - icon = document.querySelector( - "div.user-avatar img" - )?.src; + switch (true) { + case pathIncludes('/downloads'): + presenceData.details = strings.viewPage + presenceData.state = strings.downloads + break + case pathIncludes('/contributors'): + presenceData.details = strings.viewPage + presenceData.state = strings.contributors + break + case pathIncludes('/beta'): + presenceData.details = strings.viewPage + presenceData.state = 'BETA' + break + case pathIncludes('/partner'): + presenceData.details = strings.viewPage + presenceData.state = strings.partners + break + case pathIncludes('/cookies'): + presenceData.details = strings.viewPage + presenceData.state = strings.cookies + break + case pathIncludes('/privacy'): + presenceData.details = strings.viewPage + presenceData.state = strings.privacy + break + case pathIncludes('/tos'): + presenceData.details = strings.viewPage + presenceData.state = strings.terms + break + case pathIncludes('/users/'): + icon = document.querySelector( + 'div.user-avatar img', + )?.src - presenceData.details = strings.viewUser; - presenceData.state = document.querySelector("div.user-data p") - ? document - .querySelector("div.user-data p") - .textContent.replace(/[\s\n]+/gi, "") - : "USER NOT FOUND..."; + presenceData.details = strings.viewUser + presenceData.state = document.querySelector('div.user-data p') + ? document + .querySelector('div.user-data p') + ?.textContent + ?.replace(/\s+/g, '') + : 'USER NOT FOUND...' - if (icon) { - presenceData.largeImageKey = icon; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/P/PreMiD/assets/logo.png"; - } - break; - case pathIncludes("/store/presences/"): - icon = document.querySelector( - "div.header__title div.section img" - )?.src; + if (icon) { + presenceData.largeImageKey = icon + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/P/PreMiD/assets/logo.png' + } + break + case pathIncludes('/store/presences/'): + icon = document.querySelector( + 'div.header__title div.section img', + )?.src - presenceData.details = strings.viewPresence; - presenceData.state = document.querySelector( - ".header__title > div > h1" - ) - ? document - .querySelector(".header__title > div > h1") - .textContent.replace(/^\s+|\s+$/g, "") - : strings.store; + presenceData.details = strings.viewPresence + presenceData.state = document.querySelector( + '.header__title > div > h1', + ) + ? document + .querySelector('.header__title > div > h1') + ?.textContent + ?.replace(/^\s+|\s+$/g, '') + : strings.store - if (icon) { - presenceData.largeImageKey = icon; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/P/PreMiD/assets/logo.png"; - } - break; - case pathIncludes("/store"): - presenceData.details = strings.viewPage; - presenceData.state = strings.store; - break; - default: - presenceData.details = strings.viewPage; - presenceData.state = strings.home; - } + if (icon) { + presenceData.largeImageKey = icon + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/P/PreMiD/assets/logo.png' + } + break + case pathIncludes('/store'): + presenceData.details = strings.viewPage + presenceData.state = strings.store + break + default: + presenceData.details = strings.viewPage + presenceData.state = strings.home + } - break; - } - case "docs.premid.app": { - presenceData.details = `${strings.docs} | ${strings.viewPage}`; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.reading; + break + } + case 'docs.premid.app': { + presenceData.details = `${strings.docs} | ${strings.viewPage}` + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.reading - switch (true) { - case pathIncludes("/troubleshooting"): - presenceData.state = strings.yikes; - break; - case pathIncludes("/install/requirements"): - presenceData.state = strings.sysreq; - break; - case pathIncludes("/install/windows"): - presenceData.state = strings.installFor.replace("{0}", "Windows"); - break; - case pathIncludes("/install/macos"): - presenceData.state = strings.installFor.replace("{0}", "MacOS"); - break; - case pathIncludes("/install/linux"): - presenceData.state = strings.installFor.replace("{0}", "Linux"); - break; - case pathIncludes("/install/firefox"): - presenceData.state = strings.installFor.replace("{0}", "Firefox"); - break; - case pathIncludes("/install/chromium"): - presenceData.state = strings.installFor.replace( - "{0}", - "Chromium-based browsers" - ); - break; - case pathIncludes("/install"): - presenceData.state = strings.install; - break; - case pathIncludes("/dev/presence/guidelines"): - presenceData.state = strings.presenceGuide; - break; - case pathIncludes("/dev/presence/tsconfig"): - presenceData.state = strings.ts; - break; - case pathIncludes("/dev/presence/metadata"): - presenceData.state = strings.metadata; - break; - case pathIncludes("/dev/presence/iframe"): - presenceData.state = strings.iframe; - break; - case pathIncludes("/dev/presence/class"): - presenceData.state = strings.class; - break; - case pathIncludes("/dev/presence/slideshow"): - presenceData.state = strings.slideshow; - break; - case pathIncludes("/dev/presence"): - presenceData.state = strings.presenceDev; - break; - case pathIncludes("/dev/api/v3"): - presenceData.state = strings.apiPage.replace("{0}", "3"); - break; - case pathIncludes("/dev/api/v2"): - presenceData.state = strings.apiPage.replace("{0}", "2"); - break; - case pathIncludes("/dev/api/v1"): - presenceData.state = strings.apiPage.replace("{0}", "1"); - break; - case pathIncludes("/dev/api"): - presenceData.state = strings.api; - break; - case pathIncludes("/dev"): - presenceData.state = strings.start; - break; - case pathIncludes("/about"): - presenceData.state = strings.about; - break; - case pathIncludes("/home"): - default: - presenceData.state = strings.home; - } + switch (true) { + case pathIncludes('/troubleshooting'): + presenceData.state = strings.yikes + break + case pathIncludes('/install/requirements'): + presenceData.state = strings.sysreq + break + case pathIncludes('/install/windows'): + presenceData.state = strings.installFor.replace('{0}', 'Windows') + break + case pathIncludes('/install/macos'): + presenceData.state = strings.installFor.replace('{0}', 'MacOS') + break + case pathIncludes('/install/linux'): + presenceData.state = strings.installFor.replace('{0}', 'Linux') + break + case pathIncludes('/install/firefox'): + presenceData.state = strings.installFor.replace('{0}', 'Firefox') + break + case pathIncludes('/install/chromium'): + presenceData.state = strings.installFor.replace( + '{0}', + 'Chromium-based browsers', + ) + break + case pathIncludes('/install'): + presenceData.state = strings.install + break + case pathIncludes('/dev/presence/guidelines'): + presenceData.state = strings.presenceGuide + break + case pathIncludes('/dev/presence/tsconfig'): + presenceData.state = strings.ts + break + case pathIncludes('/dev/presence/metadata'): + presenceData.state = strings.metadata + break + case pathIncludes('/dev/presence/iframe'): + presenceData.state = strings.iframe + break + case pathIncludes('/dev/presence/class'): + presenceData.state = strings.class + break + case pathIncludes('/dev/presence/slideshow'): + presenceData.state = strings.slideshow + break + case pathIncludes('/dev/presence'): + presenceData.state = strings.presenceDev + break + case pathIncludes('/dev/api/v3'): + presenceData.state = strings.apiPage.replace('{0}', '3') + break + case pathIncludes('/dev/api/v2'): + presenceData.state = strings.apiPage.replace('{0}', '2') + break + case pathIncludes('/dev/api/v1'): + presenceData.state = strings.apiPage.replace('{0}', '1') + break + case pathIncludes('/dev/api'): + presenceData.state = strings.api + break + case pathIncludes('/dev'): + presenceData.state = strings.start + break + case pathIncludes('/about'): + presenceData.state = strings.about + break + case pathIncludes('/home'): + default: + presenceData.state = strings.home + } - break; - } - case "status.premid.app": { - presenceData.details = `Status page | ${strings.viewing}`; - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = strings.browsing; + break + } + case 'status.premid.app': { + presenceData.details = `Status page | ${strings.viewing}` + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = strings.browsing - switch (true) { - case pathIncludes("/incidents"): - presenceData.details = `${strings.viewing} ${document.title.replace( - "PreMiD Status - ", - "" - )}`; - break; - case pathIncludes("/history"): - presenceData.state = strings.incident; - break; - case pathIncludes("/uptime"): - presenceData.state = strings.uptime; - break; - default: - presenceData.state = strings.home; - } + switch (true) { + case pathIncludes('/incidents'): + presenceData.details = `${strings.viewing} ${document.title.replace( + 'PreMiD Status - ', + '', + )}` + break + case pathIncludes('/history'): + presenceData.state = strings.incident + break + case pathIncludes('/uptime'): + presenceData.state = strings.uptime + break + default: + presenceData.state = strings.home + } - break; - } - // No default - } - presence.setActivity(presenceData); -}); + break + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/P/PresenceDB/metadata.json b/websites/P/PresenceDB/metadata.json index fc795731076f..14b4e5ab01a5 100644 --- a/websites/P/PresenceDB/metadata.json +++ b/websites/P/PresenceDB/metadata.json @@ -1,39 +1,39 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "vasc", - "id": "346977366569910274" - }, - "service": "PresenceDB", - "description": { - "en": "Tracks and saves the playtime of your Discord activities.", - "de": "Verfolgt und speichert die Spielzeit Ihrer Discord Aktivitäten." - }, - "url": [ - "www.presencedb.com", - "preview.presencedb.com" - ], - "regExp": "(www|preview)[.]presencedb[.]com[/]", - "version": "1.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PresenceDB/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PresenceDB/assets/thumbnail.png", - "color": "#fff", - "category": "other", - "tags": [ - "presencedb", - "database" - ], - "settings": [ - { - "id": "lang", - "title": "Language", - "icon": "fas fa-language", - "value": 0, - "values": [ - "English", - "German" - ] - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "vasc", + "id": "346977366569910274" + }, + "service": "PresenceDB", + "description": { + "en": "Tracks and saves the playtime of your Discord activities.", + "de": "Verfolgt und speichert die Spielzeit Ihrer Discord Aktivitäten." + }, + "url": [ + "www.presencedb.com", + "preview.presencedb.com" + ], + "regExp": "(www|preview)[.]presencedb[.]com[/]", + "version": "1.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PresenceDB/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PresenceDB/assets/thumbnail.png", + "color": "#fff", + "category": "other", + "tags": [ + "presencedb", + "database" + ], + "settings": [ + { + "id": "lang", + "title": "Language", + "icon": "fas fa-language", + "value": 0, + "values": [ + "English", + "German" + ] + } + ] +} diff --git a/websites/P/PresenceDB/presence.ts b/websites/P/PresenceDB/presence.ts index 2429a6c0a380..455552b9b0db 100644 --- a/websites/P/PresenceDB/presence.ts +++ b/websites/P/PresenceDB/presence.ts @@ -1,118 +1,122 @@ const presence = new Presence({ - clientId: "840759396103749633", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '840759396103749633', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -async function getTranslation(name: string) { - const language = - (await presence.getSetting<0 | 1>("lang")) === 0 ? "en" : "de"; +async function getTranslation(name: string): Promise { + const language = (await presence.getSetting<0 | 1>('lang')) === 0 ? 'en' : 'de' - switch (name) { - case "home": - switch (language) { - case "de": - return "Durchsucht die Startseite"; - default: - return "Browsing home page"; - } - case "search": - switch (language) { - case "de": - return "Sucht nach etwas"; - default: - return "Searching for something"; - } - case "faq": - switch (language) { - case "de": - return "Durchsucht das FAQ"; - default: - return "Browsing FAQ page"; - } - case "activity": - switch (language) { - case "de": - return "Schaut sich Aktivität an"; - default: - return "Viewing activity"; - } - case "user": - switch (language) { - case "de": - return "Schaut sich Benutzer an"; - default: - return "Viewing user"; - } - case "settings": - switch (language) { - case "de": - return "Durchsucht die Einstellungen"; - default: - return "Browsing settings page"; - } - case "viewUser": - switch (language) { - case "de": - return "Benutzer anzeigen"; - default: - return "View user"; - } - case "viewActivity": - switch (language) { - case "de": - return "Aktivität anzeigen"; - default: - return "View activity"; - } - } + switch (name) { + case 'home': + switch (language) { + case 'de': + return 'Durchsucht die Startseite' + default: + return 'Browsing home page' + } + case 'search': + switch (language) { + case 'de': + return 'Sucht nach etwas' + default: + return 'Searching for something' + } + case 'faq': + switch (language) { + case 'de': + return 'Durchsucht das FAQ' + default: + return 'Browsing FAQ page' + } + case 'activity': + switch (language) { + case 'de': + return 'Schaut sich Aktivität an' + default: + return 'Viewing activity' + } + case 'user': + switch (language) { + case 'de': + return 'Schaut sich Benutzer an' + default: + return 'Viewing user' + } + case 'settings': + switch (language) { + case 'de': + return 'Durchsucht die Einstellungen' + default: + return 'Browsing settings page' + } + case 'viewUser': + switch (language) { + case 'de': + return 'Benutzer anzeigen' + default: + return 'View user' + } + case 'viewActivity': + switch (language) { + case 'de': + return 'Aktivität anzeigen' + default: + return 'View activity' + } + } + return 'Unknown' } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PresenceDB/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PresenceDB/assets/logo.png', + startTimestamp: browsingTimestamp, + } - switch (window.location.pathname) { - case "/": { - presenceData.details = await getTranslation("home"); - break; - } - case "/search": { - presenceData.details = await getTranslation("search"); - break; - } - case "/faq": { - presenceData.details = await getTranslation("faq"); - break; - } - default: - if (window.location.pathname.includes("/activity/")) { - if (!document.querySelector("#activityName")) return; - presenceData.details = await getTranslation("activity"); - presenceData.state = - document.querySelector("#activityName").textContent; - presenceData.buttons = [ - { - label: await getTranslation("viewActivity"), - url: window.location.href, - }, - ]; - } else if (window.location.pathname.includes("/user/")) { - if (!document.querySelector("#userName")) return; - presenceData.details = await getTranslation("user"); - presenceData.state = document.querySelector("#userName").textContent; - presenceData.buttons = [ - { - label: await getTranslation("viewUser"), - url: window.location.href, - }, - ]; - } else if (window.location.pathname === "/settings") - presenceData.details = await getTranslation("settings"); - } + switch (window.location.pathname) { + case '/': { + presenceData.details = await getTranslation('home') + break + } + case '/search': { + presenceData.details = await getTranslation('search') + break + } + case '/faq': { + presenceData.details = await getTranslation('faq') + break + } + default: + if (window.location.pathname.includes('/activity/')) { + if (!document.querySelector('#activityName')) + return + presenceData.details = await getTranslation('activity') + presenceData.state = document.querySelector('#activityName')?.textContent + presenceData.buttons = [ + { + label: await getTranslation('viewActivity'), + url: window.location.href, + }, + ] + } + else if (window.location.pathname.includes('/user/')) { + if (!document.querySelector('#userName')) + return + presenceData.details = await getTranslation('user') + presenceData.state = document.querySelector('#userName')?.textContent + presenceData.buttons = [ + { + label: await getTranslation('viewUser'), + url: window.location.href, + }, + ] + } + else if (window.location.pathname === '/settings') { + presenceData.details = await getTranslation('settings') + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/Prime Video/metadata.json b/websites/P/Prime Video/metadata.json index 61c819551569..f0ec8bd8e79c 100644 --- a/websites/P/Prime Video/metadata.json +++ b/websites/P/Prime Video/metadata.json @@ -1,34 +1,34 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "contributors": [ - { - "name": "Spinne", - "id": "363790841636192259" - } - ], - "service": "Prime Video", - "description": { - "en": "Enjoy exclusive Amazon Originals as well as popular movies and TV shows. Watch anytime, anywhere. Start your free trial.", - "fr": "Découvrez les programmes Amazon Original exclusifs et de nombreux films et séries populaires. Regardez quand vous voulez, où vous voulez. Commencez votre essai gratuit.", - "de": "Spielfilme und Serien online streamen, als Einzelabruf online leihen oder kaufen bei Prime Video, Amazons großer Video on Demand Online-Videothek.", - "nl": "Geniet van exclusieve Amazon Originals en populaire films en tv-programma's. Bekijk altijd en overal. Start uw gratis proefperiode.", - "ja_JP": "ここでしか見れない、先行や独占配信作品が続々追加!まずは30日間無料でお試し" - }, - "url": "www.primevideo.com", - "regExp": "(([a-z0-9-]+[.])*amazon([.][a-z]+)+[/]((-[/])?(([a-z0-9]+)[/])?)?Prime-Video|Prime-Instant-Video|Amazon-Video|gp[/]video)|([a-z0-9-]+[.])*primevideo([.][a-z]+)+([/]?)?", - "version": "2.1.32", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Prime%20Video/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Prime%20Video/assets/thumbnail.jpg", - "color": "#FFFFFF", - "category": "videos", - "tags": [ - "video", - "amazon", - "prime" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "contributors": [ + { + "name": "Spinne", + "id": "363790841636192259" + } + ], + "service": "Prime Video", + "description": { + "en": "Enjoy exclusive Amazon Originals as well as popular movies and TV shows. Watch anytime, anywhere. Start your free trial.", + "fr": "Découvrez les programmes Amazon Original exclusifs et de nombreux films et séries populaires. Regardez quand vous voulez, où vous voulez. Commencez votre essai gratuit.", + "de": "Spielfilme und Serien online streamen, als Einzelabruf online leihen oder kaufen bei Prime Video, Amazons großer Video on Demand Online-Videothek.", + "nl": "Geniet van exclusieve Amazon Originals en populaire films en tv-programma's. Bekijk altijd en overal. Start uw gratis proefperiode.", + "ja_JP": "ここでしか見れない、先行や独占配信作品が続々追加!まずは30日間無料でお試し" + }, + "url": "www.primevideo.com", + "regExp": "(([a-z0-9-]+[.])*amazon([.][a-z]+)+[/]((-[/])?(([a-z0-9]+)[/])?)?Prime-Video|Prime-Instant-Video|Amazon-Video|gp[/]video)|([a-z0-9-]+[.])*primevideo([.][a-z]+)+([/]?)?", + "version": "2.1.32", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Prime%20Video/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Prime%20Video/assets/thumbnail.jpg", + "color": "#FFFFFF", + "category": "videos", + "tags": [ + "video", + "amazon", + "prime" + ] +} diff --git a/websites/P/Prime Video/presence.ts b/websites/P/Prime Video/presence.ts index eefe4f4147df..da0cd2cf4d96 100644 --- a/websites/P/Prime Video/presence.ts +++ b/websites/P/Prime Video/presence.ts @@ -1,119 +1,133 @@ const presence = new Presence({ - clientId: "705139844883677224", - }), - strings = presence.getStrings({ - paused: "general.paused", - playing: "general.playing", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '705139844883677224', +}) +const strings = presence.getStrings({ + paused: 'general.paused', + playing: 'general.playing', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - type: ActivityType.Watching, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Prime%20Video/assets/logo.png", - }; - presenceData.startTimestamp = browsingTimestamp; - const title: string = - document.querySelector( - ".webPlayerSDKUiContainer > div > div > div > div:nth-child(2) > div > div:nth-child(4) > div > div:nth-child(2) > div:nth-child(2) > div > div > div > h1" - )?.textContent || - document.querySelector(".atvwebplayersdk-title-text")?.textContent, - title2: string = - document.querySelector(".av-detail-section > div > h1")?.textContent || - document.querySelector( - ".av-detail-section > div > h1 > div > img" - )?.alt; - if (title || title2) { - let video = document.querySelector( - ".scalingVideoContainer > div.scalingVideoContainerBottom > div > video" - ); - if (video === null || isNaN(video.duration)) - video = document.querySelector("video"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + type: ActivityType.Watching, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Prime%20Video/assets/logo.png', + } + presenceData.startTimestamp = browsingTimestamp + const title = document.querySelector( + '.webPlayerSDKUiContainer > div > div > div > div:nth-child(2) > div > div:nth-child(4) > div > div:nth-child(2) > div:nth-child(2) > div > div > div > h1', + )?.textContent + || document.querySelector('.atvwebplayersdk-title-text')?.textContent + const title2 = document.querySelector('.av-detail-section > div > h1')?.textContent + || document.querySelector( + '.av-detail-section > div > h1 > div > img', + )?.alt + if (title || title2) { + let video = document.querySelector( + '.scalingVideoContainer > div.scalingVideoContainerBottom > div > video', + ) + if (video === null || Number.isNaN(video.duration)) + video = document.querySelector('video') - if (video === null || isNaN(video.duration)) - video = document.querySelector("video:nth-child(2)"); + if (video === null || Number.isNaN(video.duration)) + video = document.querySelector('video:nth-child(2)') - const subtitle = - document.querySelector( - ".webPlayerSDKUiContainer > div > div > div > div:nth-child(2) > div > div:nth-child(4) > div > div:nth-child(2) > div:nth-child(2) > div > div > div > h2" - ) || - document.querySelector(".atvwebplayersdk-subtitle-text"); + const subtitle = document.querySelector( + '.webPlayerSDKUiContainer > div > div > div > div:nth-child(2) > div > div:nth-child(4) > div > div:nth-child(2) > div:nth-child(2) > div > div > div > h2', + ) + || document.querySelector('.atvwebplayersdk-subtitle-text') - if (video && title && !video.className.includes("tst")) { - presenceData.details = title; - if ( - subtitle && - subtitle.textContent && - subtitle.textContent.trim() !== title.trim() - ) - presenceData.state = subtitle.textContent; + if (video && title && !video.className.includes('tst')) { + presenceData.details = title + if ( + subtitle + && subtitle.textContent + && subtitle.textContent.trim() !== title.trim() + ) { + presenceData.state = subtitle.textContent + } - if (video.paused) { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = (await strings).paused; - delete presenceData.startTimestamp; - } else { - const [unformattedCurrentTime, unformattedDuration] = document - .querySelector(".atvwebplayersdk-timeindicator-text") - .textContent.trim() - .split(" / "); - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - presence.timestampFromFormat(unformattedCurrentTime), - presence.timestampFromFormat(unformattedDuration) + - presence.timestampFromFormat(unformattedCurrentTime) - ); - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = (await strings).playing; - } - } else if (video && !video.className.includes("tst")) { - if (title2 !== "") presenceData.details = title2; - if (video.paused) { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = (await strings).paused; - delete presenceData.startTimestamp; - } else { - const [unformattedCurrentTime, unformattedDuration] = document - .querySelector(".atvwebplayersdk-timeindicator-text") - .textContent.trim() - .split(" / "); - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - presence.timestampFromFormat(unformattedCurrentTime), - presence.timestampFromFormat(unformattedDuration) + - presence.timestampFromFormat(unformattedCurrentTime) - ); - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = (await strings).playing; - } - } else if (title2) { - presenceData.details = "Viewing:"; - presenceData.state = title2; - } else if (document.location.pathname.includes("shop")) - presenceData.details = "Browsing the store..."; - else presenceData.details = "Browsing..."; - } else if (document.location.pathname.includes("/home/")) - presenceData.details = "Browsing..."; - else if (document.location.pathname.includes("shop")) - presenceData.details = "Browsing the store..."; - else if (document.location.pathname.includes("/tv/")) - presenceData.details = "Browsing TV-Series"; - else if (document.location.pathname.includes("/movie/")) - presenceData.details = "Browsing Movies"; - else if (document.location.pathname.includes("/kids/")) - presenceData.details = "Browsing Movies for kids"; - else if ( - document.location.pathname.includes("/search/") && - document.querySelector(".av-refine-bar-summaries") - ) { - presenceData.details = "Searching for:"; - [presenceData.state] = document - .querySelector(".av-refine-bar-summaries") - .textContent.split(/["„]/)[1] - .split(/[”"]/); - presenceData.smallImageKey = Assets.Search; - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (video.paused) { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = (await strings).paused + delete presenceData.startTimestamp + } + else { + const [unformattedCurrentTime, unformattedDuration] = document + .querySelector('.atvwebplayersdk-timeindicator-text') + ?.textContent + ?.trim() + .split(' / ') ?? []; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + presence.timestampFromFormat(unformattedCurrentTime), + presence.timestampFromFormat(unformattedDuration) + + presence.timestampFromFormat(unformattedCurrentTime), + ) + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = (await strings).playing + } + } + else if (video && !video.className.includes('tst')) { + if (title2 !== '') + presenceData.details = title2 + if (video.paused) { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = (await strings).paused + delete presenceData.startTimestamp + } + else { + const [unformattedCurrentTime, unformattedDuration] = document + .querySelector('.atvwebplayersdk-timeindicator-text') + ?.textContent + ?.trim() + .split(' / ') ?? []; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + presence.timestampFromFormat(unformattedCurrentTime), + presence.timestampFromFormat(unformattedDuration) + + presence.timestampFromFormat(unformattedCurrentTime), + ) + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = (await strings).playing + } + } + else if (title2) { + presenceData.details = 'Viewing:' + presenceData.state = title2 + } + else if (document.location.pathname.includes('shop')) { + presenceData.details = 'Browsing the store...' + } + else { + presenceData.details = 'Browsing...' + } + } + else if (document.location.pathname.includes('/home/')) { + presenceData.details = 'Browsing...' + } + else if (document.location.pathname.includes('shop')) { + presenceData.details = 'Browsing the store...' + } + else if (document.location.pathname.includes('/tv/')) { + presenceData.details = 'Browsing TV-Series' + } + else if (document.location.pathname.includes('/movie/')) { + presenceData.details = 'Browsing Movies' + } + else if (document.location.pathname.includes('/kids/')) { + presenceData.details = 'Browsing Movies for kids' + } + else if ( + document.location.pathname.includes('/search/') + && document.querySelector('.av-refine-bar-summaries') + ) { + presenceData.details = 'Searching for:'; + [presenceData.state] = document + .querySelector('.av-refine-bar-summaries') + ?.textContent + ?.split(/["„]/)[1] + .split(/[”"]/) ?? [] + presenceData.smallImageKey = Assets.Search + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/ProBot/metadata.json b/websites/P/ProBot/metadata.json index 7997faab79e2..3087647fdeac 100644 --- a/websites/P/ProBot/metadata.json +++ b/websites/P/ProBot/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "NMW03", - "id": "534099893979971584" - }, - "contributors": [ - { - "name": "a@a", - "id": "405028899798384640" - } - ], - "service": "ProBot", - "description": { - "en": "Welcome images, moderation, leveling, reaction roles, logs, high quality music and many many more!", - "nl": "Welkomstafbeeldingen, moderatie, niveaus, reactie rollen, logboeken, muziek van hoge kwaliteit en nog veel meer!" - }, - "url": "probot.io", - "version": "2.0.11", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/ProBot/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/ProBot/assets/thumbnail.png", - "color": "#450F40", - "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" + }, + "contributors": [ + { + "name": "a@a", + "id": "405028899798384640" + } + ], + "service": "ProBot", + "description": { + "en": "Welcome images, moderation, leveling, reaction roles, logs, high quality music and many many more!", + "nl": "Welkomstafbeeldingen, moderatie, niveaus, reactie rollen, logboeken, muziek van hoge kwaliteit en nog veel meer!" + }, + "url": "probot.io", + "version": "2.0.11", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/ProBot/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/ProBot/assets/thumbnail.png", + "color": "#450F40", + "category": "other", + "tags": [ + "bot", + "discord" + ] +} diff --git a/websites/P/ProBot/presence.ts b/websites/P/ProBot/presence.ts index 111b5d51c758..af216d474bca 100644 --- a/websites/P/ProBot/presence.ts +++ b/websites/P/ProBot/presence.ts @@ -1,164 +1,194 @@ const presence = new Presence({ - clientId: "655050505726197781", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '655050505726197781', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/ProBot/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/ProBot/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (document.location.pathname === "/") - presenceData.details = "Viewing the main page"; - else if (document.location.pathname.includes("/dashboard")) { - presenceData.details = "Viewing the dashboard"; - presenceData.buttons = [ - { - label: "Go to Dashboard", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/commands")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Commands"; - presenceData.buttons = [ - { - label: "View ProBot Commands", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("premium")) { - if (document.location.pathname.includes("/manage")) - presenceData.details = "Managing their Premium settings"; - else presenceData.details = "Reading more about Premium"; - } else if (document.location.pathname.includes("/store")) { - presenceData.details = "Managing their"; - if (document.location.pathname.includes("/profile")) - presenceData.state = "Profile Backgrounds"; - else if (document.location.pathname.includes("/rank")) - presenceData.state = "ID Backgrounds"; - else presenceData.state = "Purchased items"; - } else if (document.location.pathname.includes("/badges")) { - presenceData.details = "Managing their"; - presenceData.state = "Profile Badges"; - } else if (document.location.pathname.includes("/xp")) { - presenceData.details = "Viewing leaderboard:"; - presenceData.state = "Most XP"; - presenceData.buttons = [ - { - label: "View the leaderboard", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/credits")) { - presenceData.details = "Viewing leaderboard:"; - presenceData.state = "Most credits"; - presenceData.buttons = [ - { - label: "View the leaderboard", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/daily")) - presenceData.details = "Claiming their daily credits"; - else if (document.location.pathname.includes("/transactions")) { - presenceData.details = "Viewing their"; - presenceData.state = "Credit transactions history"; - } else if (document.location.pathname.includes("terms-of-use")) { - presenceData.details = "Reading the Terms Of Use"; - presenceData.buttons = [ - { - label: "Read the Terms of Use", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("privacy-policy")) { - presenceData.details = "Reading the Privacy Policy"; - presenceData.buttons = [ - { - label: "Read the Privacy Policy", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("refund-policy")) { - presenceData.details = "Reading the Refund Policy"; - presenceData.buttons = [ - { - label: "Read the Refund Policy", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/server/")) { - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/P/ProBot/assets/logo.png"; - presenceData.largeImageKey = document.querySelector( - "#sidebar_sidebar__avatar__QDGRP" - ).src; - presenceData.smallImageText = document.querySelector( - "#sidebar_sidebar__server-info__03ViT > h4" - ).textContent; - if (document.location.pathname.includes("/settings")) - presenceData.details = "Changing the Server Settings"; - else if (document.location.pathname.includes("embed")) - presenceData.details = "Managing the Embed Messages"; - else if (document.location.pathname.includes("panel_logs")) - presenceData.details = "Viewing Control Panel Logs"; - else if (document.location.pathname.includes("mod_actions")) - presenceData.details = "Viewing Moderation Actions"; - else if (document.location.pathname.includes("utility")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Utility Commands"; - } else if (document.location.pathname.includes("mod")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Moderation Commands"; - } else if (document.location.pathname.includes("automod")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Automod Features"; - } else if (document.location.pathname.includes("welcomer")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Welcome & Goodbye Features"; - } else if (document.location.pathname.includes("auto_responder")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Auto Responder Features"; - } else if (document.location.pathname.includes("leveling")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Leveling System Features"; - } else if (document.location.pathname.includes("logs")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Server Log Features"; - } else if (document.location.pathname.includes("colors")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Color Commands & Features"; - } else if (document.location.pathname.includes("autoroles")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Auto Role Features"; - } else if (document.location.pathname.includes("reaction_roles")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Reaction Roles"; - } else if (document.location.pathname.includes("music")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Music Commands"; - } else if (document.location.pathname.includes("temp_link")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Temp Link Features"; - } else if (document.location.pathname.includes("voice_online")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Voice Online Feature"; - } else if (document.location.pathname.includes("anti_raid")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "Anti-Raid Features"; - } else if (document.location.pathname.includes("protection")) { - presenceData.details = "Changing Module Settings"; - presenceData.state = "VIP Protection Features"; - } else { - presenceData.details = "Server Overview page"; - presenceData.state = presenceData.smallImageText = document.querySelector( - "#sidebar_sidebar__server-info__03ViT > h4" - ).textContent; - } - } + if (document.location.pathname === '/') { + presenceData.details = 'Viewing the main page' + } + else if (document.location.pathname.includes('/dashboard')) { + presenceData.details = 'Viewing the dashboard' + presenceData.buttons = [ + { + label: 'Go to Dashboard', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/commands')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Commands' + presenceData.buttons = [ + { + label: 'View ProBot Commands', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('premium')) { + if (document.location.pathname.includes('/manage')) + presenceData.details = 'Managing their Premium settings' + else presenceData.details = 'Reading more about Premium' + } + else if (document.location.pathname.includes('/store')) { + presenceData.details = 'Managing their' + if (document.location.pathname.includes('/profile')) + presenceData.state = 'Profile Backgrounds' + else if (document.location.pathname.includes('/rank')) + presenceData.state = 'ID Backgrounds' + else presenceData.state = 'Purchased items' + } + else if (document.location.pathname.includes('/badges')) { + presenceData.details = 'Managing their' + presenceData.state = 'Profile Badges' + } + else if (document.location.pathname.includes('/xp')) { + presenceData.details = 'Viewing leaderboard:' + presenceData.state = 'Most XP' + presenceData.buttons = [ + { + label: 'View the leaderboard', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/credits')) { + presenceData.details = 'Viewing leaderboard:' + presenceData.state = 'Most credits' + presenceData.buttons = [ + { + label: 'View the leaderboard', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/daily')) { + presenceData.details = 'Claiming their daily credits' + } + else if (document.location.pathname.includes('/transactions')) { + presenceData.details = 'Viewing their' + presenceData.state = 'Credit transactions history' + } + else if (document.location.pathname.includes('terms-of-use')) { + presenceData.details = 'Reading the Terms Of Use' + presenceData.buttons = [ + { + label: 'Read the Terms of Use', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('privacy-policy')) { + presenceData.details = 'Reading the Privacy Policy' + presenceData.buttons = [ + { + label: 'Read the Privacy Policy', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('refund-policy')) { + presenceData.details = 'Reading the Refund Policy' + presenceData.buttons = [ + { + label: 'Read the Refund Policy', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/server/')) { + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/P/ProBot/assets/logo.png' + presenceData.largeImageKey = document.querySelector( + '#sidebar_sidebar__avatar__QDGRP', + )?.src + presenceData.smallImageText = document.querySelector( + '#sidebar_sidebar__server-info__03ViT > h4', + )?.textContent + if (document.location.pathname.includes('/settings')) { + presenceData.details = 'Changing the Server Settings' + } + else if (document.location.pathname.includes('embed')) { + presenceData.details = 'Managing the Embed Messages' + } + else if (document.location.pathname.includes('panel_logs')) { + presenceData.details = 'Viewing Control Panel Logs' + } + else if (document.location.pathname.includes('mod_actions')) { + presenceData.details = 'Viewing Moderation Actions' + } + else if (document.location.pathname.includes('utility')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Utility Commands' + } + else if (document.location.pathname.includes('mod')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Moderation Commands' + } + else if (document.location.pathname.includes('automod')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Automod Features' + } + else if (document.location.pathname.includes('welcomer')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Welcome & Goodbye Features' + } + else if (document.location.pathname.includes('auto_responder')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Auto Responder Features' + } + else if (document.location.pathname.includes('leveling')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Leveling System Features' + } + else if (document.location.pathname.includes('logs')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Server Log Features' + } + else if (document.location.pathname.includes('colors')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Color Commands & Features' + } + else if (document.location.pathname.includes('autoroles')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Auto Role Features' + } + else if (document.location.pathname.includes('reaction_roles')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Reaction Roles' + } + else if (document.location.pathname.includes('music')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Music Commands' + } + else if (document.location.pathname.includes('temp_link')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Temp Link Features' + } + else if (document.location.pathname.includes('voice_online')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Voice Online Feature' + } + else if (document.location.pathname.includes('anti_raid')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'Anti-Raid Features' + } + else if (document.location.pathname.includes('protection')) { + presenceData.details = 'Changing Module Settings' + presenceData.state = 'VIP Protection Features' + } + else { + presenceData.details = 'Server Overview page' + presenceData.state = presenceData.smallImageText = document.querySelector( + '#sidebar_sidebar__server-info__03ViT > h4', + )?.textContent + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/Proxer/iframe.ts b/websites/P/Proxer/iframe.ts index 7f14b8042a7e..4143eda9902c 100644 --- a/websites/P/Proxer/iframe.ts +++ b/websites/P/Proxer/iframe.ts @@ -1,20 +1,26 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", async () => { - // Exclude proxer - if (document.querySelector("#proxerToken")) return; +iframe.on('UpdateData', async () => { + // Exclude proxer + if (document.querySelector('#proxerToken')) + return - const videos = document.querySelectorAll("video"), - [video] = videos; - if (videos.length === 0) return; + const videos = document.querySelectorAll('video') + const [video] = videos + if (videos.length === 0) + return - if (video) { - // Exclude proxer ads - if (video.className.includes("ads")) return; - iframe.send({ - currentTime: video.currentTime, - duration: video.duration, - paused: video.paused, - }); - } else iframe.send(null); -}); + if (video) { + // Exclude proxer ads + if (video.className.includes('ads')) + return + iframe.send({ + currentTime: video.currentTime, + duration: video.duration, + paused: video.paused, + }) + } + else { + iframe.send(null) + } +}) diff --git a/websites/P/Proxer/metadata.json b/websites/P/Proxer/metadata.json index da548c33394e..50cc5a1509ce 100644 --- a/websites/P/Proxer/metadata.json +++ b/websites/P/Proxer/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Paul1365972", - "id": "243125346751217664" - }, - "service": "Proxer", - "description": { - "en": "Free and open German Anime Community", - "de": "Kostenlose und Freie deutsche Anime Community", - "nl": "Gratis en open Duitse Anime-community" - }, - "url": "proxer.me", - "version": "1.0.26", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Proxer/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Proxer/assets/thumbnail.png", - "color": "#8A0E0E", - "category": "anime", - "tags": [ - "anime", - "streaming", - "proxer", - "proxerme" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Paul1365972", + "id": "243125346751217664" + }, + "service": "Proxer", + "description": { + "en": "Free and open German Anime Community", + "de": "Kostenlose und Freie deutsche Anime Community", + "nl": "Gratis en open Duitse Anime-community" + }, + "url": "proxer.me", + "version": "1.0.26", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Proxer/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Proxer/assets/thumbnail.png", + "color": "#8A0E0E", + "category": "anime", + "tags": [ + "anime", + "streaming", + "proxer", + "proxerme" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git a/websites/P/Proxer/presence.ts b/websites/P/Proxer/presence.ts index 53b72a817f9a..8d62a7dea36b 100644 --- a/websites/P/Proxer/presence.ts +++ b/websites/P/Proxer/presence.ts @@ -1,74 +1,75 @@ const presence = new Presence({ - clientId: "776479405009666098", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '776479405009666098', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -class VideoData { - currentTime: number; - duration: number; - paused: boolean; +let videoData = { + currentTime: 0, + duration: 0, + paused: false, } -let videoData: VideoData = null; +presence.on('iFrameData', (data: unknown) => { + videoData = data as typeof videoData +}) -presence.on("iFrameData", (data: VideoData) => { - videoData = data; -}); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/Proxer/assets/logo.png', + details: 'Idle', + state: 'Browsing Proxer.me', + } as PresenceData + const { pathname } = document.location -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/Proxer/assets/logo.png", - details: "Idle", - state: "Browsing Proxer.me", - }, - { pathname } = document.location; + if (pathname.startsWith('/watch')) { + const ep = getByXpath( + '//*[@id=\'wContainer\']//*[@class=\'wEp\']', + e => e.textContent, + ) + const maxEp = getByXpath('//*[@id=\'wContainer\']//*[@class=\'wEp\']', e => + e.nextSibling?.textContent?.substr(1).trim()) + const lang = getByXpath( + '//*[@id=\'wContainer\']//*[@class=\'wLanguage\']', + e => e.textContent, + ) - if (pathname.startsWith("/watch")) { - const ep = getByXpath( - "//*[@id='wContainer']//*[@class='wEp']", - e => e.textContent - ), - maxEp = getByXpath("//*[@id='wContainer']//*[@class='wEp']", e => - e.nextSibling.textContent.substr(1).trim() - ), - lang = getByXpath( - "//*[@id='wContainer']//*[@class='wLanguage']", - e => e.textContent - ); - - if (videoData) { - presenceData.type = ActivityType.Watching; - if (!videoData.paused) { - presenceData.details = "Watching"; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(videoData.currentTime, videoData.duration); - } else presenceData.details = "Paused"; - } else if ( - getByXpath("//*[@id='wContainer']//*[@class='wStream']/div/@style", e => - e.textContent.includes("/images/misc/streamfehlt.png") - ) - ) - presenceData.details = "Awaiting"; - else { - presenceData.details = "Watching"; - presenceData.startTimestamp = browsingTimestamp; - } - presenceData.details += ` ${ - getByXpath( - "//*[@id='wContainer']//*[@class='wName']", - e => e.textContent - ) || "Unknown Anime" - }`; + if (videoData) { + presenceData.type = ActivityType.Watching + if (!videoData.paused) { + presenceData.details = 'Watching'; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(videoData.currentTime, videoData.duration) + } + else { + presenceData.details = 'Paused' + } + } + else if ( + getByXpath('//*[@id=\'wContainer\']//*[@class=\'wStream\']/div/@style', e => + e.textContent?.includes('/images/misc/streamfehlt.png')) + ) { + presenceData.details = 'Awaiting' + } + else { + presenceData.details = 'Watching' + presenceData.startTimestamp = browsingTimestamp + } + presenceData.details += ` ${ + getByXpath( + '//*[@id=\'wContainer\']//*[@class=\'wName\']', + e => e.textContent, + ) || 'Unknown Anime' + }` - presenceData.state = ""; - if (ep) { - presenceData.state += ep; - if (maxEp) presenceData.state += `/${maxEp}`; + presenceData.state = '' + if (ep) { + presenceData.state += ep + if (maxEp) + presenceData.state += `/${maxEp}` - if (lang) presenceData.state += ` (${lang})`; - } - /* + if (lang) + presenceData.state += ` (${lang})` + } + /* // For the future to make watch together requests const id = /(?:\/watch\/)([0-9]*)\/([0-9]*)\/([a-z]*)/.exec(pathname); if (id.length == 3) { @@ -77,33 +78,43 @@ presence.on("UpdateData", () => { langId = id[2]; } */ - } else if (pathname.startsWith("/info")) { - presenceData.details = `Checking out ${document.title.replace( - / - Proxer\.Me$/, - "" - )}`; - } else if (pathname.startsWith("/anime") || pathname.startsWith("/season")) - presenceData.details = "Checking out Anime"; - else if (pathname.startsWith("/chat")) presenceData.details = "Chatting"; - else if (pathname.startsWith("/forum")) - presenceData.details = "Checking the forum"; - else if (pathname.startsWith("/gallery")) - presenceData.details = "Checking the gallery"; - else if (pathname.startsWith("/news")) - presenceData.details = "Checking the news"; + } + else if (pathname.startsWith('/info')) { + presenceData.details = `Checking out ${document.title.replace( + / - Proxer\.Me$/, + '', + )}` + } + else if (pathname.startsWith('/anime') || pathname.startsWith('/season')) { + presenceData.details = 'Checking out Anime' + } + else if (pathname.startsWith('/chat')) { + presenceData.details = 'Chatting' + } + else if (pathname.startsWith('/forum')) { + presenceData.details = 'Checking the forum' + } + else if (pathname.startsWith('/gallery')) { + presenceData.details = 'Checking the gallery' + } + else if (pathname.startsWith('/news')) { + presenceData.details = 'Checking the news' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) -function getByXpath(xpath: string, extractor: (e: Node) => T): T | Node { - try { - return (extractor || (e => e))( - document - .evaluate(xpath, document, null, XPathResult.ANY_TYPE, null) - .iterateNext() - ); - } catch (e) { - return null; - } +function getByXpath(xpath: string, extractor: (e: Node) => T): T | Node | null { + try { + return (extractor || (e => e))( + document + .evaluate(xpath, document, null, XPathResult.ANY_TYPE, null) + .iterateNext()!, + ) + } + catch { + return null + } } diff --git a/websites/P/Prydwen Institute/metadata.json b/websites/P/Prydwen Institute/metadata.json index 1807f30a7214..7f871636f0d7 100644 --- a/websites/P/Prydwen Institute/metadata.json +++ b/websites/P/Prydwen Institute/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Kyrie", - "id": "368399721494216706" - }, - "service": "Prydwen Institute", - "description": { - "en": "Prydwen Institute is a Counter Side tier list and database that contains information about employees, ships, operators, and skins available in both SEA and KR versions of the game.", - "vi_VN": "Prydwen Insutitute là bảng xếp hạng và cơ sở dữ liệu dành cho Counter Side chứa các thông tin của nhân viên, đặc vụ, tàu chiến, và skin có mặt ở trong cả hai phiên bản SEA và KR của trò chơi." - }, - "url": "www.prydwen.co", - "version": "1.1.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/thumbnail.png", - "color": "#161833", - "category": "games", - "tags": [ - "counter", - "side", - "prydwen", - "institute", - "wiki", - "database" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Kyrie", + "id": "368399721494216706" + }, + "service": "Prydwen Institute", + "description": { + "en": "Prydwen Institute is a Counter Side tier list and database that contains information about employees, ships, operators, and skins available in both SEA and KR versions of the game.", + "vi_VN": "Prydwen Insutitute là bảng xếp hạng và cơ sở dữ liệu dành cho Counter Side chứa các thông tin của nhân viên, đặc vụ, tàu chiến, và skin có mặt ở trong cả hai phiên bản SEA và KR của trò chơi." + }, + "url": "www.prydwen.co", + "version": "1.1.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/thumbnail.png", + "color": "#161833", + "category": "games", + "tags": [ + "counter", + "side", + "prydwen", + "institute", + "wiki", + "database" + ] +} diff --git a/websites/P/Prydwen Institute/presence.ts b/websites/P/Prydwen Institute/presence.ts index 2df860183e3d..1a7598273b46 100644 --- a/websites/P/Prydwen Institute/presence.ts +++ b/websites/P/Prydwen Institute/presence.ts @@ -1,158 +1,172 @@ const presence = new Presence({ - clientId: "918337184929546322", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '918337184929546322', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/0.png", - Employees = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/1.png", - Gearbuilder = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/2.png", - Guide = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/3.png", - Tierlist = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/4.png", - Operators = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/5.png", - Ships = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/6.png", - Upcoming = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/7.png", - Skins = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/8.png", - Stats = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/9.png", - Blogs = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/10.png", - Shipbg = "https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/11.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/0.png', + Employees = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/1.png', + Gearbuilder = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/2.png', + Guide = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/3.png', + Tierlist = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/4.png', + Operators = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/5.png', + Ships = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/6.png', + Upcoming = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/7.png', + Skins = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/8.png', + Stats = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/9.png', + Blogs = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/10.png', + Shipbg = 'https://cdn.rcd.gg/PreMiD/websites/P/Prydwen%20Institute/assets/11.png', } -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - startTimestamp: browsingTimestamp, - }, - [shortTitle] = document.title.split(/[|/]/, 1); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + startTimestamp: browsingTimestamp, + } + const [shortTitle] = document.title.split(/[|/]/, 1) - if (document.location.pathname === "/employees") { - presenceData.details = "Viewing employees"; - presenceData.largeImageKey = Assets.Ships; - presenceData.smallImageKey = Assets.Employees; - presenceData.smallImageText = "Viewing employees"; - } else if (document.location.pathname.startsWith("/employees")) { - presenceData.details = "Looking into an employee's profile"; - presenceData.state = shortTitle; - presenceData.largeImageKey = document.querySelector( - "#gatsby-focus-wrapper > div > main > div > div > div > div.unit-header.align-items-center.d-flex.flex-wrap > div:nth-child(1) > span > a > div > div > picture > img" - ).src; - presenceData.smallImageKey = Assets.Ships; - presenceData.smallImageText = "Prydwen Institute"; - presenceData.buttons = [{ label: "View Employee", url: document.URL }]; - } else if (document.location.pathname === "/operators") { - presenceData.details = "Viewing operators"; - presenceData.largeImageKey = Assets.Ships; - presenceData.smallImageKey = Assets.Operators; - presenceData.smallImageText = "Viewing operators"; - } else if (document.location.pathname.startsWith("/operators")) { - presenceData.details = "Looking into an operator's profile"; - presenceData.state = shortTitle; - presenceData.largeImageKey = document.querySelector( - "#gatsby-focus-wrapper > div > main > div > div > div.unit-page.operator > div.unit-header.align-items-center.d-flex.flex-wrap > div:nth-child(1) > span > a > div > div > picture > img" - ).src; - presenceData.smallImageKey = Assets.Ships; - presenceData.smallImageText = "Prydwen Institute"; - presenceData.buttons = [{ label: "View Operator", url: document.URL }]; - } else if (document.location.pathname === "/ships") { - presenceData.details = "Viewing ships"; - presenceData.largeImageKey = Assets.Ships; - presenceData.smallImageKey = Assets.Ships; - presenceData.smallImageText = "Viewing ships"; - } else if (document.location.pathname.startsWith("/ships")) { - presenceData.details = "Viewing a ship"; - presenceData.state = shortTitle; - presenceData.largeImageKey = document.querySelector( - "#gatsby-focus-wrapper > div > main > div > div > div.unit-page.ship > div.unit-header.align-items-center.d-flex.flex-wrap > div:nth-child(1) > span > a > div > div > picture > img" - ).src; - presenceData.smallImageKey = Assets.Ships; - presenceData.smallImageText = "Viewing ships"; - presenceData.buttons = [{ label: "View Ship", url: document.URL }]; - } else if ( - document.querySelector("body > div.fade.modal-backdrop.show") && - document.location.href.includes("skins") - ) { - presenceData.details = "Viewing skin"; - presenceData.state = document - .querySelector( - "body > div.fade.skin-viewer.modal.show > div > div > div.modal-body > div.details > div.name" - ) - .textContent.substring( - 0, - document - .querySelector( - "body > div.fade.skin-viewer.modal.show > div > div > div.modal-body > div.details > div.name" - ) - .textContent.lastIndexOf("-") - 1 - ); - presenceData.largeImageKey = Assets.Ships; - presenceData.smallImageKey = Assets.Skins; - presenceData.smallImageText = "Viewing skins"; - } else { - switch (document.location.pathname) { - case "/skins": { - presenceData.details = "Viewing skins"; - presenceData.largeImageKey = Assets.Ships; - presenceData.smallImageKey = Assets.Skins; - presenceData.smallImageText = "Viewing skins"; + if (document.location.pathname === '/employees') { + presenceData.details = 'Viewing employees' + presenceData.largeImageKey = Assets.Ships + presenceData.smallImageKey = Assets.Employees + presenceData.smallImageText = 'Viewing employees' + } + else if (document.location.pathname.startsWith('/employees')) { + presenceData.details = 'Looking into an employee\'s profile' + presenceData.state = shortTitle + presenceData.largeImageKey = document.querySelector( + '#gatsby-focus-wrapper > div > main > div > div > div > div.unit-header.align-items-center.d-flex.flex-wrap > div:nth-child(1) > span > a > div > div > picture > img', + )?.src + presenceData.smallImageKey = Assets.Ships + presenceData.smallImageText = 'Prydwen Institute' + presenceData.buttons = [{ label: 'View Employee', url: document.URL }] + } + else if (document.location.pathname === '/operators') { + presenceData.details = 'Viewing operators' + presenceData.largeImageKey = Assets.Ships + presenceData.smallImageKey = Assets.Operators + presenceData.smallImageText = 'Viewing operators' + } + else if (document.location.pathname.startsWith('/operators')) { + presenceData.details = 'Looking into an operator\'s profile' + presenceData.state = shortTitle + presenceData.largeImageKey = document.querySelector( + '#gatsby-focus-wrapper > div > main > div > div > div.unit-page.operator > div.unit-header.align-items-center.d-flex.flex-wrap > div:nth-child(1) > span > a > div > div > picture > img', + )?.src + presenceData.smallImageKey = Assets.Ships + presenceData.smallImageText = 'Prydwen Institute' + presenceData.buttons = [{ label: 'View Operator', url: document.URL }] + } + else if (document.location.pathname === '/ships') { + presenceData.details = 'Viewing ships' + presenceData.largeImageKey = Assets.Ships + presenceData.smallImageKey = Assets.Ships + presenceData.smallImageText = 'Viewing ships' + } + else if (document.location.pathname.startsWith('/ships')) { + presenceData.details = 'Viewing a ship' + presenceData.state = shortTitle + presenceData.largeImageKey = document.querySelector( + '#gatsby-focus-wrapper > div > main > div > div > div.unit-page.ship > div.unit-header.align-items-center.d-flex.flex-wrap > div:nth-child(1) > span > a > div > div > picture > img', + )?.src + presenceData.smallImageKey = Assets.Ships + presenceData.smallImageText = 'Viewing ships' + presenceData.buttons = [{ label: 'View Ship', url: document.URL }] + } + else if ( + document.querySelector('body > div.fade.modal-backdrop.show') + && document.location.href.includes('skins') + ) { + presenceData.details = 'Viewing skin' + presenceData.state = document + .querySelector( + 'body > div.fade.skin-viewer.modal.show > div > div > div.modal-body > div.details > div.name', + ) + ?.textContent + ?.substring( + 0, + (document + .querySelector( + 'body > div.fade.skin-viewer.modal.show > div > div > div.modal-body > div.details > div.name', + ) + ?.textContent + ?.lastIndexOf('-') ?? 0) - 1, + ) + presenceData.largeImageKey = Assets.Ships + presenceData.smallImageKey = Assets.Skins + presenceData.smallImageText = 'Viewing skins' + } + else { + switch (document.location.pathname) { + case '/skins': { + presenceData.details = 'Viewing skins' + presenceData.largeImageKey = Assets.Ships + presenceData.smallImageKey = Assets.Skins + presenceData.smallImageText = 'Viewing skins' - break; - } - case "/stats": { - presenceData.details = "Viewing stats"; - presenceData.largeImageKey = Assets.Ships; - presenceData.smallImageKey = Assets.Stats; - presenceData.smallImageText = "Viewing stats"; + break + } + case '/stats': { + presenceData.details = 'Viewing stats' + presenceData.largeImageKey = Assets.Ships + presenceData.smallImageKey = Assets.Stats + presenceData.smallImageText = 'Viewing stats' - break; - } - case "/tier-list": { - presenceData.details = "Viewing the tier list"; - presenceData.largeImageKey = Assets.Ships; - presenceData.smallImageKey = Assets.Tierlist; - presenceData.smallImageText = "Viewing tier list"; + break + } + case '/tier-list': { + presenceData.details = 'Viewing the tier list' + presenceData.largeImageKey = Assets.Ships + presenceData.smallImageKey = Assets.Tierlist + presenceData.smallImageText = 'Viewing tier list' - break; - } - case "/guides": { - presenceData.details = "Finding guides"; - presenceData.largeImageKey = Assets.Ships; - presenceData.smallImageKey = Assets.Guide; - presenceData.smallImageText = "Viewing guides"; + break + } + case '/guides': { + presenceData.details = 'Finding guides' + presenceData.largeImageKey = Assets.Ships + presenceData.smallImageKey = Assets.Guide + presenceData.smallImageText = 'Viewing guides' - break; - } - default: - if (document.location.pathname.startsWith("/guides")) { - presenceData.details = "Reading a guide:"; - presenceData.state = shortTitle; - presenceData.largeImageKey = Assets.Guide; - presenceData.smallImageKey = Assets.Ships; - presenceData.smallImageText = "Prydwen Institute"; - presenceData.buttons = [{ label: "Read Guide", url: document.URL }]; - } else if (document.location.pathname === "/blog") { - presenceData.details = "Finding blogs"; - presenceData.largeImageKey = Assets.Ships; - presenceData.smallImageKey = Assets.Blogs; - presenceData.smallImageText = "Viewing blogs"; - } else if (document.location.pathname.startsWith("/blog")) { - presenceData.details = "Reading a blog:"; - presenceData.state = shortTitle; - presenceData.largeImageKey = Assets.Blogs; - presenceData.smallImageKey = Assets.Ships; - presenceData.smallImageText = "Prydwen Institute"; - presenceData.buttons = [{ label: "Read Blog", url: document.URL }]; - } else if (document.location.href.includes("gear-builder")) { - presenceData.details = "Making a Gear Builder template"; - presenceData.largeImageKey = Assets.Ships; - presenceData.smallImageKey = Assets.Gearbuilder; - presenceData.smallImageText = "Gear building"; - } else if (document.location.href === "https://www.prydwen.co/") { - presenceData.details = "Viewing home page"; - presenceData.largeImageKey = Assets.Ships; - } else { - presenceData.details = "Browsing the wiki"; - presenceData.largeImageKey = Assets.Ships; - } - } - } - presence.setActivity(presenceData); -}); + break + } + default: + if (document.location.pathname.startsWith('/guides')) { + presenceData.details = 'Reading a guide:' + presenceData.state = shortTitle + presenceData.largeImageKey = Assets.Guide + presenceData.smallImageKey = Assets.Ships + presenceData.smallImageText = 'Prydwen Institute' + presenceData.buttons = [{ label: 'Read Guide', url: document.URL }] + } + else if (document.location.pathname === '/blog') { + presenceData.details = 'Finding blogs' + presenceData.largeImageKey = Assets.Ships + presenceData.smallImageKey = Assets.Blogs + presenceData.smallImageText = 'Viewing blogs' + } + else if (document.location.pathname.startsWith('/blog')) { + presenceData.details = 'Reading a blog:' + presenceData.state = shortTitle + presenceData.largeImageKey = Assets.Blogs + presenceData.smallImageKey = Assets.Ships + presenceData.smallImageText = 'Prydwen Institute' + presenceData.buttons = [{ label: 'Read Blog', url: document.URL }] + } + else if (document.location.href.includes('gear-builder')) { + presenceData.details = 'Making a Gear Builder template' + presenceData.largeImageKey = Assets.Ships + presenceData.smallImageKey = Assets.Gearbuilder + presenceData.smallImageText = 'Gear building' + } + else if (document.location.href === 'https://www.prydwen.co/') { + presenceData.details = 'Viewing home page' + presenceData.largeImageKey = Assets.Ships + } + else { + presenceData.details = 'Browsing the wiki' + presenceData.largeImageKey = Assets.Ships + } + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/P/Pub/metadata.json b/websites/P/Pub/metadata.json index 3271018889c1..1d14ac070271 100644 --- a/websites/P/Pub/metadata.json +++ b/websites/P/Pub/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "Pub", - "altnames": [ - "pub.dev" - ], - "description": { - "en": "Pub is the package manager for the Dart programming language, containing reusable libraries & packages for Flutter and general Dart programs." - }, - "url": "pub.dev", - "version": "1.0.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pub/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pub/assets/thumbnail.png", - "color": "#29B6F6", - "category": "other", - "tags": [ - "development", - "coding", - "dart", - "flutter", - "package", - "repository" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "Pub", + "altnames": [ + "pub.dev" + ], + "description": { + "en": "Pub is the package manager for the Dart programming language, containing reusable libraries & packages for Flutter and general Dart programs." + }, + "url": "pub.dev", + "version": "1.0.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pub/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pub/assets/thumbnail.png", + "color": "#29B6F6", + "category": "other", + "tags": [ + "development", + "coding", + "dart", + "flutter", + "package", + "repository" + ] +} diff --git a/websites/P/Pub/presence.ts b/websites/P/Pub/presence.ts index 1dcb26e9df6c..f338fb5f4201 100644 --- a/websites/P/Pub/presence.ts +++ b/websites/P/Pub/presence.ts @@ -1,57 +1,61 @@ const presence = new Presence({ - clientId: "1233135474395189399", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1233135474395189399', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Pub/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Pub/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname, href, search } = document.location, - searchParams = new URLSearchParams(search), - pathList = pathname.split("/").filter(Boolean); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname, href, search } = document.location + const searchParams = new URLSearchParams(search) + const pathList = pathname.split('/').filter(Boolean) - switch (pathList[0] ?? "/") { - case "/": { - presenceData.details = "Browsing the home page"; - break; - } - case "help": { - presenceData.details = "Browsing help"; - if (pathList[1]) presenceData.state = document.querySelector("h1"); - break; - } - case "packages": { - if (pathList[1]) { - presenceData.details = "Viewing a package"; - presenceData.state = pathList[1]; - presenceData.buttons = [{ label: "View Package", url: href }]; - } else if (searchParams.has("q")) { - presenceData.details = "Searching for packages"; - presenceData.state = searchParams.get("q"); - } else { - presenceData.details = "Browsing packages"; - presenceData.state = `${ - document.querySelector(".count").textContent - } packages`; - } - break; - } - case "policy": { - presenceData.details = "Reading the policy"; - break; - } - case "security": { - presenceData.details = "Reading the security policy"; - break; - } - } + switch (pathList[0] ?? '/') { + case '/': { + presenceData.details = 'Browsing the home page' + break + } + case 'help': { + presenceData.details = 'Browsing help' + if (pathList[1]) + presenceData.state = document.querySelector('h1') + break + } + case 'packages': { + if (pathList[1]) { + presenceData.details = 'Viewing a package' + presenceData.state = pathList[1] + presenceData.buttons = [{ label: 'View Package', url: href }] + } + else if (searchParams.has('q')) { + presenceData.details = 'Searching for packages' + presenceData.state = searchParams.get('q') + } + else { + presenceData.details = 'Browsing packages' + presenceData.state = `${ + document.querySelector('.count')?.textContent + } packages` + } + break + } + case 'policy': { + presenceData.details = 'Reading the policy' + break + } + case 'security': { + presenceData.details = 'Reading the security policy' + break + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.clearActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.clearActivity() +}) diff --git a/websites/P/Pulsus/assets.ts b/websites/P/Pulsus/assets.ts index 0b1dd1fe7aac..e890c3897265 100644 --- a/websites/P/Pulsus/assets.ts +++ b/websites/P/Pulsus/assets.ts @@ -1,39 +1,39 @@ export const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/logo.png", - RankedBeginner = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/0.png", - RankedEasy = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/1.png", - RankedNormal = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/2.png", - RankedHard = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/3.png", - RankedAdvanced = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/4.png", - RankedInsane = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/5.png", - RankedExpert = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/6.png", - RankedSpecial = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/7.png", - UnrankedBeginner = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/8.png", - UnrankedEasy = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/9.png", - UnrankedNormal = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/10.png", - UnrankedHard = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/11.png", - UnrankedAdvanced = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/12.png", - UnrankedInsane = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/13.png", - UnrankedExpert = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/14.png", - UnrankedSpecial = "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/15.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/logo.png', + RankedBeginner = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/0.png', + RankedEasy = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/1.png', + RankedNormal = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/2.png', + RankedHard = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/3.png', + RankedAdvanced = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/4.png', + RankedInsane = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/5.png', + RankedExpert = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/6.png', + RankedSpecial = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/7.png', + UnrankedBeginner = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/8.png', + UnrankedEasy = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/9.png', + UnrankedNormal = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/10.png', + UnrankedHard = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/11.png', + UnrankedAdvanced = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/12.png', + UnrankedInsane = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/13.png', + UnrankedExpert = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/14.png', + UnrankedSpecial = 'https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/15.png', } export const rankedImages = [ - Assets.RankedBeginner, - Assets.RankedEasy, - Assets.RankedNormal, - Assets.RankedHard, - Assets.RankedAdvanced, - Assets.RankedInsane, - Assets.RankedExpert, -]; + Assets.RankedBeginner, + Assets.RankedEasy, + Assets.RankedNormal, + Assets.RankedHard, + Assets.RankedAdvanced, + Assets.RankedInsane, + Assets.RankedExpert, +] export const unrankedImages = [ - Assets.UnrankedBeginner, - Assets.UnrankedEasy, - Assets.UnrankedNormal, - Assets.UnrankedHard, - Assets.UnrankedAdvanced, - Assets.UnrankedInsane, - Assets.UnrankedExpert, -]; + Assets.UnrankedBeginner, + Assets.UnrankedEasy, + Assets.UnrankedNormal, + Assets.UnrankedHard, + Assets.UnrankedAdvanced, + Assets.UnrankedInsane, + Assets.UnrankedExpert, +] diff --git a/websites/P/Pulsus/metadata.json b/websites/P/Pulsus/metadata.json index 3fb92108f8ce..0453bc4afe66 100644 --- a/websites/P/Pulsus/metadata.json +++ b/websites/P/Pulsus/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "205984221859151873", - "name": "joerkig" - }, - "service": "Pulsus", - "description": { - "en": "Play Pulsus, an online rhythm game in which you hit incoming beats on a 3x3 tile board!" - }, - "url": "pulsus.cc", - "version": "1.0.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/thumbnail.png", - "color": "#50AFFD", - "category": "games", - "tags": [ - "rhythm", - "game", - "leaderboard" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "205984221859151873", + "name": "joerkig" + }, + "service": "Pulsus", + "description": { + "en": "Play Pulsus, an online rhythm game in which you hit incoming beats on a 3x3 tile board!" + }, + "url": "pulsus.cc", + "version": "1.0.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pulsus/assets/thumbnail.png", + "color": "#50AFFD", + "category": "games", + "tags": [ + "rhythm", + "game", + "leaderboard" + ] +} diff --git a/websites/P/Pulsus/presence.ts b/websites/P/Pulsus/presence.ts index 6c2e5e0ec36b..e6e0b89efa20 100644 --- a/websites/P/Pulsus/presence.ts +++ b/websites/P/Pulsus/presence.ts @@ -1,123 +1,124 @@ -import type { PageVars, dataObject } from "./types"; -import { Assets, rankedImages, unrankedImages } from "./assets"; +import type { dataObject, PageVars } from './types' +import { Assets, rankedImages, unrankedImages } from './assets' const presence = new Presence({ - clientId: "770491262997889055", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '770491262997889055', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let data: PageVars, gameData: dataObject; +let data: PageVars, gameData: dataObject async function getData() { - const pageVariables: PageVars = await presence.getPageVariable( - "Tt.time", - "Tt.timeEnd", - "Tt.paused", - "Tt.failed", - "Bt.screen", - "Bt.online.mode", - "Bt.song.mode", - "Tt.bpm" - ); - return pageVariables; + const pageVariables: PageVars = await presence.getPageVariable( + 'Tt.time', + 'Tt.timeEnd', + 'Tt.paused', + 'Tt.failed', + 'Bt.screen', + 'Bt.online.mode', + 'Bt.song.mode', + 'Tt.bpm', + ) + return pageVariables } function getLevelPresence(presenceData: PresenceData) { - presenceData.details = "Playing a level"; - presenceData.state = `${gameData.title} by ${gameData.author}`; - if ( - data["Tt.time"] < data["Tt.timeEnd"] && - !data["Tt.paused"] && - !data["Tt.failed"] - ) { - presenceData.endTimestamp = presence.getTimestamps( - (data["Tt.time"] / data["Tt.bpm"]) * 60, - (data["Tt.timeEnd"] / data["Tt.bpm"]) * 60 - )[1]; - } - if (gameData.special) { - presenceData.smallImageKey = gameData.ranked - ? Assets.RankedSpecial - : Assets.UnrankedSpecial; - } else if (gameData.ranked) { - presenceData.smallImageKey = - rankedImages[Math.floor(gameData.stars)] || rankedImages.at(-1); - } else { - presenceData.smallImageKey = - unrankedImages[Math.floor(gameData.stars)] || unrankedImages.at(-1); - } - presenceData.smallImageText = `${gameData.stars - .toPrecision(2) - .toString()} stars`; + presenceData.details = 'Playing a level' + presenceData.state = `${gameData.title} by ${gameData.author}` + if ( + data['Tt.time'] < data['Tt.timeEnd'] + && !data['Tt.paused'] + && !data['Tt.failed'] + ) { + presenceData.endTimestamp = presence.getTimestamps( + (data['Tt.time'] / data['Tt.bpm']) * 60, + (data['Tt.timeEnd'] / data['Tt.bpm']) * 60, + )[1] + } + if (gameData.special) { + presenceData.smallImageKey = gameData.ranked + ? Assets.RankedSpecial + : Assets.UnrankedSpecial + } + else if (gameData.ranked) { + presenceData.smallImageKey = rankedImages[Math.floor(gameData.stars)] || rankedImages.at(-1) + } + else { + presenceData.smallImageKey = unrankedImages[Math.floor(gameData.stars)] || unrankedImages.at(-1) + } + presenceData.smallImageText = `${gameData.stars + .toPrecision(2) + .toString()} stars` - return presenceData; + return presenceData } window.addEventListener( - "message", - event => { - gameData = event.data; - }, - false -); + 'message', + (event) => { + gameData = event.data + }, + false, +) setInterval(async () => { - data = await getData(); -}, 1000); + data = await getData() +}, 1000) -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } - switch (data["Bt.screen"]) { - case "settings": { - presenceData.details = "Viewing settings"; - break; - } - case "logo": { - presenceData.details = "Viewing homescreen"; - break; - } - case "online": { - switch (data["Bt.online.mode"]) { - case "main": { - presenceData.details = "Browsing leaderboard"; - break; - } - case "viewUser": { - presenceData.details = "Viewing user"; - break; - } - } + switch (data['Bt.screen']) { + case 'settings': { + presenceData.details = 'Viewing settings' + break + } + case 'logo': { + presenceData.details = 'Viewing homescreen' + break + } + case 'online': { + switch (data['Bt.online.mode']) { + case 'main': { + presenceData.details = 'Browsing leaderboard' + break + } + case 'viewUser': { + presenceData.details = 'Viewing user' + break + } + } - break; - } - case "account": { - presenceData.details = "Viewing account settings"; - break; - } - case "song": { - switch (data["Bt.song.mode"]) { - case "song": { - presenceData.details = "Browsing songs"; - break; - } - case "newSong": { - presenceData.details = "Uploading song"; - break; - } - } - break; - } - case "lvl": { - if (gameData.screen[0] === "game" && data["Tt.time"]) - presenceData = getLevelPresence(presenceData); - else presenceData.details = "Browsing levels"; - break; - } - } + break + } + case 'account': { + presenceData.details = 'Viewing account settings' + break + } + case 'song': { + switch (data['Bt.song.mode']) { + case 'song': { + presenceData.details = 'Browsing songs' + break + } + case 'newSong': { + presenceData.details = 'Uploading song' + break + } + } + break + } + case 'lvl': { + if (gameData.screen[0] === 'game' && data['Tt.time']) + presenceData = getLevelPresence(presenceData) + else presenceData.details = 'Browsing levels' + break + } + } - if (presenceData.details) presence.setActivity(presenceData); -}); + if (presenceData.details) + presence.setActivity(presenceData) +}) diff --git a/websites/P/Pulsus/types.ts b/websites/P/Pulsus/types.ts index 148c85fe60a4..20c20dbe2328 100644 --- a/websites/P/Pulsus/types.ts +++ b/websites/P/Pulsus/types.ts @@ -1,27 +1,27 @@ -export type dataObject = { - acc: number; - author: string; - combo: number; - ranked: boolean; - score: number; - screen: { - 0: string; - 1: number; - }; - special: boolean; - stars: number; - through: number; - title: string; - type: string; -}; +export interface dataObject { + acc: number + author: string + combo: number + ranked: boolean + score: number + screen: { + 0: string + 1: number + } + special: boolean + stars: number + through: number + title: string + type: string +} -export type PageVars = { - "Tt.time": number; - "Tt.timeEnd": number; - "Tt.paused": boolean; - "Tt.failed": boolean; - "Bt.screen": string; - "Bt.online.mode": string; - "Bt.song.mode": string; - "Tt.bpm": number; -}; +export interface PageVars { + 'Tt.time': number + 'Tt.timeEnd': number + 'Tt.paused': boolean + 'Tt.failed': boolean + 'Bt.screen': string + 'Bt.online.mode': string + 'Bt.song.mode': string + 'Tt.bpm': number +} diff --git a/websites/P/PyPi/metadata.json b/websites/P/PyPi/metadata.json index 620ff04153ef..19961f6d3eb3 100644 --- a/websites/P/PyPi/metadata.json +++ b/websites/P/PyPi/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Jake.", - "id": "480407581085532180" - }, - "service": "PyPi", - "description": { - "en": "The Python Package Index (PyPI) is a repository of software for the Python programming language.", - "nl": "De Python Package Index (PyPI) is een opslagplaats van software voor de programmeertaal Python." - }, - "url": "pypi.org", - "version": "1.4.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PyPi/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PyPi/assets/thumbnail.jpg", - "color": "#ebcc34", - "category": "other", - "tags": [ - "developing", - "modules", - "packages", - "coding" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Jake.", + "id": "480407581085532180" + }, + "service": "PyPi", + "description": { + "en": "The Python Package Index (PyPI) is a repository of software for the Python programming language.", + "nl": "De Python Package Index (PyPI) is een opslagplaats van software voor de programmeertaal Python." + }, + "url": "pypi.org", + "version": "1.4.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/PyPi/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/PyPi/assets/thumbnail.jpg", + "color": "#ebcc34", + "category": "other", + "tags": [ + "developing", + "modules", + "packages", + "coding" + ] +} diff --git a/websites/P/PyPi/presence.ts b/websites/P/PyPi/presence.ts index f3ef3b7de7de..85ed6cadd5fe 100644 --- a/websites/P/PyPi/presence.ts +++ b/websites/P/PyPi/presence.ts @@ -1,56 +1,64 @@ const presence = new Presence({ - clientId: "685491676155871281", -}); + clientId: '685491676155871281', +}) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/PyPi/assets/logo.png", - }, - Path = document.location.pathname; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - if (Path === "/") { - presenceData.details = "Viewing the home-page :"; - presenceData.state = `${ - document.querySelector( - "#content > div.horizontal-section.horizontal-section--grey.horizontal-section--thin.horizontal-section--statistics > div > p:nth-child(1)" - ).textContent - }`; - } else if (Path.startsWith("/help")) { - presenceData.details = "Viewing the help-page :"; - presenceData.state = `${ - document.querySelector("#content > div:nth-child(1) > div").children - .length - } total topics`; - } else if (Path.startsWith("/account/login")) - presenceData.details = "Logging into their account "; - else if (Path.startsWith("/account/register")) - presenceData.details = "Registering a new account "; - else if (Path.startsWith("/search")) { - presenceData.details = `Searching for ${ - (document.querySelector("#search") as HTMLInputElement).value - } :`; - presenceData.state = `${ - document.querySelector( - "#content > div > div > div.left-layout__main > form > div.split-layout.split-layout--table.split-layout--wrap-on-tablet > div:nth-child(1) > p > strong" - ).textContent - } total results`; - } else if (Path.startsWith("/project")) { - presenceData.details = "Viewing a package :"; - presenceData.state = `${ - document.querySelector( - "#content > div.banner > div > div.package-header__left > h1" - ).textContent - } BY ${ - document.querySelector( - "#content > div:nth-child(3) > div > div > div.vertical-tabs__tabs > div:nth-child(5) > span > a > span.sidebar-section__user-gravatar-text" - ).textContent - }`; - } else if (Path.startsWith("/security")) - presenceData.details = "Reporting a security flaw "; - else if (Path.startsWith("/policy/terms-of-use/")) - presenceData.details = "Viewing the terms of use "; - else presenceData.details = "Browsing the site "; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/PyPi/assets/logo.png', + } + const Path = document.location.pathname + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + if (Path === '/') { + presenceData.details = 'Viewing the home-page :' + presenceData.state = `${ + document.querySelector( + '#content > div.horizontal-section.horizontal-section--grey.horizontal-section--thin.horizontal-section--statistics > div > p:nth-child(1)', + )?.textContent + }` + } + else if (Path.startsWith('/help')) { + presenceData.details = 'Viewing the help-page :' + presenceData.state = `${ + document.querySelector('#content > div:nth-child(1) > div')?.children.length + } total topics` + } + else if (Path.startsWith('/account/login')) { + presenceData.details = 'Logging into their account ' + } + else if (Path.startsWith('/account/register')) { + presenceData.details = 'Registering a new account ' + } + else if (Path.startsWith('/search')) { + presenceData.details = `Searching for ${ + (document.querySelector('#search') as HTMLInputElement).value + } :` + presenceData.state = `${ + document.querySelector( + '#content > div > div > div.left-layout__main > form > div.split-layout.split-layout--table.split-layout--wrap-on-tablet > div:nth-child(1) > p > strong', + )?.textContent + } total results` + } + else if (Path.startsWith('/project')) { + presenceData.details = 'Viewing a package :' + presenceData.state = `${ + document.querySelector( + '#content > div.banner > div > div.package-header__left > h1', + )?.textContent + } BY ${ + document.querySelector( + '#content > div:nth-child(3) > div > div > div.vertical-tabs__tabs > div:nth-child(5) > span > a > span.sidebar-section__user-gravatar-text', + )?.textContent + }` + } + else if (Path.startsWith('/security')) { + presenceData.details = 'Reporting a security flaw ' + } + else if (Path.startsWith('/policy/terms-of-use/')) { + presenceData.details = 'Viewing the terms of use ' + } + else { + presenceData.details = 'Browsing the site ' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/P/Pylon/metadata.json b/websites/P/Pylon/metadata.json index 80cb6252ecff..ef3c30ba1ef3 100644 --- a/websites/P/Pylon/metadata.json +++ b/websites/P/Pylon/metadata.json @@ -1,57 +1,57 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Snazzah", - "id": "158049329150427136" - }, - "contributors": [ - { - "name": "Cem", - "id": "767790973736452107" - } - ], - "service": "Pylon", - "description": { - "en": "Build and deploy Discord bots in minutes using our simple online studio.", - "nl": "Bouw en implementeer Discord-bots in enkele minuten met behulp van onze eenvoudige online studio." - }, - "url": "pylon.bot", - "version": "2.0.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/thumbnail.png", - "color": "#3961DD", - "category": "other", - "tags": [ - "bot", - "discord" - ], - "settings": [ - { - "id": "docname", - "title": "Show Doc Name on SDK Reference", - "icon": "fas fa-book-reader", - "value": true - }, - { - "id": "studioguildname", - "title": "Show Server Name in Studio", - "icon": "fas fa-address-card", - "value": true - }, - { - "id": "details", - "title": "Studio Editor Details Template", - "icon": "fas fa-info", - "value": "Editing %file%", - "placeholder": "can use %file%, %guild%, %ext%" - }, - { - "id": "state", - "title": "Studio Editor State Template", - "icon": "fas fa-bars", - "value": "Guild: %guild%", - "placeholder": "can use %file%, %guild%, %ext%" - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Snazzah", + "id": "158049329150427136" + }, + "contributors": [ + { + "name": "Cem", + "id": "767790973736452107" + } + ], + "service": "Pylon", + "description": { + "en": "Build and deploy Discord bots in minutes using our simple online studio.", + "nl": "Bouw en implementeer Discord-bots in enkele minuten met behulp van onze eenvoudige online studio." + }, + "url": "pylon.bot", + "version": "2.0.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/thumbnail.png", + "color": "#3961DD", + "category": "other", + "tags": [ + "bot", + "discord" + ], + "settings": [ + { + "id": "docname", + "title": "Show Doc Name on SDK Reference", + "icon": "fas fa-book-reader", + "value": true + }, + { + "id": "studioguildname", + "title": "Show Server Name in Studio", + "icon": "fas fa-address-card", + "value": true + }, + { + "id": "details", + "title": "Studio Editor Details Template", + "icon": "fas fa-info", + "value": "Editing %file%", + "placeholder": "can use %file%, %guild%, %ext%" + }, + { + "id": "state", + "title": "Studio Editor State Template", + "icon": "fas fa-bars", + "value": "Guild: %guild%", + "placeholder": "can use %file%, %guild%, %ext%" + } + ] +} diff --git a/websites/P/Pylon/presence.ts b/websites/P/Pylon/presence.ts index eb31a137881e..966ba0d7e735 100644 --- a/websites/P/Pylon/presence.ts +++ b/websites/P/Pylon/presence.ts @@ -1,645 +1,621 @@ const presence = new Presence({ - clientId: "779062000412000307", - }), - // https://github.com/iCrawl/discord-vscode/blob/master/src/data/languages.json - knownExtensions: { [key: string]: { image: string } } = { - ".ahk": { image: "ahk" }, - ".ahkl": { image: "ahk" }, - "androidmanifest.xml": { image: "android" }, - "/^angular[^.]*\\.js$/i": { image: "angular" }, - ".applescript": { image: "applescript" }, - "/(\\.)?appveyor\\.yml/i": { image: "appveyor" }, - ".ino": { image: "arduino" }, - ".swf": { image: "as" }, - ".as": { image: "as" }, - ".jsfl": { image: "as" }, - ".swc": { image: "as" }, - ".asp": { image: "asp" }, - ".asax": { image: "asp" }, - ".ascx": { image: "asp" }, - ".ashx": { image: "asp" }, - ".asmx": { image: "asp" }, - ".aspx": { image: "asp" }, - ".axd": { image: "asp" }, - "/\\.setTrayTitle(l?a|[ls]?o|out|s|a51|asm|axf|elf|prx|puff|z80)$/i": { - image: "assembly", - }, - ".agc": { image: "assembly" }, - ".ko": { image: "assembly" }, - ".lst": { image: "assembly" }, - "/\\.setTrayTitle((c([+px]{2}?)?-?)?objdump|bsdiff|bin|dat|pak|pdb)$/i": { - image: "assembly", - }, - ".d-objdump": { image: "assembly" }, - "/\\.gcode|\\.gco/i": { image: "assembly" }, - "/\\.rpy[bc]$/i": { image: "assembly" }, - "/\\.py[co]$/i": { image: "assembly" }, - ".swp": { image: "assembly" }, - ".DS_Store": { image: "assembly" }, - ".au3": { image: "autoit" }, - "babel.config.js": { image: "babel" }, - "/\\.babelrc/i": { image: "babel" }, - ".bat": { image: "bat" }, - ".batch": { image: "bat" }, - ".cmd": { image: "bat" }, - "/\\.setTrayTitle(exe|com|msi)$/i": { image: "bat" }, - ".reg": { image: "bat" }, - "/^(\\.bowerrc|bower\\.json|Bowerfile)$/i": { image: "bower" }, - "/\\.bf?$/i": { image: "brainfuck" }, - "/\\.c$/i": { image: "c" }, - "/(cargo.toml|cargo.lock)/i": { image: "cargo" }, - "circle.yml": { image: "circleci" }, - ".clj": { image: "clojure" }, - ".cl2": { image: "clojure" }, - ".cljc": { image: "clojure" }, - ".cljx": { image: "clojure" }, - ".hic": { image: "clojure" }, - "/\\.cljs(cm)?$/i": { image: "clojure" }, - ".cmake": { image: "cmake" }, - "/^CMakeLists\\.txt$/": { image: "cmake" }, - "/\\.codeclimate\\.setTrayTitle(yml|json)/i": { image: "codeclimate" }, - ".coffee": { image: "coffee" }, - ".cjsx": { image: "coffee" }, - ".coffee.ecr": { image: "coffee" }, - ".coffee.erb": { image: "coffee" }, - ".litcoffee": { image: "coffee" }, - ".iced": { image: "coffee" }, - "/\\.c[+px]{2}$|\\.cc$/i": { image: "cpp" }, - "/\\.h[+px]{2}$/i": { image: "cpp" }, - "/\\.[it]pp$/i": { image: "cpp" }, - "/\\.setTrayTitle(tcc|inl)$/i": { image: "cpp" }, - ".cats": { image: "cpp" }, - ".idc": { image: "cpp" }, - ".w": { image: "cpp" }, - ".nc": { image: "cpp" }, - ".upc": { image: "cpp" }, - ".xpm": { image: "cpp" }, - "/\\.e?cr$/i": { image: "crystal" }, - ".cs": { image: "csharp" }, - ".csx": { image: "csharp" }, - ".cshtml": { image: "cshtml" }, - // ".css": { "image": "css" }, - ".css.map": { image: "cssmap" }, - ".cu": { image: "cuda" }, - "/\\.di?$/i": { image: "d" }, - ".dart": { image: "dart" }, - ".dfm": { image: "delphi" }, - ".dpr": { image: "delphi" }, - ".dsc": { image: "denizen" }, - ".dm": { image: "dm" }, - ".dme": { image: "dm" }, - ".dmm": { image: "dm" }, - "/^(Dockerfile|docker-compose)|\\.docker(file|ignore)$/i": { - image: "docker", - }, - "/^docker-sync\\.yml$/i": { image: "docker" }, - ".editorconfig": { image: "editorconfig" }, - ".ejs": { image: "ejs" }, - ".ex": { image: "elixir" }, - "/\\.setTrayTitle(exs|l?eex)$/i": { image: "elixir" }, - "/^mix\\.setTrayTitle(exs?|lock)$/i": { image: "elixir" }, - ".elm": { image: "elm" }, - ".env": { image: "env" }, - ".erl": { image: "erlang" }, - ".beam": { image: "erlang" }, - ".hrl": { image: "erlang" }, - ".xrl": { image: "erlang" }, - ".yrl": { image: "erlang" }, - ".app.src": { image: "erlang" }, - "/^Emakefile$/": { image: "erlang" }, - "/^rebar(\\.config)?\\.lock$/i": { image: "erlang" }, - "/\\.setTrayTitle(eslintrc|eslintignore)/i": { image: "eslint" }, - "/(\\.firebaserc|firebase\\.json)/i": { image: "firebase" }, - ".flowconfig": { image: "flowconfig" }, - ".fs": { image: "fsharp" }, - ".fsi": { image: "fsharp" }, - ".fsscript": { image: "fsharp" }, - ".fsx": { image: "fsharp" }, - "/gatsby-(browser|node|ssr|config)\\.js/i": { image: "gatsbyjs" }, - "/^Gemfile(\\.lock)?$/i": { image: "gemfile" }, - "/^\\.git|^\\.keep$|\\.mailmap$/i": { image: "git" }, - ".go": { image: "go" }, - ".gd": { image: "godot" }, - ".gradle": { image: "gradle" }, - gradlew: { image: "gradle" }, - ".gql": { image: "graphql" }, - ".graphql": { image: "graphql" }, - ".groovy": { image: "groovy" }, - ".gvy": { image: "groovy" }, - ".gy": { image: "groovy" }, - ".gsh": { image: "groovy" }, - "/gruntfile\\.setTrayTitle(js|coffee)/i": { image: "gruntfile" }, - "gulpfile.js": { image: "gulp" }, - "/\\.setTrayTitle(hbs|handlebars|(mu)?stache)$/i": { image: "handlebars" }, - ".prg": { image: "harbour" }, - ".hbp": { image: "harbour" }, - ".hbc": { image: "harbour" }, - ".rc": { image: "harbour" }, - ".fmg": { image: "harbour" }, - ".hs": { image: "haskell" }, - ".hsc": { image: "haskell" }, - ".c2hs": { image: "haskell" }, - ".lhs": { image: "haskell" }, - ".hx": { image: "haxe" }, - ".hxml": { image: "haxe" }, - "/^procfile/i": { image: "heroku" }, - "heroku.yml": { image: "heroku" }, - ".hjson": { image: "hjson" }, - "/\\.x?html?$/i": { image: "html" }, - ".http": { image: "http" }, - ".rest": { image: "http" }, - ".jar": { image: "java" }, - ".java": { image: "java" }, - "jest.config.js": { image: "jest" }, - // ".js": { "image": "js" }, - ".es6": { image: "js" }, - ".es": { image: "js" }, - ".mjs": { image: "js" }, - ".js.map": { image: "jsmap" }, - // ".json": { "image": "json" }, - ".jsonc": { image: "json" }, - ".jsx": { image: "jsx" }, - "/\\.setTrayTitle(jil|jl)/i": { image: "julia" }, - ".ipynb": { image: "jupyter" }, - ".kt": { image: "kotlin" }, - ".ktm": { image: "kotlin" }, - ".kts": { image: "kotlin" }, - ".less": { image: "less" }, - ".lsp": { image: "lisp" }, - ".lisp": { image: "lisp" }, - ".l": { image: "lisp" }, - ".nl": { image: "lisp" }, - ".ny": { image: "lisp" }, - ".podsl": { image: "lisp" }, - ".sexp": { image: "lisp" }, - ".ls": { image: "livescript" }, - ".log": { image: "log" }, - ".lua": { image: "lua" }, - ".pd_lua": { image: "lua" }, - ".rbxs": { image: "lua" }, - ".wlua": { image: "lua" }, - "/^Makefile/": { image: "makefile" }, - "/^mk\\.config$/": { image: "makefile" }, - "/\\.setTrayTitle(mk|mak|make)$/i": { image: "makefile" }, - "/^BSDmakefile$/i": { image: "makefile" }, - "/^GNUmakefile$/i": { image: "makefile" }, - "/^makefile\\.sco$/i": { image: "makefile" }, - "/^Kbuild$/": { image: "makefile" }, - "/^makefile$/": { image: "makefile" }, - "/^mkfile$/i": { image: "makefile" }, - "/^\\.?qmake$/i": { image: "makefile" }, - "/\\.setTrayTitle(h|geo|topo)$/i": { image: "manifest" }, - ".cson": { image: "manifest" }, - ".json5": { image: "manifest" }, - ".ndjson": { image: "manifest" }, - ".fea": { image: "manifest" }, - ".json.eex": { image: "manifest" }, - ".proto": { image: "manifest" }, - ".pytb": { image: "manifest" }, - ".pydeps": { image: "manifest" }, - "/\\.pot?$/i": { image: "manifest" }, - ".ejson": { image: "manifest" }, - ".edn": { image: "manifest" }, - ".eam.fs": { image: "manifest" }, - ".qml": { image: "manifest" }, - ".qbs": { image: "manifest" }, - ".ston": { image: "manifest" }, - ".ttl": { image: "manifest" }, - ".rviz": { image: "manifest" }, - ".syntax": { image: "manifest" }, - ".webmanifest": { image: "manifest" }, - "/^pkginfo$/": { image: "manifest" }, - "/^mime\\.types$/i": { image: "manifest" }, - "/^METADATA\\.pb$/": { image: "manifest" }, - "/[\\/\\\\](?:magic[\\/\\\\]Magdir|file[\\/\\\\]magic)[\\/\\\\][-.\\w]+$/i": - { - image: "manifest", - }, - "/(\\\\|\\/)dev[-\\w]+\\1(?:[^\\\\\\/]+\\1)*(?!DESC|NOTES)(?:[A-Z][-A-Z]*)(?:\\.in)?$/": - { - image: "manifest", - }, - "lib/icons/.icondb.js": { image: "manifest" }, - "/\\.git[\\/\\\\](.*[\\/\\\\])?(HEAD|ORIG_HEAD|packed-refs|logs[\\/\\\\](.+[\\/\\\\])?[^\\/\\\\]+)$/": - { - image: "manifest", - }, - "/\\.setTrayTitle(md|mdown|markdown|mkd|mkdown|mdwn|mkdn|rmd|ron|pmd)$/i": { - image: "markdown", - }, - ".mdx": { image: "markdownx" }, - ".marko": { image: "marko" }, - ".nim": { image: "nim" }, - ".nims": { image: "nim" }, - ".nimble": { image: "nim" }, - ".nix": { image: "nix" }, - "nodemon.json": { image: "nodemon" }, - ".npmrc": { image: "npm" }, - "/\\.mm?$/i": { image: "objc" }, - ".pch": { image: "objc" }, - ".x": { image: "objc" }, - ".ml": { image: "ocaml" }, - ".mli": { image: "ocaml" }, - ".eliom": { image: "ocaml" }, - ".eliomi": { image: "ocaml" }, - ".ml4": { image: "ocaml" }, - ".mll": { image: "ocaml" }, - ".mly": { image: "ocaml" }, - "/\\.pas(cal)?$/i": { image: "pascal" }, - ".lpr": { image: "pascal" }, - ".p": { image: "pawn" }, - ".inc": { image: "pawn" }, - ".sma": { image: "pawn" }, - ".pwn": { image: "pawn" }, - ".sp": { image: "pawn" }, - "/\\.p(er)?l$/i": { image: "perl" }, - ".al": { image: "perl" }, - ".ph": { image: "perl" }, - ".plx": { image: "perl" }, - ".pm": { image: "perl" }, - "/\\.setTrayTitle(psgi|xs)$/i": { image: "perl" }, - ".pl6": { image: "perl" }, - "/\\.[tp]6$|\\.6pl$/i": { image: "perl" }, - "/\\.setTrayTitle(pm6|p6m)$/i": { image: "perl" }, - ".6pm": { image: "perl" }, - ".nqp": { image: "perl" }, - ".p6l": { image: "perl" }, - ".pod6": { image: "perl" }, - "/^Rexfile$/": { image: "perl" }, - "/\\.php([st\\d]|_cs)?$/i": { image: "php" }, - "/^Phakefile/": { image: "php" }, - ".pony": { image: "ponylang" }, - ".pcss": { image: "postcss" }, - ".ps1": { image: "powershell" }, - ".psd1": { image: "powershell" }, - ".psm1": { image: "powershell" }, - ".ps1xml": { image: "powershell" }, - ".prettierignore": { image: "prettier" }, - "/\\.prettier((rc)|(\\.setTrayTitle(toml|yml|yaml|json|js))?$){2}/i": { - image: "prettier", - }, - "prettier.config.js": { image: "prettier" }, - "prisma.yml": { image: "prisma" }, - ".pde": { image: "processing" }, - ".jade": { image: "pug" }, - ".pug": { image: "pug" }, - ".purs": { image: "purescript" }, - ".py": { image: "python" }, - ".ipy": { image: "python" }, - ".isolate": { image: "python" }, - ".pep": { image: "python" }, - ".gyp": { image: "python" }, - ".gypi": { image: "python" }, - ".pyde": { image: "python" }, - ".pyp": { image: "python" }, - ".pyt": { image: "python" }, - ".py3": { image: "python" }, - ".pyi": { image: "python" }, - ".pyw": { image: "python" }, - ".tac": { image: "python" }, - ".wsgi": { image: "python" }, - ".xpy": { image: "python" }, - ".rpy": { image: "python" }, - "/\\.?(pypirc|pythonrc|python-venv)$/i": { image: "python" }, - "/^(SConstruct|SConscript)$/": { image: "python" }, - "/^(Snakefile|WATCHLISTS)$/": { image: "python" }, - "/^wscript$/": { image: "python" }, - "/\\.setTrayTitle(r|Rprofile|rsx|rd)$/i": { image: "r" }, - ".re": { image: "reasonml" }, - "/\\.setTrayTitle(rb|ru|ruby|erb|gemspec|god|mspec|pluginspec|podspec|rabl|rake|opal)$/i": - { - image: "ruby", - }, - "/^\\.?(irbrc|gemrc|pryrc|ruby-(gemset|version))$/i": { image: "ruby" }, - "/^(Appraisals|(Rake|[bB]uild|Cap|Danger|Deliver|Fast|Guard|Jar|Maven|Pod|Puppet|Snap)file(\\.lock)?)$/": - { - image: "ruby", - }, - "/\\.setTrayTitle(jbuilder|rbuild|rb[wx]|builder)$/i": { image: "ruby" }, - "/^rails$/": { image: "ruby" }, - ".watchr": { image: "ruby" }, - ".rs": { image: "rust" }, - "/\\.setTrayTitle(sc|scala)$/i": { image: "scala" }, - ".scss": { image: "scss" }, - ".sass": { image: "scss" }, - "/\\.setTrayTitle(sh|rc|bats|bash|tool|install|command)$/i": { - image: "shell", - }, - "/^(\\.?bash(rc|[-_]?(profile|login|logout|history|prompt))|_osc|config|install-sh|PKGBUILD)$/i": - { - image: "shell", - }, - "/\\.setTrayTitle(ksh|mksh|pdksh)$/i": { image: "shell" }, - ".sh-session": { image: "shell" }, - "/\\.zsh(-theme|_history)?$|^\\.?(antigen|zpreztorc|zlogin|zlogout|zprofile|zshenv|zshrc)$/i": - { - image: "shell", - }, - "/\\.fish$|^\\.fishrc$/i": { image: "shell" }, - "/^\\.?(login|profile)$/": { image: "shell" }, - ".inputrc": { image: "shell" }, - ".tmux": { image: "shell" }, - "/^(configure|config\\.setTrayTitle(guess|rpath|status|sub)|depcomp|libtool|compile)$/": - { - image: "shell", - }, - "/^\\/(private\\/)?etc\\/([^\\/]+\\/)*(profile$|nanorc$|rc\\.|csh\\.)/i": { - image: "shell", - }, - "/^\\.?cshrc$/i": { image: "shell" }, - ".profile": { image: "shell" }, - ".tcsh": { image: "shell" }, - ".csh": { image: "shell" }, - ".sqf": { image: "sqf" }, - "/\\.setTrayTitle(my)?sql$/i": { image: "sql" }, - ".ddl": { image: "sql" }, - ".udf": { image: "sql" }, - ".hql": { image: "sql" }, - ".viw": { image: "sql" }, - ".prc": { image: "sql" }, - ".cql": { image: "sql" }, - ".db2": { image: "sql" }, - "/\\.setTrayTitle(styl|stylus)$/i": { image: "stylus" }, - ".svelte": { image: "svelte" }, - ".svg": { image: "svg" }, - ".swift": { image: "swift" }, - ".tex": { image: "tex" }, - ".ltx": { image: "tex" }, - ".aux": { image: "tex" }, - ".sty": { image: "tex" }, - ".dtx": { image: "tex" }, - ".cls": { image: "tex" }, - ".ins": { image: "tex" }, - ".lbx": { image: "tex" }, - ".mkiv": { image: "tex" }, - ".mkvi": { image: "tex" }, - ".mkii": { image: "tex" }, - ".texi": { image: "tex" }, - "/^hyphen(ex)?\\.setTrayTitle(cs|den|det|fr|sv|us)$/": { image: "tex" }, - "/\\.te?xt$/i": { image: "text" }, - ".rtf": { image: "text" }, - "/\\.i?nfo$/i": { image: "text" }, - ".msg": { image: "text" }, - "/\\.setTrayTitle(utxt|utf8)$/i": { image: "text" }, - ".toml": { image: "toml" }, - ".travis.yml": { image: "travis" }, - ".ts": { image: "ts" }, - ".tsx": { image: "tsx" }, - ".twig": { image: "twig" }, - ".v": { image: "v" }, - ".vh": { image: "v" }, - ".vala": { image: "vala" }, - ".vapi": { image: "vala" }, - ".vb": { image: "vb" }, - ".vbs": { image: "vb" }, - ".vbhtml": { image: "vb" }, - ".vbproj": { image: "vb" }, - ".vba": { image: "vba" }, - ".vcxproj": { image: "vcxproj" }, - ".vscodeignore": { image: "vscodeignore" }, - ".vue": { image: "vue" }, - ".wat": { image: "wasm" }, - ".wast": { image: "wasm" }, - ".wasm": { image: "wasm" }, - "/webpack(\\.dev|\\.development|\\.prod|\\.production)?\\.config(\\.babel)?\\.setTrayTitle(js|jsx|coffee|ts|json|json5|yaml|yml)/i": - { - image: "webpack", - }, - ".xml": { image: "xml" }, - "/\\.ya?ml$/i": { image: "yaml" }, - "/^yarn(\\.lock)?$/i": { image: "yarn" }, - ".yarnrc": { image: "yarn" }, - ".zig": { image: "zig" }, + clientId: '779062000412000307', +}) +// https://github.com/iCrawl/discord-vscode/blob/master/src/data/languages.json +const knownExtensions: { [key: string]: { image: string } } = { + '.ahk': { image: 'ahk' }, + '.ahkl': { image: 'ahk' }, + 'androidmanifest.xml': { image: 'android' }, + '/^angular[^.]*\\.js$/i': { image: 'angular' }, + '.applescript': { image: 'applescript' }, + '/(\\.)?appveyor\\.yml/i': { image: 'appveyor' }, + '.ino': { image: 'arduino' }, + '.swf': { image: 'as' }, + '.as': { image: 'as' }, + '.jsfl': { image: 'as' }, + '.swc': { image: 'as' }, + '.asp': { image: 'asp' }, + '.asax': { image: 'asp' }, + '.ascx': { image: 'asp' }, + '.ashx': { image: 'asp' }, + '.asmx': { image: 'asp' }, + '.aspx': { image: 'asp' }, + '.axd': { image: 'asp' }, + '/\\.setTrayTitle(l?a|[ls]?o|out|s|a51|asm|axf|elf|prx|puff|z80)$/i': { + image: 'assembly', + }, + '.agc': { image: 'assembly' }, + '.ko': { image: 'assembly' }, + '.lst': { image: 'assembly' }, + '/\\.setTrayTitle((c([+px]{2}?)?-?)?objdump|bsdiff|bin|dat|pak|pdb)$/i': { + image: 'assembly', + }, + '.d-objdump': { image: 'assembly' }, + '/\\.gcode|\\.gco/i': { image: 'assembly' }, + '/\\.rpy[bc]$/i': { image: 'assembly' }, + '/\\.py[co]$/i': { image: 'assembly' }, + '.swp': { image: 'assembly' }, + '.DS_Store': { image: 'assembly' }, + '.au3': { image: 'autoit' }, + 'babel.config.js': { image: 'babel' }, + '/\\.babelrc/i': { image: 'babel' }, + '.bat': { image: 'bat' }, + '.batch': { image: 'bat' }, + '.cmd': { image: 'bat' }, + '/\\.setTrayTitle(exe|com|msi)$/i': { image: 'bat' }, + '.reg': { image: 'bat' }, + '/^(\\.bowerrc|bower\\.json|Bowerfile)$/i': { image: 'bower' }, + '/\\.bf?$/i': { image: 'brainfuck' }, + '/\\.c$/i': { image: 'c' }, + '/(cargo.toml|cargo.lock)/i': { image: 'cargo' }, + 'circle.yml': { image: 'circleci' }, + '.clj': { image: 'clojure' }, + '.cl2': { image: 'clojure' }, + '.cljc': { image: 'clojure' }, + '.cljx': { image: 'clojure' }, + '.hic': { image: 'clojure' }, + '/\\.cljs(cm)?$/i': { image: 'clojure' }, + '.cmake': { image: 'cmake' }, + '/^CMakeLists\\.txt$/': { image: 'cmake' }, + '/\\.codeclimate\\.setTrayTitle(yml|json)/i': { image: 'codeclimate' }, + '.coffee': { image: 'coffee' }, + '.cjsx': { image: 'coffee' }, + '.coffee.ecr': { image: 'coffee' }, + '.coffee.erb': { image: 'coffee' }, + '.litcoffee': { image: 'coffee' }, + '.iced': { image: 'coffee' }, + '/\\.c[+px]{2}$|\\.cc$/i': { image: 'cpp' }, + '/\\.h[+px]{2}$/i': { image: 'cpp' }, + '/\\.[it]pp$/i': { image: 'cpp' }, + '/\\.setTrayTitle(tcc|inl)$/i': { image: 'cpp' }, + '.cats': { image: 'cpp' }, + '.idc': { image: 'cpp' }, + '.w': { image: 'cpp' }, + '.nc': { image: 'cpp' }, + '.upc': { image: 'cpp' }, + '.xpm': { image: 'cpp' }, + '/\\.e?cr$/i': { image: 'crystal' }, + '.cs': { image: 'csharp' }, + '.csx': { image: 'csharp' }, + '.cshtml': { image: 'cshtml' }, + // ".css": { "image": "css" }, + '.css.map': { image: 'cssmap' }, + '.cu': { image: 'cuda' }, + '/\\.di?$/i': { image: 'd' }, + '.dart': { image: 'dart' }, + '.dfm': { image: 'delphi' }, + '.dpr': { image: 'delphi' }, + '.dsc': { image: 'denizen' }, + '.dm': { image: 'dm' }, + '.dme': { image: 'dm' }, + '.dmm': { image: 'dm' }, + '/^(Dockerfile|docker-compose)|\\.docker(file|ignore)$/i': { + image: 'docker', + }, + '/^docker-sync\\.yml$/i': { image: 'docker' }, + '.editorconfig': { image: 'editorconfig' }, + '.ejs': { image: 'ejs' }, + '.ex': { image: 'elixir' }, + '/\\.setTrayTitle(exs|l?eex)$/i': { image: 'elixir' }, + '/^mix\\.setTrayTitle(exs?|lock)$/i': { image: 'elixir' }, + '.elm': { image: 'elm' }, + '.env': { image: 'env' }, + '.erl': { image: 'erlang' }, + '.beam': { image: 'erlang' }, + '.hrl': { image: 'erlang' }, + '.xrl': { image: 'erlang' }, + '.yrl': { image: 'erlang' }, + '.app.src': { image: 'erlang' }, + '/^Emakefile$/': { image: 'erlang' }, + '/^rebar(\\.config)?\\.lock$/i': { image: 'erlang' }, + '/\\.setTrayTitle(eslintrc|eslintignore)/i': { image: 'eslint' }, + '/(\\.firebaserc|firebase\\.json)/i': { image: 'firebase' }, + '.flowconfig': { image: 'flowconfig' }, + '.fs': { image: 'fsharp' }, + '.fsi': { image: 'fsharp' }, + '.fsscript': { image: 'fsharp' }, + '.fsx': { image: 'fsharp' }, + '/gatsby-(browser|node|ssr|config)\\.js/i': { image: 'gatsbyjs' }, + '/^Gemfile(\\.lock)?$/i': { image: 'gemfile' }, + '/^\\.git|^\\.keep$|\\.mailmap$/i': { image: 'git' }, + '.go': { image: 'go' }, + '.gd': { image: 'godot' }, + '.gradle': { image: 'gradle' }, + 'gradlew': { image: 'gradle' }, + '.gql': { image: 'graphql' }, + '.graphql': { image: 'graphql' }, + '.groovy': { image: 'groovy' }, + '.gvy': { image: 'groovy' }, + '.gy': { image: 'groovy' }, + '.gsh': { image: 'groovy' }, + '/gruntfile\\.setTrayTitle(js|coffee)/i': { image: 'gruntfile' }, + 'gulpfile.js': { image: 'gulp' }, + '/\\.setTrayTitle(hbs|handlebars|(mu)?stache)$/i': { image: 'handlebars' }, + '.prg': { image: 'harbour' }, + '.hbp': { image: 'harbour' }, + '.hbc': { image: 'harbour' }, + '.rc': { image: 'harbour' }, + '.fmg': { image: 'harbour' }, + '.hs': { image: 'haskell' }, + '.hsc': { image: 'haskell' }, + '.c2hs': { image: 'haskell' }, + '.lhs': { image: 'haskell' }, + '.hx': { image: 'haxe' }, + '.hxml': { image: 'haxe' }, + '/^procfile/i': { image: 'heroku' }, + 'heroku.yml': { image: 'heroku' }, + '.hjson': { image: 'hjson' }, + '/\\.x?html?$/i': { image: 'html' }, + '.http': { image: 'http' }, + '.rest': { image: 'http' }, + '.jar': { image: 'java' }, + '.java': { image: 'java' }, + 'jest.config.js': { image: 'jest' }, + // ".js": { "image": "js" }, + '.es6': { image: 'js' }, + '.es': { image: 'js' }, + '.mjs': { image: 'js' }, + '.js.map': { image: 'jsmap' }, + // ".json": { "image": "json" }, + '.jsonc': { image: 'json' }, + '.jsx': { image: 'jsx' }, + '/\\.setTrayTitle(jil|jl)/i': { image: 'julia' }, + '.ipynb': { image: 'jupyter' }, + '.kt': { image: 'kotlin' }, + '.ktm': { image: 'kotlin' }, + '.kts': { image: 'kotlin' }, + '.less': { image: 'less' }, + '.lsp': { image: 'lisp' }, + '.lisp': { image: 'lisp' }, + '.l': { image: 'lisp' }, + '.nl': { image: 'lisp' }, + '.ny': { image: 'lisp' }, + '.podsl': { image: 'lisp' }, + '.sexp': { image: 'lisp' }, + '.ls': { image: 'livescript' }, + '.log': { image: 'log' }, + '.lua': { image: 'lua' }, + '.pd_lua': { image: 'lua' }, + '.rbxs': { image: 'lua' }, + '.wlua': { image: 'lua' }, + '/^Makefile/': { image: 'makefile' }, + '/^mk\\.config$/': { image: 'makefile' }, + '/\\.setTrayTitle(mk|mak|make)$/i': { image: 'makefile' }, + '/^BSDmakefile$/i': { image: 'makefile' }, + '/^GNUmakefile$/i': { image: 'makefile' }, + '/^makefile\\.sco$/i': { image: 'makefile' }, + '/^Kbuild$/': { image: 'makefile' }, + '/^makefile$/': { image: 'makefile' }, + '/^mkfile$/i': { image: 'makefile' }, + '/^\\.?qmake$/i': { image: 'makefile' }, + '/\\.setTrayTitle(h|geo|topo)$/i': { image: 'manifest' }, + '.cson': { image: 'manifest' }, + '.json5': { image: 'manifest' }, + '.ndjson': { image: 'manifest' }, + '.fea': { image: 'manifest' }, + '.json.eex': { image: 'manifest' }, + '.proto': { image: 'manifest' }, + '.pytb': { image: 'manifest' }, + '.pydeps': { image: 'manifest' }, + '/\\.pot?$/i': { image: 'manifest' }, + '.ejson': { image: 'manifest' }, + '.edn': { image: 'manifest' }, + '.eam.fs': { image: 'manifest' }, + '.qml': { image: 'manifest' }, + '.qbs': { image: 'manifest' }, + '.ston': { image: 'manifest' }, + '.ttl': { image: 'manifest' }, + '.rviz': { image: 'manifest' }, + '.syntax': { image: 'manifest' }, + '.webmanifest': { image: 'manifest' }, + '/^pkginfo$/': { image: 'manifest' }, + '/^mime\\.types$/i': { image: 'manifest' }, + '/^METADATA\\.pb$/': { image: 'manifest' }, + '/[\\/\\\\](?:magic[\\/\\\\]Magdir|file[\\/\\\\]magic)[\\/\\\\][-.\\w]+$/i': { image: 'manifest' }, + '/(\\\\|\\/)dev[-\\w]+\\1(?:[^\\\\\\/]+\\1)*(?!DESC|NOTES)(?:[A-Z][-A-Z]*)(?:\\.in)?$/': { image: 'manifest' }, + 'lib/icons/.icondb.js': { image: 'manifest' }, + '/\\.git[\\/\\\\](.*[\\/\\\\])?(HEAD|ORIG_HEAD|packed-refs|logs[\\/\\\\](.+[\\/\\\\])?[^\\/\\\\]+)$/': { image: 'manifest' }, + '/\\.setTrayTitle(md|mdown|markdown|mkd|mkdown|mdwn|mkdn|rmd|ron|pmd)$/i': { image: 'markdown' }, + '.mdx': { image: 'markdownx' }, + '.marko': { image: 'marko' }, + '.nim': { image: 'nim' }, + '.nims': { image: 'nim' }, + '.nimble': { image: 'nim' }, + '.nix': { image: 'nix' }, + 'nodemon.json': { image: 'nodemon' }, + '.npmrc': { image: 'npm' }, + '/\\.mm?$/i': { image: 'objc' }, + '.pch': { image: 'objc' }, + '.x': { image: 'objc' }, + '.ml': { image: 'ocaml' }, + '.mli': { image: 'ocaml' }, + '.eliom': { image: 'ocaml' }, + '.eliomi': { image: 'ocaml' }, + '.ml4': { image: 'ocaml' }, + '.mll': { image: 'ocaml' }, + '.mly': { image: 'ocaml' }, + '/\\.pas(cal)?$/i': { image: 'pascal' }, + '.lpr': { image: 'pascal' }, + '.p': { image: 'pawn' }, + '.inc': { image: 'pawn' }, + '.sma': { image: 'pawn' }, + '.pwn': { image: 'pawn' }, + '.sp': { image: 'pawn' }, + '/\\.p(er)?l$/i': { image: 'perl' }, + '.al': { image: 'perl' }, + '.ph': { image: 'perl' }, + '.plx': { image: 'perl' }, + '.pm': { image: 'perl' }, + '/\\.setTrayTitle(psgi|xs)$/i': { image: 'perl' }, + '.pl6': { image: 'perl' }, + '/\\.[tp]6$|\\.6pl$/i': { image: 'perl' }, + '/\\.setTrayTitle(pm6|p6m)$/i': { image: 'perl' }, + '.6pm': { image: 'perl' }, + '.nqp': { image: 'perl' }, + '.p6l': { image: 'perl' }, + '.pod6': { image: 'perl' }, + '/^Rexfile$/': { image: 'perl' }, + '/\\.php([st\\d]|_cs)?$/i': { image: 'php' }, + '/^Phakefile/': { image: 'php' }, + '.pony': { image: 'ponylang' }, + '.pcss': { image: 'postcss' }, + '.ps1': { image: 'powershell' }, + '.psd1': { image: 'powershell' }, + '.psm1': { image: 'powershell' }, + '.ps1xml': { image: 'powershell' }, + '.prettierignore': { image: 'prettier' }, + '/\\.prettier((rc)|(\\.setTrayTitle(toml|yml|yaml|json|js))?$){2}/i': { + image: 'prettier', + }, + 'prettier.config.js': { image: 'prettier' }, + 'prisma.yml': { image: 'prisma' }, + '.pde': { image: 'processing' }, + '.jade': { image: 'pug' }, + '.pug': { image: 'pug' }, + '.purs': { image: 'purescript' }, + '.py': { image: 'python' }, + '.ipy': { image: 'python' }, + '.isolate': { image: 'python' }, + '.pep': { image: 'python' }, + '.gyp': { image: 'python' }, + '.gypi': { image: 'python' }, + '.pyde': { image: 'python' }, + '.pyp': { image: 'python' }, + '.pyt': { image: 'python' }, + '.py3': { image: 'python' }, + '.pyi': { image: 'python' }, + '.pyw': { image: 'python' }, + '.tac': { image: 'python' }, + '.wsgi': { image: 'python' }, + '.xpy': { image: 'python' }, + '.rpy': { image: 'python' }, + '/\\.?(pypirc|pythonrc|python-venv)$/i': { image: 'python' }, + '/^(SConstruct|SConscript)$/': { image: 'python' }, + '/^(Snakefile|WATCHLISTS)$/': { image: 'python' }, + '/^wscript$/': { image: 'python' }, + '/\\.setTrayTitle(r|Rprofile|rsx|rd)$/i': { image: 'r' }, + '.re': { image: 'reasonml' }, + '/\\.setTrayTitle(rb|ru|ruby|erb|gemspec|god|mspec|pluginspec|podspec|rabl|rake|opal)$/i': { image: 'ruby' }, + '/^\\.?(irbrc|gemrc|pryrc|ruby-(gemset|version))$/i': { image: 'ruby' }, + '/^(Appraisals|(Rake|[bB]uild|Cap|Danger|Deliver|Fast|Guard|Jar|Maven|Pod|Puppet|Snap)file(\\.lock)?)$/': { image: 'ruby' }, + '/\\.setTrayTitle(jbuilder|rbuild|rb[wx]|builder)$/i': { image: 'ruby' }, + '/^rails$/': { image: 'ruby' }, + '.watchr': { image: 'ruby' }, + '.rs': { image: 'rust' }, + '/\\.setTrayTitle(sc|scala)$/i': { image: 'scala' }, + '.scss': { image: 'scss' }, + '.sass': { image: 'scss' }, + '/\\.setTrayTitle(sh|rc|bats|bash|tool|install|command)$/i': { + image: 'shell', + }, + '/^(\\.?bash(rc|[-_]?(profile|login|logout|history|prompt))|_osc|config|install-sh|PKGBUILD)$/i': { image: 'shell' }, + '/\\.setTrayTitle(ksh|mksh|pdksh)$/i': { image: 'shell' }, + '.sh-session': { image: 'shell' }, + '/\\.zsh(-theme|_history)?$|^\\.?(antigen|zpreztorc|zlogin|zlogout|zprofile|zshenv|zshrc)$/i': { image: 'shell' }, + '/\\.fish$|^\\.fishrc$/i': { image: 'shell' }, + '/^\\.?(login|profile)$/': { image: 'shell' }, + '.inputrc': { image: 'shell' }, + '.tmux': { image: 'shell' }, + '/^(configure|config\\.setTrayTitle(guess|rpath|status|sub)|depcomp|libtool|compile)$/': { image: 'shell' }, + '/^\\/(private\\/)?etc\\/([^\\/]+\\/)*(profile$|nanorc$|rc\\.|csh\\.)/i': { + image: 'shell', + }, + '/^\\.?cshrc$/i': { image: 'shell' }, + '.profile': { image: 'shell' }, + '.tcsh': { image: 'shell' }, + '.csh': { image: 'shell' }, + '.sqf': { image: 'sqf' }, + '/\\.setTrayTitle(my)?sql$/i': { image: 'sql' }, + '.ddl': { image: 'sql' }, + '.udf': { image: 'sql' }, + '.hql': { image: 'sql' }, + '.viw': { image: 'sql' }, + '.prc': { image: 'sql' }, + '.cql': { image: 'sql' }, + '.db2': { image: 'sql' }, + '/\\.setTrayTitle(styl|stylus)$/i': { image: 'stylus' }, + '.svelte': { image: 'svelte' }, + '.svg': { image: 'svg' }, + '.swift': { image: 'swift' }, + '.tex': { image: 'tex' }, + '.ltx': { image: 'tex' }, + '.aux': { image: 'tex' }, + '.sty': { image: 'tex' }, + '.dtx': { image: 'tex' }, + '.cls': { image: 'tex' }, + '.ins': { image: 'tex' }, + '.lbx': { image: 'tex' }, + '.mkiv': { image: 'tex' }, + '.mkvi': { image: 'tex' }, + '.mkii': { image: 'tex' }, + '.texi': { image: 'tex' }, + '/^hyphen(ex)?\\.setTrayTitle(cs|den|det|fr|sv|us)$/': { image: 'tex' }, + '/\\.te?xt$/i': { image: 'text' }, + '.rtf': { image: 'text' }, + '/\\.i?nfo$/i': { image: 'text' }, + '.msg': { image: 'text' }, + '/\\.setTrayTitle(utxt|utf8)$/i': { image: 'text' }, + '.toml': { image: 'toml' }, + '.travis.yml': { image: 'travis' }, + '.ts': { image: 'ts' }, + '.tsx': { image: 'tsx' }, + '.twig': { image: 'twig' }, + '.v': { image: 'v' }, + '.vh': { image: 'v' }, + '.vala': { image: 'vala' }, + '.vapi': { image: 'vala' }, + '.vb': { image: 'vb' }, + '.vbs': { image: 'vb' }, + '.vbhtml': { image: 'vb' }, + '.vbproj': { image: 'vb' }, + '.vba': { image: 'vba' }, + '.vcxproj': { image: 'vcxproj' }, + '.vscodeignore': { image: 'vscodeignore' }, + '.vue': { image: 'vue' }, + '.wat': { image: 'wasm' }, + '.wast': { image: 'wasm' }, + '.wasm': { image: 'wasm' }, + '/webpack(\\.dev|\\.development|\\.prod|\\.production)?\\.config(\\.babel)?\\.setTrayTitle(js|jsx|coffee|ts|json|json5|yaml|yml)/i': { image: 'webpack' }, + '.xml': { image: 'xml' }, + '/\\.ya?ml$/i': { image: 'yaml' }, + '/^yarn(\\.lock)?$/i': { image: 'yarn' }, + '.yarnrc': { image: 'yarn' }, + '.zig': { image: 'zig' }, - ".json": { image: "json" }, - ".js": { image: "js" }, - ".css": { image: "css" }, - }, - assets = { - pylon: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/0.png", - ahk: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/1.png", - angular: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/2.png", - applescript: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/3.png", - android: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/4.png", - appveyor: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/5.png", - arduino: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/6.png", - as: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/7.png", - autoit: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/8.png", - asp: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/9.png", - assembly: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/10.png", - bat: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/11.png", - bower: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/12.png", - cmake: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/13.png", - clojure: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/14.png", - circleci: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/15.png", - c: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/16.png", - cargo: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/17.png", - env: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/18.png", - flowconfig: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/19.png", - cssmap: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/20.png", - cshtml: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/21.png", - firebase: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/22.png", - crystal: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/23.png", - eslint: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/24.png", - git: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/25.png", - elm: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/26.png", - d: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/27.png", - denizen: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/28.png", - dart: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/29.png", - csharp: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/30.png", - elixir: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/31.png", - css: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/32.png", - dm: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/33.png", - docker: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/34.png", - haskell: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/35.png", - ejs: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/36.png", - cuda: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/37.png", - fsharp: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/38.png", - gemfile: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/39.png", - gradle: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/40.png", - go: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/41.png", - coffee: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/42.png", - brainfuck: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/43.png", - erlang: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/44.png", - gatsbyjs: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/45.png", - graphql: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/46.png", - cpp: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/47.png", - godot: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/48.png", - log: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/49.png", - livescript: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/50.png", - heroku: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/51.png", - handlebars: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/52.png", - npm: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/53.png", - jsmap: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/54.png", - hjson: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/55.png", - html: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/56.png", - markdown: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/57.png", - manifest: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/58.png", - markdownx: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/59.png", - json: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/60.png", - gruntfile: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/61.png", - toml: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/62.png", - harbour: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/63.png", - js: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/64.png", - gulp: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/65.png", - makefile: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/66.png", - reasonml: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/67.png", - shell: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/68.png", - nim: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/69.png", - julia: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/70.png", - editorconfig: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/71.png", - text: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/72.png", - jest: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/73.png", - ts: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/74.png", - xml: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/75.png", - haxe: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/76.png", - yaml: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/77.png", - tex: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/78.png", - wasm: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/79.png", - prisma: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/80.png", - vcxproj: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/81.png", - kotlin: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/82.png", - nodemon: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/83.png", - r: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/84.png", - ocaml: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/85.png", - powershell: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/86.png", - svg: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/87.png", - delphi: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/88.png", - python: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/89.png", - sql: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/90.png", - http: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/91.png", - v: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/92.png", - yarn: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/93.png", - txt: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/94.png", - zig: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/95.png", - groovy: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/96.png", - marko: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/97.png", - prettier: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/98.png", - php: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/99.png", - twig: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/100.png", - swift: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/101.png", - lua: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/102.png", - purescript: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/103.png", - vue: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/104.png", - java: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/105.png", - less: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/106.png", - jsx: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/107.png", - jupyter: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/108.png", - lisp: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/109.png", - perl: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/110.png", - objc: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/111.png", - pascal: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/112.png", - pawn: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/113.png", - postcss: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/114.png", - pug: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/115.png", - vba: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/116.png", - vscodeignore: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/117.png", - tsx: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/118.png", - vb: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/119.png", - sqf: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/120.png", - svelte: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/121.png", - ruby: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/122.png", - scala: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/123.png", - stylus: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/124.png", - webpack: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/125.png", - vala: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/126.png", - travis: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/127.png", - rust: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/128.png", - scss: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/129.png", - ponylang: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/130.png", - processing: "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/131.png", - }; + '.json': { image: 'json' }, + '.js': { image: 'js' }, + '.css': { image: 'css' }, +} +const assets = { + pylon: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/0.png', + ahk: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/1.png', + angular: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/2.png', + applescript: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/3.png', + android: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/4.png', + appveyor: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/5.png', + arduino: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/6.png', + as: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/7.png', + autoit: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/8.png', + asp: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/9.png', + assembly: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/10.png', + bat: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/11.png', + bower: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/12.png', + cmake: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/13.png', + clojure: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/14.png', + circleci: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/15.png', + c: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/16.png', + cargo: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/17.png', + env: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/18.png', + flowconfig: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/19.png', + cssmap: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/20.png', + cshtml: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/21.png', + firebase: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/22.png', + crystal: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/23.png', + eslint: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/24.png', + git: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/25.png', + elm: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/26.png', + d: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/27.png', + denizen: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/28.png', + dart: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/29.png', + csharp: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/30.png', + elixir: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/31.png', + css: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/32.png', + dm: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/33.png', + docker: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/34.png', + haskell: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/35.png', + ejs: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/36.png', + cuda: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/37.png', + fsharp: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/38.png', + gemfile: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/39.png', + gradle: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/40.png', + go: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/41.png', + coffee: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/42.png', + brainfuck: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/43.png', + erlang: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/44.png', + gatsbyjs: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/45.png', + graphql: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/46.png', + cpp: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/47.png', + godot: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/48.png', + log: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/49.png', + livescript: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/50.png', + heroku: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/51.png', + handlebars: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/52.png', + npm: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/53.png', + jsmap: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/54.png', + hjson: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/55.png', + html: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/56.png', + markdown: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/57.png', + manifest: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/58.png', + markdownx: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/59.png', + json: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/60.png', + gruntfile: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/61.png', + toml: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/62.png', + harbour: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/63.png', + js: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/64.png', + gulp: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/65.png', + makefile: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/66.png', + reasonml: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/67.png', + shell: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/68.png', + nim: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/69.png', + julia: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/70.png', + editorconfig: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/71.png', + text: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/72.png', + jest: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/73.png', + ts: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/74.png', + xml: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/75.png', + haxe: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/76.png', + yaml: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/77.png', + tex: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/78.png', + wasm: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/79.png', + prisma: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/80.png', + vcxproj: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/81.png', + kotlin: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/82.png', + nodemon: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/83.png', + r: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/84.png', + ocaml: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/85.png', + powershell: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/86.png', + svg: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/87.png', + delphi: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/88.png', + python: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/89.png', + sql: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/90.png', + http: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/91.png', + v: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/92.png', + yarn: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/93.png', + txt: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/94.png', + zig: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/95.png', + groovy: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/96.png', + marko: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/97.png', + prettier: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/98.png', + php: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/99.png', + twig: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/100.png', + swift: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/101.png', + lua: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/102.png', + purescript: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/103.png', + vue: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/104.png', + java: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/105.png', + less: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/106.png', + jsx: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/107.png', + jupyter: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/108.png', + lisp: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/109.png', + perl: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/110.png', + objc: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/111.png', + pascal: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/112.png', + pawn: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/113.png', + postcss: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/114.png', + pug: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/115.png', + vba: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/116.png', + vscodeignore: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/117.png', + tsx: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/118.png', + vb: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/119.png', + sqf: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/120.png', + svelte: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/121.png', + ruby: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/122.png', + scala: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/123.png', + stylus: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/124.png', + webpack: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/125.png', + vala: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/126.png', + travis: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/127.png', + rust: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/128.png', + scss: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/129.png', + ponylang: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/130.png', + processing: 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/131.png', +} const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/logo.png", - Idle = "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/132.png", - PylonD = "https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/133.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/logo.png', + Idle = 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/132.png', + PylonD = 'https://cdn.rcd.gg/PreMiD/websites/P/Pylon/assets/133.png', } -let lastFileChange: number = null, - lastElement: Element = null; +let lastFileChange: number | null = null +let lastElement: Element | null = null -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }, - docsSelector = - ".current.tsd-kind-namespace > a, .current.tsd-parent-kind-namespace > a"; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } + const docsSelector = '.current.tsd-kind-namespace > a, .current.tsd-parent-kind-namespace > a' - if (document.location.pathname.startsWith("/docs/changelog")) - presenceData.details = "Viewing the changelog"; - else if (document.location.pathname.startsWith("/docs/reference")) { - presenceData.details = "Viewing the SDK reference"; - if ( - document.querySelector(docsSelector) && - (await presence.getSetting("docname")) - ) { - presenceData.state = Array.from(document.querySelectorAll(docsSelector)) - .map(el => el.textContent) - .join(" - "); - } - } else if (document.location.pathname.startsWith("/docs/")) - presenceData.details = "Looking at the docs"; - else if (document.location.pathname.startsWith("/studio")) { - presenceData.details = "Studio"; - if (document.location.pathname.endsWith("editor")) { - presenceData.smallImageKey = Assets.PylonD; - presenceData.smallImageText = "Pylon Studio Editor"; - const guildName = document.querySelector( - "#root > div.PageStudioGuildEdit_studioContainer__2vaAW > div > div.PylonEditor_editorContainerOuter__3o4x4 > div.PylonEditor_editorContainerGridVertical__10qLF > div > div:nth-child(1) > div > div.SideBar_header__2dvwm > h3" - ).textContent, - currentFile = document.querySelector(".TabBar_tabSelected__foMO4"); - if (currentFile) { - const largeImageKey = - knownExtensions[ - Object.keys(knownExtensions).find(key => { - if (currentFile.textContent.endsWith(key)) return true; - const match = /^\/(.*)\/([mgiy]+)$/.exec(key); - if (!match) return false; - return new RegExp(match[1], match[2]).test( - currentFile.textContent - ); - }) - ]; + if (document.location.pathname.startsWith('/docs/changelog')) { + presenceData.details = 'Viewing the changelog' + } + else if (document.location.pathname.startsWith('/docs/reference')) { + presenceData.details = 'Viewing the SDK reference' + if ( + document.querySelector(docsSelector) + && (await presence.getSetting('docname')) + ) { + presenceData.state = Array.from(document.querySelectorAll(docsSelector)) + .map(el => el.textContent) + .join(' - ') + } + } + else if (document.location.pathname.startsWith('/docs/')) { + presenceData.details = 'Looking at the docs' + } + else if (document.location.pathname.startsWith('/studio')) { + presenceData.details = 'Studio' + if (document.location.pathname.endsWith('editor')) { + presenceData.smallImageKey = Assets.PylonD + presenceData.smallImageText = 'Pylon Studio Editor' + const guildName = document.querySelector( + '#root > div.PageStudioGuildEdit_studioContainer__2vaAW > div > div.PylonEditor_editorContainerOuter__3o4x4 > div.PylonEditor_editorContainerGridVertical__10qLF > div > div:nth-child(1) > div > div.SideBar_header__2dvwm > h3', + )?.textContent + const currentFile = document.querySelector('.TabBar_tabSelected__foMO4') + if (currentFile) { + const largeImageKey = knownExtensions[ + Object.keys(knownExtensions).find((key) => { + if (currentFile.textContent?.endsWith(key)) + return true + const match = /^\/(.*)\/([mgiy]+)$/.exec(key) + if (!match) + return false + return new RegExp(match[1], match[2]).test( + currentFile.textContent ?? '', + ) + })! + ] - if (lastElement !== currentFile) { - lastElement = currentFile; - lastFileChange = Date.now(); - } + if (lastElement !== currentFile) { + lastElement = currentFile + lastFileChange = Date.now() + } - presenceData.startTimestamp = lastFileChange; - presenceData.largeImageKey = - assets[ - (largeImageKey ? largeImageKey.image : "txt") as keyof typeof assets - ]; - presenceData.details = (await presence.getSetting("details")) - .replaceAll("%file%", currentFile.textContent) - .replaceAll("%guild%", guildName) - .replaceAll( - "%ext%", - (largeImageKey ? largeImageKey.image : "txt").toUpperCase() - ); - presenceData.state = (await presence.getSetting("state")) - .replaceAll("%file%", currentFile.textContent) - .replaceAll("%guild%", guildName) - .replaceAll( - "%ext%", - (largeImageKey ? largeImageKey.image : "txt").toUpperCase() - ); - } else { - presenceData.largeImageKey = Assets.Idle; - presenceData.details = "Idling"; - } - } else if (document.location.pathname.startsWith("/studio/guilds/")) { - presenceData.details += ": Viewing Server"; - if (await presence.getSetting("studioguildname")) { - presenceData.state = document.querySelector( - "#root > div:nth-child(4) > div.📦h_130px.📦box-szg_border-box > div.📦flt_left.📦w_340px.📦box-szg_border-box > div > div.📦flt_left.📦pl_0px.📦w_100prcnt.📦box-szg_border-box > div.📦flt_left.📦w_60prcnt.📦box-szg_border-box > div.PageStudioGuild_guildName__tgbvT" - ).textContent; - } - } - } + presenceData.startTimestamp = lastFileChange + presenceData.largeImageKey = assets[ + (largeImageKey ? largeImageKey.image : 'txt') as keyof typeof assets + ] + presenceData.details = (await presence.getSetting('details')) + .replaceAll('%file%', currentFile.textContent ?? '') + .replaceAll('%guild%', guildName ?? '') + .replaceAll( + '%ext%', + (largeImageKey ? largeImageKey.image : 'txt').toUpperCase(), + ) + presenceData.state = (await presence.getSetting('state')) + .replaceAll('%file%', currentFile.textContent ?? '') + .replaceAll('%guild%', guildName ?? '') + .replaceAll( + '%ext%', + (largeImageKey ? largeImageKey.image : 'txt').toUpperCase(), + ) + } + else { + presenceData.largeImageKey = Assets.Idle + presenceData.details = 'Idling' + } + } + else if (document.location.pathname.startsWith('/studio/guilds/')) { + presenceData.details += ': Viewing Server' + if (await presence.getSetting('studioguildname')) { + presenceData.state = document.querySelector( + '#root > div:nth-child(4) > div.📦h_130px.📦box-szg_border-box > div.📦flt_left.📦w_340px.📦box-szg_border-box > div > div.📦flt_left.📦pl_0px.📦w_100prcnt.📦box-szg_border-box > div.📦flt_left.📦w_60prcnt.📦box-szg_border-box > div.PageStudioGuild_guildName__tgbvT', + )?.textContent + } + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/p90.zone/metadata.json b/websites/P/p90.zone/metadata.json index daed0f2d2b77..4663846393b8 100644 --- a/websites/P/p90.zone/metadata.json +++ b/websites/P/p90.zone/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "fror", - "id": "515668127829458945" - }, - "service": "p90.zone", - "description": { - "en": "p90.zone is a website that shows random WebMs (mostly memes) uploaded by their users", - "nl": "p90.zone is een website die willekeurige WebM's (meestal memes) laat zien die door hun gebruikers zijn geüpload" - }, - "url": "p90.zone", - "version": "1.2.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/p90.zone/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/p90.zone/assets/thumbnail.png", - "color": "#000084", - "category": "videos", - "tags": [ - "video", - "memes", - "webm" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "fror", + "id": "515668127829458945" + }, + "service": "p90.zone", + "description": { + "en": "p90.zone is a website that shows random WebMs (mostly memes) uploaded by their users", + "nl": "p90.zone is een website die willekeurige WebM's (meestal memes) laat zien die door hun gebruikers zijn geüpload" + }, + "url": "p90.zone", + "version": "1.2.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/p90.zone/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/p90.zone/assets/thumbnail.png", + "color": "#000084", + "category": "videos", + "tags": [ + "video", + "memes", + "webm" + ] +} diff --git a/websites/P/p90.zone/presence.ts b/websites/P/p90.zone/presence.ts index ed0442287059..1ba476597264 100644 --- a/websites/P/p90.zone/presence.ts +++ b/websites/P/p90.zone/presence.ts @@ -1,40 +1,42 @@ const presence = new Presence({ - clientId: "633714339999645737", -}); + clientId: '633714339999645737', +}) function getTimestamps(curr: number, dura: number): number[] { - const startTime = Math.floor(Date.now() / 1000); - return [startTime, Math.floor(startTime - curr + dura)]; + const startTime = Math.floor(Date.now() / 1000) + return [startTime, Math.floor(startTime - curr + dura)] } -presence.on("UpdateData", async () => { - const video = document.querySelector("video"), - strings = await presence.getStrings({ - playing: "general.playing", - paused: "general.paused", - browsing: "general.browsing", - }); +presence.on('UpdateData', async () => { + const video = document.querySelector('video') + const strings = await presence.getStrings({ + playing: 'general.playing', + paused: 'general.paused', + browsing: 'general.browsing', + }) - if (video) { - const timestamps = getTimestamps(video.currentTime, video.duration), - presenceData: PresenceData = { - state: document.querySelector("body > div.menu.main > div > h2") - .textContent, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/p90.zone/assets/logo.png", - startTimestamp: timestamps[0], - endTimestamp: timestamps[1], - smallImageKey: video.paused ? Assets.Pause : Assets.Play, - smallImageText: video.paused - ? (await strings).paused - : (await strings).playing, - }; + if (video) { + const timestamps = getTimestamps(video.currentTime, video.duration) + const presenceData: PresenceData = { + state: document.querySelector('body > div.menu.main > div > h2') + ?.textContent, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/p90.zone/assets/logo.png', + startTimestamp: timestamps[0], + endTimestamp: timestamps[1], + smallImageKey: video.paused ? Assets.Pause : Assets.Play, + smallImageText: video.paused + ? (await strings).paused + : (await strings).playing, + } - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } - presence.setActivity(presenceData); - } else presence.setActivity(); -}); + presence.setActivity(presenceData) + } + else { + presence.setActivity() + } +}) diff --git a/websites/P/padlet/metadata.json b/websites/P/padlet/metadata.json index 39e3332306e9..26e9b9913a8d 100644 --- a/websites/P/padlet/metadata.json +++ b/websites/P/padlet/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "The Gamerzs", - "id": "730142125181894657" - }, - "service": "padlet", - "description": { - "en": "From your hobby to your career, your class notes to your final exam, your mood board to your runway show, padlets help you organize your life." - }, - "url": "padlet.com", - "version": "1.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/padlet/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/padlet/assets/thumbnail.png", - "color": "#303644", - "category": "other", - "tags": [ - "boards", - "information" - ], - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "The Gamerzs", + "id": "730142125181894657" + }, + "service": "padlet", + "description": { + "en": "From your hobby to your career, your class notes to your final exam, your mood board to your runway show, padlets help you organize your life." + }, + "url": "padlet.com", + "version": "1.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/padlet/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/padlet/assets/thumbnail.png", + "color": "#303644", + "category": "other", + "tags": [ + "boards", + "information" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/P/padlet/presence.ts b/websites/P/padlet/presence.ts index f7380c78a357..817063f158fb 100644 --- a/websites/P/padlet/presence.ts +++ b/websites/P/padlet/presence.ts @@ -1,96 +1,101 @@ const presence = new Presence({ - clientId: "889524311566725161", - }), - browsingTimestamp = Date.now(); - -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/padlet/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - pathnames = location.pathname.split("/"); - - if (pathnames[1] === "dashboard") { - //Dashboard - let type, count; - - switch (pathnames[2]) { - case "drive": - presenceData.details = "Viewing"; - presenceData.state = "Padlet Drive"; - break; - case null: - type = document - .querySelector( - 'body > div > div > div > div > nav > a[data-selected="true"]' - ) - .textContent.replace("edit", ""); - count = document.querySelector(".padlet-cards-list")?.children.length; - - presenceData.details = `Viewing ${type}`; - presenceData.state = `Padlets - ${count ?? "0"}`; - break; - - default: - presenceData.details = "Viewing their"; - presenceData.state = "Dashboard"; - break; - } - - if (document.querySelector('.universal-search[data-status="expanded"]')) { - presenceData.details = `Searching: ${ - (document.querySelector(".universal-search-input") as HTMLInputElement) - .value - }`; - presenceData.state = `${ - document.querySelector(".padlet-cards-list").children.length - } Results`; - } - } else if (pathnames[1] === "create") { - //Creating a Padlet - - presenceData.details = "Creating a Padlet"; - presenceData.state = "Choosing a template"; - - presenceData.smallImageKey = Assets.Writing; - presenceData.smallImageText = "Creating"; - } else if (document.querySelector("#wall-container")) { - //Padlet - const padletData = JSON.parse( - document.querySelector('head > script[type="application/ld+json"]') - .textContent - ); - - presenceData.details = padletData.name; - presenceData.state = `By: ${padletData.author.name}`; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - - presenceData.buttons = [ - { label: "View Padlet", url: padletData.url }, - { label: "View Author", url: padletData.author.url }, - ]; - } else if (document.querySelector(".header-user-info")) { - //Author - const padletData = JSON.parse( - document.querySelector('head > script[type="application/ld+json"]') - .textContent - ); - - presenceData.details = `Viewing ${padletData.name}`; - - presenceData.state = document.querySelector(".header-user-bio").textContent; - - presenceData.buttons = [ - { label: "View Author", url: `https://padlet.com/${padletData.url}` }, - ]; - } - - const showButtons = await presence.getSetting("buttons"); - - if (!showButtons) delete presenceData.buttons; - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + clientId: '889524311566725161', +}) +const browsingTimestamp = Date.now() + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/padlet/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const pathnames = location.pathname.split('/') + + if (pathnames[1] === 'dashboard') { + // Dashboard + let type, count + + switch (pathnames[2]) { + case 'drive': + presenceData.details = 'Viewing' + presenceData.state = 'Padlet Drive' + break + case null: + type = document + .querySelector( + 'body > div > div > div > div > nav > a[data-selected="true"]', + ) + ?.textContent + ?.replace('edit', '') + count = document.querySelector('.padlet-cards-list')?.children.length + + presenceData.details = `Viewing ${type}` + presenceData.state = `Padlets - ${count ?? '0'}` + break + + default: + presenceData.details = 'Viewing their' + presenceData.state = 'Dashboard' + break + } + + if (document.querySelector('.universal-search[data-status="expanded"]')) { + presenceData.details = `Searching: ${ + (document.querySelector('.universal-search-input') as HTMLInputElement) + .value + }` + presenceData.state = `${ + document.querySelector('.padlet-cards-list')?.children.length + } Results` + } + } + else if (pathnames[1] === 'create') { + // Creating a Padlet + + presenceData.details = 'Creating a Padlet' + presenceData.state = 'Choosing a template' + + presenceData.smallImageKey = Assets.Writing + presenceData.smallImageText = 'Creating' + } + else if (document.querySelector('#wall-container')) { + // Padlet + const padletData = JSON.parse( + document.querySelector('head > script[type="application/ld+json"]') + ?.textContent ?? '{}', + ) + + presenceData.details = padletData.name + presenceData.state = `By: ${padletData.author.name}` + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + + presenceData.buttons = [ + { label: 'View Padlet', url: padletData.url }, + { label: 'View Author', url: padletData.author.url }, + ] + } + else if (document.querySelector('.header-user-info')) { + // Author + const padletData = JSON.parse( + document.querySelector('head > script[type="application/ld+json"]') + ?.textContent ?? '{}', + ) + + presenceData.details = `Viewing ${padletData.name}` + + presenceData.state = document.querySelector('.header-user-bio')?.textContent + + presenceData.buttons = [ + { label: 'View Author', url: `https://padlet.com/${padletData.url}` }, + ] + } + + const showButtons = await presence.getSetting('buttons') + + if (!showButtons) + delete presenceData.buttons + + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/paimon.moe/metadata.json b/websites/P/paimon.moe/metadata.json index 7956500bceea..7cebaf7efe5e 100644 --- a/websites/P/paimon.moe/metadata.json +++ b/websites/P/paimon.moe/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "rushia", - "id": "398752205043400724" - }, - "service": "paimon.moe", - "description": { - "en": "Your best Genshin Impact companion! Help you plan what to farm with ascension calculator, also track your progress with todo and wish counter.", - "zh_CN": "你最好的原神伙伴! 帮助你规划材料消耗与刷本, 追踪你的游戏进度与抽卡结果.", - "fr": "Votre meilleur compagnon pour Genshin Impact ! Vous aide à planifier ce que vous souhaitez farmer avec le calculateur d'élévation et vous permet de suivre votre progression avec la liste de tâches et le compteur de voeux.", - "ko_KR": "최고의 원신 동반자! 돌파 계산기로 파밍 계획을 도와주고, 할 일 목록과 기원 통계를 통해 진척도를 확인해줍니다.", - "id": "Your best Genshin Impact companion! Membantu kamu merencanakan apa yang harus di farm dengan kalkulator ascension, juga catat progress mu dengan todo dan wish counter.", - "pt": "Seu melhor companheiro de Genshin Impact! Planeje seu farm com a calculadora de ascensão e acompanhe seu progresso com a lista de afazeres e o histórico de orações.", - "ru": "Твой лучший компаньон в Genshin Impact! Поможет тебе распланировать что фармить в калькуляторе возвышения, а также отслеживать свой прогресс с помощью счетчика молитв и cписка дел" - }, - "url": "paimon.moe", - "version": "1.0.20", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/paimon.moe/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/paimon.moe/assets/thumbnail.png", - "color": "#25294A", - "category": "games", - "tags": [ - "genshin-impact", - "game", - "action-role-playing-game" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "rushia", + "id": "398752205043400724" + }, + "service": "paimon.moe", + "description": { + "en": "Your best Genshin Impact companion! Help you plan what to farm with ascension calculator, also track your progress with todo and wish counter.", + "zh_CN": "你最好的原神伙伴! 帮助你规划材料消耗与刷本, 追踪你的游戏进度与抽卡结果.", + "fr": "Votre meilleur compagnon pour Genshin Impact ! Vous aide à planifier ce que vous souhaitez farmer avec le calculateur d'élévation et vous permet de suivre votre progression avec la liste de tâches et le compteur de voeux.", + "ko_KR": "최고의 원신 동반자! 돌파 계산기로 파밍 계획을 도와주고, 할 일 목록과 기원 통계를 통해 진척도를 확인해줍니다.", + "id": "Your best Genshin Impact companion! Membantu kamu merencanakan apa yang harus di farm dengan kalkulator ascension, juga catat progress mu dengan todo dan wish counter.", + "pt": "Seu melhor companheiro de Genshin Impact! Planeje seu farm com a calculadora de ascensão e acompanhe seu progresso com a lista de afazeres e o histórico de orações.", + "ru": "Твой лучший компаньон в Genshin Impact! Поможет тебе распланировать что фармить в калькуляторе возвышения, а также отслеживать свой прогресс с помощью счетчика молитв и cписка дел" + }, + "url": "paimon.moe", + "version": "1.0.20", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/paimon.moe/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/paimon.moe/assets/thumbnail.png", + "color": "#25294A", + "category": "games", + "tags": [ + "genshin-impact", + "game", + "action-role-playing-game" + ] +} diff --git a/websites/P/paimon.moe/presence.ts b/websites/P/paimon.moe/presence.ts index eef2a6346ccc..ba2ca20ce0b7 100644 --- a/websites/P/paimon.moe/presence.ts +++ b/websites/P/paimon.moe/presence.ts @@ -1,228 +1,248 @@ const presence = new Presence({ - clientId: "859781231351693312", - }), - timer = Math.floor(Date.now() / 1000), - characterList = [ - "amber", - "barbara", - "beidou", - "bennett", - "chongyun", - "diluc", - "diona", - "eula", - "fischl", - "ganyu", - "hu_tao", - "jean", - "kaeya", - "kaedehara_kazuha", - "keqing", - "klee", - "lisa", - "mona", - "ningguang", - "noelle", - "qiqi", - "razor", - "rosaria", - "sucrose", - "tartaglia", - "traveler_anemo", - "traveler_geo", - "venti", - "xiangling", - "xiao", - "xingqiu", - "xinyan", - "yanfei", - "zhongli", - "albedo", - "kujou_sara", - "raiden_shogun", - "kamisato_ayaka", - "yoimiya", - "traveler_electro", - "sangonomiya_kokomi", - "sayu", - "aloy", - ], - validCharacter = characterList.includes(document.URL.match(/\w+/gi).pop()); + clientId: '859781231351693312', +}) +const timer = Math.floor(Date.now() / 1000) +const characterList = [ + 'amber', + 'barbara', + 'beidou', + 'bennett', + 'chongyun', + 'diluc', + 'diona', + 'eula', + 'fischl', + 'ganyu', + 'hu_tao', + 'jean', + 'kaeya', + 'kaedehara_kazuha', + 'keqing', + 'klee', + 'lisa', + 'mona', + 'ningguang', + 'noelle', + 'qiqi', + 'razor', + 'rosaria', + 'sucrose', + 'tartaglia', + 'traveler_anemo', + 'traveler_geo', + 'venti', + 'xiangling', + 'xiao', + 'xingqiu', + 'xinyan', + 'yanfei', + 'zhongli', + 'albedo', + 'kujou_sara', + 'raiden_shogun', + 'kamisato_ayaka', + 'yoimiya', + 'traveler_electro', + 'sangonomiya_kokomi', + 'sayu', + 'aloy', +] +const validCharacter = characterList.includes(document.URL.match(/\w+/g)?.pop() ?? '') -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/paimon.moe/assets/logo.png", - startTimestamp: timer, - }, - // {hostname} = document.location, - { pathname } = window.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/paimon.moe/assets/logo.png', + startTimestamp: timer, + } + // {hostname} = document.location, + const { pathname } = window.location - let stateText: string; + let stateText: string - if (pathname === "/") presenceData.details = "Viewing homepage"; + if (pathname === '/') + presenceData.details = 'Viewing homepage' - if (pathname.includes("/characters") || pathname.includes("/characters/")) { - presenceData.details = "Viewing the character list/details"; - if (validCharacter) { - const original = document.URL.match(/(\/\w+)/gi) - .pop() - .substr(1); - switch (original) { - case "traveler_anemo": { - stateText = "Anemo Traveler"; - break; - } - case "traveler_geo": { - stateText = "Geo Traveler"; - break; - } - case "kaedehara_kazuha": { - stateText = "Kaedehara Kazuha"; - break; - } - case "hu_tao": { - stateText = "Hu Tao"; - break; - } - case "raiden_shogun": { - stateText = "Raiden Shogun (Baal)"; - break; - } - case "kujou_sara": { - stateText = "Kujou Sara"; - break; - } - case "traveler_electro": { - stateText = "Electro Traveler"; - break; - } - case "kamisato_ayaka": { - stateText = "Kamisato Ayaka"; - break; - } - case "sangonomiya_kokomi": { - stateText = "Sangonomiya Kokomi"; - break; - } - default: - stateText = original.charAt(0).toUpperCase() + original.slice(1); - } + if (pathname.includes('/characters') || pathname.includes('/characters/')) { + presenceData.details = 'Viewing the character list/details' + if (validCharacter) { + const original = document.URL.match(/(\/\w+)/g) + ?.pop() + ?.substr(1) + switch (original) { + case 'traveler_anemo': { + stateText = 'Anemo Traveler' + break + } + case 'traveler_geo': { + stateText = 'Geo Traveler' + break + } + case 'kaedehara_kazuha': { + stateText = 'Kaedehara Kazuha' + break + } + case 'hu_tao': { + stateText = 'Hu Tao' + break + } + case 'raiden_shogun': { + stateText = 'Raiden Shogun (Baal)' + break + } + case 'kujou_sara': { + stateText = 'Kujou Sara' + break + } + case 'traveler_electro': { + stateText = 'Electro Traveler' + break + } + case 'kamisato_ayaka': { + stateText = 'Kamisato Ayaka' + break + } + case 'sangonomiya_kokomi': { + stateText = 'Sangonomiya Kokomi' + break + } + default: + stateText = `${original?.charAt(0).toUpperCase()}${original?.slice(1)}` + } - presenceData.details = "Viewing the character details:"; - presenceData.state = stateText; - } - } - if ( - pathname.includes("/wish/character-event") || - pathname.includes("/wish/character-event/") - ) { - presenceData.details = "Viewing at the Wish Counter"; - presenceData.state = "Wish Counter: Character Event"; - } else if ( - pathname.includes("/wish/weapon-event") || - pathname.includes("/wish/weapon-event/") - ) { - presenceData.details = "Viewing at the Wish Counter"; - presenceData.state = "Wish Counter: Weapon Event"; - } else if ( - pathname.includes("/wish/standard") || - pathname.includes("/wish/standar/") - ) { - presenceData.details = "Viewing at the Wish Counter"; - presenceData.state = "Wish Counter: Standard Banner"; - } else if ( - pathname.includes("/wish/beginners") || - pathname.includes("/wish/beginners/") - ) { - presenceData.details = "Viewing at the Wish Counter"; - presenceData.state = "Wish Counter: Beginners' Wish"; - } else if ( - pathname.includes("/wish/tally") || - pathname.includes("/wish/tally/") - ) - presenceData.details = "🌏 Global Wish Tally"; - else if (pathname.startsWith("/wish") || pathname.startsWith("/wish/")) { - const number = document - .querySelector( - "#sapper > main > div > div.flex.flex-col.xl\\:flex-row > div.grid.gap-4.grid-cols-1.md\\:grid-cols-2.xl\\:grid-cols-3.max-w-screen-xl > div:nth-child(6) > div.bg-item.rounded-xl.p-4.flex.items-center.w-full.text-white" - ) - .textContent.split(" ")[3]; + presenceData.details = 'Viewing the character details:' + presenceData.state = stateText + } + } + if ( + pathname.includes('/wish/character-event') + || pathname.includes('/wish/character-event/') + ) { + presenceData.details = 'Viewing at the Wish Counter' + presenceData.state = 'Wish Counter: Character Event' + } + else if ( + pathname.includes('/wish/weapon-event') + || pathname.includes('/wish/weapon-event/') + ) { + presenceData.details = 'Viewing at the Wish Counter' + presenceData.state = 'Wish Counter: Weapon Event' + } + else if ( + pathname.includes('/wish/standard') + || pathname.includes('/wish/standar/') + ) { + presenceData.details = 'Viewing at the Wish Counter' + presenceData.state = 'Wish Counter: Standard Banner' + } + else if ( + pathname.includes('/wish/beginners') + || pathname.includes('/wish/beginners/') + ) { + presenceData.details = 'Viewing at the Wish Counter' + presenceData.state = 'Wish Counter: Beginners\' Wish' + } + else if ( + pathname.includes('/wish/tally') + || pathname.includes('/wish/tally/') + ) { + presenceData.details = '🌏 Global Wish Tally' + } + else if (pathname.startsWith('/wish') || pathname.startsWith('/wish/')) { + const number = document + .querySelector( + '#sapper > main > div > div.flex.flex-col.xl\\:flex-row > div.grid.gap-4.grid-cols-1.md\\:grid-cols-2.xl\\:grid-cols-3.max-w-screen-xl > div:nth-child(6) > div.bg-item.rounded-xl.p-4.flex.items-center.w-full.text-white', + ) + ?.textContent + ?.split(' ')[3] - presenceData.details = "Viewing at the Wish Counter"; - presenceData.state = `Wishes Worth: ✧ ${number}`; - } else if ( - pathname.includes("/calculator") || - pathname.includes("/calculator/") - ) - presenceData.details = "Using the calculator"; - else if (pathname.includes("/todo") || pathname.includes("/todo/")) - presenceData.details = "Viewing at Todo list"; - else if (pathname.includes("/items") || pathname.includes("/items/")) { - presenceData.details = "Viewing at the Database"; - presenceData.state = "Items"; - } else if ( - pathname.includes("/achievement") || - pathname.includes("/achievement/") - ) { - presenceData.details = "Viewing at the Database"; - presenceData.state = "Achievements"; - } else if ( - pathname.includes("/reminder") || - pathname.includes("/reminder/") - ) { - presenceData.details = "Viewing at the Database"; - presenceData.state = "Reminder"; - } else if ( - pathname.includes("/furnishing") || - pathname.includes("/furnishing/") - ) { - presenceData.details = "Viewing at the Database"; - presenceData.state = "Furnishing"; - if ( - pathname.includes("/furnishing/inventory") || - pathname.includes("/furnishing/inventory/") - ) { - presenceData.details = "Viewing at the Database"; - presenceData.state = "Looking at Furnishing Inventory"; - } else if ( - pathname.includes("/furnishing/list") || - pathname.includes("/furnishing/list/") - ) { - presenceData.details = "Viewing at the Database"; - presenceData.state = "Looking at the Furnishing List"; - } - } else if (pathname.includes("/weapons") || pathname.includes("/weapons/")) { - presenceData.details = "Viewing at the Database"; - presenceData.state = "Weapons"; - } else if ( - pathname.includes("/artifacts") || - pathname.includes("/artifacts/") - ) { - presenceData.details = "Viewing at the Database"; - presenceData.state = "Artifacts"; - } else if ( - pathname.includes("/timeline") || - pathname.includes("/timeline/") - ) { - presenceData.details = "Viewing at the Timeline"; - presenceData.state = `Time of ${document - .querySelector( - "#sapper > main > div > div.flex.svelte-15n1215 > div.svelte-15n1215 > div > label" - ) - .textContent.match(/(\w(\s+)?)+/gi) - .pop()}`; - } else if (pathname.includes("/settings") || pathname.includes("/settings/")) - presenceData.details = "Settings"; - else if ( - pathname.includes("/privacy-policy") || - pathname.includes("/privacy-policy/") - ) { - presenceData.details = "Reading the Privacy Policy"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - } + presenceData.details = 'Viewing at the Wish Counter' + presenceData.state = `Wishes Worth: ✧ ${number}` + } + else if ( + pathname.includes('/calculator') + || pathname.includes('/calculator/') + ) { + presenceData.details = 'Using the calculator' + } + else if (pathname.includes('/todo') || pathname.includes('/todo/')) { + presenceData.details = 'Viewing at Todo list' + } + else if (pathname.includes('/items') || pathname.includes('/items/')) { + presenceData.details = 'Viewing at the Database' + presenceData.state = 'Items' + } + else if ( + pathname.includes('/achievement') + || pathname.includes('/achievement/') + ) { + presenceData.details = 'Viewing at the Database' + presenceData.state = 'Achievements' + } + else if ( + pathname.includes('/reminder') + || pathname.includes('/reminder/') + ) { + presenceData.details = 'Viewing at the Database' + presenceData.state = 'Reminder' + } + else if ( + pathname.includes('/furnishing') + || pathname.includes('/furnishing/') + ) { + presenceData.details = 'Viewing at the Database' + presenceData.state = 'Furnishing' + if ( + pathname.includes('/furnishing/inventory') + || pathname.includes('/furnishing/inventory/') + ) { + presenceData.details = 'Viewing at the Database' + presenceData.state = 'Looking at Furnishing Inventory' + } + else if ( + pathname.includes('/furnishing/list') + || pathname.includes('/furnishing/list/') + ) { + presenceData.details = 'Viewing at the Database' + presenceData.state = 'Looking at the Furnishing List' + } + } + else if (pathname.includes('/weapons') || pathname.includes('/weapons/')) { + presenceData.details = 'Viewing at the Database' + presenceData.state = 'Weapons' + } + else if ( + pathname.includes('/artifacts') + || pathname.includes('/artifacts/') + ) { + presenceData.details = 'Viewing at the Database' + presenceData.state = 'Artifacts' + } + else if ( + pathname.includes('/timeline') + || pathname.includes('/timeline/') + ) { + presenceData.details = 'Viewing at the Timeline' + presenceData.state = `Time of ${document + .querySelector( + '#sapper > main > div > div.flex.svelte-15n1215 > div.svelte-15n1215 > div > label', + ) + ?.textContent + ?.match(/(\w(\s+)?)+/g) + ?.pop()}` + } + else if (pathname.includes('/settings') || pathname.includes('/settings/')) { + presenceData.details = 'Settings' + } + else if ( + pathname.includes('/privacy-policy') + || pathname.includes('/privacy-policy/') + ) { + presenceData.details = 'Reading the Privacy Policy' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/pass Culture/metadata.json b/websites/P/pass Culture/metadata.json index 74d1d6b3c3f6..6ce8fcab4270 100644 --- a/websites/P/pass Culture/metadata.json +++ b/websites/P/pass Culture/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "807326854314590228", - "name": "Yuuto" - }, - "service": "pass Culture", - "description": { - "en": "The \"pass Culture\" is a system of access to cultural activities set up by the French government for young people between 15 and 18 years old.", - "fr": "Le \"pass Culture\" est un dispositif d'accès aux activités culturelles mis en place par le gouvernement français à destination des jeunes entre 15 et 18 ans." - }, - "url": "passculture.app", - "version": "1.0.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/pass%20Culture/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/pass%20Culture/assets/thumbnail.png", - "color": "#d6005c", - "category": "other", - "tags": [ - "french" - ], - "settings": [ - { - "id": "show_counts", - "title": "Afficher le nombre de favoris et de réservations", - "icon": "fas fa-1", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "807326854314590228", + "name": "Yuuto" + }, + "service": "pass Culture", + "description": { + "en": "The \"pass Culture\" is a system of access to cultural activities set up by the French government for young people between 15 and 18 years old.", + "fr": "Le \"pass Culture\" est un dispositif d'accès aux activités culturelles mis en place par le gouvernement français à destination des jeunes entre 15 et 18 ans." + }, + "url": "passculture.app", + "version": "1.0.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/pass%20Culture/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/pass%20Culture/assets/thumbnail.png", + "color": "#d6005c", + "category": "other", + "tags": [ + "french" + ], + "settings": [ + { + "id": "show_counts", + "title": "Afficher le nombre de favoris et de réservations", + "icon": "fas fa-1", + "value": true + } + ] +} diff --git a/websites/P/pass Culture/presence.ts b/websites/P/pass Culture/presence.ts index c2768035bfec..7b6949a64d1c 100644 --- a/websites/P/pass Culture/presence.ts +++ b/websites/P/pass Culture/presence.ts @@ -1,130 +1,133 @@ const presence = new Presence({ - clientId: "1165384499987742800", -}); + clientId: '1165384499987742800', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/pass%20Culture/assets/logo.png", - }, - path = document.location.pathname.split("/"), - showCounts = await presence.getSetting("show_counts"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/pass%20Culture/assets/logo.png', + } + const path = document.location.pathname.split('/') + const showCounts = await presence.getSetting('show_counts') - switch (path[1]) { - case "questionnaire-pratiques-initiales": - presenceData.details = "En train de faire le questionnaire"; - break; - case "accueil": - presenceData.details = "Regarde la page d'accueil"; - break; - case "accueil-thematique": { - presenceData.details = "Regarde la page d'accueil"; + switch (path[1]) { + case 'questionnaire-pratiques-initiales': + presenceData.details = 'En train de faire le questionnaire' + break + case 'accueil': + presenceData.details = 'Regarde la page d\'accueil' + break + case 'accueil-thematique': { + presenceData.details = 'Regarde la page d\'accueil' - const offersType = document.querySelector( - '[data-testid="ThematicHome"] [data-testid="homeBodyScrollView"] h1' - )?.textContent; - if (offersType) presenceData.state = offersType; - break; - } - case "profil": - presenceData.details = "Regarde son profil"; - break; - case "recherche": { - presenceData.details = "Recherche :"; + const offersType = document.querySelector( + '[data-testid="ThematicHome"] [data-testid="homeBodyScrollView"] h1', + )?.textContent + if (offersType) + presenceData.state = offersType + break + } + case 'profil': + presenceData.details = 'Regarde son profil' + break + case 'recherche': { + presenceData.details = 'Recherche :' - const query = - document.querySelector("input[type=search]")?.value, - results = parseInt(document.title); - if (query && !isNaN(results)) - presenceData.state = `${query} (${results} résultats)`; - break; - } - case "reservations": { - const reservationsCount = document.querySelector( - '[data-testid="OnGoingBookingsList"] h2' - )?.textContent; + const query = document.querySelector('input[type=search]')?.value + const results = Number.parseInt(document.title) + if (query && !Number.isNaN(results)) + presenceData.state = `${query} (${results} résultats)` + break + } + case 'reservations': { + const reservationsCount = document.querySelector( + '[data-testid="OnGoingBookingsList"] h2', + )?.textContent - presenceData.details = "Regarde ses réservations"; - if (reservationsCount && showCounts) - presenceData.state = reservationsCount; - break; - } - case "reservations-terminees": { - const doneReservationsCount = document.querySelector( - '[data-testid="EndedBookings"] h2' - )?.textContent; + presenceData.details = 'Regarde ses réservations' + if (reservationsCount && showCounts) + presenceData.state = reservationsCount + break + } + case 'reservations-terminees': { + const doneReservationsCount = document.querySelector( + '[data-testid="EndedBookings"] h2', + )?.textContent - presenceData.details = "Regarde ses réservations terminées"; - if (doneReservationsCount && showCounts) - presenceData.state = doneReservationsCount; - break; - } - case "reservation": { - presenceData.details = "Regarde une réservation"; + presenceData.details = 'Regarde ses réservations terminées' + if (doneReservationsCount && showCounts) + presenceData.state = doneReservationsCount + break + } + case 'reservation': { + presenceData.details = 'Regarde une réservation' - const reservation = document.querySelector( - '[data-testid="BookingDetailsScrollView"] h1' - )?.textContent, - reservationPrice = document - .querySelector( - '[data-testid="BookingDetailsScrollView"] button span' - ) - ?.textContent.trim(), - offerLink = document - .querySelector( - 'a[data-testid="Voir le détail de l’offre"]' - ) - ?.getAttribute("href"); - if (reservation && reservationPrice) { - presenceData.state = `${reservation} (${reservationPrice})`; - presenceData.buttons = [ - { - label: "Voir l'offre", - url: `${document.location.protocol}//${document.location.hostname}${ - offerLink.split("?")[0] - }`, - }, - ]; - } - break; - } - case "favoris": { - presenceData.details = "Regarde ses favoris"; + const reservation = document.querySelector( + '[data-testid="BookingDetailsScrollView"] h1', + )?.textContent + const reservationPrice = document + .querySelector( + '[data-testid="BookingDetailsScrollView"] button span', + ) + ?.textContent + ?.trim() + const offerLink = document + .querySelector( + 'a[data-testid="Voir le détail de l’offre"]', + ) + ?.getAttribute('href') + if (reservation && reservationPrice) { + presenceData.state = `${reservation} (${reservationPrice})` + presenceData.buttons = [ + { + label: 'Voir l\'offre', + url: `${document.location.protocol}//${document.location.hostname}${ + offerLink?.split('?')[0] + }`, + }, + ] + } + break + } + case 'favoris': { + presenceData.details = 'Regarde ses favoris' - const favoritesCount = document.querySelector( - '[data-testid="favoritesResultsFlatlist"] h2' - )?.textContent; - if (favoritesCount && showCounts) presenceData.state = favoritesCount; - break; - } - case "offre": { - if (path[3] && path[3] === "description") - presenceData.details = "Regarde les détails d'une offre"; - else { - presenceData.details = "Regarde une offre"; + const favoritesCount = document.querySelector( + '[data-testid="favoritesResultsFlatlist"] h2', + )?.textContent + if (favoritesCount && showCounts) + presenceData.state = favoritesCount + break + } + case 'offre': { + if (path[3] && path[3] === 'description') { + presenceData.details = 'Regarde les détails d\'une offre' + } + else { + presenceData.details = 'Regarde une offre' - const offer = document.querySelector( - '[data-testid="offer-container"] h1[data-testid^="Nom de l’offre"]' - )?.textContent, - price = document.querySelector( - "div[data-testid=caption-iconPrice]" - )?.textContent; - if (offer && price) { - presenceData.state = `${offer} (${price})`; - presenceData.buttons = [ - { - label: "Voir l'offre", - url: document.location.href.split("?")[0], - }, - ]; - } - } - break; - } - default: - presence.clearActivity(); - } + const offer = document.querySelector( + '[data-testid="offer-container"] h1[data-testid^="Nom de l’offre"]', + )?.textContent + const price = document.querySelector( + 'div[data-testid=caption-iconPrice]', + )?.textContent + if (offer && price) { + presenceData.state = `${offer} (${price})` + presenceData.buttons = [ + { + label: 'Voir l\'offre', + url: document.location.href.split('?')[0], + }, + ] + } + } + break + } + default: + presence.clearActivity() + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/piapro/metadata.json b/websites/P/piapro/metadata.json index 40fdbda257f1..393ba2c4ffa1 100644 --- a/websites/P/piapro/metadata.json +++ b/websites/P/piapro/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "piapro", - "description": { - "en": "Listen to piapro! look! Use! Admit! A CGM-type content posting site that realizes.", - "nl": "Luister naar piapro! Kijk! Gebruik het! Toegegeven! Een site voor het plaatsen van inhoud van het CGM-type die dat realiseert.", - "ja_JP": "piapro(ピアプロ)は、聞いて!見て!使って!認めて!を実現するCGM型コンテンツ投稿サイトです" - }, - "url": "piapro.jp", - "version": "1.2.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/piapro/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/piapro/assets/thumbnail.png", - "color": "#e4007b", - "category": "music", - "tags": [ - "music", - "albums" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "piapro", + "description": { + "en": "Listen to piapro! look! Use! Admit! A CGM-type content posting site that realizes.", + "nl": "Luister naar piapro! Kijk! Gebruik het! Toegegeven! Een site voor het plaatsen van inhoud van het CGM-type die dat realiseert.", + "ja_JP": "piapro(ピアプロ)は、聞いて!見て!使って!認めて!を実現するCGM型コンテンツ投稿サイトです" + }, + "url": "piapro.jp", + "version": "1.2.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/piapro/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/piapro/assets/thumbnail.png", + "color": "#e4007b", + "category": "music", + "tags": [ + "music", + "albums" + ] +} diff --git a/websites/P/piapro/presence.ts b/websites/P/piapro/presence.ts index a47d6c4da3a2..a1fab4a7e032 100644 --- a/websites/P/piapro/presence.ts +++ b/websites/P/piapro/presence.ts @@ -1,146 +1,163 @@ const presence = new Presence({ - clientId: "641416608790609942", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '641416608790609942', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let search: HTMLInputElement, - min: number, - sec: number, - time: number, - min2: number, - sec2: number, - time2: number, - paused: boolean, - timestamps: number[]; +let min: number, + sec: number, + time: number, + min2: number, + sec2: number, + time2: number, + paused: boolean, + timestamps: number[] -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/piapro/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/piapro/assets/logo.png', + } - if (document.location.hostname === "piapro.jp") { - if (document.location.pathname === "/") { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Viewing home page"; - } else if (document.location.pathname.includes("/html5_player_popup/")) { - min = parseInt( - document - .querySelector( - "#jp_container_1 > div > div.jp-gui > div.jp-interface > div.jp-current-time" - ) - .textContent.split(":")[0] - ); - sec = parseInt( - document - .querySelector( - "#jp_container_1 > div > div.jp-gui > div.jp-interface > div.jp-current-time" - ) - .textContent.split(":")[1] - ); - min = min * 60; - time = min + sec; + if (document.location.hostname === 'piapro.jp') { + if (document.location.pathname === '/') { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Viewing home page' + } + else if (document.location.pathname.includes('/html5_player_popup/')) { + min = Number.parseInt( + document + .querySelector( + '#jp_container_1 > div > div.jp-gui > div.jp-interface > div.jp-current-time', + ) + ?.textContent + ?.split(':')[0] ?? '', + ) + sec = Number.parseInt( + document + .querySelector( + '#jp_container_1 > div > div.jp-gui > div.jp-interface > div.jp-current-time', + ) + ?.textContent + ?.split(':')[1] ?? '', + ) + min = min * 60 + time = min + sec - min2 = parseInt( - document - .querySelector( - "#jp_container_1 > div > div.jp-gui > div.jp-interface > div.jp-duration" - ) - .textContent.split(":")[0] - ); - sec2 = parseInt( - document - .querySelector( - "#jp_container_1 > div > div.jp-gui > div.jp-interface > div.jp-duration" - ) - .textContent.split(":")[1] - ); - min2 = min2 * 60; - time2 = min2 + sec2; - if ( - !document - .querySelector("#jp_container_1") - .className.includes("jp-state-playing") - ) - paused = true; - else paused = false; + min2 = Number.parseInt( + document + .querySelector( + '#jp_container_1 > div > div.jp-gui > div.jp-interface > div.jp-duration', + ) + ?.textContent + ?.split(':')[0] ?? '', + ) + sec2 = Number.parseInt( + document + .querySelector( + '#jp_container_1 > div > div.jp-gui > div.jp-interface > div.jp-duration', + ) + ?.textContent + ?.split(':')[1] ?? '', + ) + min2 = min2 * 60 + time2 = min2 + sec2 + if ( + !document + .querySelector('#jp_container_1') + ?.className + .includes('jp-state-playing') + ) { + paused = true + } + else { + paused = false + } - timestamps = presence.getTimestamps(time, time2); - [presenceData.startTimestamp, presenceData.endTimestamp] = timestamps; - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Playing"; + timestamps = presence.getTimestamps(time, time2); + [presenceData.startTimestamp, presenceData.endTimestamp] = timestamps + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Playing' - presenceData.details = - document.querySelector("body > header > h1").textContent; - presenceData.state = document.querySelector( - "body > header > div > p.artist" - ).textContent; + presenceData.details = document.querySelector('body > header > h1')?.textContent + presenceData.state = document.querySelector( + 'body > header > div > p.artist', + )?.textContent - if (paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = "Paused"; - } - } else if (document.location.pathname.includes("/t/")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = `Viewing ${ - document - .querySelector("head > title") - .textContent.split("|")[1] - .split("「")[0] - }:`; - presenceData.state = document.querySelector( - "#main > div.cd_works-whole.illust > div.cd_works-mainclm > h1" - ).textContent; - } else if (document.location.pathname.includes("/music")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Browsing the"; - presenceData.state = "music category"; - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/illust")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Browsing the"; - presenceData.state = "illustrations category"; - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/text")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Browsing the"; - presenceData.state = "text category"; - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/search/")) { - presenceData.startTimestamp = browsingTimestamp; - presenceData.details = "Searching for:"; - search = document.querySelector("#keyword"); - presenceData.state = search.textContent; - presenceData.smallImageKey = Assets.Search; - } else if (document.querySelector("#user_prof > p:nth-child(2)")) { - presenceData.details = "Viewing user:"; - presenceData.state = document.querySelector( - "#user_prof > p:nth-child(2)" - ).textContent; - presenceData.startTimestamp = browsingTimestamp; - } else if (document.location.pathname.includes("/collabo/")) { - presenceData.details = "Viewing collab:"; - presenceData.state = - document.querySelector("#main_name > h2").textContent; - presenceData.startTimestamp = browsingTimestamp; - } else if (document.location.pathname.includes("/collabo_list/")) { - presenceData.details = "Viewing collab list"; - presenceData.startTimestamp = browsingTimestamp; - } else if ( - document.location.pathname.includes("/pages/official_collabo/") - ) { - presenceData.details = "Viewing official collab:"; - presenceData.state = document.querySelector( - "#main > div.static_path > span" - ).textContent; - presenceData.startTimestamp = browsingTimestamp; - } else if (document.location.pathname.includes("/official_collabo/")) { - presenceData.details = "Viewing official collab list"; - presenceData.startTimestamp = browsingTimestamp; - } - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Paused' + } + } + else if (document.location.pathname.includes('/t/')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = `Viewing ${ + document + .querySelector('head > title') + ?.textContent + ?.split('|')[1] + .split('「')[0] + }:` + presenceData.state = document.querySelector( + '#main > div.cd_works-whole.illust > div.cd_works-mainclm > h1', + )?.textContent + } + else if (document.location.pathname.includes('/music')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Browsing the' + presenceData.state = 'music category' + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/illust')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Browsing the' + presenceData.state = 'illustrations category' + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/text')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Browsing the' + presenceData.state = 'text category' + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/search/')) { + presenceData.startTimestamp = browsingTimestamp + presenceData.details = 'Searching for:' + const search = document.querySelector('#keyword') + presenceData.state = search?.textContent + presenceData.smallImageKey = Assets.Search + } + else if (document.querySelector('#user_prof > p:nth-child(2)')) { + presenceData.details = 'Viewing user:' + presenceData.state = document.querySelector( + '#user_prof > p:nth-child(2)', + )?.textContent + presenceData.startTimestamp = browsingTimestamp + } + else if (document.location.pathname.includes('/collabo/')) { + presenceData.details = 'Viewing collab:' + presenceData.state = document.querySelector('#main_name > h2')?.textContent + presenceData.startTimestamp = browsingTimestamp + } + else if (document.location.pathname.includes('/collabo_list/')) { + presenceData.details = 'Viewing collab list' + presenceData.startTimestamp = browsingTimestamp + } + else if ( + document.location.pathname.includes('/pages/official_collabo/') + ) { + presenceData.details = 'Viewing official collab:' + presenceData.state = document.querySelector( + '#main > div.static_path > span', + )?.textContent + presenceData.startTimestamp = browsingTimestamp + } + else if (document.location.pathname.includes('/official_collabo/')) { + presenceData.details = 'Viewing official collab list' + presenceData.startTimestamp = browsingTimestamp + } + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/picoCTF/metadata.json b/websites/P/picoCTF/metadata.json index c791a5802195..fc96349a78ce 100644 --- a/websites/P/picoCTF/metadata.json +++ b/websites/P/picoCTF/metadata.json @@ -1,36 +1,36 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Chihiro Fujisaki", - "id": "560183438393737264" - }, - "service": "picoCTF", - "description": { - "en": "picoCTF is a free computer security education program with original content in a capture-the-flag format." - }, - "url": [ - "picoctf.org", - "play.picoctf.org" - ], - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/picoCTF/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/picoCTF/assets/thumbnail.png", - "color": "#9b1e33", - "category": "other", - "tags": [ - "ctf", - "capture-the-flag", - "hacking", - "challenge", - "cybersecurity" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Chihiro Fujisaki", + "id": "560183438393737264" + }, + "service": "picoCTF", + "description": { + "en": "picoCTF is a free computer security education program with original content in a capture-the-flag format." + }, + "url": [ + "picoctf.org", + "play.picoctf.org" + ], + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/picoCTF/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/picoCTF/assets/thumbnail.png", + "color": "#9b1e33", + "category": "other", + "tags": [ + "ctf", + "capture-the-flag", + "hacking", + "challenge", + "cybersecurity" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + } + ] +} diff --git a/websites/P/picoCTF/presence.ts b/websites/P/picoCTF/presence.ts index 31a1a3105163..aa5d22479112 100644 --- a/websites/P/picoCTF/presence.ts +++ b/websites/P/picoCTF/presence.ts @@ -1,182 +1,207 @@ const presence = new Presence({ - clientId: "989558631823474748", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '989558631823474748', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const privacy = await presence.getSetting("privacy"), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/picoCTF/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const privacy = await presence.getSetting('privacy') + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/picoCTF/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (document.location.hostname === "picoctf.org") { - if (document.location.pathname.includes("/learning_guides/")) { - presenceData.details = "Reading a guide:"; - presenceData.state = `${document.location.pathname - .split("/")[2] - .replaceAll("-", " ") - .slice(6, -4)}`; - } else if (document.location.pathname.includes("/pdfs/")) { - presenceData.details = document.location.pathname.includes( - "Sponsorship_Flyer" - ) - ? "Reading about sponsoring" - : "Reading a research paper"; - } else if (document.location.pathname === "/get_started.html") { - const viewing = - document.querySelectorAll( - 'ul#competition-tabs li a:not([aria-selected="false"])' - )[0].innerHTML === "User Guide" - ? "Viewing the user guide" - : "Viewing the FAQ"; + if (document.location.hostname === 'picoctf.org') { + if (document.location.pathname.includes('/learning_guides/')) { + presenceData.details = 'Reading a guide:' + presenceData.state = `${document.location.pathname + .split('/')[2] + .replaceAll('-', ' ') + .slice(6, -4)}` + } + else if (document.location.pathname.includes('/pdfs/')) { + presenceData.details = document.location.pathname.includes( + 'Sponsorship_Flyer', + ) + ? 'Reading about sponsoring' + : 'Reading a research paper' + } + else if (document.location.pathname === '/get_started.html') { + const viewing = document.querySelectorAll( + 'ul#competition-tabs li a:not([aria-selected="false"])', + )[0].innerHTML === 'User Guide' + ? 'Viewing the user guide' + : 'Viewing the FAQ' - presenceData.details = viewing; + presenceData.details = viewing - if (!privacy && viewing === "Viewing the user guide") { - presenceData.state = Array.from( - document.querySelectorAll( - 'div.active button:not([aria-selected="false"]) span' - ), - el => el.innerHTML - ) - .splice( - document - .querySelectorAll( - 'ul#guide-tabs li a:not([aria-selected="false"])' - )[0] - .innerHTML.includes("Learner") - ? 0 - : 2, - 2 - ) - .join(": "); - } - } else { - switch (document.location.pathname) { - case "/": - presenceData.details = "Viewing home page"; - break; - case "/resources.html": - presenceData.details = "Viewing learning resources"; - break; - case "/community.html": - presenceData.details = "Viewing community page"; - break; - case "/competitions/past.html": - presenceData.details = "Viewing past competitions"; - break; - case "/privacy.html": - presenceData.details = "Reading privacy statement"; - break; - case "/terms.html": - presenceData.details = "Reading terms of service"; - break; - case "/about.html": - presenceData.details = "Reading the about page"; - break; - case "/research.html": - presenceData.details = "Reading the research page"; - break; - case "/sponsors.html": - presenceData.details = "Viewing sponsors"; - break; - case "/contact.html": - presenceData.details = "Viewing the contact page"; - break; - } - } - } + if (!privacy && viewing === 'Viewing the user guide') { + presenceData.state = Array.from( + document.querySelectorAll( + 'div.active button:not([aria-selected="false"]) span', + ), + el => el.innerHTML, + ) + .splice( + document + .querySelectorAll( + 'ul#guide-tabs li a:not([aria-selected="false"])', + )[0] + .innerHTML + .includes('Learner') + ? 0 + : 2, + 2, + ) + .join(': ') + } + } + else { + switch (document.location.pathname) { + case '/': + presenceData.details = 'Viewing home page' + break + case '/resources.html': + presenceData.details = 'Viewing learning resources' + break + case '/community.html': + presenceData.details = 'Viewing community page' + break + case '/competitions/past.html': + presenceData.details = 'Viewing past competitions' + break + case '/privacy.html': + presenceData.details = 'Reading privacy statement' + break + case '/terms.html': + presenceData.details = 'Reading terms of service' + break + case '/about.html': + presenceData.details = 'Reading the about page' + break + case '/research.html': + presenceData.details = 'Reading the research page' + break + case '/sponsors.html': + presenceData.details = 'Viewing sponsors' + break + case '/contact.html': + presenceData.details = 'Viewing the contact page' + break + } + } + } - if (document.location.hostname === "play.picoctf.org") { - if (document.location.pathname === "/login") - presenceData.details = !privacy ? "Logging in" : "Viewing home page"; - else if (document.location.pathname === "/practice") { - const practiceparams = new URLSearchParams(document.location.search), - formatCategory = (cat: number) => { - if (cat === 34) return "uncategorized"; + if (document.location.hostname === 'play.picoctf.org') { + if (document.location.pathname === '/login') { + presenceData.details = !privacy ? 'Logging in' : 'Viewing home page' + } + else if (document.location.pathname === '/practice') { + const practiceparams = new URLSearchParams(document.location.search) + const formatCategory = (cat: number) => { + if (cat === 34) + return 'uncategorized' - const catText = document - .querySelector("ul.filter-list") - .children[cat].innerHTML.toLowerCase() - .split(" "), - amount = - parseInt(catText[catText.length - 1].replace(/\D/g, "")) || ""; + const catText = document + .querySelector('ul.filter-list') + ?.children[cat] + .innerHTML + .toLowerCase() + .split(' ') + const amount = Number.parseInt(catText?.[catText.length - 1].replace(/\D/g, '') ?? '') || '' - if (cat === 0) return amount; + if (cat === 0) + return amount - return catText.length === 3 - ? `${amount} ${catText[0]} ${catText[1]}` - : `${amount} ${catText[0]}`; - }; + return catText && catText.length === 3 + ? `${amount} ${catText[0]} ${catText[1]}` + : `${amount} ${catText?.[0]}` + } - if (practiceparams.has("category")) { - presenceData.details = `Viewing ${formatCategory( - parseInt(practiceparams.get("category")) - )} challs`; - } else presenceData.details = `Viewing ${formatCategory(0)} challs`; + if (practiceparams.has('category')) { + presenceData.details = `Viewing ${formatCategory( + Number.parseInt(practiceparams.get('category')!), + )} challs` + } + else { + presenceData.details = `Viewing ${formatCategory(0)} challs` + } - presenceData.state = practiceparams.has("page") - ? `Page ${practiceparams.get("page")}` - : "Page 1"; + presenceData.state = practiceparams.has('page') + ? `Page ${practiceparams.get('page')}` + : 'Page 1' - if (!privacy) { - const score = document - .querySelector("div.col-md-3 h3.text-bluish") - .innerHTML.split(" "); - score.splice(0, 1); - score.unshift(", "); - presenceData.state += score.join(" "); - } - } else if (document.location.pathname.includes("/practice/challenge/")) { - if (!privacy) { - presenceData.details = `Viewing "${ - document - .querySelector("div.row.d-flex.justify-content-between h3.mb-1") - .innerHTML.split(" = { - "": { details: "Viewing homepage" }, - fanbox: { details: "Viewing fanbox" }, - event: { details: "Browsing events..." }, - "history.php": { details: "Browsing history" }, - bookmark: { details: "Viewing bookmarks" }, - "mypixivall.php": { details: "Browsing my pixiv" }, - group: { details: "Browsing group" }, - idea: { details: "Browsing idea" }, - howto: { details: "Browsing how-to" }, - eventadd: { details: "Ready to create an event" }, - profileevent: { details: "Manage event..." }, - premium: { details: "Viewing Premier Registered info" }, - "messages.php": { details: "Browsing private message" }, - "ugoiraupload.php": { details: "Submiting new Ugoira(Animations)" }, - manage: { details: "Managing artworks" }, - "settinguser.php": { details: "User settings", state: "Basic settings" }, - settingsnspost: { - details: "User settings", - state: "Post on social media", - }, - "settingprofile.php": { - details: "Profile settings", - state: "Profile information", - }, - "settingprofileimg.php": { - details: "Profile settings", - state: "Profile images", - }, - "settingworkspace.php": { - details: "Profile settings", - state: "Workspace", - }, - settinginfophp: { details: "Notification settings" }, - lives: { details: "Sketch- Browsing livestreams" }, - popular: { details: "Sketch- Viewing popular posts" }, - followings: { details: "Sketch- Viewing following posts" }, - tagshistory: { details: "Sketch- Viewing tags:", state: "Featured tags" }, - "upload.php": { details: "Submitting new novel" }, - discovery: { details: "Viewing recommended novels" }, - "ranking.php": { details: "Viewing novels ranking" }, - }; + clientId: '640234287525920834', +}) +const typeURL = new URL(document.location.href) +const typeResult = typeURL.searchParams.get('type') +const staticPages: Record = { + '': { details: 'Viewing homepage' }, + 'fanbox': { details: 'Viewing fanbox' }, + 'event': { details: 'Browsing events...' }, + 'history.php': { details: 'Browsing history' }, + 'bookmark': { details: 'Viewing bookmarks' }, + 'mypixivall.php': { details: 'Browsing my pixiv' }, + 'group': { details: 'Browsing group' }, + 'idea': { details: 'Browsing idea' }, + 'howto': { details: 'Browsing how-to' }, + 'eventadd': { details: 'Ready to create an event' }, + 'profileevent': { details: 'Manage event...' }, + 'premium': { details: 'Viewing Premier Registered info' }, + 'messages.php': { details: 'Browsing private message' }, + 'ugoiraupload.php': { details: 'Submiting new Ugoira(Animations)' }, + 'manage': { details: 'Managing artworks' }, + 'settinguser.php': { details: 'User settings', state: 'Basic settings' }, + 'settingsnspost': { + details: 'User settings', + state: 'Post on social media', + }, + 'settingprofile.php': { + details: 'Profile settings', + state: 'Profile information', + }, + 'settingprofileimg.php': { + details: 'Profile settings', + state: 'Profile images', + }, + 'settingworkspace.php': { + details: 'Profile settings', + state: 'Workspace', + }, + 'settinginfophp': { details: 'Notification settings' }, + 'lives': { details: 'Sketch- Browsing livestreams' }, + 'popular': { details: 'Sketch- Viewing popular posts' }, + 'followings': { details: 'Sketch- Viewing following posts' }, + 'tagshistory': { details: 'Sketch- Viewing tags:', state: 'Featured tags' }, + 'upload.php': { details: 'Submitting new novel' }, + 'discovery': { details: 'Viewing recommended novels' }, + 'ranking.php': { details: 'Viewing novels ranking' }, +} const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/P/pixiv/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/P/pixiv/assets/logo.png', } -let browsingTimestamp = Math.floor(Date.now() / 1000), - lastPath: string; +let browsingTimestamp = Math.floor(Date.now() / 1000) +let lastPath: string -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }; - const { pathname, href, hostname } = document.location, - arrPath = pathname.replace("/en/", "/").replace("_", "").split("/"), - [buttons] = await Promise.all([presence.getSetting("buttons")]); - if (lastPath !== pathname) { - browsingTimestamp = Math.floor(Date.now() / 1000); - presenceData.startTimestamp = browsingTimestamp; - lastPath = pathname; - } +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname, href, hostname } = document.location + const arrPath = pathname.replace('/en/', '/').replace('_', '').split('/') + const [buttons] = await Promise.all([presence.getSetting('buttons')]) + if (lastPath !== pathname) { + browsingTimestamp = Math.floor(Date.now() / 1000) + presenceData.startTimestamp = browsingTimestamp + lastPath = pathname + } - switch (arrPath[1]) { - case "users": - presenceData.details = "Viewing user:"; - presenceData.state = - document.querySelector("h1").textContent ?? - document.querySelector("div:nth-child(2) > div > a:nth-child(3)") - .textContent; - presenceData.buttons = [{ label: "View User", url: href }]; - break; - case "tags": - presenceData.details = "Sketch- Viewing tags:"; - presenceData.state = "Featured tags"; - if (hostname === "www.pixiv.net") { - presenceData.details = "Viewing tags:"; - presenceData.state = document.querySelector("div > span").textContent; - presenceData.buttons = [{ label: "View Tag", url: href }]; - } else if (arrPath.length > 2) { - presenceData.state = document.querySelector(".title").textContent; - presenceData.buttons = [{ label: "View Tag", url: href }]; - } - break; - case "searchuser.php": - presenceData.details = "Searching for user:"; - presenceData.state = typeURL.searchParams.get("nick"); - presenceData.smallImageKey = Assets.Search; - break; - case "dashboard": - if (arrPath[2] === "works") { - presenceData.details = `Managing ${ - arrPath[3] === "series" ? "Series" : "Artworks" - }`; - } else if (pathname.includes("/report/artworks")) - presenceData.details = "Viewing access analytics"; - else if (pathname.includes("report/ranking")) - presenceData.details = "Viewing ranking report"; - else presenceData.details = "Viewing dashboard"; - break; - case "stacc": - presenceData.details = "Auto Feed activity"; - if (arrPath[2] !== "my") { - presenceData.details = "Browsing Feed"; - presenceData.state = document.querySelector( - "#stacc_center_title" - ).textContent; - } - break; - case "eventdetail": - presenceData.details = "Viewing event:"; - presenceData.state = document.querySelector("h1").textContent; - break; - case "ranking.php": - presenceData.details = "Viewing ranking:"; - presenceData.state = document.querySelector(".current").textContent; - break; - case "discovery": - presenceData.details = `Viewing Recommanded ${ - arrPath[2] === "users" ? "Users" : "Works" - }`; - break; - case "sociallogin": - case "linkedservices": - presenceData.details = "User settings"; - presenceData.state = "Link other accounts to pixiv"; - break; - case "settingmute.php": - presenceData.details = `Mute setting | ${ - typeResult === "user" ? "User" : "Tags" - }`; - break; - case "upload.php": - presenceData.details = `Submiting New ${ - typeResult === "manga" ? "Manga" : "Illustrations" - }`; - break; - case "artworks": - presenceData.details = "Viewing artwork:"; - presenceData.smallImageKey = Assets.Search; - presenceData.state = `${document.querySelector("h1").textContent} (${ - document.querySelector("div:nth-child(2) > a > div").textContent - })`; - presenceData.buttons = [ - { - label: "View Artwork", - url: href, - }, - ]; - break; - case "novel": { - presenceData.details = "Browsing for novels..."; - const title = document.querySelector("h1"); - if (Object.keys(staticPages).includes(arrPath[2])) - presenceData = { ...presenceData, ...staticPages[arrPath[2]] }; - else if (title) { - presenceData.details = "Viewing novel:"; - presenceData.state = `${title.textContent} (${ - document.querySelector("h2").textContent - })`; - presenceData.buttons = [{ label: "Read Novel", url: href }]; - } - break; - } - default: - if (Object.keys(staticPages).includes(arrPath[1])) - presenceData = { ...presenceData, ...staticPages[arrPath[1]] }; - } + switch (arrPath[1]) { + case 'users': + presenceData.details = 'Viewing user:' + presenceData.state = document.querySelector('h1')?.textContent + ?? document.querySelector('div:nth-child(2) > div > a:nth-child(3)') + ?.textContent + presenceData.buttons = [{ label: 'View User', url: href }] + break + case 'tags': + presenceData.details = 'Sketch- Viewing tags:' + presenceData.state = 'Featured tags' + if (hostname === 'www.pixiv.net') { + presenceData.details = 'Viewing tags:' + presenceData.state = document.querySelector('div > span')?.textContent + presenceData.buttons = [{ label: 'View Tag', url: href }] + } + else if (arrPath.length > 2) { + presenceData.state = document.querySelector('.title')?.textContent + presenceData.buttons = [{ label: 'View Tag', url: href }] + } + break + case 'searchuser.php': + presenceData.details = 'Searching for user:' + presenceData.state = typeURL.searchParams.get('nick') + presenceData.smallImageKey = Assets.Search + break + case 'dashboard': + if (arrPath[2] === 'works') { + presenceData.details = `Managing ${ + arrPath[3] === 'series' ? 'Series' : 'Artworks' + }` + } + else if (pathname.includes('/report/artworks')) { + presenceData.details = 'Viewing access analytics' + } + else if (pathname.includes('report/ranking')) { + presenceData.details = 'Viewing ranking report' + } + else { + presenceData.details = 'Viewing dashboard' + } + break + case 'stacc': + presenceData.details = 'Auto Feed activity' + if (arrPath[2] !== 'my') { + presenceData.details = 'Browsing Feed' + presenceData.state = document.querySelector( + '#stacc_center_title', + )?.textContent + } + break + case 'eventdetail': + presenceData.details = 'Viewing event:' + presenceData.state = document.querySelector('h1')?.textContent + break + case 'ranking.php': + presenceData.details = 'Viewing ranking:' + presenceData.state = document.querySelector('.current')?.textContent + break + case 'discovery': + presenceData.details = `Viewing Recommanded ${ + arrPath[2] === 'users' ? 'Users' : 'Works' + }` + break + case 'sociallogin': + case 'linkedservices': + presenceData.details = 'User settings' + presenceData.state = 'Link other accounts to pixiv' + break + case 'settingmute.php': + presenceData.details = `Mute setting | ${ + typeResult === 'user' ? 'User' : 'Tags' + }` + break + case 'upload.php': + presenceData.details = `Submiting New ${ + typeResult === 'manga' ? 'Manga' : 'Illustrations' + }` + break + case 'artworks': + presenceData.details = 'Viewing artwork:' + presenceData.smallImageKey = Assets.Search + presenceData.state = `${document.querySelector('h1')?.textContent} (${ + document.querySelector('div:nth-child(2) > a > div')?.textContent + })` + presenceData.buttons = [ + { + label: 'View Artwork', + url: href, + }, + ] + break + case 'novel': { + presenceData.details = 'Browsing for novels...' + const title = document.querySelector('h1') + if (Object.keys(staticPages).includes(arrPath[2])) { + presenceData = { ...presenceData, ...staticPages[arrPath[2]] } + } + else if (title) { + presenceData.details = 'Viewing novel:' + presenceData.state = `${title.textContent} (${ + document.querySelector('h2')?.textContent + })` + presenceData.buttons = [{ label: 'Read Novel', url: href }] + } + break + } + default: + if (Object.keys(staticPages).includes(arrPath[1])) + presenceData = { ...presenceData, ...staticPages[arrPath[1]] } + } - if (hostname === "sketch.pixiv.net") - presenceData.smallImageKey = Assets.Writing; - if ( - (pathname === "/" || pathname.includes("/public")) && - hostname === "sketch.pixiv.net" - ) - presenceData.details = "Viewing sketch page"; - else if (pathname.includes("/lives/")) { - presenceData.details = "Sketch- Viewing livestream"; - presenceData.state = `by user: ${ - document.querySelector("div.name").textContent - }`; - presenceData.buttons = [{ label: "Watch Live", url: href }]; - presenceData.smallImageKey = Assets.Live; - } else if (pathname.includes("/@")) { - presenceData.details = "Sketch- Viewing user:"; - presenceData.state = document.querySelector("div.name").textContent; - presenceData.buttons = [{ label: "View User", url: href }]; - } + if (hostname === 'sketch.pixiv.net') + presenceData.smallImageKey = Assets.Writing + if ( + (pathname === '/' || pathname.includes('/public')) + && hostname === 'sketch.pixiv.net' + ) { + presenceData.details = 'Viewing sketch page' + } + else if (pathname.includes('/lives/')) { + presenceData.details = 'Sketch- Viewing livestream' + presenceData.state = `by user: ${ + document.querySelector('div.name')?.textContent + }` + presenceData.buttons = [{ label: 'Watch Live', url: href }] + presenceData.smallImageKey = Assets.Live + } + else if (pathname.includes('/@')) { + presenceData.details = 'Sketch- Viewing user:' + presenceData.state = document.querySelector('div.name')?.textContent + presenceData.buttons = [{ label: 'View User', url: href }] + } - if (!buttons) delete presenceData.buttons; - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (!buttons) + delete presenceData.buttons + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/P/puhutv/metadata.json b/websites/P/puhutv/metadata.json index 69d8034c4232..89fa7738b401 100644 --- a/websites/P/puhutv/metadata.json +++ b/websites/P/puhutv/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "EGGSY", - "id": "162969778699501569" - }, - "service": "puhutv", - "description": { - "en": " puhutv is a Turkish entertainment and video on demand service!", - "tr": "puhutv ile en popüler dizileri ve unutulmaz Türk filmlerini tek parça, HD görüntü kalitesiyle ücretsiz izle!", - "nl": "puhutv is een Turkse service voor entertainment en video op aanvraag!" - }, - "url": "puhutv.com", - "version": "1.1.27", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/puhutv/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/puhutv/assets/thumbnail.png", - "color": "#232527", - "category": "videos", - "tags": [ - "puhutv", - "movie", - "video", - "turkish" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "EGGSY", + "id": "162969778699501569" + }, + "service": "puhutv", + "description": { + "en": " puhutv is a Turkish entertainment and video on demand service!", + "tr": "puhutv ile en popüler dizileri ve unutulmaz Türk filmlerini tek parça, HD görüntü kalitesiyle ücretsiz izle!", + "nl": "puhutv is een Turkse service voor entertainment en video op aanvraag!" + }, + "url": "puhutv.com", + "version": "1.1.27", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/puhutv/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/puhutv/assets/thumbnail.png", + "color": "#232527", + "category": "videos", + "tags": [ + "puhutv", + "movie", + "video", + "turkish" + ] +} diff --git a/websites/P/puhutv/presence.ts b/websites/P/puhutv/presence.ts index 6d68747f8062..db7d3c05eeb5 100644 --- a/websites/P/puhutv/presence.ts +++ b/websites/P/puhutv/presence.ts @@ -1,90 +1,88 @@ const presence = new Presence({ - clientId: "628341182581440531", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }); + clientId: '628341182581440531', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) -presence.on("UpdateData", async () => { - const category = document.querySelector( - "#widget_serie_contents_3 > section > div > div > div.category-main-content-right > header > h1 > strong" - ) as HTMLElement; +presence.on('UpdateData', async () => { + const category = document.querySelector( + '#widget_serie_contents_3 > section > div > div > div.category-main-content-right > header > h1 > strong', + ) as HTMLElement - if ( - document.location.pathname === "/" || - !document.location.pathname || - (category && category.textContent !== "") - ) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/puhutv/assets/logo.png", - startTimestamp: Math.floor(Date.now() / 1000), - details: "Geziniyor...", - state: - category && category.textContent ? category.textContent : "Ana Sayfa", - }); - } else { - const video = document.querySelector( - "#dyg_player_dogusPlayer_html5_api" - ) as HTMLVideoElement; + if ( + document.location.pathname === '/' + || !document.location.pathname + || (category && category.textContent !== '') + ) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/puhutv/assets/logo.png', + startTimestamp: Math.floor(Date.now() / 1000), + details: 'Geziniyor...', + state: category && category.textContent ? category.textContent : 'Ana Sayfa', + }) + } + else { + const video = document.querySelector( + '#dyg_player_dogusPlayer_html5_api', + ) - if (!video) return; - else { - const title = document.querySelector( - "#widget_video_detail_3 > section.hero.hero--video-detay.hero--subpages > header > div > div.video-detay-header-content > h1 > a" - ), - episode = - title && - document.querySelector( - "#widget_video_detail_3 > section.hero.hero--video-detay.hero--subpages > header > div > div.video-detay-header-content > h1" - ) - ? document - .querySelector( - "#widget_video_detail_3 > section.hero.hero--video-detay.hero--subpages > header > div > div.video-detay-header-content > h1" - ) - .textContent.replace(`${title.outerHTML} `, "") - : null, - timestamps = presence.getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ); + if (video) { + const title = document.querySelector( + '#widget_video_detail_3 > section.hero.hero--video-detay.hero--subpages > header > div > div.video-detay-header-content > h1 > a', + ) + const episode = title + && document.querySelector( + '#widget_video_detail_3 > section.hero.hero--video-detay.hero--subpages > header > div > div.video-detay-header-content > h1', + ) + ? document + .querySelector( + '#widget_video_detail_3 > section.hero.hero--video-detay.hero--subpages > header > div > div.video-detay-header-content > h1', + ) + ?.textContent + ?.replace(`${title.outerHTML} `, '') + : null + const timestamps = presence.getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) - if (!title || title.textContent === "") return; + if (!title || title.textContent === '') + return - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/puhutv/assets/logo.png", - details: title.textContent, - state: - episode !== "" - ? episode - : `${ - document.querySelector( - "#widget_serie_detail_tab_5 > section > div > div > div > div.kunye-content-left > div:nth-child(3)" - ) - ? document - .querySelector( - "#widget_serie_detail_tab_5 > section > div > div > div > div.kunye-content-left > div:nth-child(3)" - ) - .textContent.replace("\n", ": ") - : null - }`, - smallImageKey: video.paused ? Assets.Pause : Assets.Play, - smallImageText: video.paused - ? (await strings).pause - : (await strings).play, - }; + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/puhutv/assets/logo.png', + details: title.textContent, + state: episode !== '' + ? episode + : `${ + document.querySelector( + '#widget_serie_detail_tab_5 > section > div > div > div > div.kunye-content-left > div:nth-child(3)', + ) + ? document + .querySelector( + '#widget_serie_detail_tab_5 > section > div > div > div > div.kunye-content-left > div:nth-child(3)', + ) + ?.textContent + ?.replace('\n', ': ') + : null + }`, + smallImageKey: video.paused ? Assets.Pause : Assets.Play, + smallImageText: video.paused + ? (await strings).pause + : (await strings).play, + } - if (!isNaN(timestamps[0]) && !isNaN(timestamps[1])) - [presenceData.startTimestamp, presenceData.endTimestamp] = timestamps; + if (!Number.isNaN(timestamps[0]) && !Number.isNaN(timestamps[1])) + [presenceData.startTimestamp, presenceData.endTimestamp] = timestamps - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } - presence.setActivity(presenceData); - } - } -}); + presence.setActivity(presenceData) + } + } +}) diff --git a/websites/P/pxls.space/metadata.json b/websites/P/pxls.space/metadata.json index 8be3f899c4a9..ceafb7c5da68 100644 --- a/websites/P/pxls.space/metadata.json +++ b/websites/P/pxls.space/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Morrays", - "id": "156190372354064384" - }, - "service": "pxls.space", - "description": { - "en": "Pxls.space is a clone of the r/place social experiment performed by the social platform Reddit on the 1st of April 2017. (April Fools Day) After several weeks, the canvas resets and takes on a new shape. ", - "nl": "Pxls.space is een kloon van het sociale experiment r / place uitgevoerd door het sociale platform Reddit op 1 april 2017. (April Fools Day) Na enkele weken wordt het canvas gereset en krijgt het een nieuwe vorm." - }, - "url": "pxls.space", - "version": "1.0.20", - "logo": "https://cdn.rcd.gg/PreMiD/websites/P/pxls.space/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/pxls.space/assets/thumbnail.png", - "color": "#F00", - "category": "games", - "tags": [ - "pxls-space", - "game", - "art", - "pixelart", - "community" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Morrays", + "id": "156190372354064384" + }, + "service": "pxls.space", + "description": { + "en": "Pxls.space is a clone of the r/place social experiment performed by the social platform Reddit on the 1st of April 2017. (April Fools Day) After several weeks, the canvas resets and takes on a new shape. ", + "nl": "Pxls.space is een kloon van het sociale experiment r / place uitgevoerd door het sociale platform Reddit op 1 april 2017. (April Fools Day) Na enkele weken wordt het canvas gereset en krijgt het een nieuwe vorm." + }, + "url": "pxls.space", + "version": "1.0.20", + "logo": "https://cdn.rcd.gg/PreMiD/websites/P/pxls.space/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/P/pxls.space/assets/thumbnail.png", + "color": "#F00", + "category": "games", + "tags": [ + "pxls-space", + "game", + "art", + "pixelart", + "community" + ] +} diff --git a/websites/P/pxls.space/presence.ts b/websites/P/pxls.space/presence.ts index 6c3c84013f7e..4599499c1f06 100644 --- a/websites/P/pxls.space/presence.ts +++ b/websites/P/pxls.space/presence.ts @@ -1,20 +1,19 @@ -const browsingTimestamp = Math.floor(Date.now() / 1000), - presence = new Presence({ - clientId: "785958064192749600", - }); -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/P/pxls.space/assets/logo.png", - startTimestamp: browsingTimestamp, - }; - if (document.location.hostname === "pxls.space") { - presenceData.state = `Canvas: ${ - document.querySelector("#current-pixel-count").textContent - }`; - presenceData.details = `All time: ${ - document.querySelector("#alltime-pixel-count").textContent - }`; - presence.setActivity(presenceData); - } -}); +const browsingTimestamp = Math.floor(Date.now() / 1000) +const presence = new Presence({ + clientId: '785958064192749600', +}) +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/P/pxls.space/assets/logo.png', + startTimestamp: browsingTimestamp, + } + if (document.location.hostname === 'pxls.space') { + presenceData.state = `Canvas: ${ + document.querySelector('#current-pixel-count')?.textContent + }` + presenceData.details = `All time: ${ + document.querySelector('#alltime-pixel-count')?.textContent + }` + presence.setActivity(presenceData) + } +})