From 1905cb584accd5773df012aed23d0c0a7c98a6c9 Mon Sep 17 00:00:00 2001 From: Bas950 Date: Sun, 19 Jan 2025 16:43:55 +0100 Subject: [PATCH] chore: lint D folder --- websites/D/D&D Beyond/metadata.json | 48 +- websites/D/D&D Beyond/presence.ts | 1002 +++++----- websites/D/DALL-E/metadata.json | 76 +- websites/D/DALL-E/presence.ts | 364 ++-- websites/D/DEV Community/metadata.json | 68 +- websites/D/DEV Community/presence.ts | 574 +++--- websites/D/DEX Screener/metadata.json | 44 +- websites/D/DEX Screener/presence.ts | 347 ++-- websites/D/DMOJ/metadata.json | 46 +- websites/D/DMOJ/presence.ts | 656 ++++--- websites/D/DaFont/metadata.json | 46 +- websites/D/DaFont/presence.ts | 183 +- websites/D/Daily Mail/data.ts | 652 +++---- websites/D/Daily Mail/findPage.ts | 156 +- websites/D/Daily Mail/handleSport.ts | 48 +- websites/D/Daily Mail/metadata.json | 70 +- websites/D/Daily Mail/newsPage.ts | 98 +- websites/D/Daily Mail/presence.ts | 128 +- websites/D/Daily Wire/metadata.json | 70 +- websites/D/Daily Wire/presence.ts | 228 ++- websites/D/Dank Memer/metadata.json | 44 +- websites/D/Dank Memer/presence.ts | 71 +- websites/D/DashNet/metadata.json | 52 +- websites/D/DashNet/presence.ts | 188 +- websites/D/Daum/iframe.ts | 62 +- websites/D/Daum/metadata.json | 92 +- websites/D/Daum/presence.ts | 964 +++++----- websites/D/Deconreconstruction/metadata.json | 56 +- websites/D/Deconreconstruction/presence.ts | 293 ++- websites/D/DeepL/metadata.json | 46 +- websites/D/DeepL/presence.ts | 35 +- websites/D/Deezer/metadata.json | 118 +- websites/D/Deezer/presence.ts | 282 +-- websites/D/Defly.io/metadata.json | 50 +- websites/D/Defly.io/presence.ts | 70 +- websites/D/Dek-d/metadata.json | 54 +- websites/D/Dek-d/presence.ts | 591 +++--- websites/D/Deno/metadata.json | 104 +- websites/D/Deno/presence.ts | 420 ++--- websites/D/Derpibooru/metadata.json | 44 +- websites/D/Derpibooru/presence.ts | 315 ++-- websites/D/Desmos/metadata.json | 44 +- websites/D/Desmos/presence.ts | 156 +- websites/D/Destiny Item Manager/metadata.json | 48 +- websites/D/Destiny Item Manager/presence.ts | 139 +- websites/D/Destiny.gg/metadata.json | 52 +- websites/D/Destiny.gg/presence.ts | 84 +- websites/D/Desu-Online/iframe.ts | 22 +- websites/D/Desu-Online/metadata.json | 82 +- websites/D/Desu-Online/presence.ts | 363 ++-- websites/D/DeviantArt/metadata.json | 100 +- websites/D/DeviantArt/presence.ts | 1626 +++++++++-------- websites/D/Di.FM/metadata.json | 48 +- websites/D/Di.FM/presence.ts | 51 +- websites/D/Dice Sweden/metadata.json | 70 +- websites/D/Dice Sweden/presence.ts | 321 ++-- websites/D/Discogs/metadata.json | 46 +- websites/D/Discogs/presence.ts | 852 ++++----- websites/D/Discohook/metadata.json | 46 +- websites/D/Discohook/presence.ts | 36 +- websites/D/Discord Bot List/metadata.json | 48 +- websites/D/Discord Bot List/presence.ts | 90 +- websites/D/Discord BotList/metadata.json | 86 +- websites/D/Discord BotList/presence.ts | 276 +-- websites/D/Discord Bots/metadata.json | 48 +- websites/D/Discord Bots/presence.ts | 78 +- websites/D/Discord Extreme List/metadata.json | 114 +- websites/D/Discord Extreme List/presence.ts | 31 +- websites/D/Discord ID/metadata.json | 94 +- websites/D/Discord ID/presence.ts | 196 +- websites/D/Discord Resources/metadata.json | 44 +- websites/D/Discord Resources/presence.ts | 148 +- websites/D/Discord SFX/metadata.json | 44 +- websites/D/Discord SFX/presence.ts | 214 +-- websites/D/Discord Turkiye/metadata.json | 60 +- websites/D/Discord Turkiye/presence.ts | 242 +-- websites/D/Discord/metadata.json | 184 +- websites/D/Discord/presence.ts | 1506 +++++++-------- websites/D/DiscordJS Guide/metadata.json | 48 +- websites/D/DiscordJS Guide/presence.ts | 33 +- websites/D/DiscordLabs.org/metadata.json | 48 +- websites/D/DiscordLabs.org/presence.ts | 93 +- websites/D/Discords.com/metadata.json | 100 +- websites/D/Discords.com/presence.ts | 749 ++++---- websites/D/Discovery/metadata.json | 116 +- websites/D/Discovery/presence.ts | 691 +++---- websites/D/Disney+/metadata.json | 150 +- websites/D/Disney+/presence.ts | 512 +++--- websites/D/Distrokid/metadata.json | 40 +- websites/D/Distrokid/presence.ts | 92 +- websites/D/DiziBOX/iframe.ts | 33 +- websites/D/DiziBOX/metadata.json | 58 +- websites/D/DiziBOX/presence.ts | 323 ++-- websites/D/Dizilla/iframe.ts | 22 +- websites/D/Dizilla/metadata.json | 56 +- websites/D/Dizilla/presence.ts | 226 +-- websites/D/Diziroll/iframe.ts | 22 +- websites/D/Diziroll/metadata.json | 60 +- websites/D/Diziroll/presence.ts | 138 +- websites/D/Docchi/iframe.ts | 22 +- websites/D/Docchi/metadata.json | 86 +- websites/D/Docchi/presence.ts | 432 ++--- websites/D/DockerHub/metadata.json | 42 +- websites/D/DockerHub/presence.ts | 382 ++-- websites/D/Dominion Online/metadata.json | 44 +- websites/D/Dominion Online/presence.ts | 120 +- websites/D/Domino's Pizza (UK)/metadata.json | 56 +- websites/D/Domino's Pizza (UK)/presence.ts | 321 ++-- websites/D/Doodstreams/metadata.json | 52 +- websites/D/Doodstreams/presence.ts | 64 +- websites/D/Doordash/metadata.json | 68 +- websites/D/Doordash/presence.ts | 165 +- websites/D/Doronime/metadata.json | 48 +- websites/D/Doronime/presence.ts | 255 +-- websites/D/Downdetector/metadata.json | 44 +- websites/D/Downdetector/presence.ts | 118 +- websites/D/Drama/metadata.json | 44 +- websites/D/Drama/presence.ts | 178 +- websites/D/DramaCool/iframe.ts | 30 +- websites/D/DramaCool/metadata.json | 74 +- websites/D/DramaCool/presence.ts | 330 ++-- websites/D/Dribbble/metadata.json | 52 +- websites/D/Dribbble/presence.ts | 152 +- websites/D/Dropbox/metadata.json | 68 +- websites/D/Dropbox/presence.ts | 132 +- websites/D/Dropout/iframe.ts | 22 +- websites/D/Dropout/interfaces.ts | 8 +- websites/D/Dropout/metadata.json | 68 +- websites/D/Dropout/presence.ts | 349 ++-- websites/D/Dsc.gg/metadata.json | 82 +- websites/D/Dsc.gg/presence.ts | 222 +-- websites/D/DuckDuckGo/metadata.json | 220 +-- websites/D/DuckDuckGo/presence.ts | 150 +- websites/D/Dueling Nexus/metadata.json | 66 +- websites/D/Dueling Nexus/presence.ts | 188 +- websites/D/Dumpert/metadata.json | 100 +- websites/D/Dumpert/presence.ts | 259 +-- .../D/Dungeon Crawl Stone Soup/metadata.json | 58 +- .../D/Dungeon Crawl Stone Soup/presence.ts | 99 +- websites/D/Duolingo/metadata.json | 118 +- websites/D/Duolingo/presence.ts | 696 +++---- websites/D/Duolingo/util.ts | 190 +- websites/D/Durarara/metadata.json | 44 +- websites/D/Durarara/presence.ts | 61 +- websites/D/Dyno/metadata.json | 44 +- websites/D/Dyno/presence.ts | 81 +- websites/D/daily.dev/metadata.json | 44 +- websites/D/daily.dev/presence.ts | 224 +-- websites/D/dailymotion/metadata.json | 58 +- websites/D/dailymotion/presence.ts | 88 +- websites/D/dizilab/iframe.ts | 50 +- websites/D/dizilab/metadata.json | 52 +- websites/D/dizilab/presence.ts | 581 +++--- websites/D/diziwatch/metadata.json | 44 +- websites/D/diziwatch/presence.ts | 149 +- websites/D/dlive/metadata.json | 52 +- websites/D/dlive/presence.ts | 81 +- websites/D/dod Games/metadata.json | 44 +- websites/D/dod Games/presence.ts | 475 ++--- websites/D/draw.io/metadata.json | 86 +- websites/D/draw.io/presence.ts | 34 +- .../metadata.json" | 50 +- .../presence.ts" | 63 +- 163 files changed, 14752 insertions(+), 14081 deletions(-) diff --git a/websites/D/D&D Beyond/metadata.json b/websites/D/D&D Beyond/metadata.json index e4ce14d14022..fe7f4700801e 100644 --- a/websites/D/D&D Beyond/metadata.json +++ b/websites/D/D&D Beyond/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "D&D Beyond", - "description": { - "en": "An official digital toolset for Fifth Edition (5e) Dungeons & Dragons (D&D)." - }, - "url": "www.dndbeyond.com", - "version": "1.0.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/D&D%20Beyond/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/D&D%20Beyond/assets/thumbnail.png", - "color": "#E40712", - "category": "games", - "tags": [ - "dnd", - "character", - "creation", - "official", - "store" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "D&D Beyond", + "description": { + "en": "An official digital toolset for Fifth Edition (5e) Dungeons & Dragons (D&D)." + }, + "url": "www.dndbeyond.com", + "version": "1.0.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/D&D%20Beyond/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/D&D%20Beyond/assets/thumbnail.png", + "color": "#E40712", + "category": "games", + "tags": [ + "dnd", + "character", + "creation", + "official", + "store" + ] +} diff --git a/websites/D/D&D Beyond/presence.ts b/websites/D/D&D Beyond/presence.ts index 92e3c5c13c84..51fff5f8e6f0 100644 --- a/websites/D/D&D Beyond/presence.ts +++ b/websites/D/D&D Beyond/presence.ts @@ -1,491 +1,529 @@ const presence = new Presence({ - clientId: "1021922769111351379", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1021922769111351379', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) enum Asset { - info = "https://cdn.rcd.gg/PreMiD/websites/D/D&D%20Beyond/assets/0.png", - logo = "https://cdn.rcd.gg/PreMiD/websites/D/D&D%20Beyond/assets/logo.png", + info = 'https://cdn.rcd.gg/PreMiD/websites/D/D&D%20Beyond/assets/0.png', + logo = 'https://cdn.rcd.gg/PreMiD/websites/D/D&D%20Beyond/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Asset.logo, - startTimestamp: browsingTimestamp, - }, - { pathname, href, search } = window.location, - pathSplit = pathname.split("/").filter(path => path), - pageTitle = document - .querySelector(".page-title") - ?.textContent.trim(); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Asset.logo, + startTimestamp: browsingTimestamp, + } + const { pathname, href, search } = window.location + const pathSplit = pathname.split('/').filter(path => path) + const pageTitle = document + .querySelector('.page-title') + ?.textContent + ?.trim() - switch (pathSplit[0] ?? "") { - case "": { - presenceData.details = "Browsing home page"; - break; - } - case "account": { - presenceData.details = "Managing preferences"; - presenceData.state = pageTitle; - break; - } - case "backgrounds": { - if (pathSplit[1]) { - presenceData.details = "Viewing a background"; - presenceData.state = pageTitle; - presenceData.largeImageKey = - document.querySelector(".image").src; - presenceData.buttons = [ - { - label: "View Background", - url: href, - }, - ]; - } else presenceData.details = "Browsing list of backgrounds"; - break; - } - case "changelog": { - if (pathSplit[1]) { - presenceData.details = "Reading a changelog"; - presenceData.state = pageTitle; - } else presenceData.details = "Browsing the changelog"; - break; - } - case "characters": { - if (pathSplit[1] === "builder") - presenceData.details = "Creating a new character"; - else if (pathSplit[2] === "builder") { - const characterName = document.querySelector( - ".character-builder-page-header-name" - ).textContent; - presenceData.details = "Modifying a character"; - presenceData.largeImageKey = getComputedStyle( - document.querySelector( - ".ddbc-character-avatar__portrait" - ) - ).backgroundImage?.match(/url\("(.*?)"\)/)[1]; - switch (pathSplit[3]) { - case "home": { - presenceData.state = `Basic preferences | ${characterName}`; - break; - } - case "race": { - if (pathSplit[4] === "manage") { - presenceData.state = `Racial traits | ${characterName}`; - presenceData.smallImageKey = - document.querySelector( - ".race-detail-preview-img" - ).src; - presenceData.smallImageText = document.querySelector( - ".builder-page-header" - ).textContent; - } else presenceData.state = `Choosing race | ${characterName}`; + switch (pathSplit[0] ?? '') { + case '': { + presenceData.details = 'Browsing home page' + break + } + case 'account': { + presenceData.details = 'Managing preferences' + presenceData.state = pageTitle + break + } + case 'backgrounds': { + if (pathSplit[1]) { + presenceData.details = 'Viewing a background' + presenceData.state = pageTitle + presenceData.largeImageKey = document.querySelector('.image')?.src + presenceData.buttons = [ + { + label: 'View Background', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing list of backgrounds' + } + break + } + case 'changelog': { + if (pathSplit[1]) { + presenceData.details = 'Reading a changelog' + presenceData.state = pageTitle + } + else { + presenceData.details = 'Browsing the changelog' + } + break + } + case 'characters': { + if (pathSplit[1] === 'builder') { + presenceData.details = 'Creating a new character' + } + else if (pathSplit[2] === 'builder') { + const characterName = document.querySelector( + '.character-builder-page-header-name', + )?.textContent + presenceData.details = 'Modifying a character' + presenceData.largeImageKey = getComputedStyle( + document.querySelector( + '.ddbc-character-avatar__portrait', + )!, + ).backgroundImage?.match(/url\("(.*?)"\)/)?.[1] + switch (pathSplit[3]) { + case 'home': { + presenceData.state = `Basic preferences | ${characterName}` + break + } + case 'race': { + if (pathSplit[4] === 'manage') { + presenceData.state = `Racial traits | ${characterName}` + presenceData.smallImageKey = document.querySelector( + '.race-detail-preview-img', + )?.src + presenceData.smallImageText = document.querySelector( + '.builder-page-header', + )?.textContent + } + else { + presenceData.state = `Choosing race | ${characterName}` + } - break; - } - case "class": { - if (pathSplit[4] === "manage") - presenceData.state = `Class features | ${characterName}`; - else presenceData.state = `Choosing a class | ${characterName}`; + break + } + case 'class': { + if (pathSplit[4] === 'manage') + presenceData.state = `Class features | ${characterName}` + else presenceData.state = `Choosing a class | ${characterName}` - break; - } - case "ability-scores": { - presenceData.state = `Ability scores | ${characterName}`; - break; - } - case "description": { - presenceData.state = `Background | ${characterName}`; - presenceData.smallImageKey = Asset.info; - presenceData.smallImageText = - document.querySelector( - ".description-manage-background-chooser" - ).selectedOptions[0].textContent; - break; - } - case "equipment": { - presenceData.state = `Equipment | ${characterName}`; - break; - } - default: { - presenceData.state = characterName; - break; - } - } - } else if (pathSplit[1]) { - presenceData.details = "Viewing a character sheet"; - presenceData.state = document.querySelector( - ".ddbc-character-tidbits__heading > h1" - ).textContent; - presenceData.largeImageKey = getComputedStyle( - document.querySelector( - ".ddbc-character-avatar__portrait" - ) - ).backgroundImage?.match(/url\("(.*?)"\)/)[1]; - presenceData.smallImageKey = Asset.info; - presenceData.smallImageText = `${ - document.querySelector( - ".ddbc-character-summary__race" - ).textContent - } (${ - document.querySelector( - ".ddbc-character-summary__classes" - ).textContent - })`; - presenceData.buttons = [ - { - label: "View character sheet", - url: href, - }, - ]; - } else presenceData.details = "Browsing their characters"; - break; - } - case "classes": { - if (pathSplit[1]) { - presenceData.details = "Viewing a class"; - presenceData.state = pageTitle; - presenceData.largeImageKey = - document.querySelector(".image").src; - presenceData.buttons = [ - { - label: "View class", - url: href, - }, - ]; - } else presenceData.details = "Browsing list of classes"; - break; - } - case "encounter-builder": { - presenceData.details = "Creating an encounter"; - presenceData.state = - document.querySelector("[name=encounterName]") - .value || "Untitled Encounter"; - break; - } - case "encounters": { - if (pathSplit[2] === "edit") { - presenceData.details = "Editing an encounter"; - presenceData.state = - document.querySelector("[name=encounterName]") - .value || "Untitled Encounter"; - } else { - presenceData.details = "Viewing an encounter"; - presenceData.state = document.querySelector( - ".ddb-page-header__title" - ).textContent; - } - break; - } - case "equipment": { - if (pathSplit[1]) { - presenceData.details = "Viewing an equipment"; - presenceData.state = pageTitle; - presenceData.largeImageKey = - document.querySelector(".image").src; - presenceData.buttons = [ - { - label: "View equipment", - url: href, - }, - ]; - } else presenceData.details = "Browsing list of equipment"; - break; - } - case "feats": { - if (pathSplit[1]) { - presenceData.details = "Viewing a feat"; - presenceData.state = pageTitle; - presenceData.largeImageKey = - document.querySelector(".image").src; - presenceData.buttons = [ - { - label: "View feat", - url: href, - }, - ]; - } else presenceData.details = "Browsing list of feats"; - break; - } - case "forums": { - if (pathSplit[1] === "search") { - presenceData.details = "Searching forums"; - presenceData.state = new URLSearchParams(search).get("search"); - } else if (pathSplit[1]) { - if (/^\d+-/.test(pathSplit[pathSplit.length - 1])) { - presenceData.details = "Reading a forum post"; - presenceData.state = pageTitle; - presenceData.buttons = [ - { - label: "Read post", - url: href, - }, - ]; - } else if (pathSplit[pathSplit.length - 1] === "create-thread") { - presenceData.details = "Creating a forum post"; - presenceData.state = - document.querySelector("#field-title").value; - } else { - presenceData.details = "Browsing forums"; - presenceData.state = pageTitle; - } - } else { - presenceData.details = "Browsing forums"; - presenceData.state = "Main page"; - } - break; - } - case "homebrew": { - switch (pathSplit[1] ?? "") { - case "": { - presenceData.details = "Browsing Homebrew categories"; - break; - } - case "creations": { - switch (pathSplit[2]) { - case "create-background": { - presenceData.details = "Creating a background"; - break; - } - case "create-feat": { - presenceData.details = "Creating a feat"; - break; - } - case "create-magic-item": { - presenceData.details = "Creating a magic item"; - break; - } - case "create-monster": { - presenceData.details = "Creating a monster"; - break; - } - case "create-race": { - presenceData.details = "Creating a race"; - break; - } - case "create-spell": { - presenceData.details = "Creating a spell"; - break; - } - case "create-subclass": { - presenceData.details = "Creating a subclass"; - break; - } - } - presenceData.state = document.querySelector( - ".ddb-homebrew-create-form-fields-item-input > input" - ).value; - break; - } - default: { - presenceData.details = "Browsing Hombrew category"; - presenceData.state = pageTitle; - } - } - break; - } - case "magic-items": { - if (pathSplit[1]) { - presenceData.details = "Viewing a magic item"; - presenceData.state = pageTitle; - presenceData.smallImageKey = - document.querySelector(".magic-item-image").src; - presenceData.smallImageText = document - .querySelector(".item-info") - .textContent.trim(); - presenceData.buttons = [ - { - label: "View magic item", - url: href, - }, - ]; - } else presenceData.details = "Browsing list of magic items"; - break; - } - case "marketplace": { - if (pathSplit[1] === "redeem-key") - presenceData.details = "Redeeming a product key"; - else if ( - pathSplit[1] === "cart" || - pathSplit[1] === "address" || - pathSplit[1] === "checkout" - ) - presenceData.details = "Purchasing materials"; - else if (!pathSplit[1]) presenceData.details = "Browsing marketplace"; - else { - presenceData.details = "Browsing marketplace"; - presenceData.state = pageTitle; - presenceData.largeImageKey = document.querySelector( - ".product-hero-avatar__image" - ).src; - } - break; - } - case "members": { - if (pathSplit[1]) { - const username = document - .querySelector(".username") - .textContent.trim(); - presenceData.details = "Viewing a member's profile"; - presenceData.largeImageKey = - document.querySelector(".user-avatar img").src; - if (pathSplit[2] === "posts") - presenceData.state = `${username}'s posts`; - else presenceData.state = username; - } else presenceData.details = "Viewing list of members"; - break; - } - case "monsters": { - if (pathSplit[1]) { - presenceData.details = "Viewing a monster"; - presenceData.state = pageTitle; - presenceData.largeImageKey = - document.querySelector(".monster-image").src; - presenceData.buttons = [ - { - label: "View monster", - url: href, - }, - ]; - } else presenceData.details = "Browsing list of monsters"; - break; - } - case "my-collection": { - presenceData.details = "Browsing their Homebrew collection"; - break; - } - case "my-creations": { - presenceData.details = "Browsing their Homebrew creations"; - break; - } - case "my-encounters": { - presenceData.details = "Browsing their encounters"; - break; - } - case "posts": { - if (pathSplit[1]) { - presenceData.details = "Reading a post"; - presenceData.state = pageTitle; - presenceData.buttons = [ - { - label: "Read post", - url: href, - }, - ]; - } else presenceData.details = "Browsing posts"; - break; - } - case "private-messages": { - if (pathSplit[1] === "send") - presenceData.details = "Writing a direct message"; - else presenceData.details = "Viewing direct messages"; - break; - } - case "races": { - if (pathSplit[1]) { - presenceData.details = "Viewing a race"; - presenceData.state = pageTitle; - presenceData.largeImageKey = - document.querySelector(".image").src; - presenceData.buttons = [ - { - label: "View race", - url: href, - }, - ]; - } else presenceData.details = "Browsing list of races"; - break; - } - case "search": { - presenceData.details = "Searching"; - presenceData.state = new URLSearchParams(search).get("q"); - break; - } - case "sources": { - if (pathSplit[1]) { - if (pathSplit[2]) { - presenceData.details = "Viewing a section of a source"; - presenceData.state = document.querySelector( - ".p-article-content > h1" - ).textContent; - presenceData.buttons = [ - { - label: "Read section", - url: href, - }, - ]; - } else { - presenceData.details = "Viewing table of contents for source"; - presenceData.state = pageTitle; - presenceData.buttons = [ - { - label: "View source", - url: href, - }, - ]; - } - } else presenceData.details = "Browsing list of sources"; - break; - } - case "spells": { - switch (pathSplit[1] ?? "") { - case "": { - presenceData.details = "Browsing list of spells"; - break; - } - case "class": - case "school": { - presenceData.details = "Browsing list of spells"; - presenceData.state = pageTitle; - break; - } - default: { - presenceData.details = "Viewing a spell"; - presenceData.state = pageTitle; - presenceData.smallImageKey = - document.querySelector(".spell-image").src; - presenceData.smallImageText = `School of ${document - .querySelector( - ".ddb-statblock-item-school > .ddb-statblock-item-value" - ) - .textContent.trim()}`; - presenceData.buttons = [ - { - label: "View spell", - url: href, - }, - ]; - } - } - break; - } - case "tag": { - presenceData.details = `Browsing posts tagged '${pageTitle}'`; - break; - } - case "vehicles": { - if (pathSplit[1]) { - presenceData.details = "Viewing a vehicle"; - presenceData.state = pageTitle; - presenceData.largeImageKey = - document.querySelector(".monster-image").src; - presenceData.buttons = [ - { - label: "View vehicle", - url: href, - }, - ]; - } else presenceData.details = "Browsing list of vehicles"; - break; - } - default: { - presenceData.details = "Browsing"; - presenceData.state = - pageTitle ?? document.title.match(/^(.*?)( - D&D Beyond)?$/)[1]; - break; - } - } + break + } + case 'ability-scores': { + presenceData.state = `Ability scores | ${characterName}` + break + } + case 'description': { + presenceData.state = `Background | ${characterName}` + presenceData.smallImageKey = Asset.info + presenceData.smallImageText = document.querySelector( + '.description-manage-background-chooser', + )?.selectedOptions[0]?.textContent + break + } + case 'equipment': { + presenceData.state = `Equipment | ${characterName}` + break + } + default: { + presenceData.state = characterName + break + } + } + } + else if (pathSplit[1]) { + presenceData.details = 'Viewing a character sheet' + presenceData.state = document.querySelector( + '.ddbc-character-tidbits__heading > h1', + )?.textContent + presenceData.largeImageKey = getComputedStyle( + document.querySelector( + '.ddbc-character-avatar__portrait', + )!, + ).backgroundImage?.match(/url\("(.*?)"\)/)?.[1] + presenceData.smallImageKey = Asset.info + presenceData.smallImageText = `${ + document.querySelector( + '.ddbc-character-summary__race', + )?.textContent + } (${ + document.querySelector( + '.ddbc-character-summary__classes', + )?.textContent + })` + presenceData.buttons = [ + { + label: 'View character sheet', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing their characters' + } + break + } + case 'classes': { + if (pathSplit[1]) { + presenceData.details = 'Viewing a class' + presenceData.state = pageTitle + presenceData.largeImageKey = document.querySelector('.image')?.src + presenceData.buttons = [ + { + label: 'View class', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing list of classes' + } + break + } + case 'encounter-builder': { + presenceData.details = 'Creating an encounter' + presenceData.state = document.querySelector('[name=encounterName]')?.value || 'Untitled Encounter' + break + } + case 'encounters': { + if (pathSplit[2] === 'edit') { + presenceData.details = 'Editing an encounter' + presenceData.state = document.querySelector('[name=encounterName]')?.value || 'Untitled Encounter' + } + else { + presenceData.details = 'Viewing an encounter' + presenceData.state = document.querySelector( + '.ddb-page-header__title', + )?.textContent + } + break + } + case 'equipment': { + if (pathSplit[1]) { + presenceData.details = 'Viewing an equipment' + presenceData.state = pageTitle + presenceData.largeImageKey = document.querySelector('.image')?.src + presenceData.buttons = [ + { + label: 'View equipment', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing list of equipment' + } + break + } + case 'feats': { + if (pathSplit[1]) { + presenceData.details = 'Viewing a feat' + presenceData.state = pageTitle + presenceData.largeImageKey = document.querySelector('.image')?.src + presenceData.buttons = [ + { + label: 'View feat', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing list of feats' + } + break + } + case 'forums': { + if (pathSplit[1] === 'search') { + presenceData.details = 'Searching forums' + presenceData.state = new URLSearchParams(search).get('search') + } + else if (pathSplit[1]) { + if (/^\d+-/.test(pathSplit[pathSplit.length - 1])) { + presenceData.details = 'Reading a forum post' + presenceData.state = pageTitle + presenceData.buttons = [ + { + label: 'Read post', + url: href, + }, + ] + } + else if (pathSplit[pathSplit.length - 1] === 'create-thread') { + presenceData.details = 'Creating a forum post' + presenceData.state = document.querySelector('#field-title')?.value + } + else { + presenceData.details = 'Browsing forums' + presenceData.state = pageTitle + } + } + else { + presenceData.details = 'Browsing forums' + presenceData.state = 'Main page' + } + break + } + case 'homebrew': { + switch (pathSplit[1] ?? '') { + case '': { + presenceData.details = 'Browsing Homebrew categories' + break + } + case 'creations': { + switch (pathSplit[2]) { + case 'create-background': { + presenceData.details = 'Creating a background' + break + } + case 'create-feat': { + presenceData.details = 'Creating a feat' + break + } + case 'create-magic-item': { + presenceData.details = 'Creating a magic item' + break + } + case 'create-monster': { + presenceData.details = 'Creating a monster' + break + } + case 'create-race': { + presenceData.details = 'Creating a race' + break + } + case 'create-spell': { + presenceData.details = 'Creating a spell' + break + } + case 'create-subclass': { + presenceData.details = 'Creating a subclass' + break + } + } + presenceData.state = document.querySelector( + '.ddb-homebrew-create-form-fields-item-input > input', + )?.value + break + } + default: { + presenceData.details = 'Browsing Hombrew category' + presenceData.state = pageTitle + } + } + break + } + case 'magic-items': { + if (pathSplit[1]) { + presenceData.details = 'Viewing a magic item' + presenceData.state = pageTitle + presenceData.smallImageKey = document.querySelector('.magic-item-image')?.src + presenceData.smallImageText = document.querySelector('.item-info')?.textContent?.trim() + presenceData.buttons = [ + { + label: 'View magic item', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing list of magic items' + } + break + } + case 'marketplace': { + if (pathSplit[1] === 'redeem-key') { + presenceData.details = 'Redeeming a product key' + } + else if ( + pathSplit[1] === 'cart' + || pathSplit[1] === 'address' + || pathSplit[1] === 'checkout' + ) { + presenceData.details = 'Purchasing materials' + } + else if (!pathSplit[1]) { + presenceData.details = 'Browsing marketplace' + } + else { + presenceData.details = 'Browsing marketplace' + presenceData.state = pageTitle + presenceData.largeImageKey = document.querySelector( + '.product-hero-avatar__image', + )?.src + } + break + } + case 'members': { + if (pathSplit[1]) { + const username = document + .querySelector('.username') + ?.textContent + ?.trim() + presenceData.details = 'Viewing a member\'s profile' + presenceData.largeImageKey = document.querySelector('.user-avatar img')?.src + if (pathSplit[2] === 'posts') + presenceData.state = `${username}'s posts` + else presenceData.state = username + } + else { + presenceData.details = 'Viewing list of members' + } + break + } + case 'monsters': { + if (pathSplit[1]) { + presenceData.details = 'Viewing a monster' + presenceData.state = pageTitle + presenceData.largeImageKey = document.querySelector('.monster-image')?.src + presenceData.buttons = [ + { + label: 'View monster', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing list of monsters' + } + break + } + case 'my-collection': { + presenceData.details = 'Browsing their Homebrew collection' + break + } + case 'my-creations': { + presenceData.details = 'Browsing their Homebrew creations' + break + } + case 'my-encounters': { + presenceData.details = 'Browsing their encounters' + break + } + case 'posts': { + if (pathSplit[1]) { + presenceData.details = 'Reading a post' + presenceData.state = pageTitle + presenceData.buttons = [ + { + label: 'Read post', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing posts' + } + break + } + case 'private-messages': { + if (pathSplit[1] === 'send') + presenceData.details = 'Writing a direct message' + else presenceData.details = 'Viewing direct messages' + break + } + case 'races': { + if (pathSplit[1]) { + presenceData.details = 'Viewing a race' + presenceData.state = pageTitle + presenceData.largeImageKey = document.querySelector('.image')?.src + presenceData.buttons = [ + { + label: 'View race', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing list of races' + } + break + } + case 'search': { + presenceData.details = 'Searching' + presenceData.state = new URLSearchParams(search).get('q') + break + } + case 'sources': { + if (pathSplit[1]) { + if (pathSplit[2]) { + presenceData.details = 'Viewing a section of a source' + presenceData.state = document.querySelector( + '.p-article-content > h1', + )?.textContent + presenceData.buttons = [ + { + label: 'Read section', + url: href, + }, + ] + } + else { + presenceData.details = 'Viewing table of contents for source' + presenceData.state = pageTitle + presenceData.buttons = [ + { + label: 'View source', + url: href, + }, + ] + } + } + else { + presenceData.details = 'Browsing list of sources' + } + break + } + case 'spells': { + switch (pathSplit[1] ?? '') { + case '': { + presenceData.details = 'Browsing list of spells' + break + } + case 'class': + case 'school': { + presenceData.details = 'Browsing list of spells' + presenceData.state = pageTitle + break + } + default: { + presenceData.details = 'Viewing a spell' + presenceData.state = pageTitle + presenceData.smallImageKey = document.querySelector('.spell-image')?.src + presenceData.smallImageText = `School of ${document + .querySelector( + '.ddb-statblock-item-school > .ddb-statblock-item-value', + ) + ?.textContent + ?.trim()}` + presenceData.buttons = [ + { + label: 'View spell', + url: href, + }, + ] + } + } + break + } + case 'tag': { + presenceData.details = `Browsing posts tagged '${pageTitle}'` + break + } + case 'vehicles': { + if (pathSplit[1]) { + presenceData.details = 'Viewing a vehicle' + presenceData.state = pageTitle + presenceData.largeImageKey = document.querySelector('.monster-image')?.src + presenceData.buttons = [ + { + label: 'View vehicle', + url: href, + }, + ] + } + else { + presenceData.details = 'Browsing list of vehicles' + } + break + } + default: { + presenceData.details = 'Browsing' + presenceData.state = pageTitle ?? document.title.match(/^(.*?)( - D&D Beyond)?$/)?.[1] + break + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/DALL-E/metadata.json b/websites/D/DALL-E/metadata.json index 286342c49aa6..bb35261142e2 100644 --- a/websites/D/DALL-E/metadata.json +++ b/websites/D/DALL-E/metadata.json @@ -1,39 +1,39 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "DALL-E", - "altnames": [ - "DALL·E 2", - "DALLE", - "DALL·E", - "DALL-E", - "DALL-E 2" - ], - "description": { - "en": "DALL·E 2 is a new AI system that can create realistic images and art from a description in natural language." - }, - "url": "labs.openai.com", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DALL-E/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DALL-E/assets/thumbnail.jpg", - "color": "#fff", - "category": "other", - "tags": [ - "ai", - "dalle", - "image", - "art" - ], - "settings": [ - { - "id": "showImages", - "title": "Show Images", - "icon": "fad fa-images", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "DALL-E", + "altnames": [ + "DALL·E 2", + "DALLE", + "DALL·E", + "DALL-E", + "DALL-E 2" + ], + "description": { + "en": "DALL·E 2 is a new AI system that can create realistic images and art from a description in natural language." + }, + "url": "labs.openai.com", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DALL-E/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DALL-E/assets/thumbnail.jpg", + "color": "#fff", + "category": "other", + "tags": [ + "ai", + "dalle", + "image", + "art" + ], + "settings": [ + { + "id": "showImages", + "title": "Show Images", + "icon": "fad fa-images", + "value": true + } + ] +} diff --git a/websites/D/DALL-E/presence.ts b/websites/D/DALL-E/presence.ts index 7c4f194e30fd..49821b9f2d5a 100644 --- a/websites/D/DALL-E/presence.ts +++ b/websites/D/DALL-E/presence.ts @@ -1,178 +1,206 @@ const presence = new Presence({ - clientId: "1037407267336753152", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - slideshow = presence.createSlideshow(); + clientId: '1037407267336753152', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const slideshow = presence.createSlideshow() async function getListImages() { - return await Promise.all( - [ - ...document.querySelectorAll( - ".image-prompt-overlay-container" - ), - ].map(async container => [ - await getShortURL( - container.querySelector(".generated-image > img").src - ), - container.querySelector(".image-prompt-overlay") - .textContent, - ]) - ); + return await Promise.all( + [ + ...document.querySelectorAll( + '.image-prompt-overlay-container', + ), + ].map(async container => [ + await getShortURL( + container.querySelector('.generated-image > img')!.src, + ), + container.querySelector('.image-prompt-overlay')! + .textContent, + ]), + ) } -const shortenedURLs: Record = {}; +const shortenedURLs: Record = {} async function getShortURL(url: string) { - if (url.length < 256) return url; - if (shortenedURLs[url]) return shortenedURLs[url]; - try { - const pdURL = await ( - await fetch(`https://pd.premid.app/create/${url}`) - ).text(); - shortenedURLs[url] = pdURL; - return pdURL; - } catch (err) { - presence.error(err); - return url; - } + if (url.length < 256) + return url + if (shortenedURLs[url]) + return shortenedURLs[url] + try { + const pdURL = await ( + await fetch(`https://pd.premid.app/create/${url}`) + ).text() + shortenedURLs[url] = pdURL + return pdURL + } + catch (err) { + presence.error(err as string) + return url + } } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DALL-E/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, href } = window.location, - showImages = await presence.getSetting("showImages"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DALL-E/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, href } = window.location + const showImages = await presence.getSetting('showImages') - if (pathname === "/") { - const input = document.querySelector( - ".image-prompt-input" - ); - if (input.value) { - presenceData.details = "Crafting a prompt"; - presenceData.state = input.value; - } else presenceData.details = "Thinking of a prompt"; - } else if (pathname.startsWith("/history")) { - if (showImages) { - const images = await getListImages(); - if (images.length > 0) { - for (const [i, [image, text]] of images.entries()) { - slideshow.addSlide( - i.toString(), - { - ...presenceData, - details: "Viewing history", - state: text, - largeImageKey: image, - }, - 5000 - ); - } - } else presenceData.details = "Viewing history"; - } else presenceData.details = "Viewing history"; - } else if (pathname.startsWith("/c/")) { - if (showImages) { - const images = await getListImages(); - if (images.length === 0) { - presenceData.details = "Viewing a collection"; - presenceData.state = - document.querySelector("[class*=h3]").textContent; - } else { - for (const [i, [image, text]] of images.entries()) { - const slide = { - ...presenceData, - details: `Viewing collection: ${ - document.querySelector("[class*=h3]").textContent - }`, - state: text, - largeImageKey: image, - }; - if ( - !document.querySelector( - ".collection-layout-private" - ) && - !pathname.includes("/private") - ) { - slide.buttons = [ - { - label: "View Collection", - url: href, - }, - ]; - } - slideshow.addSlide(i.toString(), slide, 5000); - } - } - } else { - presenceData.details = "Viewing a collection"; - presenceData.state = - document.querySelector("[class*=h3]").textContent; - } - } else if (pathname.startsWith("/collections")) - presenceData.details = "Viewing collections"; - else if (pathname.startsWith("/account")) - presenceData.details = "Viewing their account"; - else if (pathname.startsWith("/e/")) { - const input = document.querySelector( - ".image-prompt-input" - )?.value; - if (showImages) { - const images = await Promise.all( - [ - ...document.querySelectorAll( - ".task-page-generations-img .generated-image > img" - ), - ].map(image => getShortURL(image.src)) - ), - centeredImage = document.querySelector( - ".edit-page-image .generated-image > img" - ); - if (images.length === 0 && !centeredImage) { - presenceData.details = "Generating images"; - presenceData.state = input; - } else if (centeredImage) { - presenceData.details = "Viewing an image"; - presenceData.largeImageKey = await getShortURL(centeredImage.src); - } else { - for (const [i, image] of images.entries()) { - slideshow.addSlide( - i.toString(), - { - ...presenceData, - details: "Viewing a generation", - state: input, - largeImageKey: image, - }, - 5000 - ); - } - } - } else { - presenceData.details = "Viewing a generation"; - presenceData.state = input; - } - } else if (pathname.startsWith("/s/")) { - presenceData.details = "Viewing an image"; - presenceData.state = document.querySelector( - ".gen-detail-caption" - ).textContent; - presenceData.buttons = [{ label: "View Image", url: href }]; - if (showImages) { - presenceData.largeImageKey = await getShortURL( - document.querySelector(".generated-image > img").src - ); - } - } else if (pathname.startsWith("/editor")) - presenceData.details = "Using the image editor"; - else { - presenceData.details = "Browsing"; - presenceData.state = document.title.match(/^(.*)?( \| DALL·E)?$/)[1]; - } + if (pathname === '/') { + const input = document.querySelector( + '.image-prompt-input', + ) + if (input?.value) { + presenceData.details = 'Crafting a prompt' + presenceData.state = input.value + } + else { + presenceData.details = 'Thinking of a prompt' + } + } + else if (pathname.startsWith('/history')) { + if (showImages) { + const images = await getListImages() + if (images.length > 0) { + for (const [i, [image, text]] of images.entries()) { + slideshow.addSlide( + i.toString(), + { + ...presenceData, + details: 'Viewing history', + state: text, + largeImageKey: image, + }, + 5000, + ) + } + } + else { + presenceData.details = 'Viewing history' + } + } + else { + presenceData.details = 'Viewing history' + } + } + else if (pathname.startsWith('/c/')) { + if (showImages) { + const images = await getListImages() + if (images.length === 0) { + presenceData.details = 'Viewing a collection' + presenceData.state = document.querySelector('[class*=h3]')?.textContent + } + else { + for (const [i, [image, text]] of images.entries()) { + const slide = { + ...presenceData, + details: `Viewing collection: ${ + document.querySelector('[class*=h3]')?.textContent + }`, + state: text, + largeImageKey: image, + } + if ( + !document.querySelector( + '.collection-layout-private', + ) + && !pathname.includes('/private') + ) { + slide.buttons = [ + { + label: 'View Collection', + url: href, + }, + ] + } + slideshow.addSlide(i.toString(), slide, 5000) + } + } + } + else { + presenceData.details = 'Viewing a collection' + presenceData.state = document.querySelector('[class*=h3]')?.textContent + } + } + else if (pathname.startsWith('/collections')) { + presenceData.details = 'Viewing collections' + } + else if (pathname.startsWith('/account')) { + presenceData.details = 'Viewing their account' + } + else if (pathname.startsWith('/e/')) { + const input = document.querySelector( + '.image-prompt-input', + )?.value + if (showImages) { + const images = await Promise.all( + [ + ...document.querySelectorAll( + '.task-page-generations-img .generated-image > img', + ), + ].map(image => getShortURL(image.src)), + ) + const centeredImage = document.querySelector( + '.edit-page-image .generated-image > img', + ) + if (images.length === 0 && !centeredImage) { + presenceData.details = 'Generating images' + presenceData.state = input + } + else if (centeredImage) { + presenceData.details = 'Viewing an image' + presenceData.largeImageKey = await getShortURL(centeredImage.src) + } + else { + for (const [i, image] of images.entries()) { + slideshow.addSlide( + i.toString(), + { + ...presenceData, + details: 'Viewing a generation', + state: input, + largeImageKey: image, + }, + 5000, + ) + } + } + } + else { + presenceData.details = 'Viewing a generation' + presenceData.state = input + } + } + else if (pathname.startsWith('/s/')) { + presenceData.details = 'Viewing an image' + presenceData.state = document.querySelector( + '.gen-detail-caption', + )?.textContent + presenceData.buttons = [{ label: 'View Image', url: href }] + if (showImages) { + presenceData.largeImageKey = await getShortURL( + document.querySelector('.generated-image > img')!.src, + ) + } + } + else if (pathname.startsWith('/editor')) { + presenceData.details = 'Using the image editor' + } + else { + presenceData.details = 'Browsing' + // eslint-disable-next-line regexp/no-useless-quantifier, regexp/optimal-quantifier-concatenation + presenceData.state = document.title.match(/^(.*)?( \| DALL·E)?$/)?.[1] + } - if (presenceData.details) { - presence.setActivity(presenceData); - slideshow.deleteAllSlides(); - } else if (slideshow.getSlides().length > 0) presence.setActivity(slideshow); - else presence.setActivity(); -}); + if (presenceData.details) { + presence.setActivity(presenceData) + slideshow.deleteAllSlides() + } + else if (slideshow.getSlides().length > 0) { + presence.setActivity(slideshow) + } + else { + presence.setActivity() + } +}) diff --git a/websites/D/DEV Community/metadata.json b/websites/D/DEV Community/metadata.json index f4e534ac95c4..76ae56e0b804 100644 --- a/websites/D/DEV Community/metadata.json +++ b/websites/D/DEV Community/metadata.json @@ -1,35 +1,35 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "The Gamerzs", - "id": "730142125181894657" - }, - "service": "DEV Community", - "description": { - "en": "A constructive and inclusive social network for software developers. With you every step of your journey.", - "nl": "Een constructief en inclusief sociaal netwerk voor software ontwikkelaars. Bij u elke stap van uw reis." - }, - "url": [ - "dev.to", - "shop.dev.to" - ], - "version": "1.0.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DEV%20Community/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DEV%20Community/assets/thumbnail.png", - "color": "#7289DA", - "category": "socials", - "tags": [ - "tutorials", - "dev-to", - "community" - ], - "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": "DEV Community", + "description": { + "en": "A constructive and inclusive social network for software developers. With you every step of your journey.", + "nl": "Een constructief en inclusief sociaal netwerk voor software ontwikkelaars. Bij u elke stap van uw reis." + }, + "url": [ + "dev.to", + "shop.dev.to" + ], + "version": "1.0.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DEV%20Community/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DEV%20Community/assets/thumbnail.png", + "color": "#7289DA", + "category": "socials", + "tags": [ + "tutorials", + "dev-to", + "community" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/D/DEV Community/presence.ts b/websites/D/DEV Community/presence.ts index 52a2b5ed608b..00c4e056a472 100644 --- a/websites/D/DEV Community/presence.ts +++ b/websites/D/DEV Community/presence.ts @@ -1,319 +1,321 @@ const presence = new Presence({ - clientId: "829466407321731082", - }), - timestamp = Math.floor(Date.now() / 1000); + clientId: '829466407321731082', +}) +const timestamp = Math.floor(Date.now() / 1000) let articleTitle: string, - authorName: string, - authorUrl: string, - feedTop: string, - feedTag: string, - feedListings: string, - listingTitle: string, - podcastTitle: string, - searchTerm: string, - searchLength: number, - contentStateKey: string, - contentStateText: string; + authorName: string, + authorUrl: string, + feedTop: string, + feedTag: string, + feedListings: string, + listingTitle: string, + podcastTitle: string, + searchTerm: string, + searchLength: number, + contentStateKey: string, + contentStateText: string // checkmate javascript function pathIncludes(string: string): boolean { - return document.location.pathname.toLowerCase().includes(string); + return document.location.pathname.toLowerCase().includes(string) } function isShop(): boolean { - if (document.location.host.includes("shop")) return true; + if (document.location.host.includes('shop')) + return true + return false } function isProfile(): boolean { - if (document.querySelectorAll(".profile-header__meta").length === 1) { - authorUrl = document.location.href.toString(); - authorName = document.querySelector( - "#page-content-inner > div.brand-bg > div > header > div.profile-header__details > h1" - ).textContent; + if (document.querySelectorAll('.profile-header__meta').length === 1) { + authorUrl = document.location.href.toString() + authorName = document.querySelector( + '#page-content-inner > div.brand-bg > div > header > div.profile-header__details > h1', + )?.textContent ?? '' - return true; - } + return true + } + return false } function isArticle(): boolean { - if ( - document.querySelectorAll(".article-wrapper").length === 1 && - document.querySelectorAll(".crayons-article__video").length === 0 - ) { - articleTitle = document.querySelector( - "#main-title > div.crayons-article__header__meta > h1" - ).textContent; - authorName = document.querySelector( - "#main-title > div.crayons-article__header__meta > div.crayons-article__subheader > a" - ).textContent; - authorUrl = document - .querySelector( - "#main-title > div.crayons-article__header__meta > div.crayons-article__subheader > a" - ) - .getAttribute("href"); + if ( + document.querySelectorAll('.article-wrapper').length === 1 + && document.querySelectorAll('.crayons-article__video').length === 0 + ) { + articleTitle = document.querySelector( + '#main-title > div.crayons-article__header__meta > h1', + )?.textContent ?? '' + authorName = document.querySelector( + '#main-title > div.crayons-article__header__meta > div.crayons-article__subheader > a', + )?.textContent ?? '' + authorUrl = document + .querySelector( + '#main-title > div.crayons-article__header__meta > div.crayons-article__subheader > a', + ) + ?.getAttribute('href') ?? '' - return true; - } + return true + } + return false } function isVideo(): boolean { - if ( - document.querySelectorAll(".article-wrapper").length === 1 && - document.querySelectorAll(".crayons-article__video").length === 1 - ) { - articleTitle = document.querySelector( - "#main-title > div.crayons-article__header__meta > h1" - ).textContent; - authorName = document.querySelector( - "#main-title > div.crayons-article__header__meta > div.crayons-article__subheader > a" - ).textContent; - authorUrl = document - .querySelector( - "#main-title > div.crayons-article__header__meta > div.crayons-article__subheader > a" - ) - .getAttribute("href"); + if ( + document.querySelectorAll('.article-wrapper').length === 1 + && document.querySelectorAll('.crayons-article__video').length === 1 + ) { + articleTitle = document.querySelector( + '#main-title > div.crayons-article__header__meta > h1', + )?.textContent ?? '' + authorName = document.querySelector( + '#main-title > div.crayons-article__header__meta > div.crayons-article__subheader > a', + )?.textContent ?? '' + authorUrl = document + .querySelector( + '#main-title > div.crayons-article__header__meta > div.crayons-article__subheader > a', + ) + ?.getAttribute('href') ?? '' - return true; - } + return true + } + return false } function isPodcast(): boolean { - if (document.querySelectorAll(".podcast-episode-container").length === 1) { - podcastTitle = document.querySelector("h1").textContent; - authorName = document.querySelector("div.title > h2 > a").textContent; - authorUrl = (( - document.querySelector("div.title > h2 > a") - )).href; - return true; - } + if (document.querySelectorAll('.podcast-episode-container').length === 1) { + podcastTitle = document.querySelector('h1')?.textContent ?? '' + authorName = document.querySelector('div.title > h2 > a')?.textContent ?? '' + authorUrl = (( + document.querySelector('div.title > h2 > a') + ) + )?.href ?? '' + return true + } + return false } const assets: Record = { - play: Assets.Play, - pause: Assets.Pause, -}; + play: Assets.Play, + pause: Assets.Pause, +} -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DEV%20Community/assets/logo.png", - startTimestamp: timestamp, - }, - buttons = await presence.getSetting("buttons"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DEV%20Community/assets/logo.png', + startTimestamp: timestamp, + } + const buttons = await presence.getSetting('buttons') - switch (true) { - case isShop(): - presenceData.details = "Browsing Shop"; - break; - case isProfile(): - presenceData.details = authorName; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/DEV%20Community/assets/0.png"; - presenceData.smallImageText = "Profile"; - if (buttons) { - presenceData.buttons = [ - { - label: "View Profile", - url: document.location.origin + authorUrl, - }, - ]; - } - break; - case isArticle(): - presenceData.details = articleTitle; - presenceData.state = authorName; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - if (buttons) { - presenceData.buttons = [ - { - label: "View Article", - url: document.location.href, - }, - { - label: "View Author", - url: document.location.origin + authorUrl, - }, - ]; - } - break; - case isVideo(): - presenceData.details = articleTitle; - presenceData.state = authorName; - if (buttons) { - presenceData.buttons = [ - { - label: "View Video", - url: document.location.href, - }, - { - label: "View Author", - url: document.location.origin + authorUrl, - }, - ]; - } - contentStateKey = (document.querySelector("video")) - ?.paused - ? "pause" - : "play"; - contentStateText = contentStateKey === "pause" ? "Paused" : "Playing"; + switch (true) { + case isShop(): + presenceData.details = 'Browsing Shop' + break + case isProfile(): + presenceData.details = authorName + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/DEV%20Community/assets/0.png' + presenceData.smallImageText = 'Profile' + if (buttons) { + presenceData.buttons = [ + { + label: 'View Profile', + url: document.location.origin + authorUrl, + }, + ] + } + break + case isArticle(): + presenceData.details = articleTitle + presenceData.state = authorName + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + if (buttons) { + presenceData.buttons = [ + { + label: 'View Article', + url: document.location.href, + }, + { + label: 'View Author', + url: document.location.origin + authorUrl, + }, + ] + } + break + case isVideo(): + presenceData.details = articleTitle + presenceData.state = authorName + if (buttons) { + presenceData.buttons = [ + { + label: 'View Video', + url: document.location.href, + }, + { + label: 'View Author', + url: document.location.origin + authorUrl, + }, + ] + } + contentStateKey = (document.querySelector('video')) + ?.paused + ? 'pause' + : 'play' + contentStateText = contentStateKey === 'pause' ? 'Paused' : 'Playing' - presenceData.smallImageKey = assets[contentStateKey]; - presenceData.smallImageText = contentStateText; + presenceData.smallImageKey = assets[contentStateKey] + presenceData.smallImageText = contentStateText - if (contentStateKey === "play") { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(document.querySelector("video")); - } else { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - break; - case isPodcast(): - presenceData.details = podcastTitle; - presenceData.state = authorName; + if (contentStateKey === 'play') { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(document.querySelector('video')!) + } + else { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + break + case isPodcast(): + presenceData.details = podcastTitle + presenceData.state = authorName - if (buttons) { - presenceData.buttons = [ - { - label: "View Podcast", - url: document.location.href, - }, - { - label: "View Author", - url: document.location.origin + authorUrl, - }, - ]; - } - contentStateKey = (document.querySelector("#audio")) - .paused - ? "pause" - : "play"; - contentStateText = contentStateKey === "pause" ? "Paused" : "Listening"; + if (buttons) { + presenceData.buttons = [ + { + label: 'View Podcast', + url: document.location.href, + }, + { + label: 'View Author', + url: document.location.origin + authorUrl, + }, + ] + } + contentStateKey = (document.querySelector('#audio')) + .paused + ? 'pause' + : 'play' + contentStateText = contentStateKey === 'pause' ? 'Paused' : 'Listening' - presenceData.smallImageKey = assets[contentStateKey]; - presenceData.smallImageText = contentStateText; + presenceData.smallImageKey = assets[contentStateKey] + presenceData.smallImageText = contentStateText - if (contentStateKey === "play") { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(document.querySelector("video")); - } else { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - break; - case pathIncludes("/top/"): - feedTop = document.querySelector( - "#main-content > header > nav > a.crayons-tabs__item.crayons-tabs__item--current" - ).textContent; - presenceData.details = `${feedTop} Feed`; - break; - case pathIncludes("/t/"): - feedTag = document.querySelector("h1").textContent; - presenceData.details = `${feedTag} Articles`; - break; - case pathIncludes("/tags"): - presenceData.details = "Tags"; - break; - case pathIncludes("/listings"): - feedListings = document.querySelector( - ".crayons-link--current" - ).textContent; - listingTitle = - document.querySelector( - ".crayons-modal__box__body > div > div >div > div > header > h2 > a" - )?.textContent ?? null; - presenceData.details = listingTitle ?? feedListings; - presenceData.state = listingTitle ? feedListings : null; - break; - case pathIncludes("/pod"): - presenceData.details = "Podcasts"; - break; - case pathIncludes("/videos"): - presenceData.details = "Videos"; - break; - case pathIncludes("/new"): - presenceData.details = "Writing a Post"; - presenceData.smallImageKey = Assets.Writing; - presenceData.smallImageText = "Writing"; - break; - case pathIncludes("/readinglist"): - presenceData.details = "Viewing Read List"; - break; - case pathIncludes("/series"): - authorName = document.querySelector("h1").textContent; - presenceData.details = authorName; - if (buttons) { - presenceData.buttons = [ - { - label: "View Series", - url: document.location.href, - }, - ]; - } - break; - case pathIncludes("/search"): - searchTerm = (( - document.querySelector(".crayons-textfield") - )).value; - searchLength = document.querySelector("#substories").children.length; - presenceData.details = `Search: ${searchTerm}`; - presenceData.state = `${searchLength} Results`; - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Searching..."; - break; - case pathIncludes("/settings"): - presenceData.details = "Updating settings"; - break; - case pathIncludes("/notifications"): - presenceData.details = "Notifications"; - break; - case pathIncludes("/connect"): - presenceData.details = "Messages"; - break; - case pathIncludes("/dashboard"): - presenceData.details = "Dashboard Analytics"; - break; - case pathIncludes("/code-of-conduct"): - presenceData.details = "Code of Conduct"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - break; - case pathIncludes("/faq"): - presenceData.details = "FAQ 🤔"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - break; - case pathIncludes("/sponsors"): - presenceData.details = "Sponsors"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - break; - case pathIncludes("/about"): - presenceData.details = "About"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - break; - case pathIncludes("/privacy"): - presenceData.details = "Privacy"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - break; - case pathIncludes("/terms"): - presenceData.details = "Terms and Conditions"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - break; - case pathIncludes("/contact"): - presenceData.details = "Contact"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - break; - case pathIncludes("/onboarding"): - presenceData.details = "Setting up Profile"; - break; - default: - presenceData.details = "General Feed"; - } - presence.setActivity(presenceData); -}); + if (contentStateKey === 'play') { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(document.querySelector('video')!) + } + else { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + break + case pathIncludes('/top/'): + feedTop = document.querySelector( + '#main-content > header > nav > a.crayons-tabs__item.crayons-tabs__item--current', + )?.textContent ?? '' + presenceData.details = `${feedTop} Feed` + break + case pathIncludes('/t/'): + feedTag = document.querySelector('h1')?.textContent ?? '' + presenceData.details = `${feedTag} Articles` + break + case pathIncludes('/tags'): + presenceData.details = 'Tags' + break + case pathIncludes('/listings'): + feedListings = document.querySelector( + '.crayons-link--current', + )?.textContent ?? '' + listingTitle = document.querySelector( + '.crayons-modal__box__body > div > div >div > div > header > h2 > a', + )?.textContent ?? '' + presenceData.details = listingTitle || feedListings + presenceData.state = listingTitle ? feedListings : null + break + case pathIncludes('/pod'): + presenceData.details = 'Podcasts' + break + case pathIncludes('/videos'): + presenceData.details = 'Videos' + break + case pathIncludes('/new'): + presenceData.details = 'Writing a Post' + presenceData.smallImageKey = Assets.Writing + presenceData.smallImageText = 'Writing' + break + case pathIncludes('/readinglist'): + presenceData.details = 'Viewing Read List' + break + case pathIncludes('/series'): + authorName = document.querySelector('h1')?.textContent ?? '' + presenceData.details = authorName + if (buttons) { + presenceData.buttons = [ + { + label: 'View Series', + url: document.location.href, + }, + ] + } + break + case pathIncludes('/search'): + searchTerm = document.querySelector('.crayons-textfield')?.value ?? '' + searchLength = document.querySelector('#substories')?.children.length ?? 0 + presenceData.details = `Search: ${searchTerm}` + presenceData.state = `${searchLength} Results` + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Searching...' + break + case pathIncludes('/settings'): + presenceData.details = 'Updating settings' + break + case pathIncludes('/notifications'): + presenceData.details = 'Notifications' + break + case pathIncludes('/connect'): + presenceData.details = 'Messages' + break + case pathIncludes('/dashboard'): + presenceData.details = 'Dashboard Analytics' + break + case pathIncludes('/code-of-conduct'): + presenceData.details = 'Code of Conduct' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + break + case pathIncludes('/faq'): + presenceData.details = 'FAQ 🤔' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + break + case pathIncludes('/sponsors'): + presenceData.details = 'Sponsors' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + break + case pathIncludes('/about'): + presenceData.details = 'About' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + break + case pathIncludes('/privacy'): + presenceData.details = 'Privacy' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + break + case pathIncludes('/terms'): + presenceData.details = 'Terms and Conditions' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + break + case pathIncludes('/contact'): + presenceData.details = 'Contact' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + break + case pathIncludes('/onboarding'): + presenceData.details = 'Setting up Profile' + break + default: + presenceData.details = 'General Feed' + } + presence.setActivity(presenceData) +}) diff --git a/websites/D/DEX Screener/metadata.json b/websites/D/DEX Screener/metadata.json index c0d313157c80..3cf24c7e4368 100644 --- a/websites/D/DEX Screener/metadata.json +++ b/websites/D/DEX Screener/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "695817459206324265", - "name": "parrizu" - }, - "service": "DEX Screener", - "description": { - "en": "Realtime price charts and trading history on DEXes across Ethereum, BSC, Polygon, Avalanche, Fantom, Harmony, Cronos, Arbitrum, Optimism and more." - }, - "url": "dexscreener.com", - "version": "1.0.1", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/logo.jpeg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/thumbnail.png", - "color": "#111111", - "category": "other", - "tags": [ - "markets", - "currency", - "crypto" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "695817459206324265", + "name": "parrizu" + }, + "service": "DEX Screener", + "description": { + "en": "Realtime price charts and trading history on DEXes across Ethereum, BSC, Polygon, Avalanche, Fantom, Harmony, Cronos, Arbitrum, Optimism and more." + }, + "url": "dexscreener.com", + "version": "1.0.1", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/logo.jpeg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/thumbnail.png", + "color": "#111111", + "category": "other", + "tags": [ + "markets", + "currency", + "crypto" + ] +} diff --git a/websites/D/DEX Screener/presence.ts b/websites/D/DEX Screener/presence.ts index 6e9b86244c7d..5e76e2f450b4 100644 --- a/websites/D/DEX Screener/presence.ts +++ b/websites/D/DEX Screener/presence.ts @@ -1,197 +1,200 @@ // functions interface DexTokenInfo { - name: string; - symbol: string; - price: number; - chainId: string; - thumbnail: string; - chainSymbol: string; + name: string + symbol: string + price: number + chainId: string + thumbnail: string + chainSymbol: string } -const tokenCache: Map = new Map(); +const tokenCache: Map = new Map() async function getTokenInfo( - tokenAddress: string, - chainId: string + tokenAddress: string, + chainId: string, ): Promise { - const cacheKey = `${chainId}-${tokenAddress}`; - if (tokenCache.has(cacheKey)) return tokenCache.get(cacheKey) || null; + const cacheKey = `${chainId}-${tokenAddress}` + if (tokenCache.has(cacheKey)) + return tokenCache.get(cacheKey) || null - const fetchTokenInfo = async () => { - let response = await fetch( - `https://api.dexscreener.com/latest/dex/pairs/${chainId}/${tokenAddress}` - ), - data = await response.json(); + const fetchTokenInfo = async () => { + let response = await fetch( + `https://api.dexscreener.com/latest/dex/pairs/${chainId}/${tokenAddress}`, + ) + let data = await response.json() - if (!data.pairs || data.pairs.length === 0) { - response = await fetch( - `https://api.dexscreener.com/latest/dex/tokens/${tokenAddress}` - ); - data = await response.json(); - } + if (!data.pairs || data.pairs.length === 0) { + response = await fetch( + `https://api.dexscreener.com/latest/dex/tokens/${tokenAddress}`, + ) + data = await response.json() + } - if (data && data.pairs && data.pairs.length > 0) { - const pair = data.pairs[0], - getTitlePrice = () => { - const priceMatch = document.title.match(/\$([0-9.]+)/); - return priceMatch ? parseFloat(priceMatch[1]) : 0; - }; - let price = getTitlePrice(); - // price get from title instead of API, for efficiency - const tokenInfo = { - name: pair.baseToken.name, - symbol: pair.baseToken.symbol, - price, - chainId: pair.chainId, - thumbnail: pair.info.imageUrl, - chainSymbol: pair.quoteToken.symbol, - }; - tokenCache.set(cacheKey, tokenInfo); + if (data && data.pairs && data.pairs.length > 0) { + const pair = data.pairs[0] + const getTitlePrice = () => { + const priceMatch = document.title.match(/\$([0-9.]+)/) + return priceMatch ? Number.parseFloat(priceMatch[1]) : 0 + } + let price = getTitlePrice() + // price get from title instead of API, for efficiency + const tokenInfo = { + name: pair.baseToken.name, + symbol: pair.baseToken.symbol, + price, + chainId: pair.chainId, + thumbnail: pair.info.imageUrl, + chainSymbol: pair.quoteToken.symbol, + } + tokenCache.set(cacheKey, tokenInfo) - // Update price periodically based on title changes - setInterval(() => { - const newPrice = getTitlePrice(); - if (newPrice !== price) { - tokenInfo.price = newPrice; - price = newPrice; - } - }, 10000); - return tokenInfo; - } - return null; - }; - return await fetchTokenInfo(); + // Update price periodically based on title changes + setInterval(() => { + const newPrice = getTitlePrice() + if (newPrice !== price) { + tokenInfo.price = newPrice + price = newPrice + } + }, 10000) + return tokenInfo + } + return null + } + return await fetchTokenInfo() } function capitalize(string: string): string { - return string.charAt(0).toUpperCase() + string.slice(1); + return string.charAt(0).toUpperCase() + string.slice(1) } const presence = new Presence({ - clientId: "1326168769403289683", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1326168769403289683', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/logo.jpeg", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/logo.jpeg', } const chainLogo = { - ethereum: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/0.png", - bsc: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/1.png", - solana: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/2.png", - base: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/3.png", - sui: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/4.png", - aptos: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/5.png", - arbitrum: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/6.png", - avalanche: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/7.png", - cronos: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/8.png", - fantom: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/9.png", - hyperliquid: - "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/10.png", - ink: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/11.png", - linea: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/12.png", - optimism: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/13.png", - osmosis: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/14.png", - polygon: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/15.png", - zksync: "https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/16.png", -}; + ethereum: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/0.png', + bsc: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/1.png', + solana: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/2.png', + base: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/3.png', + sui: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/4.png', + aptos: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/5.png', + arbitrum: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/6.png', + avalanche: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/7.png', + cronos: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/8.png', + fantom: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/9.png', + hyperliquid: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/10.png', + ink: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/11.png', + linea: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/12.png', + optimism: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/13.png', + osmosis: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/14.png', + polygon: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/15.png', + zksync: 'https://cdn.rcd.gg/PreMiD/websites/D/DEX%20Screener/assets/16.png', +} -presence.on("UpdateData", async () => { - let details: string | undefined, - state: string | undefined, - presenceData: PresenceData, - tokenInfo: DexTokenInfo | null = null, - urlToken: string | undefined, - query; - const path = document.location.pathname; - switch (true) { - case path === "/": - details = "Home Page"; - state = "Browsing"; - break; - case path.startsWith("/watchlist"): - details = "Watchlist"; - break; - case path.startsWith("/multicharts"): - details = "Looking at Multi Charts"; - break; - case path.startsWith("/new-pairs"): - details = "New Pairs"; - state = "Browsing"; - break; - case path.startsWith("/gainers"): - details = "Gainers and Losers"; - state = "Browsing"; - break; - case path.startsWith("/portfolio"): - details = "Looking at Portfolio"; - break; - case path.startsWith("/moonshot"): - details = "Moonshot"; - state = "Browsing"; - break; - case path.startsWith("/search"): - query = new URLSearchParams(document.location.search).get("q") || "-"; - if (query !== "-") { - details = "Searching for:"; - state = `${query}`; - } else details = "Searching tokens"; - break; - default: { - const pathParts = path.split("/"); - if (pathParts.length === 2) { - details = `Browsing ${capitalize(pathParts[1])} tokens`; - const smallImageKey = - new Map(Object.entries(chainLogo)).get(pathParts[1]) || - `https://dd.dexscreener.com/ds-data/chains/${pathParts[1]}.png`; - presenceData = { - details, - largeImageKey: Assets.Logo, - smallImageKey, - startTimestamp: browsingTimestamp, - }; - presence.setActivity(presenceData); - return; - } else if (pathParts.length >= 3) { - const chainId = pathParts[1], - tokenAddress = pathParts[2]; - tokenInfo = await getTokenInfo( - decodeURIComponent(tokenAddress), - chainId - ); +presence.on('UpdateData', async () => { + let details: string | undefined + let state: string | undefined + let presenceData: PresenceData + let tokenInfo: DexTokenInfo | null = null + let urlToken: string | undefined + let query + const path = document.location.pathname + switch (true) { + case path === '/': + details = 'Home Page' + state = 'Browsing' + break + case path.startsWith('/watchlist'): + details = 'Watchlist' + break + case path.startsWith('/multicharts'): + details = 'Looking at Multi Charts' + break + case path.startsWith('/new-pairs'): + details = 'New Pairs' + state = 'Browsing' + break + case path.startsWith('/gainers'): + details = 'Gainers and Losers' + state = 'Browsing' + break + case path.startsWith('/portfolio'): + details = 'Looking at Portfolio' + break + case path.startsWith('/moonshot'): + details = 'Moonshot' + state = 'Browsing' + break + case path.startsWith('/search'): + query = new URLSearchParams(document.location.search).get('q') || '-' + if (query !== '-') { + details = 'Searching for:' + state = `${query}` + } + else { + details = 'Searching tokens' + } + break + default: { + const pathParts = path.split('/') + if (pathParts.length === 2) { + details = `Browsing ${capitalize(pathParts[1])} tokens` + const smallImageKey = new Map(Object.entries(chainLogo)).get(pathParts[1]) + || `https://dd.dexscreener.com/ds-data/chains/${pathParts[1]}.png` + presenceData = { + details, + largeImageKey: Assets.Logo, + smallImageKey, + startTimestamp: browsingTimestamp, + } + presence.setActivity(presenceData) + return + } + else if (pathParts.length >= 3) { + const chainId = pathParts[1] + const tokenAddress = pathParts[2] + tokenInfo = await getTokenInfo( + decodeURIComponent(tokenAddress), + chainId, + ) - if (tokenInfo) { - urlToken = `https://dexscreener.com/${chainId}/${tokenAddress}`; - details = `(${tokenInfo.symbol}/${tokenInfo.chainSymbol}) ${tokenInfo.name}`; - state = `$${tokenInfo.price}`; - presenceData = { - details, - state, - largeImageKey: tokenInfo.thumbnail, - smallImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - buttons: [ - { - label: "View Token", - url: urlToken, - }, - ], - }; - presence.setActivity(presenceData); - return; - } - } - } - } + if (tokenInfo) { + urlToken = `https://dexscreener.com/${chainId}/${tokenAddress}` + details = `(${tokenInfo.symbol}/${tokenInfo.chainSymbol}) ${tokenInfo.name}` + state = `$${tokenInfo.price}` + presenceData = { + details, + state, + largeImageKey: tokenInfo.thumbnail, + smallImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + buttons: [ + { + label: 'View Token', + url: urlToken, + }, + ], + } + presence.setActivity(presenceData) + return + } + } + } + } - if (details) { - presenceData = { - details, - state, - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }; - presence.setActivity(presenceData); - } -}); + if (details) { + presenceData = { + details, + state, + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + presence.setActivity(presenceData) + } +}) diff --git a/websites/D/DMOJ/metadata.json b/websites/D/DMOJ/metadata.json index 4eb86d33aa87..e00a87cb97b3 100644 --- a/websites/D/DMOJ/metadata.json +++ b/websites/D/DMOJ/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "vidhan", - "id": "1063329635569512520" - }, - "service": "DMOJ", - "description": { - "en": "The DMOJ is a modern contest platform and archive of programming problems.", - "nl": "De DMOJ is een modern wedstrijdplatform en een archief van programmeringsproblemen." - }, - "url": "dmoj.ca", - "version": "2.0.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/thumbnail.png", - "color": "#fcdb05", - "category": "other", - "tags": [ - "coding", - "programming", - "code" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "vidhan", + "id": "1063329635569512520" + }, + "service": "DMOJ", + "description": { + "en": "The DMOJ is a modern contest platform and archive of programming problems.", + "nl": "De DMOJ is een modern wedstrijdplatform en een archief van programmeringsproblemen." + }, + "url": "dmoj.ca", + "version": "2.0.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/thumbnail.png", + "color": "#fcdb05", + "category": "other", + "tags": [ + "coding", + "programming", + "code" + ] +} diff --git a/websites/D/DMOJ/presence.ts b/websites/D/DMOJ/presence.ts index d59287b0b963..3871f1058f86 100644 --- a/websites/D/DMOJ/presence.ts +++ b/websites/D/DMOJ/presence.ts @@ -1,324 +1,376 @@ const presence = new Presence({ - clientId: "754070047193956492", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '754070047193956492', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Editorial = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/0.png", - Post = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/1.png", - EditProfile = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/2.png", - Organization = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/3.png", - Problem = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/4.png", - About = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/5.png", - Home = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/6.png", - Contest = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/7.png", - Leaderboard = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/8.png", - Status = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/9.png", - SubmissionList = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/10.png", - Ticket = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/11.png", - ProblemList = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/12.png", - Submit = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/13.png", - Statistics = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/14.png", - Submission = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/15.png", - Source = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/16.png", - User = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/17.png", - Users = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/18.png", - Icon = "https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/19.png", + Editorial = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/0.png', + Post = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/1.png', + EditProfile = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/2.png', + Organization = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/3.png', + Problem = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/4.png', + About = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/5.png', + Home = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/6.png', + Contest = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/7.png', + Leaderboard = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/8.png', + Status = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/9.png', + SubmissionList = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/10.png', + Ticket = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/11.png', + ProblemList = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/12.png', + Submit = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/13.png', + Statistics = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/14.png', + Submission = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/15.png', + Source = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/16.png', + User = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/17.png', + Users = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/18.png', + Icon = 'https://cdn.rcd.gg/PreMiD/websites/D/DMOJ/assets/19.png', } -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - smallImageKey: Assets.Icon, - smallImageText: "DMOJ: Modern Online Judge", - startTimestamp: browsingTimestamp, - }, - url = document.location.pathname.split("/"); - if (url.includes("post")) { - presenceData.details = "Viewing post:"; - presenceData.state = document - .querySelector("#content > h2") - .textContent.trim(); - presenceData.largeImageKey = Assets.Post; - presenceData.buttons = [ - { label: "View Post", url: `https://dmoj.ca/post/${url[2][2]}` }, - ]; - } else if (url.includes("problems")) { - presenceData.details = "Browsing problems"; - presenceData.largeImageKey = Assets.ProblemList; - } else if (url.includes("problem")) { - const problemURL = `https://dmoj.ca/problem/${url[2]}`; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + smallImageKey: Assets.Icon, + smallImageText: 'DMOJ: Modern Online Judge', + startTimestamp: browsingTimestamp, + } + const url = document.location.pathname.split('/') + if (url.includes('post')) { + presenceData.details = 'Viewing post:' + presenceData.state = document + .querySelector('#content > h2') + ?.textContent + ?.trim() + presenceData.largeImageKey = Assets.Post + presenceData.buttons = [ + { label: 'View Post', url: `https://dmoj.ca/post/${url[2][2]}` }, + ] + } + else if (url.includes('problems')) { + presenceData.details = 'Browsing problems' + presenceData.largeImageKey = Assets.ProblemList + } + else if (url.includes('problem')) { + const problemURL = `https://dmoj.ca/problem/${url[2]}` - presenceData.buttons = [{ label: "View Problem", url: problemURL }]; + presenceData.buttons = [{ label: 'View Problem', url: problemURL }] - if (url.includes("submit")) { - presenceData.details = "Submitting to problem:"; - presenceData.state = document - .querySelector("#content > h2 > a") - .textContent.trim(); - presenceData.largeImageKey = Assets.Submit; - } else if (url.includes("submissions")) { - presenceData.details = "Viewing submissions to problem:"; - presenceData.state = document.querySelectorAll(".tabs > h2 > a")[ - // eslint messed up the next line - document.querySelectorAll(".tabs > h2 > a").length - 1 - ].textContent.trim(); - presenceData.largeImageKey = Assets.SubmissionList; - presenceData.buttons.push({ - label: "View Submissions", - url: `${problemURL}/submissions/`, - }); - } else if (url.includes("rank")) { - presenceData.details = "Viewing best submissions to problem:"; - presenceData.state = document - .querySelector(".tabs > h2 > a") - .textContent.trim(); - presenceData.largeImageKey = Assets.SubmissionList; - presenceData.buttons.push({ - label: "View Best Submissions", - url: `${problemURL}/rank/`, - }); - } else if (url.includes("editorial")) { - presenceData.details = "Viewing editorial for problem:"; - presenceData.state = document - .querySelector("#content > h2 > a") - .textContent.trim(); - presenceData.largeImageKey = Assets.Editorial; - presenceData.buttons.push({ - label: "View Editorial", - url: `${problemURL}/editorial/`, - }); - } else if (url.includes("tickets") && url.includes("new")) { - presenceData.details = "Creating a ticket for problem:"; - presenceData.state = document - .querySelector("#content > h2 > a") - .textContent.trim(); - presenceData.largeImageKey = Assets.Ticket; - } else { - const problemName = document - .querySelector(".problem-title > h2") - .textContent.trim(), - problemPoints = document.querySelector(".pi-value").textContent.trim(); + if (url.includes('submit')) { + presenceData.details = 'Submitting to problem:' + presenceData.state = document + .querySelector('#content > h2 > a') + ?.textContent + ?.trim() + presenceData.largeImageKey = Assets.Submit + } + else if (url.includes('submissions')) { + presenceData.details = 'Viewing submissions to problem:' + presenceData.state = document.querySelectorAll('.tabs > h2 > a')[ + // eslint messed up the next line + document.querySelectorAll('.tabs > h2 > a').length - 1 + ].textContent?.trim() + presenceData.largeImageKey = Assets.SubmissionList + presenceData.buttons.push({ + label: 'View Submissions', + url: `${problemURL}/submissions/`, + }) + } + else if (url.includes('rank')) { + presenceData.details = 'Viewing best submissions to problem:' + presenceData.state = document + .querySelector('.tabs > h2 > a') + ?.textContent + ?.trim() + presenceData.largeImageKey = Assets.SubmissionList + presenceData.buttons.push({ + label: 'View Best Submissions', + url: `${problemURL}/rank/`, + }) + } + else if (url.includes('editorial')) { + presenceData.details = 'Viewing editorial for problem:' + presenceData.state = document + .querySelector('#content > h2 > a') + ?.textContent + ?.trim() + presenceData.largeImageKey = Assets.Editorial + presenceData.buttons.push({ + label: 'View Editorial', + url: `${problemURL}/editorial/`, + }) + } + else if (url.includes('tickets') && url.includes('new')) { + presenceData.details = 'Creating a ticket for problem:' + presenceData.state = document + .querySelector('#content > h2 > a') + ?.textContent + ?.trim() + presenceData.largeImageKey = Assets.Ticket + } + else { + const problemName = document + .querySelector('.problem-title > h2') + ?.textContent + ?.trim() + const problemPoints = document.querySelector('.pi-value')?.textContent?.trim() - presenceData.details = "Viewing problem:"; - presenceData.largeImageKey = Assets.Problem; + presenceData.details = 'Viewing problem:' + presenceData.largeImageKey = Assets.Problem - if (problemPoints === "1") - presenceData.state = `${problemName} (${problemPoints} point)`; - else presenceData.state = `${problemName} (${problemPoints} points)`; - } - } else if (url.includes("submissions")) { - if (url.includes("user")) { - presenceData.details = "Viewing submissions by user:"; + if (problemPoints === '1') + presenceData.state = `${problemName} (${problemPoints} point)` + else presenceData.state = `${problemName} (${problemPoints} points)` + } + } + else if (url.includes('submissions')) { + if (url.includes('user')) { + presenceData.details = 'Viewing submissions by user:' - if ( - document.querySelector(".tabs > h2").textContent.trim() === - "All my submissions" - ) { - const user = document - .querySelector("#user-links > ul > li > a > span > span > b") - .textContent.trim(); - presenceData.state = user; - presenceData.largeImageKey = Assets.SubmissionList; - presenceData.buttons = [ - { - label: "View Submissions", - url: `https://dmoj.ca/submissions/user/${user}`, - }, - { label: "View User", url: `https://dmoj.ca/user/${user}` }, - ]; - } else { - const user = document - .querySelector(".tabs > h2 > a") - .textContent.trim(); - presenceData.state = user; - presenceData.largeImageKey = Assets.SubmissionList; - presenceData.buttons = [ - { - label: "View Submissions", - url: `https://dmoj.ca/submissions/user/${user}`, - }, - { label: "View User", url: `https://dmoj.ca/user/${user}` }, - ]; - } - } else { - presenceData.details = "Browsing submissions"; - presenceData.largeImageKey = Assets.SubmissionList; - } - } else if (url.includes("submission")) { - presenceData.details = "Viewing submission to problem:"; - presenceData.state = document - .querySelector("#content > h2 > a") - .textContent.trim(); - presenceData.largeImageKey = Assets.Submission; - presenceData.buttons = [ - { - label: "View Submission", - url: `https://dmoj.ca/submission/${url[2]}`, - }, - ]; - } else if (url.includes("src")) { - presenceData.details = "Viewing submission source to problem:"; - presenceData.state = document - .querySelector("#content > h2 > a") - .textContent.trim(); - presenceData.largeImageKey = Assets.Source; - } else if (url.includes("organizations")) { - presenceData.details = "Browsing organizations"; - presenceData.largeImageKey = Assets.Organization; - } else if (url.includes("organization")) { - const organizationURL = `https://dmoj.ca/organization/${url[2]}`; - presenceData.state = document - .querySelector("#content > h2") - .textContent.trim() - .replace(" Members", ""); - presenceData.buttons = [ - { label: "View Organization", url: organizationURL }, - { label: "View Members", url: `${organizationURL}/users` }, - ]; + if ( + document.querySelector('.tabs > h2')?.textContent?.trim() + === 'All my submissions' + ) { + const user = document + .querySelector('#user-links > ul > li > a > span > span > b') + ?.textContent + ?.trim() + presenceData.state = user + presenceData.largeImageKey = Assets.SubmissionList + presenceData.buttons = [ + { + label: 'View Submissions', + url: `https://dmoj.ca/submissions/user/${user}`, + }, + { label: 'View User', url: `https://dmoj.ca/user/${user}` }, + ] + } + else { + const user = document + .querySelector('.tabs > h2 > a') + ?.textContent + ?.trim() + presenceData.state = user + presenceData.largeImageKey = Assets.SubmissionList + presenceData.buttons = [ + { + label: 'View Submissions', + url: `https://dmoj.ca/submissions/user/${user}`, + }, + { label: 'View User', url: `https://dmoj.ca/user/${user}` }, + ] + } + } + else { + presenceData.details = 'Browsing submissions' + presenceData.largeImageKey = Assets.SubmissionList + } + } + else if (url.includes('submission')) { + presenceData.details = 'Viewing submission to problem:' + presenceData.state = document + .querySelector('#content > h2 > a') + ?.textContent + ?.trim() + presenceData.largeImageKey = Assets.Submission + presenceData.buttons = [ + { + label: 'View Submission', + url: `https://dmoj.ca/submission/${url[2]}`, + }, + ] + } + else if (url.includes('src')) { + presenceData.details = 'Viewing submission source to problem:' + presenceData.state = document + .querySelector('#content > h2 > a') + ?.textContent + ?.trim() + presenceData.largeImageKey = Assets.Source + } + else if (url.includes('organizations')) { + presenceData.details = 'Browsing organizations' + presenceData.largeImageKey = Assets.Organization + } + else if (url.includes('organization')) { + const organizationURL = `https://dmoj.ca/organization/${url[2]}` + presenceData.state = document + .querySelector('#content > h2') + ?.textContent + ?.trim() + .replace(' Members', '') + presenceData.buttons = [ + { label: 'View Organization', url: organizationURL }, + { label: 'View Members', url: `${organizationURL}/users` }, + ] - if (url.includes("users")) { - presenceData.details = "Viewing members of organization:"; - presenceData.largeImageKey = Assets.Users; - } else { - presenceData.details = "Viewing organization:"; - presenceData.largeImageKey = Assets.Organization; - } - } else if (url.includes("users")) { - presenceData.details = "Viewing leaderboard"; - presenceData.largeImageKey = Assets.Leaderboard; - } else if (url.includes("user")) { - const userHeader = document.querySelector(".tabs > h2").textContent.trim(); + if (url.includes('users')) { + presenceData.details = 'Viewing members of organization:' + presenceData.largeImageKey = Assets.Users + } + else { + presenceData.details = 'Viewing organization:' + presenceData.largeImageKey = Assets.Organization + } + } + else if (url.includes('users')) { + presenceData.details = 'Viewing leaderboard' + presenceData.largeImageKey = Assets.Leaderboard + } + else if (url.includes('user')) { + const userHeader = document.querySelector('.tabs > h2')?.textContent?.trim() - if (url.includes("solved")) { - const [, userRank] = document - .querySelectorAll(".user-sidebar > div")[2] - .textContent.trim() - .split("#"); + if (url.includes('solved')) { + const [, userRank] = document + .querySelectorAll('.user-sidebar > div')[2] + ?.textContent + ?.trim() + ?.split('#') ?? [] - presenceData.details = "Viewing problems solved by:"; + presenceData.details = 'Viewing problems solved by:' - if (userHeader === "My account") { - const user = document - .querySelector("#user-links > ul > li > a > span > span > b") - .textContent.trim(), - userURL = `https://dmoj.ca/user/${user}`; + if (userHeader === 'My account') { + const user = document + .querySelector('#user-links > ul > li > a > span > span > b') + ?.textContent + ?.trim() + const userURL = `https://dmoj.ca/user/${user}` - presenceData.state = `${user} (Rank: #${userRank})`; - presenceData.largeImageKey = Assets.SubmissionList; - presenceData.buttons = [ - { label: "View User", url: userURL }, - { label: "View Solved Problems", url: `${userURL}/solved` }, - ]; - } else { - const [, user] = document - .querySelector(".tabs > h2") - .textContent.trim() - .split(" "), - userURL = `https://dmoj.ca/user/${user}`; + presenceData.state = `${user} (Rank: #${userRank})` + presenceData.largeImageKey = Assets.SubmissionList + presenceData.buttons = [ + { label: 'View User', url: userURL }, + { label: 'View Solved Problems', url: `${userURL}/solved` }, + ] + } + else { + const [, user] = document + .querySelector('.tabs > h2') + ?.textContent + ?.trim() + ?.split(' ') ?? [] + const userURL = `https://dmoj.ca/user/${user}` - presenceData.state = `${user} (Rank: #${userRank})`; - presenceData.largeImageKey = Assets.SubmissionList; - presenceData.buttons = [ - { label: "View User", url: userURL }, - { label: "View Solved Problems", url: `${userURL}/solved` }, - ]; - } - } else { - const [, userRank] = document - .querySelectorAll(".user-sidebar > div")[2] - .textContent.trim() - .split("#"); + presenceData.state = `${user} (Rank: #${userRank})` + presenceData.largeImageKey = Assets.SubmissionList + presenceData.buttons = [ + { label: 'View User', url: userURL }, + { label: 'View Solved Problems', url: `${userURL}/solved` }, + ] + } + } + else { + const [, userRank] = document + .querySelectorAll('.user-sidebar > div')[2] + ?.textContent + ?.trim() + ?.split('#') ?? [] - presenceData.details = "Viewing user:"; + presenceData.details = 'Viewing user:' - if (userHeader === "My account") { - const user = document - .querySelector("#user-links > ul > li > a > span > span > b") - .textContent.trim(); - presenceData.state = `${user} (Rank: #${userRank})`; - presenceData.largeImageKey = Assets.User; - presenceData.buttons = [ - { label: "View User", url: `https://dmoj.ca/user/${user}` }, - ]; - } else { - const [, user] = document - .querySelector(".tabs > h2") - .textContent.trim() - .split(" "); + if (userHeader === 'My account') { + const user = document + .querySelector('#user-links > ul > li > a > span > span > b') + ?.textContent + ?.trim() + presenceData.state = `${user} (Rank: #${userRank})` + presenceData.largeImageKey = Assets.User + presenceData.buttons = [ + { label: 'View User', url: `https://dmoj.ca/user/${user}` }, + ] + } + else { + const [, user] = document + .querySelector('.tabs > h2') + ?.textContent + ?.trim() + ?.split(' ') ?? [] - presenceData.state = `${user} (Rank: #${userRank})`; - presenceData.largeImageKey = Assets.User; - presenceData.buttons = [ - { label: "View User", url: `https://dmoj.ca/user/${user}` }, - ]; - } - } - } else if (url.includes("edit") && url.includes("profile")) { - presenceData.details = "Editing profile:"; - presenceData.state = document - .querySelector("#user-links > ul > li > a > span > span > b") - .textContent.trim(); - presenceData.largeImageKey = Assets.EditProfile; - } else if (url.includes("contests")) { - presenceData.details = "Browsing contests"; - presenceData.largeImageKey = Assets.Contest; - } else if (url.includes("contest")) { - const contestURL = `https://dmoj.ca/contests/${url[2]}`; + presenceData.state = `${user} (Rank: #${userRank})` + presenceData.largeImageKey = Assets.User + presenceData.buttons = [ + { label: 'View User', url: `https://dmoj.ca/user/${user}` }, + ] + } + } + } + else if (url.includes('edit') && url.includes('profile')) { + presenceData.details = 'Editing profile:' + presenceData.state = document + .querySelector('#user-links > ul > li > a > span > span > b') + ?.textContent + ?.trim() + presenceData.largeImageKey = Assets.EditProfile + } + else if (url.includes('contests')) { + presenceData.details = 'Browsing contests' + presenceData.largeImageKey = Assets.Contest + } + else if (url.includes('contest')) { + const contestURL = `https://dmoj.ca/contests/${url[2]}` - presenceData.state = document - .querySelector(".tabs > h2") - .textContent.trim(); - presenceData.buttons = [{ label: "View Contest", url: contestURL }]; + presenceData.state = document + .querySelector('.tabs > h2') + ?.textContent + ?.trim() + presenceData.buttons = [{ label: 'View Contest', url: contestURL }] - if (url.includes("stats")) { - presenceData.details = "Viewing statistics of contest:"; - presenceData.largeImageKey = Assets.Statistics; - presenceData.buttons.push({ - label: "View Statistics", - url: `${contestURL}/stats`, - }); - } else if (url.includes("ranking")) { - presenceData.details = "Viewing rankings of contest:"; - presenceData.largeImageKey = Assets.Leaderboard; - presenceData.buttons.push({ - label: "View Rankings", - url: `${contestURL}/ranking`, - }); - } else if (url.includes("participations")) { - presenceData.details = "Viewing participation of contest:"; - presenceData.largeImageKey = Assets.Users; - presenceData.buttons.push({ - label: "View Participation", - url: `${contestURL}/participations`, - }); - } else { - presenceData.details = "Viewing contest:"; - presenceData.largeImageKey = Assets.Contest; - } - } else if (url.includes("about")) { - presenceData.details = "Viewing about page"; - presenceData.largeImageKey = Assets.About; - } else if (url.includes("status")) { - presenceData.details = "Viewing status"; - presenceData.largeImageKey = Assets.Status; - } else if (url.includes("runtimes")) { - if (url.includes("matrix")) { - presenceData.details = "Viewing version matrix"; - presenceData.largeImageKey = Assets.Source; - } else { - presenceData.details = "Viewing runtimes"; - presenceData.largeImageKey = Assets.Source; - } - } else if (url.includes("tips")) { - presenceData.details = "Viewing tips"; - presenceData.largeImageKey = Assets.About; - } else if (url.includes("api")) { - presenceData.details = "Viewing API"; - presenceData.largeImageKey = Assets.Source; - } else { - presenceData.details = "Viewing home page"; - presenceData.largeImageKey = Assets.Home; - } + if (url.includes('stats')) { + presenceData.details = 'Viewing statistics of contest:' + presenceData.largeImageKey = Assets.Statistics + presenceData.buttons.push({ + label: 'View Statistics', + url: `${contestURL}/stats`, + }) + } + else if (url.includes('ranking')) { + presenceData.details = 'Viewing rankings of contest:' + presenceData.largeImageKey = Assets.Leaderboard + presenceData.buttons.push({ + label: 'View Rankings', + url: `${contestURL}/ranking`, + }) + } + else if (url.includes('participations')) { + presenceData.details = 'Viewing participation of contest:' + presenceData.largeImageKey = Assets.Users + presenceData.buttons.push({ + label: 'View Participation', + url: `${contestURL}/participations`, + }) + } + else { + presenceData.details = 'Viewing contest:' + presenceData.largeImageKey = Assets.Contest + } + } + else if (url.includes('about')) { + presenceData.details = 'Viewing about page' + presenceData.largeImageKey = Assets.About + } + else if (url.includes('status')) { + presenceData.details = 'Viewing status' + presenceData.largeImageKey = Assets.Status + } + else if (url.includes('runtimes')) { + if (url.includes('matrix')) { + presenceData.details = 'Viewing version matrix' + presenceData.largeImageKey = Assets.Source + } + else { + presenceData.details = 'Viewing runtimes' + presenceData.largeImageKey = Assets.Source + } + } + else if (url.includes('tips')) { + presenceData.details = 'Viewing tips' + presenceData.largeImageKey = Assets.About + } + else if (url.includes('api')) { + presenceData.details = 'Viewing API' + presenceData.largeImageKey = Assets.Source + } + else { + presenceData.details = 'Viewing home page' + presenceData.largeImageKey = Assets.Home + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/D/DaFont/metadata.json b/websites/D/DaFont/metadata.json index b63cbd38961f..200c4d7d6cd7 100644 --- a/websites/D/DaFont/metadata.json +++ b/websites/D/DaFont/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Jake.", - "id": "480407581085532180" - }, - "service": "DaFont", - "description": { - "en": "Archive of freely downloadable fonts. Browse by alphabetical listing, by style, by author or by popularity.", - "nl": "Archief van gratis downloadbare lettertypen. Blader door alfabetische lijst, stijl, auteur of populariteit." - }, - "url": "www.dafont.com", - "version": "1.3.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DaFont/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DaFont/assets/thumbnail.jpg", - "color": "#eb4034", - "category": "other", - "tags": [ - "fonts", - "design", - "text" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Jake.", + "id": "480407581085532180" + }, + "service": "DaFont", + "description": { + "en": "Archive of freely downloadable fonts. Browse by alphabetical listing, by style, by author or by popularity.", + "nl": "Archief van gratis downloadbare lettertypen. Blader door alfabetische lijst, stijl, auteur of populariteit." + }, + "url": "www.dafont.com", + "version": "1.3.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DaFont/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DaFont/assets/thumbnail.jpg", + "color": "#eb4034", + "category": "other", + "tags": [ + "fonts", + "design", + "text" + ] +} diff --git a/websites/D/DaFont/presence.ts b/websites/D/DaFont/presence.ts index baa75a534892..46dd85bacfdc 100644 --- a/websites/D/DaFont/presence.ts +++ b/websites/D/DaFont/presence.ts @@ -1,86 +1,105 @@ const presence = new Presence({ - clientId: "685827254256795677", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '685827254256795677', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DaFont/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - path = document.location.pathname; - let details; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DaFont/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const path = document.location.pathname + let details - if (path === "/") { - details = document.querySelector( - "#width > div.minwidth > div > div > div:nth-child(9) > div:nth-child(3) > div.dfsmall > strong" - ).textContent; - presenceData.details = "Browsing the main page :"; - presenceData.state = `${details}`; - } else if (path.startsWith("/themes.php")) { - details = document.querySelector("#menuthemespp > table > tbody > tr") - .children.length; - presenceData.details = "Browsing the theme's page :"; - presenceData.state = `${details} total themes`; - } else if (path.startsWith("/theme.php")) { - details = document - .querySelector( - "#width > div > div > div > div:nth-child(9) > div:nth-child(3) > div.dffont2" - ) - .textContent.replace(">", ">"); - presenceData.details = "Browsing a sub-theme's page :"; - presenceData.state = `${details}`; - } else if (path.startsWith("/mtheme.php")) { - details = document.querySelector( - "#width > div > div > div > div:nth-child(9) > div:nth-child(5) > div.dffont2" - ).textContent; - presenceData.details = "Browsing a main-theme's page :"; - presenceData.state = `${details}`; - } else if (path.startsWith("/new.php")) { - details = document.querySelector( - "#width > div > div > div > div:nth-child(9) > div:nth-child(5) > span > span" - ).textContent; - presenceData.details = "Browsing the new fonts :"; - presenceData.state = `${details}`; - } else if (path.startsWith("/top.php")) { - details = document.location.search.length > 1 ? "All Time" : "Yesterday"; - presenceData.details = "Browsing the top fonts :"; - presenceData.state = `${details}`; - } else if (path.startsWith("/authors.php")) { - presenceData.details = "Browsing the authors :"; - if (document.location.search.startsWith("?letter")) { - presenceData.state = `Sorted by letter : ${document.location.search - .replace("?letter=", "") - .toUpperCase()}`; - } else if (document.location.search.startsWith("?cc")) { - presenceData.state = `Sorted by country : ${ - document.querySelector( - "#width > div > div.layout > div > div:nth-child(9) > div > div:nth-child(2) > div:nth-child(11) > div:nth-child(1)" - ).textContent - }`; - } else presenceData.state = "All authors"; - } else if (path.startsWith("/forum")) presenceData.details = "On the forum"; - else if (path.startsWith("/faq.php")) - presenceData.details = "Reading the FAQ "; - else if (path.startsWith("/soft.php")) - presenceData.details = "Viewing the tools "; - else if (path.startsWith("/login.php")) - presenceData.details = "Logging into their account "; - else if (path.startsWith("/register.php")) - presenceData.details = "Registering a new account "; - else if (path.endsWith(".font")) { - presenceData.details = "Viewing a font's page :"; - presenceData.state = `${ - document.querySelector("#width > div > div > div > div:nth-child(9) > h1") - .textContent - } ( ${ - document.querySelector( - "#width > div > div > div > div:nth-child(9) > div.lv2right > span" - ).textContent - } )`; - } + if (path === '/') { + details = document.querySelector( + '#width > div.minwidth > div > div > div:nth-child(9) > div:nth-child(3) > div.dfsmall > strong', + )?.textContent + presenceData.details = 'Browsing the main page :' + presenceData.state = `${details}` + } + else if (path.startsWith('/themes.php')) { + details = document.querySelector('#menuthemespp > table > tbody > tr') + ?.children + .length + presenceData.details = 'Browsing the theme\'s page :' + presenceData.state = `${details} total themes` + } + else if (path.startsWith('/theme.php')) { + details = document + .querySelector( + '#width > div > div > div > div:nth-child(9) > div:nth-child(3) > div.dffont2', + ) + ?.textContent + ?.replace('>', '>') + presenceData.details = 'Browsing a sub-theme\'s page :' + presenceData.state = `${details}` + } + else if (path.startsWith('/mtheme.php')) { + details = document.querySelector( + '#width > div > div > div > div:nth-child(9) > div:nth-child(5) > div.dffont2', + )?.textContent + presenceData.details = 'Browsing a main-theme\'s page :' + presenceData.state = `${details}` + } + else if (path.startsWith('/new.php')) { + details = document.querySelector( + '#width > div > div > div > div:nth-child(9) > div:nth-child(5) > span > span', + )?.textContent + presenceData.details = 'Browsing the new fonts :' + presenceData.state = `${details}` + } + else if (path.startsWith('/top.php')) { + details = document.location.search.length > 1 ? 'All Time' : 'Yesterday' + presenceData.details = 'Browsing the top fonts :' + presenceData.state = `${details}` + } + else if (path.startsWith('/authors.php')) { + presenceData.details = 'Browsing the authors :' + if (document.location.search.startsWith('?letter')) { + presenceData.state = `Sorted by letter : ${document.location.search + .replace('?letter=', '') + .toUpperCase()}` + } + else if (document.location.search.startsWith('?cc')) { + presenceData.state = `Sorted by country : ${ + document.querySelector( + '#width > div > div.layout > div > div:nth-child(9) > div > div:nth-child(2) > div:nth-child(11) > div:nth-child(1)', + )?.textContent + }` + } + else { + presenceData.state = 'All authors' + } + } + else if (path.startsWith('/forum')) { + presenceData.details = 'On the forum' + } + else if (path.startsWith('/faq.php')) { + presenceData.details = 'Reading the FAQ ' + } + else if (path.startsWith('/soft.php')) { + presenceData.details = 'Viewing the tools ' + } + else if (path.startsWith('/login.php')) { + presenceData.details = 'Logging into their account ' + } + else if (path.startsWith('/register.php')) { + presenceData.details = 'Registering a new account ' + } + else if (path.endsWith('.font')) { + presenceData.details = 'Viewing a font\'s page :' + presenceData.state = `${ + document.querySelector('#width > div > div > div > div:nth-child(9) > h1') + ?.textContent + } ( ${ + document.querySelector( + '#width > div > div > div > div:nth-child(9) > div.lv2right > span', + )?.textContent + } )` + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Daily Mail/data.ts b/websites/D/Daily Mail/data.ts index 983941286cc2..e75983894fd3 100644 --- a/websites/D/Daily Mail/data.ts +++ b/websites/D/Daily Mail/data.ts @@ -1,332 +1,332 @@ interface SubsectionInfo { - subsectionTitle: string; - template?: string; - format?: string; - customMsg?: string; - subsections?: [ - { - template: string; - format: string; - pages: { subsectionTitle: string; href: string }[]; - } - ]; + subsectionTitle: string + template?: string + format?: string + customMsg?: string + subsections?: [ + { + template: string + format: string + pages: { subsectionTitle: string, href: string }[] + }, + ] } // Define the type for the object containing the mappings -type ByHrefMap = { - [url: string]: SubsectionInfo; -}; +interface ByHrefMap { + [url: string]: SubsectionInfo +} export const byHref: ByHrefMap = { - "auhome/index.html": { - subsectionTitle: "Australia", - }, - "games/daily-crossword": { - subsectionTitle: "Games", - customMsg: "Playing games!", - }, - "for-you/index.html": { - subsectionTitle: "For You", - customMsg: "Browsing personalized feed", - }, - "femail/fashionfinder/index.html": { - subsectionTitle: "Fashion Finder", - customMsg: "Browsing fashion", - }, - "news/mostread/index.html": { - subsectionTitle: "Most read", - }, - "home/latest/index.html#{any(SECTS)}": { - subsectionTitle: "{any(SECTS)}", - }, - "news/royals/index.html": { - subsectionTitle: "Royals", - customMsg: "Browsing Royal News", - }, - "video/index.html": { - template: ".vjs-title-text", - subsectionTitle: "Video", - }, - "news/joe-biden/index.html": { - subsectionTitle: "Joe Biden", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "news/donald_trump/index.html": { - subsectionTitle: "Donald Trump", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "news/us-economy/index.html": { - subsectionTitle: "Economy", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "news/king-charles-iii/index.html": { - subsectionTitle: "King Charles III", - template: ".topicHeaderTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "news/prince_harry/index.html": { - subsectionTitle: "Prince Harry", - template: ".topicHeaderTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "tvshowbiz/taylor_swift/index.html": { - subsectionTitle: "Taylor Swift", - template: ".tvshowbiz > .topicHeaderTitle", - format: "{NAME[]}", - }, - "tvshowbiz/kim_kardashian/index.html": { - subsectionTitle: "Kim Kardashian", - template: ".tvshowbiz > .topicHeaderTitle", - format: "{NAME[]}", - }, - "news/prince-andrew/index.html": { - subsectionTitle: "Prince Andrew", - template: ".tvshowbiz > .topicHeaderTitle", - format: "{NAME[]}", - }, - "tvshowbiz/jeremy-renner/index.html": { - subsectionTitle: "Jeremy Renner", - template: ".tvshowbiz > .topicHeaderTitle", - format: "Trending {NAME[]} News", - }, - "tvshowbiz/tiktok/index.html": { - subsectionTitle: "TikTok", - template: ".tvshowbiz > .topicHeaderTitle", - format: "Trending {NAME[]} News", - }, - "tvshowbiz/meghan-markle/index.html": { - subsectionTitle: "Meghan Markle", - template: ".topicHeaderTitle", - format: "{NAME}", - }, - "news/kate_middleton/index.html": { - subsectionTitle: "Kate Middleton", - template: ".topicHeaderTitle", - format: "{NAME}", - }, - "news/prince_william/index.html": { - subsectionTitle: "Prince William", - template: ".topicHeaderTitle", - format: "{NAME}", - }, - "news/camilla-parker-bowles-duchess-of-cornwall/index.html": { - subsectionTitle: "The Queen Consort", - template: ".topicHeaderTitle", - format: "{NAME}", - }, - sport: { - subsectionTitle: "Sports", - subsections: [ - { - template: ".sport > .listTitle", - format: "TRENDING {NAME[]} NEWS", - pages: [ - { - subsectionTitle: "Premier League", - href: "sport/premierleague/index.html", - }, - { - subsectionTitle: "MLS", - href: "sport/major-league-soccer/index.html", - }, - { - subsectionTitle: "Super Bowl", - href: "sport/super_bowl/index.html", - }, - { subsectionTitle: "NBA", href: "sport/nba/index.html" }, - { subsectionTitle: "MLB", href: "sport/mlb/index.html" }, - ], - }, - ], - }, - "sport/wwe/index.html": { - subsectionTitle: "WWE", - template: ".sport > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "sport/football/index.html": { - subsectionTitle: "Soccer", - }, - "sport/nfl/index.html": { - subsectionTitle: "NFL", - }, - "sport/nhl/index.html": { - subsectionTitle: "NHL", - }, - "sport/boxing/index.html": { - subsectionTitle: "Boxing", - }, - "sport/mma/index.html": { - subsectionTitle: "MMA", - }, - "sport/golf/index.html": { - subsectionTitle: "Golf", - }, - "sport/tennis/index.html": { - subsectionTitle: "Tennis", - }, - "sport/formulaone/index.html": { - subsectionTitle: "F1", - }, - "sport/othersports/index.html": { - subsectionTitle: "More", - }, - "news/coronavirus/index.html": { - subsectionTitle: "Covid-19", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "health/flu/index.html": { - subsectionTitle: "Flu", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "health/rsv/index.html": { - subsectionTitle: "RSV", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "health/monkeypox/index.html": { - subsectionTitle: "Monkeypox", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "health/dementia/index.html": { - subsectionTitle: "Dementia", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "news/cancer/index.html": { - subsectionTitle: "Cancer", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "news/weight_loss/index.html": { - subsectionTitle: "Weight Loss", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "news/centers-for-disease-control-and-prevention-cdc/index.html": { - subsectionTitle: "CDC", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "news/world-health-organization/index.html": { - subsectionTitle: "WHO", - template: ".news > .listTitle", - format: "TRENDING {NAME[]} NEWS", - }, - "news/us-politics/index.html": { - subsectionTitle: "", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "sciencetech/nasa/index.html": { - subsectionTitle: "NASA", - template: ".sciencetech > .listTitle", - format: "TRENDING {COMPANYNAME} NEWS", - }, - "sciencetech/index.html": { - subsectionTitle: "SCIENCE", - template: "USETITLE", - }, - "sciencetech/apple/index.html": { - subsectionTitle: "Apple", - template: ".sciencetech > .listTitle", - format: "TRENDING {COMPANYNAME} NEWS", - }, - "sciencetech/twitter/index.html": { - subsectionTitle: "Twitter", - template: ".sciencetech > .listTitle", - format: "TRENDING {COMPANYNAME} NEWS", - }, - "news/russia-ukraine-conflict/index.html": { - subsectionTitle: "Russia-Ukraine", - template: ".news > listTitle", - format: "TRENDING {NAME} NEWS", - }, - "news/bryan-kohberger/index.html": { - subsectionTitle: "Bryan Kohberger", - template: ".news > listTitle", - format: "TRENDING {NAME} NEWS", - }, - "wellness-us/index.html": { - subsectionTitle: "", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "yourmoney/retirement/index.html": { - subsectionTitle: "Retirement", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "yourmoney/consumer/index.html": { - subsectionTitle: "Consumer", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "yourmoney/savings/index.html": { - subsectionTitle: "Savings", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "yourmoney/cars/index.html": { - subsectionTitle: "Cars", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "yourmoney/property/index.html": { - subsectionTitle: "Property", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "tvshowbiz/index.html": { - subsectionTitle: "U.K. Showbiz", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "health/diets/index.html": { - subsectionTitle: "Diet", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "news/worldnews/index.html": { - subsectionTitle: "World News", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "home/weather/index.html": { - subsectionTitle: "UK Forecast", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "home/weatherlocation/{LOC-DATA}": { - subsectionTitle: "UK Forecast", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "travel/escape/index.html": { - subsectionTitle: "Escape", - template: "USETITLE", - format: "{NAME} | Daily Mail Online", - }, - "travel/destinations/index.html": { - subsectionTitle: "Destinations", - template: "OTHER", - }, - "travel/holidaytypes/index.html": { - subsectionTitle: "Holiday Types", - template: "OTHER", - }, - "travel/travelreviews/index.html": { - subsectionTitle: "Expert Reviews", - template: "OTHER", - }, - "travel/travelreviewshub/celebrity-travel.html": { - subsectionTitle: "Celebrity Travel", - template: "OTHER", - }, -}; + 'auhome/index.html': { + subsectionTitle: 'Australia', + }, + 'games/daily-crossword': { + subsectionTitle: 'Games', + customMsg: 'Playing games!', + }, + 'for-you/index.html': { + subsectionTitle: 'For You', + customMsg: 'Browsing personalized feed', + }, + 'femail/fashionfinder/index.html': { + subsectionTitle: 'Fashion Finder', + customMsg: 'Browsing fashion', + }, + 'news/mostread/index.html': { + subsectionTitle: 'Most read', + }, + 'home/latest/index.html#{any(SECTS)}': { + subsectionTitle: '{any(SECTS)}', + }, + 'news/royals/index.html': { + subsectionTitle: 'Royals', + customMsg: 'Browsing Royal News', + }, + 'video/index.html': { + template: '.vjs-title-text', + subsectionTitle: 'Video', + }, + 'news/joe-biden/index.html': { + subsectionTitle: 'Joe Biden', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'news/donald_trump/index.html': { + subsectionTitle: 'Donald Trump', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'news/us-economy/index.html': { + subsectionTitle: 'Economy', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'news/king-charles-iii/index.html': { + subsectionTitle: 'King Charles III', + template: '.topicHeaderTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'news/prince_harry/index.html': { + subsectionTitle: 'Prince Harry', + template: '.topicHeaderTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'tvshowbiz/taylor_swift/index.html': { + subsectionTitle: 'Taylor Swift', + template: '.tvshowbiz > .topicHeaderTitle', + format: '{NAME[]}', + }, + 'tvshowbiz/kim_kardashian/index.html': { + subsectionTitle: 'Kim Kardashian', + template: '.tvshowbiz > .topicHeaderTitle', + format: '{NAME[]}', + }, + 'news/prince-andrew/index.html': { + subsectionTitle: 'Prince Andrew', + template: '.tvshowbiz > .topicHeaderTitle', + format: '{NAME[]}', + }, + 'tvshowbiz/jeremy-renner/index.html': { + subsectionTitle: 'Jeremy Renner', + template: '.tvshowbiz > .topicHeaderTitle', + format: 'Trending {NAME[]} News', + }, + 'tvshowbiz/tiktok/index.html': { + subsectionTitle: 'TikTok', + template: '.tvshowbiz > .topicHeaderTitle', + format: 'Trending {NAME[]} News', + }, + 'tvshowbiz/meghan-markle/index.html': { + subsectionTitle: 'Meghan Markle', + template: '.topicHeaderTitle', + format: '{NAME}', + }, + 'news/kate_middleton/index.html': { + subsectionTitle: 'Kate Middleton', + template: '.topicHeaderTitle', + format: '{NAME}', + }, + 'news/prince_william/index.html': { + subsectionTitle: 'Prince William', + template: '.topicHeaderTitle', + format: '{NAME}', + }, + 'news/camilla-parker-bowles-duchess-of-cornwall/index.html': { + subsectionTitle: 'The Queen Consort', + template: '.topicHeaderTitle', + format: '{NAME}', + }, + 'sport': { + subsectionTitle: 'Sports', + subsections: [ + { + template: '.sport > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + pages: [ + { + subsectionTitle: 'Premier League', + href: 'sport/premierleague/index.html', + }, + { + subsectionTitle: 'MLS', + href: 'sport/major-league-soccer/index.html', + }, + { + subsectionTitle: 'Super Bowl', + href: 'sport/super_bowl/index.html', + }, + { subsectionTitle: 'NBA', href: 'sport/nba/index.html' }, + { subsectionTitle: 'MLB', href: 'sport/mlb/index.html' }, + ], + }, + ], + }, + 'sport/wwe/index.html': { + subsectionTitle: 'WWE', + template: '.sport > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'sport/football/index.html': { + subsectionTitle: 'Soccer', + }, + 'sport/nfl/index.html': { + subsectionTitle: 'NFL', + }, + 'sport/nhl/index.html': { + subsectionTitle: 'NHL', + }, + 'sport/boxing/index.html': { + subsectionTitle: 'Boxing', + }, + 'sport/mma/index.html': { + subsectionTitle: 'MMA', + }, + 'sport/golf/index.html': { + subsectionTitle: 'Golf', + }, + 'sport/tennis/index.html': { + subsectionTitle: 'Tennis', + }, + 'sport/formulaone/index.html': { + subsectionTitle: 'F1', + }, + 'sport/othersports/index.html': { + subsectionTitle: 'More', + }, + 'news/coronavirus/index.html': { + subsectionTitle: 'Covid-19', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'health/flu/index.html': { + subsectionTitle: 'Flu', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'health/rsv/index.html': { + subsectionTitle: 'RSV', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'health/monkeypox/index.html': { + subsectionTitle: 'Monkeypox', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'health/dementia/index.html': { + subsectionTitle: 'Dementia', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'news/cancer/index.html': { + subsectionTitle: 'Cancer', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'news/weight_loss/index.html': { + subsectionTitle: 'Weight Loss', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'news/centers-for-disease-control-and-prevention-cdc/index.html': { + subsectionTitle: 'CDC', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'news/world-health-organization/index.html': { + subsectionTitle: 'WHO', + template: '.news > .listTitle', + format: 'TRENDING {NAME[]} NEWS', + }, + 'news/us-politics/index.html': { + subsectionTitle: '', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'sciencetech/nasa/index.html': { + subsectionTitle: 'NASA', + template: '.sciencetech > .listTitle', + format: 'TRENDING {COMPANYNAME} NEWS', + }, + 'sciencetech/index.html': { + subsectionTitle: 'SCIENCE', + template: 'USETITLE', + }, + 'sciencetech/apple/index.html': { + subsectionTitle: 'Apple', + template: '.sciencetech > .listTitle', + format: 'TRENDING {COMPANYNAME} NEWS', + }, + 'sciencetech/twitter/index.html': { + subsectionTitle: 'Twitter', + template: '.sciencetech > .listTitle', + format: 'TRENDING {COMPANYNAME} NEWS', + }, + 'news/russia-ukraine-conflict/index.html': { + subsectionTitle: 'Russia-Ukraine', + template: '.news > listTitle', + format: 'TRENDING {NAME} NEWS', + }, + 'news/bryan-kohberger/index.html': { + subsectionTitle: 'Bryan Kohberger', + template: '.news > listTitle', + format: 'TRENDING {NAME} NEWS', + }, + 'wellness-us/index.html': { + subsectionTitle: '', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'yourmoney/retirement/index.html': { + subsectionTitle: 'Retirement', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'yourmoney/consumer/index.html': { + subsectionTitle: 'Consumer', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'yourmoney/savings/index.html': { + subsectionTitle: 'Savings', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'yourmoney/cars/index.html': { + subsectionTitle: 'Cars', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'yourmoney/property/index.html': { + subsectionTitle: 'Property', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'tvshowbiz/index.html': { + subsectionTitle: 'U.K. Showbiz', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'health/diets/index.html': { + subsectionTitle: 'Diet', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'news/worldnews/index.html': { + subsectionTitle: 'World News', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'home/weather/index.html': { + subsectionTitle: 'UK Forecast', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'home/weatherlocation/{LOC-DATA}': { + subsectionTitle: 'UK Forecast', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'travel/escape/index.html': { + subsectionTitle: 'Escape', + template: 'USETITLE', + format: '{NAME} | Daily Mail Online', + }, + 'travel/destinations/index.html': { + subsectionTitle: 'Destinations', + template: 'OTHER', + }, + 'travel/holidaytypes/index.html': { + subsectionTitle: 'Holiday Types', + template: 'OTHER', + }, + 'travel/travelreviews/index.html': { + subsectionTitle: 'Expert Reviews', + template: 'OTHER', + }, + 'travel/travelreviewshub/celebrity-travel.html': { + subsectionTitle: 'Celebrity Travel', + template: 'OTHER', + }, +} diff --git a/websites/D/Daily Mail/findPage.ts b/websites/D/Daily Mail/findPage.ts index 68e8bd74ac02..d5320a8368e3 100644 --- a/websites/D/Daily Mail/findPage.ts +++ b/websites/D/Daily Mail/findPage.ts @@ -1,88 +1,104 @@ -import { byHref } from "./data"; -import { handleSport } from "./handleSport"; -import { Assets } from "./presence"; +import { byHref } from './data' +import { handleSport } from './handleSport' +import { Assets } from './presence' function noTemplate(ext: string, presenceData: PresenceData): void { - switch (ext.split("/")[0]) { - case "for-you": - presenceData.details = "browsing personalized feed"; - break; + switch (ext.split('/')[0]) { + case 'for-you': + presenceData.details = 'browsing personalized feed' + break - case "games": - presenceData.details = "playing games!"; - break; + case 'games': + presenceData.details = 'playing games!' + break - default: - presenceData.details = "Browsing the news"; - } + default: + presenceData.details = 'Browsing the news' + } } -const formatTitle = (presenceData: PresenceData): void => { - presenceData.details = "Browsing Section"; - presenceData.state = document.title.split("|")[0].trim(); -}; +function formatTitle(presenceData: PresenceData): void { + presenceData.details = 'Browsing Section' + presenceData.state = document.title.split('|')[0].trim() +} // I'm leaving this well-commented because I hate regex function extractNameFromString(formattedString: string, formatPattern: string) { - let result = "", - match: RegExpExecArray; + let result = '' + let match: RegExpExecArray | null + //* Loop through the format pattern to find text between curly braces + let formatPatternCopy = formatPattern + while (true) { + match = /\{[^}]*\}|([^{}]+)/.exec(formatPatternCopy) + if (!match) + break + + //* Add any captured text (not inside braces) to result + if (match[1]) + result += match[1] - // Use a loop to find all matches - while ((match = /(?:{[^}]*})|([^{}]+)/g.exec(formatPattern)) !== null) { - // Only add the non-undefined (captured group) matches to the result - if (match[1]) result += match[1]; - } + formatPatternCopy = formatPatternCopy.slice(match.index + match[0].length) + } - // Replace occurrences of any strings from the list with nothing - return formattedString.replace( - new RegExp( - result - .split(" ") - .filter(o => o) - .map(s => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) - .join("|"), - "g" - ), - "" - ); + // Replace occurrences of any strings from the list with nothing + return formattedString.replace( + new RegExp( + result + .split(' ') + .filter(o => o) + .map(s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')) + .join('|'), + 'g', + ), + '', + ) } export function findPage(ext: string, presenceData: PresenceData): void { - // find by template - const template = byHref[ext]; - if (ext.startsWith("sport")) handleSport(ext, presenceData); - else if (template && template.customMsg) - presenceData.details = template.customMsg; - else if (!template || !template.template) noTemplate(ext, presenceData); - else if (template.template === "OTHER") { - presenceData.details = "Browsing Section"; - presenceData.state = template.subsectionTitle; - } else if (template.template === "USETITLE") formatTitle(presenceData); - else { - let el: HTMLElement = document.body; - for (const CSSsel of template.template.split(" > ")) - el = el?.querySelector(CSSsel); + // find by template + const template = byHref[ext] + if (ext.startsWith('sport')) { + handleSport(ext, presenceData) + } + else if (template && template.customMsg) { + presenceData.details = template.customMsg + } + else if (!template || !template.template) { + noTemplate(ext, presenceData) + } + else if (template.template === 'OTHER') { + presenceData.details = 'Browsing Section' + presenceData.state = template.subsectionTitle + } + else if (template.template === 'USETITLE') { + formatTitle(presenceData) + } + else { + let el: HTMLElement | null | undefined = document.body + for (const CSSsel of template.template.split(' > ')) + el = el?.querySelector(CSSsel) - // format the title - const strToAdd = - template.format && el?.textContent - ? extractNameFromString(el.textContent, template.format) - : el?.textContent; - presenceData.details = strToAdd || "the news"; - } + // format the title + const strToAdd = template.format && el?.textContent + ? extractNameFromString(el.textContent, template.format) + : el?.textContent + presenceData.details = strToAdd || 'the news' + } - if (ext === "video/index.html") { - presenceData.details = `Watching ${presenceData.details}`; - presenceData.buttons = [ - { label: "Watch Along", url: document.location.href }, - ]; + if (ext === 'video/index.html') { + presenceData.details = `Watching ${presenceData.details}` + presenceData.buttons = [ + { label: 'Watch Along', url: document.location.href }, + ] - const vid = document.querySelector("video"); - if (!vid.paused && !vid.ended) presenceData.smallImageKey = Assets.PlayIco; - else presenceData.smallImageKey = Assets.PauseIco; - } else { - presenceData.buttons = [ - { label: "Browse Along", url: document.location.href }, - ]; - } + const vid = document.querySelector('video')! + if (!vid.paused && !vid.ended) + presenceData.smallImageKey = Assets.PlayIco + else presenceData.smallImageKey = Assets.PauseIco + } + else { + presenceData.buttons = [ + { label: 'Browse Along', url: document.location.href }, + ] + } } diff --git a/websites/D/Daily Mail/handleSport.ts b/websites/D/Daily Mail/handleSport.ts index 273046e50549..cb2df48d3f5e 100644 --- a/websites/D/Daily Mail/handleSport.ts +++ b/websites/D/Daily Mail/handleSport.ts @@ -1,31 +1,33 @@ function handleFootball(page: string, presenceData: PresenceData): void { - presenceData.state = "Football"; - switch (page) { - case "results.html": - presenceData.state += " Results"; - break; + presenceData.state = 'Football' + switch (page) { + case 'results.html': + presenceData.state += ' Results' + break - case "fixtures.html": - presenceData.state += " Fixtures"; - break; + case 'fixtures.html': + presenceData.state += ' Fixtures' + break - case "tables.html": - presenceData.state += " Tables"; - break; - } + case 'tables.html': + presenceData.state += ' Tables' + break + } } export function handleSport(ext: string, presenceData: PresenceData): void { - presenceData.details = "Browsing Sports"; - const sportCat = ext.split("/"), - // try first "most popular" method - title = document - .querySelector(".sport") - ?.querySelector(".listTitle")?.textContent; + presenceData.details = 'Browsing Sports' + const sportCat = ext.split('/') + // try first "most popular" method + const title = document + .querySelector('.sport') + ?.querySelector('.listTitle') + ?.textContent - // sportCat can be 2 or 3 long - if (sportCat[1] === "football") - handleFootball(sportCat[sportCat.length - 1], presenceData); - else if (title) presenceData.state = title; - else presenceData.state = document.title.split("|")[0].trim(); + // sportCat can be 2 or 3 long + if (sportCat[1] === 'football') + handleFootball(sportCat[sportCat.length - 1], presenceData) + else if (title) + presenceData.state = title + else presenceData.state = document.title.split('|')[0].trim() } diff --git a/websites/D/Daily Mail/metadata.json b/websites/D/Daily Mail/metadata.json index 628735391116..50c3059a0a95 100644 --- a/websites/D/Daily Mail/metadata.json +++ b/websites/D/Daily Mail/metadata.json @@ -1,36 +1,36 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "358402930191106049", - "name": "ion606" - }, - "service": "Daily Mail", - "description": { - "en": "MailOnline - get the latest breaking news, celebrity photos, viral videos, science & tech news, and top stories from MailOnline and the Daily Mail newspaper." - }, - "url": "www.dailymail.co.uk", - "version": "1.0.7", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Mail/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Mail/assets/thumbnail.png", - "color": "#004db3", - "category": "other", - "tags": [ - "dailymail", - "news", - "newspaper", - "publication" - ], - "settings": [ - { - "id": "usearticlethumbnail", - "title": "Use Article Thumbnail as Image", - "value": false - }, - { - "id": "showtimestamp", - "title": "Show how long you've been browsing", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "358402930191106049", + "name": "ion606" + }, + "service": "Daily Mail", + "description": { + "en": "MailOnline - get the latest breaking news, celebrity photos, viral videos, science & tech news, and top stories from MailOnline and the Daily Mail newspaper." + }, + "url": "www.dailymail.co.uk", + "version": "1.0.7", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Mail/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Mail/assets/thumbnail.png", + "color": "#004db3", + "category": "other", + "tags": [ + "dailymail", + "news", + "newspaper", + "publication" + ], + "settings": [ + { + "id": "usearticlethumbnail", + "title": "Use Article Thumbnail as Image", + "value": false + }, + { + "id": "showtimestamp", + "title": "Show how long you've been browsing", + "value": true + } + ] +} diff --git a/websites/D/Daily Mail/newsPage.ts b/websites/D/Daily Mail/newsPage.ts index 71108a934efa..a587f43062db 100644 --- a/websites/D/Daily Mail/newsPage.ts +++ b/websites/D/Daily Mail/newsPage.ts @@ -1,59 +1,65 @@ -import { findPage } from "./findPage"; -import { Assets } from "./presence"; +import { findPage } from './findPage' +import { Assets } from './presence' function handleArticle( - presenceData: PresenceData, - useArticleThumbnail: boolean + presenceData: PresenceData, + useArticleThumbnail: boolean, ): void { - const titleEl = document - .querySelector("#js-article-text") - .querySelector("h1"); - presenceData.buttons = [ - { label: "Read Article", url: document.location.href }, - ]; + const titleEl = document + .querySelector('#js-article-text') + ?.querySelector('h1') + presenceData.buttons = [ + { label: 'Read Article', url: document.location.href }, + ] - if (titleEl.querySelector(".is-exclusive")) { - presenceData.details = "Reading Article"; - presenceData.smallImageKey = Assets.ExclIco; - presenceData.smallImageText = "Exclusive!"; - } else { - presenceData.details = "Reading Article"; - delete presenceData.smallImageKey; - } + if (titleEl?.querySelector('.is-exclusive')) { + presenceData.details = 'Reading Article' + presenceData.smallImageKey = Assets.ExclIco + presenceData.smallImageText = 'Exclusive!' + } + else { + presenceData.details = 'Reading Article' + delete presenceData.smallImageKey + } - if (useArticleThumbnail) { - presenceData.largeImageKey = document - .querySelector('[property="twitter:image"]') - ?.getAttribute("content"); - } else presenceData.largeImageKey = Assets.Logo; + if (useArticleThumbnail) { + presenceData.largeImageKey = document + .querySelector('[property="twitter:image"]') + ?.getAttribute('content') + } + else { + presenceData.largeImageKey = Assets.Logo + } - // the twitter title preview is more concise and readable - presenceData.state = - document - .querySelector('[property="twitter:title"]') - ?.getAttribute("content") || titleEl.textContent.replace("EXCLUSIVE", ""); + // the twitter title preview is more concise and readable + presenceData.state = document + .querySelector('[property="twitter:title"]') + ?.getAttribute('content') || titleEl?.textContent?.replace('EXCLUSIVE', '') - // authors (LEAVE THIS COMMENT PLEASE) - /* - const authors = Array.from( - aBody.querySelector(".author-section").querySelectorAll("a") - ).map(el => el.textContent); - presenceData.state = `By ${authors.join(", ") || "unknown"}`; - */ + // authors (LEAVE THIS COMMENT PLEASE) + /* + const authors = Array.from( + aBody.querySelector(".author-section").querySelectorAll("a") + ).map(el => el.textContent); + presenceData.state = `By ${authors.join(", ") || "unknown"}`; + */ } export function handleNewsPage( - presenceData: PresenceData, - useArticleThumbnail: boolean + presenceData: PresenceData, + useArticleThumbnail: boolean, ): void { - const newsPaths = document.location.pathname - .split("/") - .find(e => e && e !== "news"); + const newsPaths = document.location.pathname + .split('/') + .find(e => e && e !== 'news') - if ( - newsPaths.includes("article-") || - document.location.pathname.split("/")[3]?.startsWith("article-") - ) - handleArticle(presenceData, useArticleThumbnail); - else findPage(document.location.pathname.substring(1), presenceData); + if ( + newsPaths?.includes('article-') + || document.location.pathname.split('/')[3]?.startsWith('article-') + ) { + handleArticle(presenceData, useArticleThumbnail) + } + else { + findPage(document.location.pathname.substring(1), presenceData) + } } diff --git a/websites/D/Daily Mail/presence.ts b/websites/D/Daily Mail/presence.ts index f828f2ee4371..4987625f4646 100644 --- a/websites/D/Daily Mail/presence.ts +++ b/websites/D/Daily Mail/presence.ts @@ -1,79 +1,85 @@ -import { findPage } from "./findPage"; -import { handleNewsPage } from "./newsPage"; +import { findPage } from './findPage' +import { handleNewsPage } from './newsPage' const presence = new Presence({ - clientId: "1224125578504966165", - }), - sTs = Math.floor(Date.now() / 1000); + clientId: '1224125578504966165', +}) +const sTs = Math.floor(Date.now() / 1000) export const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Mail/assets/logo.png", - ExclIco = "https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Mail/assets/0.png", - PlayIco = "https://cdn.rcd.gg/PreMiD/resources/play.png", - PauseIco = "https://cdn.rcd.gg/PreMiD/resources/pause.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Mail/assets/logo.png', + ExclIco = 'https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Mail/assets/0.png', + PlayIco = 'https://cdn.rcd.gg/PreMiD/resources/play.png', + PauseIco = 'https://cdn.rcd.gg/PreMiD/resources/pause.png', } const enum Pages { - homepage = "home", - news = "news", - wellness = "wellness-us", // apparently there's....no uk page? + homepage = 'home', + news = 'news', + wellness = 'wellness-us', // apparently there's....no uk page? } // possible expansion for other countries, leave as helper function -const catToCountry = (cat: string): string[] => { - if (cat.startsWith("us")) return [cat.replace("us", ""), "Daily Mail (US)"]; - else if (cat.startsWith("au")) - return [cat.replace("au", ""), "Daily Mail (US)"]; - return [cat.replace("us", ""), "Daily Mail"]; -}; +function catToCountry(cat: string): string[] { + if (cat.startsWith('us')) + return [cat.replace('us', ''), 'Daily Mail (US)'] + else if (cat.startsWith('au')) + return [cat.replace('au', ''), 'Daily Mail (US)'] + return [cat.replace('us', ''), 'Daily Mail'] +} -presence.on("UpdateData", async () => { - if (!document.location.toString()) return; +presence.on('UpdateData', async () => { + if (!document.location.toString()) + return - // all urls are formatted "category/pagename" - const [catNoCountry, titleWithCountry] = catToCountry( - document.location.pathname.split("/")[1] - ), - presenceData: PresenceData = { - largeImageKey: Assets.Logo, - name: titleWithCountry, - type: ActivityType.Playing, - startTimestamp: sTs, - }; + // all urls are formatted "category/pagename" + const [catNoCountry, titleWithCountry] = catToCountry( + document.location.pathname.split('/')[1], + ) + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + name: titleWithCountry, + type: ActivityType.Playing, + startTimestamp: sTs, + } - if (!(await presence.getSetting("showtimestamp"))) - delete presenceData.startTimestamp; + if (!(await presence.getSetting('showtimestamp'))) + delete presenceData.startTimestamp - switch (catNoCountry) { - case Pages.homepage: - { - const subcat = document - .querySelector("[data-mol-fe-latest-headlines--active]") - ?.querySelector("a") - ?.textContent?.toLowerCase(); + switch (catNoCountry) { + case Pages.homepage: + { + const subcat = document + .querySelector('[data-mol-fe-latest-headlines--active]') + ?.querySelector('a') + ?.textContent + ?.toLowerCase() - if (subcat && ["all", "news", "home"].includes(subcat)) - presenceData.details = `Browsing the latest ${subcat} news`; - else presenceData.details = "Browsing the latest news"; - } - break; + if (subcat && ['all', 'news', 'home'].includes(subcat)) + presenceData.details = `Browsing the latest ${subcat} news` + else presenceData.details = 'Browsing the latest news' + } + break - case Pages.news: - handleNewsPage( - presenceData, - await presence.getSetting("usearticlethumbnail") - ); - break; + case Pages.news: + handleNewsPage( + presenceData, + await presence.getSetting('usearticlethumbnail'), + ) + break - default: - if (document.location.pathname.split("/")[3]?.startsWith("article-")) { - handleNewsPage( - presenceData, - await presence.getSetting("usearticlethumbnail") - ); - } else findPage(document.location.pathname.substring(1), presenceData); - break; - } + default: + if (document.location.pathname.split('/')[3]?.startsWith('article-')) { + handleNewsPage( + presenceData, + await presence.getSetting('usearticlethumbnail'), + ) + } + else { + findPage(document.location.pathname.substring(1), presenceData) + } + break + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/D/Daily Wire/metadata.json b/websites/D/Daily Wire/metadata.json index 9afbedf0f015..bb24d4dcd2fb 100644 --- a/websites/D/Daily Wire/metadata.json +++ b/websites/D/Daily Wire/metadata.json @@ -1,36 +1,36 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "N0chteil ^^", - "id": "495901098926669825" - }, - "service": "Daily Wire", - "description": { - "en": "The Daily Wire is an American conservative news website and media company founded in 2015 by political commentator Ben Shapiro and director Jeremy Boreing. The site has been criticised for promoting misinformation.", - "nl": "The Daily Wire is een Amerikaanse conservatieve nieuwswebsite en mediabedrijf opgericht in 2015 door politiek commentator Ben Shapiro en regisseur Jeremy Boreing. De site is gekritiseerd vanwege het promoten van valse informatie." - }, - "url": "www.dailywire.com", - "version": "1.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Wire/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Wire/assets/thumbnail.png", - "color": "#000", - "category": "other", - "tags": [ - "news" - ], - "settings": [ - { - "id": "timeElapsed", - "title": "Show elapsed time", - "icon": "fad fa-hourglass-half", - "value": true - }, - { - "id": "showButtons", - "title": "Show buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "N0chteil ^^", + "id": "495901098926669825" + }, + "service": "Daily Wire", + "description": { + "en": "The Daily Wire is an American conservative news website and media company founded in 2015 by political commentator Ben Shapiro and director Jeremy Boreing. The site has been criticised for promoting misinformation.", + "nl": "The Daily Wire is een Amerikaanse conservatieve nieuwswebsite en mediabedrijf opgericht in 2015 door politiek commentator Ben Shapiro en regisseur Jeremy Boreing. De site is gekritiseerd vanwege het promoten van valse informatie." + }, + "url": "www.dailywire.com", + "version": "1.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Wire/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Wire/assets/thumbnail.png", + "color": "#000", + "category": "other", + "tags": [ + "news" + ], + "settings": [ + { + "id": "timeElapsed", + "title": "Show elapsed time", + "icon": "fad fa-hourglass-half", + "value": true + }, + { + "id": "showButtons", + "title": "Show buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/D/Daily Wire/presence.ts b/websites/D/Daily Wire/presence.ts index 731a396ef986..0de9fb1568ce 100644 --- a/websites/D/Daily Wire/presence.ts +++ b/websites/D/Daily Wire/presence.ts @@ -1,130 +1,128 @@ const presence = new Presence({ - clientId: "843781235494486046", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '843781235494486046', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async function () { - const setting = { - timeElapsed: await presence.getSetting("timeElapsed"), - showButtons: await presence.getSetting("showButtons"), - }, - urlpath = window.location.pathname.split("/"), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Wire/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const setting = { + timeElapsed: await presence.getSetting('timeElapsed'), + showButtons: await presence.getSetting('showButtons'), + } + const urlpath = window.location.pathname.split('/') + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Daily%20Wire/assets/logo.png', + } - if (setting.timeElapsed) presenceData.startTimestamp = browsingTimestamp; + if (setting.timeElapsed) + presenceData.startTimestamp = browsingTimestamp - if (!urlpath[1]) presenceData.details = "Home"; - else if (urlpath[1] === "news" && urlpath[2]) { - presenceData.details = "Viewing Article"; - presenceData.state = - document.querySelector("h1.css-cmdiie.e172hw750")?.textContent || - "Unknown"; + if (!urlpath[1]) { + presenceData.details = 'Home' + } + else if (urlpath[1] === 'news' && urlpath[2]) { + presenceData.details = 'Viewing Article' + presenceData.state = document.querySelector('h1.css-cmdiie.e172hw750')?.textContent + || 'Unknown' - if (setting.showButtons) { - presenceData.buttons = [ - { - label: "Read Article", - url: window.location.href, - }, - ]; - } - } else { - switch (urlpath[1]) { - case "episode": { - presenceData.details = - document.querySelector("h2.css-n0lwas.e172hw750")?.textContent || - "Unknown"; - presenceData.state = - document.querySelectorAll("span.css-e6rih1.ew91t7w0")[1] - ?.textContent || "Unknown"; + if (setting.showButtons) { + presenceData.buttons = [ + { + label: 'Read Article', + url: window.location.href, + }, + ] + } + } + else { + switch (urlpath[1]) { + case 'episode': { + presenceData.details = document.querySelector('h2.css-n0lwas.e172hw750')?.textContent + || 'Unknown' + presenceData.state = document.querySelectorAll('span.css-e6rih1.ew91t7w0')[1] + ?.textContent || 'Unknown' - if (setting.showButtons) { - presenceData.buttons = [ - { - label: "Watch Episode", - url: window.location.href, - }, - ]; - } + if (setting.showButtons) { + presenceData.buttons = [ + { + label: 'Watch Episode', + url: window.location.href, + }, + ] + } - break; - } - case "show": { - presenceData.details = "Viewing Show"; - presenceData.state = - document.querySelector("h3.css-1qqpwph")?.textContent || "Unknown"; + break + } + case 'show': { + presenceData.details = 'Viewing Show' + presenceData.state = document.querySelector('h3.css-1qqpwph')?.textContent || 'Unknown' - if (setting.showButtons) { - presenceData.buttons = [ - { - label: "Watch Show", - url: window.location.href, - }, - ]; - } + if (setting.showButtons) { + presenceData.buttons = [ + { + label: 'Watch Show', + url: window.location.href, + }, + ] + } - break; - } - case "discussion": { - presenceData.details = "Viewing Discussion"; - presenceData.state = - document.querySelector("h2.css-n0lwas.e172hw750")?.textContent || - "Unknown"; + break + } + case 'discussion': { + presenceData.details = 'Viewing Discussion' + presenceData.state = document.querySelector('h2.css-n0lwas.e172hw750')?.textContent + || 'Unknown' - if (setting.showButtons) { - presenceData.buttons = [ - { - label: "View Discussion", - url: window.location.href, - }, - ]; - } + if (setting.showButtons) { + presenceData.buttons = [ + { + label: 'View Discussion', + url: window.location.href, + }, + ] + } - break; - } - case "author": { - presenceData.details = "Viewing Author"; - presenceData.state = - document.querySelector("h2.css-cmdiie.e172hw750")?.textContent || - "Unknown"; + break + } + case 'author': { + presenceData.details = 'Viewing Author' + presenceData.state = document.querySelector('h2.css-cmdiie.e172hw750')?.textContent + || 'Unknown' - if (setting.showButtons) { - presenceData.buttons = [ - { - label: "View Author", - url: window.location.href, - }, - ]; - } + if (setting.showButtons) { + presenceData.buttons = [ + { + label: 'View Author', + url: window.location.href, + }, + ] + } - break; - } - case "subscribe": { - presenceData.details = "Viewing Membership"; - break; - } - case "read": - case "dicuss": - case "watch": { - presenceData.details = "Browsing"; - break; - } - case "search": { - presenceData.details = "Searching"; - presenceData.state = document.querySelector( - "input.ais-SearchBox-input" - )?.value; + break + } + case 'subscribe': { + presenceData.details = 'Viewing Membership' + break + } + case 'read': + case 'dicuss': + case 'watch': { + presenceData.details = 'Browsing' + break + } + case 'search': { + presenceData.details = 'Searching' + presenceData.state = document.querySelector( + 'input.ais-SearchBox-input', + )?.value - break; - } - default: - presenceData.details = "Other"; - } - } + break + } + default: + presenceData.details = 'Other' + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Dank Memer/metadata.json b/websites/D/Dank Memer/metadata.json index 6991b33fc16d..ca92df09c2ae 100644 --- a/websites/D/Dank Memer/metadata.json +++ b/websites/D/Dank Memer/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Eren", - "id": "478937019758673931" - }, - "service": "Dank Memer", - "description": { - "en": "Dank Memer is packed full of memes, fun, and unique experiences! Whether you gamble, steal from your friends, check the latest hot memes, roast your friends, create your own memes, or use one of our other 260+ commands.", - "nl": "Dank Memer zit boordevol memes, leuke en unieke ervaringen! Of je nu gokt, steelt van je vrienden, de laatste hete memes bekijkt, je vrienden roostert, je eigen memes maakt of een van onze andere 260+ commando's gebruikt." - }, - "url": "dankmemer.lol", - "version": "1.2.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dank%20Memer/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dank%20Memer/assets/thumbnail.png", - "color": "#555C56", - "category": "other", - "tags": [ - "discord", - "bot" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Eren", + "id": "478937019758673931" + }, + "service": "Dank Memer", + "description": { + "en": "Dank Memer is packed full of memes, fun, and unique experiences! Whether you gamble, steal from your friends, check the latest hot memes, roast your friends, create your own memes, or use one of our other 260+ commands.", + "nl": "Dank Memer zit boordevol memes, leuke en unieke ervaringen! Of je nu gokt, steelt van je vrienden, de laatste hete memes bekijkt, je vrienden roostert, je eigen memes maakt of een van onze andere 260+ commando's gebruikt." + }, + "url": "dankmemer.lol", + "version": "1.2.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dank%20Memer/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dank%20Memer/assets/thumbnail.png", + "color": "#555C56", + "category": "other", + "tags": [ + "discord", + "bot" + ] +} diff --git a/websites/D/Dank Memer/presence.ts b/websites/D/Dank Memer/presence.ts index 0a77cb30d547..846b4f9f7500 100644 --- a/websites/D/Dank Memer/presence.ts +++ b/websites/D/Dank Memer/presence.ts @@ -1,37 +1,42 @@ const presence = new Presence({ - clientId: "653324146503188490", -}); + clientId: '653324146503188490', +}) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Dank%20Memer/assets/logo.png", - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Dank%20Memer/assets/logo.png', + } - if (window.location.pathname.endsWith("commands")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Commands"; - } else if (window.location.pathname.endsWith("about")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "About"; - } else if (window.location.pathname.endsWith("blogs")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Blogs"; - } else if (window.location.pathname.startsWith("/blogs/")) { - presenceData.details = "Viewing a blog:"; - presenceData.state = document.querySelector( - "#root > div.psuedoBody > header" - ).textContent; - } else if (window.location.pathname.includes("/store/presences/")) { - presenceData.details = "Viewing a presence page:"; - presenceData.state = document.querySelector( - "#app > div.page-wrapper > div.content > div > div > div.fullpresence__header > div.header__title > h1" - ).textContent; - } else if (window.location.pathname.endsWith("loot")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Lootboxes"; - } + if (window.location.pathname.endsWith('commands')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Commands' + } + else if (window.location.pathname.endsWith('about')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'About' + } + else if (window.location.pathname.endsWith('blogs')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Blogs' + } + else if (window.location.pathname.startsWith('/blogs/')) { + presenceData.details = 'Viewing a blog:' + presenceData.state = document.querySelector( + '#root > div.psuedoBody > header', + )?.textContent + } + else if (window.location.pathname.includes('/store/presences/')) { + presenceData.details = 'Viewing a presence page:' + presenceData.state = document.querySelector( + '#app > div.page-wrapper > div.content > div > div > div.fullpresence__header > div.header__title > h1', + )?.textContent + } + else if (window.location.pathname.endsWith('loot')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Lootboxes' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/DashNet/metadata.json b/websites/D/DashNet/metadata.json index 59a3177460ae..a7048514db39 100644 --- a/websites/D/DashNet/metadata.json +++ b/websites/D/DashNet/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "DashNet", - "altnames": [ - "Cookie Clicker" - ], - "description": { - "en": "DashNet by Orteil and Opti, a 2-people team that makes browser games, generators, and other wacky experiments.", - "nl": "DashNet van Orteil en Opti, een team van twee mensen dat browsergames, generatoren en andere gekke experimenten maakt." - }, - "url": "dashnet.org", - "regExp": "([a-z0-9-]+[.])*dashnet[.]org[/]", - "version": "1.3.17", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DashNet/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DashNet/assets/thumbnail.png", - "color": "#042B48", - "category": "games", - "tags": [ - "cookie", - "clicker" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "DashNet", + "altnames": [ + "Cookie Clicker" + ], + "description": { + "en": "DashNet by Orteil and Opti, a 2-people team that makes browser games, generators, and other wacky experiments.", + "nl": "DashNet van Orteil en Opti, een team van twee mensen dat browsergames, generatoren en andere gekke experimenten maakt." + }, + "url": "dashnet.org", + "regExp": "([a-z0-9-]+[.])*dashnet[.]org[/]", + "version": "1.3.17", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DashNet/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DashNet/assets/thumbnail.png", + "color": "#042B48", + "category": "games", + "tags": [ + "cookie", + "clicker" + ] +} diff --git a/websites/D/DashNet/presence.ts b/websites/D/DashNet/presence.ts index 8fdfd7b5894d..5ec5fb385466 100644 --- a/websites/D/DashNet/presence.ts +++ b/websites/D/DashNet/presence.ts @@ -1,91 +1,113 @@ -let presence: Presence, newID: string, latestID: string; -function presenceSet(pathname: string): void { - if (!latestID && !newID) { - newID = pathname.includes("/cookieclicker/") - ? "676126246928777250" - : "676120967159742465"; - presence = new Presence({ clientId: newID }); - } +let presence: Presence, newID: string, latestID: string +function presenceSet(pathname: string): Presence { + if (!latestID && !newID) { + newID = pathname.includes('/cookieclicker/') + ? '676126246928777250' + : '676120967159742465' + presence = new Presence({ clientId: newID }) + } - if ( - pathname.includes("/cookieclicker/") && - latestID !== "676126246928777250" - ) { - presence = new Presence({ clientId: "676126246928777250" }); - newID = "676126246928777250"; - } else if ( - !pathname.includes("/cookieclicker/") && - latestID !== "676120967159742465" - ) { - presence = new Presence({ clientId: "676120967159742465" }); - newID = "676120967159742465"; - } - latestID = newID; + if ( + pathname.includes('/cookieclicker/') + && latestID !== '676126246928777250' + ) { + presence = new Presence({ clientId: '676126246928777250' }) + newID = '676126246928777250' + } + else if ( + !pathname.includes('/cookieclicker/') + && latestID !== '676120967159742465' + ) { + presence = new Presence({ clientId: '676120967159742465' }) + newID = '676120967159742465' + } + latestID = newID + + return presence } -const browsingTimestamp = Math.floor(Date.now() / 1000); +const browsingTimestamp = Math.floor(Date.now() / 1000) -presenceSet(document.location.pathname); +presence = presenceSet(document.location.pathname) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DashNet/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DashNet/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname } = document.location - presenceSet(pathname); + presenceSet(pathname) - if (pathname.includes("/cookieclicker/")) { - const cookies = await presence.getPageVariable( - "Game.cookies", - "Game.cookiesPs", - "Game.ascendMeterLevel" - ); - presenceData.details = `${ - Math.round(Number(cookies["Game.cookies"]) * 100) / 100 - } cookies`; - presenceData.state = `${ - Math.round(Number(cookies["Game.cookiesPs"]) * 100) / 100 - } cookies per second`; - presenceData.smallImageText = `Legacy level: ${cookies["Game.ascendMeterLevel"]}`; - } else if (pathname === "/") { - presenceData.details = "Browsing DashNet's"; - presenceData.state = "video games and other fun things"; - presenceData.smallImageKey = Assets.Reading; - } else if (pathname.includes("/legacy/")) - presenceData.details = "Playing Legacy"; - else if (pathname.includes("/igm/")) - presenceData.details = "Making an idle game"; - else if (pathname.includes("/randomgen/")) - presenceData.details = "Using RandomGen"; - else if (pathname.includes("/nested/")) - presenceData.details = "Playing Nested"; - else if (pathname.includes("/murdergames/")) - presenceData.details = "Playing Murder Games"; - else if (pathname.includes("/lsystem/")) - presenceData.details = "Playing Tutrle Toy"; - else if (pathname.includes("/taskmaster/")) - presenceData.details = "Using TaskMaster"; - else if (pathname.includes("/cookies2cash/")) - presenceData.details = "Using Cookies2Cash"; - else if (pathname.includes("/musicgen/")) - presenceData.details = "Using MusicGen"; - else if (pathname.includes("/dungeongenerator/")) - presenceData.details = "Using Dungeon Generator"; - else if (pathname.includes("/dreamlog/")) - presenceData.details = "Playing Dreamlog"; - else if (pathname.includes("/PretendEverything/")) - presenceData.details = "Playing PretendEverything"; - else if (pathname.includes("/teaparty/")) - presenceData.details = "Having a tea party"; - else if (pathname.includes("/mailtopia/")) - presenceData.details = "Playing mailtopia"; - else if (pathname.includes("/life")) presenceData.details = "Playing Life"; - else if (pathname.includes("/3dtest/2")) - presenceData.details = "Using WebGL test"; + if (pathname.includes('/cookieclicker/')) { + const cookies = await presence.getPageVariable( + 'Game.cookies', + 'Game.cookiesPs', + 'Game.ascendMeterLevel', + ) + presenceData.details = `${ + Math.round(Number(cookies['Game.cookies']) * 100) / 100 + } cookies` + presenceData.state = `${ + Math.round(Number(cookies['Game.cookiesPs']) * 100) / 100 + } cookies per second` + presenceData.smallImageText = `Legacy level: ${cookies['Game.ascendMeterLevel']}` + } + else if (pathname === '/') { + presenceData.details = 'Browsing DashNet\'s' + presenceData.state = 'video games and other fun things' + presenceData.smallImageKey = Assets.Reading + } + else if (pathname.includes('/legacy/')) { + presenceData.details = 'Playing Legacy' + } + else if (pathname.includes('/igm/')) { + presenceData.details = 'Making an idle game' + } + else if (pathname.includes('/randomgen/')) { + presenceData.details = 'Using RandomGen' + } + else if (pathname.includes('/nested/')) { + presenceData.details = 'Playing Nested' + } + else if (pathname.includes('/murdergames/')) { + presenceData.details = 'Playing Murder Games' + } + else if (pathname.includes('/lsystem/')) { + presenceData.details = 'Playing Tutrle Toy' + } + else if (pathname.includes('/taskmaster/')) { + presenceData.details = 'Using TaskMaster' + } + else if (pathname.includes('/cookies2cash/')) { + presenceData.details = 'Using Cookies2Cash' + } + else if (pathname.includes('/musicgen/')) { + presenceData.details = 'Using MusicGen' + } + else if (pathname.includes('/dungeongenerator/')) { + presenceData.details = 'Using Dungeon Generator' + } + else if (pathname.includes('/dreamlog/')) { + presenceData.details = 'Playing Dreamlog' + } + else if (pathname.includes('/PretendEverything/')) { + presenceData.details = 'Playing PretendEverything' + } + else if (pathname.includes('/teaparty/')) { + presenceData.details = 'Having a tea party' + } + else if (pathname.includes('/mailtopia/')) { + presenceData.details = 'Playing mailtopia' + } + else if (pathname.includes('/life')) { + presenceData.details = 'Playing Life' + } + else if (pathname.includes('/3dtest/2')) { + presenceData.details = 'Using WebGL test' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Daum/iframe.ts b/websites/D/Daum/iframe.ts index c41415208efd..be56328b6c34 100644 --- a/websites/D/Daum/iframe.ts +++ b/websites/D/Daum/iframe.ts @@ -1,33 +1,35 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", () => { - if (document.querySelector("video")) { - const video = document.querySelector("video"); +iframe.on('UpdateData', () => { + if (document.querySelector('video')) { + const video = document.querySelector('video')! - iframe.send({ - video: { - duration: video.duration, - currentTime: video.currentTime, - paused: video.paused, - title: document.querySelector("span.link_title")?.textContent, - }, - }); - } + iframe.send({ + video: { + duration: video.duration, + currentTime: video.currentTime, + paused: video.paused, + title: document.querySelector('span.link_title')?.textContent, + }, + }) + } - if (document.location.hostname === "cafe.daum.net") { - iframe.send({ - cafe: { - name: document - .querySelector("#cafe_info_outer > div.cafename") - ?.textContent.trim(), - title: ( - document.querySelector("strong.tit_item") ?? - document.querySelector("h3.title") - )?.textContent.trim(), - article: document - .querySelector("strong.tit_info > b") - ?.textContent.trim(), - }, - }); - } -}); + if (document.location.hostname === 'cafe.daum.net') { + iframe.send({ + cafe: { + name: document + .querySelector('#cafe_info_outer > div.cafename') + ?.textContent + ?.trim(), + title: ( + document.querySelector('strong.tit_item') + ?? document.querySelector('h3.title') + )?.textContent?.trim(), + article: document + .querySelector('strong.tit_info > b') + ?.textContent + ?.trim(), + }, + }) + } +}) diff --git a/websites/D/Daum/metadata.json b/websites/D/Daum/metadata.json index 4101ba6033a2..0a87fe5705ca 100644 --- a/websites/D/Daum/metadata.json +++ b/websites/D/Daum/metadata.json @@ -1,47 +1,47 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "SlowLife", - "id": "374905512661221377" - }, - "service": "Daum", - "altnames": [ - "다음", - "다음 뉴스", - "다음 메일" - ], - "description": { - "en": "Daum (다음) is a South Korean web portal. It opened the first web mail service in Korea under the name of \"Hanmail\" (current Daum Mail), and also provides online community service \"Daum Cafe\" and news service \"Daum News\".", - "ko_KR": "다음(Daum)은 대한민국의 포털 사이트이다. \"한메일\"(현재의 다음 메일)이라는 이름으로 대한민국 최초의 웹 메일 서비스를 열었으며, 이 밖에도 온라인 커뮤니티 서비스 \"다음 카페\", 뉴스 서비스 \"다음 뉴스\" 등을 서비스하고 있다.", - "nl": "Daum (다음) is een Zuid-Koreaans webportaal. Het opende de eerste webmailservice in Korea onder de naam \"Hanmail\" (huidige Daum Mail), en biedt ook online gemeenschapsdienst \"Daum Cafe\" en nieuwsdienst \"Daum News\"." - }, - "url": "www.daum.net", - "regExp": "(top[.])?([a-z]+)([.]v)?[.]daum[.]([a-z0-9]+)", - "version": "1.0.27", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Daum/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Daum/assets/thumbnail.png", - "color": "#f4f7fb", - "category": "other", - "tags": [ - "daum", - "news", - "blog" - ], - "iframe": true, - "iFrameRegExp": ".*", - "settings": [ - { - "id": "timestamp", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "SlowLife", + "id": "374905512661221377" + }, + "service": "Daum", + "altnames": [ + "다음", + "다음 뉴스", + "다음 메일" + ], + "description": { + "en": "Daum (다음) is a South Korean web portal. It opened the first web mail service in Korea under the name of \"Hanmail\" (current Daum Mail), and also provides online community service \"Daum Cafe\" and news service \"Daum News\".", + "ko_KR": "다음(Daum)은 대한민국의 포털 사이트이다. \"한메일\"(현재의 다음 메일)이라는 이름으로 대한민국 최초의 웹 메일 서비스를 열었으며, 이 밖에도 온라인 커뮤니티 서비스 \"다음 카페\", 뉴스 서비스 \"다음 뉴스\" 등을 서비스하고 있다.", + "nl": "Daum (다음) is een Zuid-Koreaans webportaal. Het opende de eerste webmailservice in Korea onder de naam \"Hanmail\" (huidige Daum Mail), en biedt ook online gemeenschapsdienst \"Daum Cafe\" en nieuwsdienst \"Daum News\"." + }, + "url": "www.daum.net", + "regExp": "(top[.])?([a-z]+)([.]v)?[.]daum[.]([a-z0-9]+)", + "version": "1.0.27", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Daum/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Daum/assets/thumbnail.png", + "color": "#f4f7fb", + "category": "other", + "tags": [ + "daum", + "news", + "blog" + ], + "iframe": true, + "iFrameRegExp": ".*", + "settings": [ + { + "id": "timestamp", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/D/Daum/presence.ts b/websites/D/Daum/presence.ts index 9840376ad333..3db2465e49c2 100644 --- a/websites/D/Daum/presence.ts +++ b/websites/D/Daum/presence.ts @@ -1,497 +1,489 @@ class DaumPresence extends Presence { - constructor(presenceOptions: PresenceOptions) { - super(presenceOptions); - } - - get serviceName() { - const url = document.location.hostname; - - switch (true) { - case !!url.match(/movie([.]v)?[.]daum[.]([a-z0-9]+)/): - return "DAUM_MOVIE"; - case !!url.match(/news([.]v)?[.]daum[.]([a-z0-9]+)/): - return "DAUM_NEWS"; - case !!url.match(/sports([.]v)?[.]daum[.]([a-z0-9]+)/): - return "DAUM_SPORTS"; - case !!url.match(/entertain([.]v)?[.]daum[.]([a-z0-9]+)/): - return "DAUM_ENTERTAIN"; - case !!url.match(/blog([.]v)?[.]daum[.]([a-z0-9]+)/): - return "DAUM_BLOG"; - case !!url.match(/auto([.]v)?[.]daum[.]([a-z0-9]+)/): - return "DAUM_AUTO"; - case !!url.match(/mail([.]v)?[.]daum[.]([a-z0-9]+)/): - return "DAUM_MAIL"; - case !!url.match(/(top[.])?cafe([.]v)?[.]daum[.]([a-z0-9]+)/): - return "DAUM_CAFE"; - case !!url.match(/([a-z]+)([.]v)?[.]daum[.]([a-z0-9]+)/): - return "DAUM"; - default: - break; - } - } - - get isReadingArticle() { - return !!document.location.hostname.match( - /([a-z]+)([.]v)[.]daum[.]([a-z0-9]+)/ - ); - } + constructor(presenceOptions: PresenceOptions) { + super(presenceOptions) + } + + get serviceName() { + const url = document.location.hostname + + switch (true) { + case !!url.match(/movie(\.v)?\.daum\.([a-z0-9]+)/): + return 'DAUM_MOVIE' + case !!url.match(/news(\.v)?\.daum\.([a-z0-9]+)/): + return 'DAUM_NEWS' + case !!url.match(/sports(\.v)?\.daum\.([a-z0-9]+)/): + return 'DAUM_SPORTS' + case !!url.match(/entertain(\.v)?\.daum\.([a-z0-9]+)/): + return 'DAUM_ENTERTAIN' + case !!url.match(/blog(\.v)?\.daum\.([a-z0-9]+)/): + return 'DAUM_BLOG' + case !!url.match(/auto(\.v)?\.daum\.([a-z0-9]+)/): + return 'DAUM_AUTO' + case !!url.match(/mail(\.v)?\.daum\.([a-z0-9]+)/): + return 'DAUM_MAIL' + case !!url.match(/(top\.)?cafe(\.v)?\.daum\.([a-z0-9]+)/): + return 'DAUM_CAFE' + case !!url.match(/([a-z]+)(\.v)?\.daum\.([a-z0-9]+)/): + return 'DAUM' + default: + break + } + } + + get isReadingArticle() { + return !!document.location.hostname.match( + /([a-z]+)(\.v)\.daum\.([a-z0-9]+)/, + ) + } } const presence = new DaumPresence({ - clientId: "829266476875120650", - }), - data: { - settings?: { - id: string; - delete?: boolean; - data: string[]; - }[]; - presence: { - [key: string]: { - service: - | "DAUM" - | "DAUM_MOVIE" - | "DAUM_AUTO" - | "DAUM_NEWS" - | "DAUM_SPORTS" - | "DAUM_BLOG" - | "DAUM_MAIL" - | "DAUM_ENTERTAIN" - | "DAUM_CAFE" - | "ANY"; - href?: boolean; - hash?: boolean; - article?: boolean; - setPresenceData?: () => void; - }; - }; - } = { - presence: null, - }, - startTime = Math.floor(Date.now() / 1000); + clientId: '829266476875120650', +}) +const data: { + settings?: { + id: string + delete?: boolean + data: string[] + }[] + presence?: { + [key: string]: { + service: + | 'DAUM' + | 'DAUM_MOVIE' + | 'DAUM_AUTO' + | 'DAUM_NEWS' + | 'DAUM_SPORTS' + | 'DAUM_BLOG' + | 'DAUM_MAIL' + | 'DAUM_ENTERTAIN' + | 'DAUM_CAFE' + | 'ANY' + href?: boolean + hash?: boolean + article?: boolean + setPresenceData?: () => void + } + } +} = { + presence: undefined, +} +const startTime = Math.floor(Date.now() / 1000) let video: { - duration: number; - currentTime: number; - paused: boolean; - title?: string; - }, - cafe: { - name: string; - title: string; - article: string; - }; + duration: number + currentTime: number + paused: boolean + title?: string + }, + cafe: { + name: string + title: string + article: string + } const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Daum/assets/logo.png", - DaumMail = "https://cdn.rcd.gg/PreMiD/websites/D/Daum/assets/0.png", - DaumCafe = "https://cdn.rcd.gg/PreMiD/websites/D/Daum/assets/1.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Daum/assets/logo.png', + DaumMail = 'https://cdn.rcd.gg/PreMiD/websites/D/Daum/assets/0.png', + DaumCafe = 'https://cdn.rcd.gg/PreMiD/websites/D/Daum/assets/1.png', } presence.on( - "iFrameData", - (data: { video?: typeof video; cafe?: typeof cafe }) => { - if (data.video) ({ video } = data); - if (data.cafe) ({ cafe } = data); - } -); - -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: startTime, - }; - - switch (presence.serviceName) { - case "DAUM_MAIL": - presenceData.largeImageKey = Assets.DaumMail; - break; - - case "DAUM_CAFE": - presenceData.largeImageKey = Assets.DaumCafe; - break; - - default: - break; - } - - data.presence = { - "/v/([0-9a-zA-Z]+)": { - service: "ANY", - article: true, - setPresenceData() { - presenceData.details = "Reading article:"; - presenceData.state = document.querySelector("h3.tit_view")?.textContent; - - presenceData.buttons = [ - { - url: document.URL, - label: "Read Article", - }, - ]; - - if (video) { - presenceData.details = "Watching video:"; - presenceData.state = - video.title ?? document.querySelector("h3.tit_view")?.textContent; - - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Play; - presenceData.smallImageText = video.paused ? "Paused" : "Playing"; - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(video.currentTime, video.duration); - - presenceData.buttons = [ - { - label: "Watch Video", - url: document.URL, - }, - ]; - - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } - }, - }, - "/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)": { - service: "DAUM_BLOG", - setPresenceData() { - presenceData.details = "Reading blog:"; - presenceData.state = - document.querySelector("a.link-title")?.textContent; - - presenceData.buttons = [ - { - label: "Read Blog", - url: document.URL, - }, - ]; - }, - }, - "vod/view/([0-9a-zA-Z]+)": { - service: "DAUM_AUTO", - setPresenceData() { - presenceData.details = "Watching video:"; - presenceData.state = - document.querySelector("strong.tit_vod")?.textContent; - - presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video?.paused ? "Paused" : "Playing"; - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(video?.currentTime, video?.duration); - - presenceData.buttons = [ - { - label: "Watch Video", - url: document.URL, - }, - ]; - - if (video?.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - }, - }, - "/newcar/model/([0-9a-zA-Z]+)": { - service: "DAUM_AUTO", - setPresenceData() { - presenceData.details = "Viewing car:"; - presenceData.state = - document.querySelector("h3.tit_model")?.textContent; - - presenceData.buttons = [ - { - label: "View Car", - url: document.URL, - }, - ]; - }, - }, - "/moviedb/": { - service: "DAUM_MOVIE", - setPresenceData() { - presenceData.details = "Viewing movie:"; - presenceData.state = - document.querySelector("span.txt_tit")?.textContent; - - presenceData.buttons = [ - { - label: "View Movie", - url: document.URL, - }, - ]; - }, - }, - "/person/": { - service: "DAUM_MOVIE", - setPresenceData() { - presenceData.details = "Viewing actor:"; - presenceData.state = - document.querySelector("span.txt_tit")?.textContent; - - presenceData.buttons = [ - { - label: "View Actor", - url: document.URL, - }, - ]; - }, - }, - "/moviedb/contents": { - service: "DAUM_MOVIE", - setPresenceData() { - if (video) { - presenceData.details = "Watching video:"; - presenceData.state = - document.querySelector("strong.tit_player")?.textContent; - - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Play; - presenceData.smallImageText = video.paused ? "Paused" : "Playing"; - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(video.currentTime, video.duration); - - presenceData.buttons = [ - { - label: "Watch Video", - url: document.URL, - }, - ]; - - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } - }, - }, - "/video/([0-9a-zA-Z]+)": { - service: "DAUM_SPORTS", - setPresenceData() { - presenceData.details = "Watching video:"; - presenceData.state = - document.querySelector("strong.tit_vod")?.textContent; - - presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video?.paused ? "Paused" : "Playing"; - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(video?.currentTime, video?.duration); - - presenceData.buttons = [ - { - label: "Watch Video", - url: document.URL, - }, - ]; - - if (video?.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - }, - }, - "/tv/([0-9]+)/video/([0-9]+)": { - service: "DAUM_ENTERTAIN", - setPresenceData() { - presenceData.details = - video?.title ?? - document.querySelector("span.inner_tit2")?.textContent; - presenceData.state = document - .querySelector("a.link_txt") - ?.textContent.trim(); - - presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video?.paused ? "Paused" : "Playing"; - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(video?.currentTime, video?.duration); - - presenceData.buttons = [ - { - label: "Watch Video", - url: document.URL, - }, - { - label: "View Channel", - url: document.querySelector("a.link_txt")?.href, - }, - ]; - - if (video?.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - }, - }, - "#INBOX": { - service: "DAUM_MAIL", - hash: true, - setPresenceData() { - presenceData.details = "Viewing Inbox"; - }, - }, - "#INBOX/": { - service: "DAUM_MAIL", - hash: true, - setPresenceData() { - presenceData.details = "Reading mail"; - }, - }, - "#MINE": { - service: "DAUM_MAIL", - hash: true, - setPresenceData() { - presenceData.details = "Viewing Inbox"; - }, - }, - "#DRAFT": { - service: "DAUM_MAIL", - hash: true, - setPresenceData() { - presenceData.details = "Viewing drafts"; - }, - }, - "#SENT": { - service: "DAUM_MAIL", - hash: true, - setPresenceData() { - presenceData.details = "Viewing sent"; - }, - }, - "#TRASH": { - service: "DAUM_MAIL", - hash: true, - setPresenceData() { - presenceData.details = "Viewing trash"; - }, - }, - "#SPAM": { - service: "DAUM_MAIL", - hash: true, - setPresenceData() { - presenceData.details = "Viewing spam"; - }, - }, - "#ALL": { - service: "DAUM_MAIL", - hash: true, - setPresenceData() { - presenceData.details = "Viewing all mail"; - }, - }, - "#UNREAD": { - service: "DAUM_MAIL", - hash: true, - setPresenceData() { - presenceData.details = "Viewing unread mail"; - }, - }, - "#setting": { - service: "DAUM_MAIL", - hash: true, - setPresenceData() { - presenceData.details = "Viewing thier settings"; - }, - }, - "\\?composer": { - service: "DAUM_MAIL", - href: true, - setPresenceData() { - presenceData.details = "Composing a new mail"; - }, - }, - "/([a-zA-Z0-9]+)": { - service: "DAUM_CAFE", - setPresenceData() { - presenceData.details = "Viewing cafe:"; - presenceData.state = cafe.name ?? "Unknown"; - - presenceData.buttons = [ - { - label: "View Cafe", - url: document.URL, - }, - ]; - }, - }, - "/([0-9a-zA-Z]+)/([0-9A-Za-z]+)": { - service: "DAUM_CAFE", - setPresenceData() { - presenceData.details = "Viewing page:"; - presenceData.state = `${cafe.title ?? "Unknown"} • ${ - cafe.name ?? "Unknown" - }`; - - presenceData.buttons = [ - { - label: "View Page", - url: document.URL, - }, - ]; - }, - }, - "/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)": { - service: "DAUM_CAFE", - setPresenceData() { - presenceData.details = "Reading article:"; - presenceData.state = `${cafe.article ?? "Unknown"} • ${ - cafe.name ?? "Unknown" - }`; - - presenceData.buttons = [ - { - label: "Read Article", - url: document.URL, - }, - ]; - }, - }, - }; - - data.settings = [ - { - id: "timestamp", - delete: true, - data: ["startTimestamp", "endTimestamp"], - }, - { - id: "buttons", - delete: true, - data: ["buttons"], - }, - ]; - - for (const [pathname, PData] of Object.entries(data.presence)) { - if ( - (document.location.pathname.match(pathname) || - (PData.hash && document.location.hash.match(pathname)) || - (PData.href && document.location.href.match(pathname))) && - (PData.service === presence.serviceName || PData.service === "ANY") - ) { - if (PData.article && PData.article === presence.isReadingArticle) - PData.setPresenceData(); - else if (!PData.article) PData.setPresenceData(); - } - } - - for (const setting of data.settings) { - const settingValue = await presence.getSetting(setting.id); - - if (!settingValue && setting.delete) { - for (const PData of setting.data) - delete presenceData[PData as keyof PresenceData]; - } - } - - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); + 'iFrameData', + (inc: unknown) => { + const data = inc as { video?: typeof video, cafe?: typeof cafe } + if (data.video) + ({ video } = data) + if (data.cafe) + ({ cafe } = data) + }, +) + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: startTime, + } + + switch (presence.serviceName) { + case 'DAUM_MAIL': + presenceData.largeImageKey = Assets.DaumMail + break + + case 'DAUM_CAFE': + presenceData.largeImageKey = Assets.DaumCafe + break + + default: + break + } + + data.presence = { + '/v/([0-9a-zA-Z]+)': { + service: 'ANY', + article: true, + setPresenceData() { + presenceData.details = 'Reading article:' + presenceData.state = document.querySelector('h3.tit_view')?.textContent + + presenceData.buttons = [ + { + url: document.URL, + label: 'Read Article', + }, + ] + + if (video) { + presenceData.details = 'Watching video:' + presenceData.state = video.title ?? document.querySelector('h3.tit_view')?.textContent + + presenceData.smallImageKey = video.paused + ? Assets.Pause + : Assets.Play + presenceData.smallImageText = video.paused ? 'Paused' : 'Playing'; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(video.currentTime, video.duration) + + presenceData.buttons = [ + { + label: 'Watch Video', + url: document.URL, + }, + ] + + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + }, + }, + '/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)': { + service: 'DAUM_BLOG', + setPresenceData() { + presenceData.details = 'Reading blog:' + presenceData.state = document.querySelector('a.link-title')?.textContent + + presenceData.buttons = [ + { + label: 'Read Blog', + url: document.URL, + }, + ] + }, + }, + 'vod/view/([0-9a-zA-Z]+)': { + service: 'DAUM_AUTO', + setPresenceData() { + presenceData.details = 'Watching video:' + presenceData.state = document.querySelector('strong.tit_vod')?.textContent + + presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video?.paused ? 'Paused' : 'Playing'; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(video?.currentTime, video?.duration) + + presenceData.buttons = [ + { + label: 'Watch Video', + url: document.URL, + }, + ] + + if (video?.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + }, + }, + '/newcar/model/([0-9a-zA-Z]+)': { + service: 'DAUM_AUTO', + setPresenceData() { + presenceData.details = 'Viewing car:' + presenceData.state = document.querySelector('h3.tit_model')?.textContent + + presenceData.buttons = [ + { + label: 'View Car', + url: document.URL, + }, + ] + }, + }, + '/moviedb/': { + service: 'DAUM_MOVIE', + setPresenceData() { + presenceData.details = 'Viewing movie:' + presenceData.state = document.querySelector('span.txt_tit')?.textContent + + presenceData.buttons = [ + { + label: 'View Movie', + url: document.URL, + }, + ] + }, + }, + '/person/': { + service: 'DAUM_MOVIE', + setPresenceData() { + presenceData.details = 'Viewing actor:' + presenceData.state = document.querySelector('span.txt_tit')?.textContent + + presenceData.buttons = [ + { + label: 'View Actor', + url: document.URL, + }, + ] + }, + }, + '/moviedb/contents': { + service: 'DAUM_MOVIE', + setPresenceData() { + if (video) { + presenceData.details = 'Watching video:' + presenceData.state = document.querySelector('strong.tit_player')?.textContent + + presenceData.smallImageKey = video.paused + ? Assets.Pause + : Assets.Play + presenceData.smallImageText = video.paused ? 'Paused' : 'Playing'; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(video.currentTime, video.duration) + + presenceData.buttons = [ + { + label: 'Watch Video', + url: document.URL, + }, + ] + + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + }, + }, + '/video/([0-9a-zA-Z]+)': { + service: 'DAUM_SPORTS', + setPresenceData() { + presenceData.details = 'Watching video:' + presenceData.state = document.querySelector('strong.tit_vod')?.textContent + + presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video?.paused ? 'Paused' : 'Playing'; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(video?.currentTime, video?.duration) + + presenceData.buttons = [ + { + label: 'Watch Video', + url: document.URL, + }, + ] + + if (video?.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + }, + }, + '/tv/([0-9]+)/video/([0-9]+)': { + service: 'DAUM_ENTERTAIN', + setPresenceData() { + presenceData.details = video?.title + ?? document.querySelector('span.inner_tit2')?.textContent + presenceData.state = document + .querySelector('a.link_txt') + ?.textContent + ?.trim() + + presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video?.paused ? 'Paused' : 'Playing'; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(video?.currentTime, video?.duration) + + presenceData.buttons = [ + { + label: 'Watch Video', + url: document.URL, + }, + { + label: 'View Channel', + url: document.querySelector('a.link_txt')!.href, + }, + ] + + if (video?.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + }, + }, + '#INBOX': { + service: 'DAUM_MAIL', + hash: true, + setPresenceData() { + presenceData.details = 'Viewing Inbox' + }, + }, + '#INBOX/': { + service: 'DAUM_MAIL', + hash: true, + setPresenceData() { + presenceData.details = 'Reading mail' + }, + }, + '#MINE': { + service: 'DAUM_MAIL', + hash: true, + setPresenceData() { + presenceData.details = 'Viewing Inbox' + }, + }, + '#DRAFT': { + service: 'DAUM_MAIL', + hash: true, + setPresenceData() { + presenceData.details = 'Viewing drafts' + }, + }, + '#SENT': { + service: 'DAUM_MAIL', + hash: true, + setPresenceData() { + presenceData.details = 'Viewing sent' + }, + }, + '#TRASH': { + service: 'DAUM_MAIL', + hash: true, + setPresenceData() { + presenceData.details = 'Viewing trash' + }, + }, + '#SPAM': { + service: 'DAUM_MAIL', + hash: true, + setPresenceData() { + presenceData.details = 'Viewing spam' + }, + }, + '#ALL': { + service: 'DAUM_MAIL', + hash: true, + setPresenceData() { + presenceData.details = 'Viewing all mail' + }, + }, + '#UNREAD': { + service: 'DAUM_MAIL', + hash: true, + setPresenceData() { + presenceData.details = 'Viewing unread mail' + }, + }, + '#setting': { + service: 'DAUM_MAIL', + hash: true, + setPresenceData() { + presenceData.details = 'Viewing thier settings' + }, + }, + '\\?composer': { + service: 'DAUM_MAIL', + href: true, + setPresenceData() { + presenceData.details = 'Composing a new mail' + }, + }, + '/([a-zA-Z0-9]+)': { + service: 'DAUM_CAFE', + setPresenceData() { + presenceData.details = 'Viewing cafe:' + presenceData.state = cafe.name ?? 'Unknown' + + presenceData.buttons = [ + { + label: 'View Cafe', + url: document.URL, + }, + ] + }, + }, + '/([0-9a-zA-Z]+)/([0-9A-Za-z]+)': { + service: 'DAUM_CAFE', + setPresenceData() { + presenceData.details = 'Viewing page:' + presenceData.state = `${cafe.title ?? 'Unknown'} • ${ + cafe.name ?? 'Unknown' + }` + + presenceData.buttons = [ + { + label: 'View Page', + url: document.URL, + }, + ] + }, + }, + '/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)': { + service: 'DAUM_CAFE', + setPresenceData() { + presenceData.details = 'Reading article:' + presenceData.state = `${cafe.article ?? 'Unknown'} • ${ + cafe.name ?? 'Unknown' + }` + + presenceData.buttons = [ + { + label: 'Read Article', + url: document.URL, + }, + ] + }, + }, + } + + data.settings = [ + { + id: 'timestamp', + delete: true, + data: ['startTimestamp', 'endTimestamp'], + }, + { + id: 'buttons', + delete: true, + data: ['buttons'], + }, + ] + + for (const [pathname, PData] of Object.entries(data.presence)) { + if ( + (document.location.pathname.match(pathname) + || (PData.hash && document.location.hash.match(pathname)) + || (PData.href && document.location.href.match(pathname))) + && (PData.service === presence.serviceName || PData.service === 'ANY') + ) { + if (PData.article && PData.article === presence.isReadingArticle) + PData.setPresenceData?.() + else if (!PData.article) + PData.setPresenceData?.() + } + } + + for (const setting of data.settings) { + const settingValue = await presence.getSetting(setting.id) + + if (!settingValue && setting.delete) { + for (const PData of setting.data) + delete presenceData[PData as keyof PresenceData] + } + } + + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/D/Deconreconstruction/metadata.json b/websites/D/Deconreconstruction/metadata.json index 7ad1f18a3abf..ab6ed84694f5 100644 --- a/websites/D/Deconreconstruction/metadata.json +++ b/websites/D/Deconreconstruction/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "john", - "id": "156937406375919616" - }, - "service": "Deconreconstruction", - "description": { - "en": "The hub site for the webcomic Vast Error and its spinoff projects." - }, - "url": [ - "www.deconreconstruction.com", - "deconreconstruction.com" - ], - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/thumbnail.png", - "color": "#000000", - "category": "other", - "tags": [ - "webcomic", - "comic", - "vast-error", - "snowbound-blood", - "thaumatrope", - "mspaintadventures" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "john", + "id": "156937406375919616" + }, + "service": "Deconreconstruction", + "description": { + "en": "The hub site for the webcomic Vast Error and its spinoff projects." + }, + "url": [ + "www.deconreconstruction.com", + "deconreconstruction.com" + ], + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/thumbnail.png", + "color": "#000000", + "category": "other", + "tags": [ + "webcomic", + "comic", + "vast-error", + "snowbound-blood", + "thaumatrope", + "mspaintadventures" + ] +} diff --git a/websites/D/Deconreconstruction/presence.ts b/websites/D/Deconreconstruction/presence.ts index 103146300381..5da2969f28c1 100644 --- a/websites/D/Deconreconstruction/presence.ts +++ b/websites/D/Deconreconstruction/presence.ts @@ -1,154 +1,147 @@ const presence = new Presence({ - clientId: "945791824147128341", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); - -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/0.png", - startTimestamp: browsingTimestamp, - }, - { href, pathname } = document.location, - pathArr = pathname.split("/"); - - switch (pathArr[1]) { - case "": - presenceData.details = "Viewing the home page"; - break; - - case "vasterror": - switch (pathArr[2]) { - case "adventuremap": - presenceData.details = "Viewing the adventure map"; - break; - - case "credits": - presenceData.details = "Viewing the credits"; - break; - - case "log": - presenceData.details = "Viewing the Vast Error log"; - break; - - default: - presenceData.details = "Reading Vast Error"; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/1.png"; - presenceData.state = `Page ${pathArr[2]} of ${vePages}`; - presenceData.smallImageText = - document.querySelector("#command").textContent; - presenceData.buttons = [ - { - label: "Read Along", - url: href, - }, - ]; - break; - } - break; - - case "thaumatrope": - switch (pathArr[2]) { - case "syzygy": - presenceData.details = "Reading Thaumatrope: Syzygy"; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/2.png"; - presenceData.state = `Page ${pathArr[3]} of 162`; - presenceData.smallImageText = - document.querySelector("#command").textContent; - presenceData.buttons = [ - { - label: "Read Along", - url: href, - }, - ]; - break; - - case "haustoria": - presenceData.details = "Reading Thaumatrope: Haustoria"; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/2.png"; - presenceData.state = `Page ${pathArr[3]} of ${htPages}`; - presenceData.smallImageText = - document.querySelector("#command").textContent; - presenceData.buttons = [ - { - label: "Read Along", - url: href, - }, - ]; - break; - - case "log": - presenceData.details = "Viewing the Thaumatrope log"; - break; - - default: - presenceData.details = "Viewing an unsupported page"; - break; - } - break; - - case "bonus": - switch (pathArr[2]) { - case "april-fools-day-2017": - presenceData.details = "Reading April Fools 2017"; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/3.png"; - presenceData.state = `Page ${pathArr[3]} of 4`; - presenceData.smallImageText = - document.querySelector("#command").textContent; - presenceData.buttons = [ - { - label: "Read Along", - url: href, - }, - ]; - break; - - case "recap": - presenceData.details = "Viewing the Act 1 recap"; - break; - - case "revised": - presenceData.details = "Viewing revised pages"; - break; - - default: - presenceData.details = "Viewing bonus content"; - break; - } - break; - - default: - presenceData.details = "Viewing an unsupported page"; - break; - } - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); + clientId: '945791824147128341', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) + +let vePages: string, htPages: string + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/0.png', + startTimestamp: browsingTimestamp, + } + const { href, pathname } = document.location + const pathArr = pathname.split('/') + + switch (pathArr[1]) { + case '': + presenceData.details = 'Viewing the home page' + break + + case 'vasterror': + switch (pathArr[2]) { + case 'adventuremap': + presenceData.details = 'Viewing the adventure map' + break + + case 'credits': + presenceData.details = 'Viewing the credits' + break + + case 'log': + presenceData.details = 'Viewing the Vast Error log' + break + + default: + presenceData.details = 'Reading Vast Error' + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/1.png' + presenceData.state = `Page ${pathArr[2]} of ${vePages}` + presenceData.smallImageText = document.querySelector('#command')?.textContent + presenceData.buttons = [ + { + label: 'Read Along', + url: href, + }, + ] + break + } + break + + case 'thaumatrope': + switch (pathArr[2]) { + case 'syzygy': + presenceData.details = 'Reading Thaumatrope: Syzygy' + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/2.png' + presenceData.state = `Page ${pathArr[3]} of 162` + presenceData.smallImageText = document.querySelector('#command')?.textContent + presenceData.buttons = [ + { + label: 'Read Along', + url: href, + }, + ] + break + + case 'haustoria': + presenceData.details = 'Reading Thaumatrope: Haustoria' + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/2.png' + presenceData.state = `Page ${pathArr[3]} of ${htPages}` + presenceData.smallImageText = document.querySelector('#command')?.textContent + presenceData.buttons = [ + { + label: 'Read Along', + url: href, + }, + ] + break + + case 'log': + presenceData.details = 'Viewing the Thaumatrope log' + break + + default: + presenceData.details = 'Viewing an unsupported page' + break + } + break + + case 'bonus': + switch (pathArr[2]) { + case 'april-fools-day-2017': + presenceData.details = 'Reading April Fools 2017' + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Deconreconstruction/assets/3.png' + presenceData.state = `Page ${pathArr[3]} of 4` + presenceData.smallImageText = document.querySelector('#command')?.textContent + presenceData.buttons = [ + { + label: 'Read Along', + url: href, + }, + ] + break + + case 'recap': + presenceData.details = 'Viewing the Act 1 recap' + break + + case 'revised': + presenceData.details = 'Viewing revised pages' + break + + default: + presenceData.details = 'Viewing bonus content' + break + } + break + + default: + presenceData.details = 'Viewing an unsupported page' + break + } + + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() }); -let vePages: string, htPages: string; (function () { - function getPages() { - if (document.location.pathname.match(/^\/vasterror\/\d+$/)) { - fetch( - "https://api.deconreconstruction.com/pages/count?story.name=vast-error&published_at_null=false" - ).then(async res => { - vePages = await res.json(); - }); - } - - if (document.location.pathname.match(/^\/thaumatrope\/haustoria\/\d+$/)) { - fetch( - "https://api.deconreconstruction.com/pages/count?story.name=thaumatrope/haustoria&published_at_null=false" - ).then(async res => { - htPages = await res.json(); - }); - } - } - getPages(); - setInterval(getPages, 60000); -})(); + function getPages() { + if (document.location.pathname.match(/^\/vasterror\/\d+$/)) { + fetch( + 'https://api.deconreconstruction.com/pages/count?story.name=vast-error&published_at_null=false', + ).then(async (res) => { + vePages = await res.json() + }) + } + + if (document.location.pathname.match(/^\/thaumatrope\/haustoria\/\d+$/)) { + fetch( + 'https://api.deconreconstruction.com/pages/count?story.name=thaumatrope/haustoria&published_at_null=false', + ).then(async (res) => { + htPages = await res.json() + }) + } + } + getPages() + setInterval(getPages, 60000) +})() diff --git a/websites/D/DeepL/metadata.json b/websites/D/DeepL/metadata.json index 1864903f7809..a3c758e1d0fe 100644 --- a/websites/D/DeepL/metadata.json +++ b/websites/D/DeepL/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "CRUGG", - "id": "228965621478588416" - }, - "service": "DeepL", - "description": { - "en": "DeepL lets you translate texts to other languages using an artificial intelligence. One of the most special features of it is, that you're able to click a word to be able to replace it with another word you think would fit more. All in all, DeepL is pretty useful for quickly translating large texts to a language you already know, but not too much, for languages you don't know.", - "de": "DeepL ermöglicht es dir, Texte mit Hilfe einer künstlichen Intelligenz in andere Sprachen zu übersetzen. Eine der besonderen Eigenschaften ist, dass du auf ein Wort klicken kannst, um es durch ein anderes Wort zu ersetzen, von welchem du denkst, dass es mehr passen würde. Alles in allem ist DeepL sehr nützlich, um große Texte schnell in eine Sprache zu übersetzen, die man bereits kennt, aber nicht allzu viel, für Sprachen, die man nicht beherrscht.", - "nl": "Met DeepL kunt u teksten naar andere talen vertalen met behulp van kunstmatige intelligentie. Een van de meest bijzondere kenmerken ervan is dat u op een woord kunt klikken om het te vervangen door een ander woord waarvan u denkt dat het beter past. Al met al is DeepL best handig voor het snel vertalen van grote teksten naar een taal die u al kent, maar niet te veel, voor talen die u niet kent." - }, - "url": "www.deepl.com", - "version": "1.1.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DeepL/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DeepL/assets/thumbnail.png", - "color": "#042B48", - "category": "other", - "tags": [ - "translation", - "international" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "CRUGG", + "id": "228965621478588416" + }, + "service": "DeepL", + "description": { + "en": "DeepL lets you translate texts to other languages using an artificial intelligence. One of the most special features of it is, that you're able to click a word to be able to replace it with another word you think would fit more. All in all, DeepL is pretty useful for quickly translating large texts to a language you already know, but not too much, for languages you don't know.", + "de": "DeepL ermöglicht es dir, Texte mit Hilfe einer künstlichen Intelligenz in andere Sprachen zu übersetzen. Eine der besonderen Eigenschaften ist, dass du auf ein Wort klicken kannst, um es durch ein anderes Wort zu ersetzen, von welchem du denkst, dass es mehr passen würde. Alles in allem ist DeepL sehr nützlich, um große Texte schnell in eine Sprache zu übersetzen, die man bereits kennt, aber nicht allzu viel, für Sprachen, die man nicht beherrscht.", + "nl": "Met DeepL kunt u teksten naar andere talen vertalen met behulp van kunstmatige intelligentie. Een van de meest bijzondere kenmerken ervan is dat u op een woord kunt klikken om het te vervangen door een ander woord waarvan u denkt dat het beter past. Al met al is DeepL best handig voor het snel vertalen van grote teksten naar een taal die u al kent, maar niet te veel, voor talen die u niet kent." + }, + "url": "www.deepl.com", + "version": "1.1.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DeepL/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DeepL/assets/thumbnail.png", + "color": "#042B48", + "category": "other", + "tags": [ + "translation", + "international" + ] +} diff --git a/websites/D/DeepL/presence.ts b/websites/D/DeepL/presence.ts index b81eaab5b6f7..ff8e6bbc06c2 100644 --- a/websites/D/DeepL/presence.ts +++ b/websites/D/DeepL/presence.ts @@ -1,21 +1,18 @@ const presence = new Presence({ - clientId: "614903529240395782", -}); + clientId: '614903529240395782', +}) -presence.on("UpdateData", async () => { - if (document.location.pathname === "/translator") { - presence.setActivity({ - details: - document.querySelectorAll(".translate_from")[0].parentNode.textContent, - state: - document.querySelectorAll(".translate_to")[0].parentNode.textContent, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DeepL/assets/logo.png", - }); - } else { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DeepL/assets/logo.png", - }); - } -}); +presence.on('UpdateData', async () => { + if (document.location.pathname === '/translator') { + presence.setActivity({ + details: document.querySelectorAll('.translate_from')[0]?.parentNode?.textContent, + state: document.querySelectorAll('.translate_to')[0]?.parentNode?.textContent, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DeepL/assets/logo.png', + }) + } + else { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DeepL/assets/logo.png', + }) + } +}) diff --git a/websites/D/Deezer/metadata.json b/websites/D/Deezer/metadata.json index 62681f053d58..e5b75f7118e4 100644 --- a/websites/D/Deezer/metadata.json +++ b/websites/D/Deezer/metadata.json @@ -1,60 +1,60 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Striker", - "id": "215509157837537280" - }, - "contributors": [ - { - "name": "Encrypted", - "id": "564434085708038144" - } - ], - "service": "Deezer", - "description": { - "en": "Listen to all the songs you love anytime, anywhere.", - "de": "Höre dir all die Songs an, die du liebst. Jederzeit und überall.", - "ro": "Ascultă toate melodiile iubite, oricând, oriunde.", - "pt_BR": "Escute todas as músicas que você ama a qualquer hora, em qualquer lugar.", - "fr": "Écoutez toutes les musiques que vous aimez quand vous voulez, où vous voulez.", - "uk_UA": "Слухайте улюблену музику у будь-який час будь-де.", - "nl": "Luister altijd en overal naar alle nummers waar je van houdt.", - "vi_VN": "Nghe tất cả những bài hát bạn yêu thích mọi lúc, mọi nơi.", - "ga_IE": "Éifeall na ceimhniú a thágthóg, uair éirinn." - }, - "url": "www.deezer.com", - "version": "2.3.7", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Deezer/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Deezer/assets/thumbnail.png", - "color": "#a238ff", - "category": "music", - "tags": [ - "radio", - "music" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - }, - { - "id": "cover", - "title": "Show Cover", - "icon": "fad fa-images", - "value": true - }, - { - "id": "browseInfo", - "title": "Only show browsing info", - "icon": "fad fa-magnifying-glass", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Striker", + "id": "215509157837537280" + }, + "contributors": [ + { + "name": "Encrypted", + "id": "564434085708038144" + } + ], + "service": "Deezer", + "description": { + "en": "Listen to all the songs you love anytime, anywhere.", + "de": "Höre dir all die Songs an, die du liebst. Jederzeit und überall.", + "ro": "Ascultă toate melodiile iubite, oricând, oriunde.", + "pt_BR": "Escute todas as músicas que você ama a qualquer hora, em qualquer lugar.", + "fr": "Écoutez toutes les musiques que vous aimez quand vous voulez, où vous voulez.", + "uk_UA": "Слухайте улюблену музику у будь-який час будь-де.", + "nl": "Luister altijd en overal naar alle nummers waar je van houdt.", + "vi_VN": "Nghe tất cả những bài hát bạn yêu thích mọi lúc, mọi nơi.", + "ga_IE": "Éifeall na ceimhniú a thágthóg, uair éirinn." + }, + "url": "www.deezer.com", + "version": "2.3.7", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Deezer/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Deezer/assets/thumbnail.png", + "color": "#a238ff", + "category": "music", + "tags": [ + "radio", + "music" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + }, + { + "id": "cover", + "title": "Show Cover", + "icon": "fad fa-images", + "value": true + }, + { + "id": "browseInfo", + "title": "Only show browsing info", + "icon": "fad fa-magnifying-glass", + "value": false + } + ] +} diff --git a/websites/D/Deezer/presence.ts b/websites/D/Deezer/presence.ts index e94d85a70eae..07c394c70ea4 100644 --- a/websites/D/Deezer/presence.ts +++ b/websites/D/Deezer/presence.ts @@ -1,161 +1,165 @@ const presence = new Presence({ - clientId: "607651992567021580", -}); + clientId: '607651992567021580', +}) -let oldLang: string = null; +let oldLang: string | null = null const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Deezer/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Deezer/assets/logo.png', } function fullURL(originalURL: string, hostname: string) { - if (!originalURL) return ""; - else if (originalURL?.includes("https")) return originalURL; - else if (originalURL.startsWith("/")) - return `https://${hostname}${originalURL}`; - else return ""; + if (!originalURL) + return '' + else if (originalURL?.includes('https')) + return originalURL + else if (originalURL.startsWith('/')) + return `https://${hostname}${originalURL}` + else return '' } async function getStrings() { - return presence.getStrings( - { - play: "general.playing", - pause: "general.paused", - viewAlbum: "general.buttonViewAlbum", - viewArtist: "general.buttonViewArtist", - viewPodcast: "general.buttonViewPodcast", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + play: 'general.playing', + pause: 'general.paused', + viewAlbum: 'general.buttonViewAlbum', + viewArtist: 'general.buttonViewArtist', + viewPodcast: 'general.buttonViewPodcast', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }, - strings = await getStrings(), - paused = false; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } + let strings = await getStrings() + let paused = false - const [buttons, newLang, cover, browseInfo] = await Promise.all([ - presence.getSetting("buttons"), - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("cover"), - presence.getSetting("browseInfo"), - ]), - { pathname, hostname } = document.location, - remainingTest = document.querySelector( - '[data-testid="remaining_time"]' - )?.textContent; + const [buttons, newLang, cover, browseInfo] = await Promise.all([ + presence.getSetting('buttons'), + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('cover'), + presence.getSetting('browseInfo'), + ]) + const { pathname, hostname } = document.location + const remainingTest = document.querySelector( + '[data-testid="remaining_time"]', + )?.textContent - if (oldLang !== newLang || !oldLang) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !oldLang) { + oldLang = newLang + strings = await getStrings() + } - const pages: Record = { - shows: { - details: "Browsing shows", - }, - channels: { - details: "Browsing channels", - }, - loved: { - details: "Browsing user's loved", - }, - playlists: { - details: "Browsing user's playlists", - }, - albums: { - details: "Browsing user's albums", - }, - artists: { - details: "Browsing user's artists", - }, - podcasts: { - details: "Browsing user's podcasts", - }, - show: { - details: "Viewing a podcast", - }, - playlist: { - details: "Looking at a playlist", - }, - album: { - details: "Looking at an album", - }, - artist: { - details: "Looking at an artist", - }, - }; - for (const [path, data] of Object.entries(pages)) { - if (pathname.includes(path)) { - presenceData = { ...presenceData, ...data }; - if (browseInfo || !remainingTest || remainingTest === "00:00") - return presence.setActivity(presenceData); - } - } + const pages: Record = { + shows: { + details: 'Browsing shows', + }, + channels: { + details: 'Browsing channels', + }, + loved: { + details: 'Browsing user\'s loved', + }, + playlists: { + details: 'Browsing user\'s playlists', + }, + albums: { + details: 'Browsing user\'s albums', + }, + artists: { + details: 'Browsing user\'s artists', + }, + podcasts: { + details: 'Browsing user\'s podcasts', + }, + show: { + details: 'Viewing a podcast', + }, + playlist: { + details: 'Looking at a playlist', + }, + album: { + details: 'Looking at an album', + }, + artist: { + details: 'Looking at an artist', + }, + } + for (const [path, data] of Object.entries(pages)) { + if (pathname.includes(path)) { + presenceData = { ...presenceData, ...data } as PresenceData + if (browseInfo || !remainingTest || remainingTest === '00:00') + return presence.setActivity(presenceData) + } + } - const albumLink = document - .querySelector('[data-testid="item_title"] > a') - ?.getAttribute("href"), - artistLink = document - .querySelector('[data-testid="item_subtitle"] > a') - ?.getAttribute("href"), - timestamps = presence.getTimestamps( - presence.timestampFromFormat( - document.querySelector('[data-testid="elapsed_time"]').textContent - ), - presence.timestampFromFormat( - document.querySelector('[data-testid="remaining_time"]').textContent - ) - ); + const albumLink = document + .querySelector('[data-testid="item_title"] > a') + ?.getAttribute('href') + const artistLink = document + .querySelector('[data-testid="item_subtitle"] > a') + ?.getAttribute('href') + const timestamps = presence.getTimestamps( + presence.timestampFromFormat( + document.querySelector('[data-testid="elapsed_time"]')?.textContent ?? '', + ), + presence.timestampFromFormat( + document.querySelector('[data-testid="remaining_time"]')?.textContent ?? '', + ), + ) - if (document.querySelector('[data-testid="play_button_play"]')) paused = true; + if (document.querySelector('[data-testid="play_button_play"]')) + paused = true - presenceData.details = document.querySelector( - '[data-testid="item_title"]' - ).textContent; - presenceData.state = document.querySelector( - '[data-testid="item_subtitle"]' - ).textContent; + presenceData.details = document.querySelector( + '[data-testid="item_title"]', + )?.textContent + presenceData.state = document.querySelector( + '[data-testid="item_subtitle"]', + )?.textContent - presenceData.largeImageKey = cover - ? document - .querySelector('[data-testid="item_cover"]') - ?.querySelector("img") - ?.getAttribute("src") - ?.replace(/(264x264)|(48x48)/g, "512x512") ?? Assets.Logo - : Assets.Logo; - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = paused ? strings.pause : strings.play; - [presenceData.startTimestamp, presenceData.endTimestamp] = timestamps; + presenceData.largeImageKey = cover + ? document + .querySelector('[data-testid="item_cover"]') + ?.querySelector('img') + ?.getAttribute('src') + ?.replace(/(264x264)|(48x48)/g, '512x512') ?? Assets.Logo + : Assets.Logo + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = paused ? strings.pause : strings.play; + [presenceData.startTimestamp, presenceData.endTimestamp] = timestamps - if (paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } + if (paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } - if (buttons) { - if (albumLink?.includes("/")) { - presenceData.buttons = [ - { - label: strings.viewArtist, - url: fullURL(artistLink, hostname), - }, - { - label: strings.viewAlbum, - url: fullURL(albumLink, hostname), - }, - ]; - } else { - presenceData.buttons = [ - { - label: strings.viewPodcast, - url: fullURL(artistLink, hostname), - }, - ]; - } - } + if (buttons) { + if (albumLink?.includes('/')) { + presenceData.buttons = [ + { + label: strings.viewArtist, + url: fullURL(artistLink!, hostname), + }, + { + label: strings.viewAlbum, + url: fullURL(albumLink, hostname), + }, + ] + } + else { + presenceData.buttons = [ + { + label: strings.viewPodcast, + url: fullURL(artistLink!, hostname), + }, + ] + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/D/Defly.io/metadata.json b/websites/D/Defly.io/metadata.json index 70ff511c9162..981f656ec567 100644 --- a/websites/D/Defly.io/metadata.json +++ b/websites/D/Defly.io/metadata.json @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Apodemus", - "id": "223817321695674371" - }, - "service": "Defly.io", - "description": { - "en": "Fly your helicopter and shoot at enemies. Build walls to protect yourself and conquer as much territory as possible.", - "nl": "Vlieg met je helikopter en schiet op vijanden. Bouw muren om jezelf te beschermen en verover zo veel mogelijk grondgebied." - }, - "url": "defly.io", - "version": "1.2.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Defly.io/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Defly.io/assets/thumbnail.png", - "color": "#3D5DFF", - "category": "games", - "tags": [ - "game", - "defly", - "multiplayer", - "defly-io", - "browser-game" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Apodemus", + "id": "223817321695674371" + }, + "service": "Defly.io", + "description": { + "en": "Fly your helicopter and shoot at enemies. Build walls to protect yourself and conquer as much territory as possible.", + "nl": "Vlieg met je helikopter en schiet op vijanden. Bouw muren om jezelf te beschermen en verover zo veel mogelijk grondgebied." + }, + "url": "defly.io", + "version": "1.2.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Defly.io/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Defly.io/assets/thumbnail.png", + "color": "#3D5DFF", + "category": "games", + "tags": [ + "game", + "defly", + "multiplayer", + "defly-io", + "browser-game" + ] +} diff --git a/websites/D/Defly.io/presence.ts b/websites/D/Defly.io/presence.ts index 3e73421b036d..7ace4522a22f 100644 --- a/websites/D/Defly.io/presence.ts +++ b/websites/D/Defly.io/presence.ts @@ -1,35 +1,43 @@ const presence = new Presence({ - clientId: "685054359200858241", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '685054359200858241', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Defly.io/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Defly.io/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (document.location.pathname.includes("/gamemode-rules")) - presenceData.details = "Viewing the game rules"; - else if (document.location.pathname.includes("/changelog")) - presenceData.details = "Viewing the change log"; - else if (document.location.pathname === "/") { - if (document.location.href.includes("#0")) { - presenceData.details = "Playing FFA mode"; - presenceData.state = `on server: ${document.location.href.split("#")[1]}`; - } else if (document.location.href.includes("#1")) { - presenceData.details = "Playing TEAM mode"; - presenceData.state = `on server: ${document.location.href.split("#")[1]}`; - } else if (document.location.href.includes("#2")) { - presenceData.details = "Playing DEFUSE mode"; - presenceData.state = `on server: ${document.location.href.split("#")[1]}`; - } else if (document.location.href.includes("#3")) { - presenceData.details = "Playing E-FFA mode"; - presenceData.state = `on server: ${document.location.href.split("#")[1]}`; - } else presenceData.details = "Viewing home page"; - } + if (document.location.pathname.includes('/gamemode-rules')) { + presenceData.details = 'Viewing the game rules' + } + else if (document.location.pathname.includes('/changelog')) { + presenceData.details = 'Viewing the change log' + } + else if (document.location.pathname === '/') { + if (document.location.href.includes('#0')) { + presenceData.details = 'Playing FFA mode' + presenceData.state = `on server: ${document.location.href.split('#')[1]}` + } + else if (document.location.href.includes('#1')) { + presenceData.details = 'Playing TEAM mode' + presenceData.state = `on server: ${document.location.href.split('#')[1]}` + } + else if (document.location.href.includes('#2')) { + presenceData.details = 'Playing DEFUSE mode' + presenceData.state = `on server: ${document.location.href.split('#')[1]}` + } + else if (document.location.href.includes('#3')) { + presenceData.details = 'Playing E-FFA mode' + presenceData.state = `on server: ${document.location.href.split('#')[1]}` + } + else { + presenceData.details = 'Viewing home page' + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Dek-d/metadata.json b/websites/D/Dek-d/metadata.json index 3f3b695ce9ed..daaf74da725d 100644 --- a/websites/D/Dek-d/metadata.json +++ b/websites/D/Dek-d/metadata.json @@ -1,28 +1,28 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "302616090461077514", - "name": "puppiesa" - }, - "service": "Dek-d", - "altnames": [ - "เด็กดี", - "dekd" - ], - "description": { - "th": "พบปะเพื่อนวัยรุ่นจากทั่วประเทศไทยด้วยกันที่นี่ กับเรื่องสนุกๆ บอร์ด นิยาย แฟชั่น ไลฟ์สไตล์ บันเทิง การศึกษา แอดมิชชั่น เรียนต่อนอก ที่สร้างขึ้นสำหรับวัยรุ่นโดยเฉพาะ.", - "en": "Dek-D.com is a popular Thai online platform that serves as a hub for teenagers and young adults. The website offers a variety of features and content, including Educational Resources, Creative Writing Community, University Admissions Tools (TCAS), Interactive Forums and Social Features" - }, - "url": "www.dek-d.com", - "regExp": "([a-z0-9-]+[.])*dek-d[.]com[/]", - "version": "1.0.1", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dek-d/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dek-d/assets/thumbnail.jpeg", - "color": "#F37A01", - "category": "other", - "tags": [ - "forum", - "novels" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "302616090461077514", + "name": "puppiesa" + }, + "service": "Dek-d", + "altnames": [ + "เด็กดี", + "dekd" + ], + "description": { + "th": "พบปะเพื่อนวัยรุ่นจากทั่วประเทศไทยด้วยกันที่นี่ กับเรื่องสนุกๆ บอร์ด นิยาย แฟชั่น ไลฟ์สไตล์ บันเทิง การศึกษา แอดมิชชั่น เรียนต่อนอก ที่สร้างขึ้นสำหรับวัยรุ่นโดยเฉพาะ.", + "en": "Dek-D.com is a popular Thai online platform that serves as a hub for teenagers and young adults. The website offers a variety of features and content, including Educational Resources, Creative Writing Community, University Admissions Tools (TCAS), Interactive Forums and Social Features" + }, + "url": "www.dek-d.com", + "regExp": "([a-z0-9-]+[.])*dek-d[.]com[/]", + "version": "1.0.1", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dek-d/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dek-d/assets/thumbnail.jpeg", + "color": "#F37A01", + "category": "other", + "tags": [ + "forum", + "novels" + ] +} diff --git a/websites/D/Dek-d/presence.ts b/websites/D/Dek-d/presence.ts index 728f225e233a..efb1eb7fe9f5 100644 --- a/websites/D/Dek-d/presence.ts +++ b/websites/D/Dek-d/presence.ts @@ -1,302 +1,313 @@ const presence = new Presence({ - clientId: "1314484095614451822", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1314484095614451822', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Dek-d/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Dek-d/assets/logo.png', } -presence.on("UpdateData", async () => { - const sections = { - quiz: [ - "horoscope", - "habit", - "character", - "love", - "entertainment", - "joke", - "education", - "knowledge", - "adventure", - "music", - "movie", - "cartoon", - "game", - "novel", - "sport", - "pet", - "other", - ], - tcas: [ - "dreamcareer", - "reality", - "onstage", - "dreamcampus", - "ontour", - "review", - ], - activity: "", - studyabroad: [ - "exchange", - "high_school", - "bachelor", - "master", - "course", - "work_travel", - "foreign_culture", - "global_review", - "aec", - "english_issue", - ], - nugirl: "", - teentrends: "", - "pre-admission": "", - studyabroadfair: "", - wallet: "", - board: [ - "tcas", - "entertainment", - "knowledge", - "teen", - "nugirl", - "education", - "studyabroad", - "writer", - "problem", - ], - tag: "", - visualnovel: "", - loveroom: "", - featured: "", - store: "", - review: "", - collection: "", - }, - titleText = document.querySelector("h1.title")?.textContent ?? "", - pathSegments = document.location.pathname.split("/"), - presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - type: ActivityType.Watching, - // initial details in case of no match displaying the 1st path segment - details: `Browsing ${pathSegments[1]}`, - }, // board thread play function - displaySec = (categorys = " ") => { - presenceData.details = `Viewing${categorys}discussion thread`; - }; +presence.on('UpdateData', async () => { + const sections = { + 'quiz': [ + 'horoscope', + 'habit', + 'character', + 'love', + 'entertainment', + 'joke', + 'education', + 'knowledge', + 'adventure', + 'music', + 'movie', + 'cartoon', + 'game', + 'novel', + 'sport', + 'pet', + 'other', + ], + 'tcas': [ + 'dreamcareer', + 'reality', + 'onstage', + 'dreamcampus', + 'ontour', + 'review', + ], + 'activity': '', + 'studyabroad': [ + 'exchange', + 'high_school', + 'bachelor', + 'master', + 'course', + 'work_travel', + 'foreign_culture', + 'global_review', + 'aec', + 'english_issue', + ], + 'nugirl': '', + 'teentrends': '', + 'pre-admission': '', + 'studyabroadfair': '', + 'wallet': '', + 'board': [ + 'tcas', + 'entertainment', + 'knowledge', + 'teen', + 'nugirl', + 'education', + 'studyabroad', + 'writer', + 'problem', + ], + 'tag': '', + 'visualnovel': '', + 'loveroom': '', + 'featured': '', + 'store': '', + 'review': '', + 'collection': '', + } + const titleText = document.querySelector('h1.title')?.textContent ?? '' + const pathSegments = document.location.pathname.split('/') + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + type: ActivityType.Watching, + // initial details in case of no match displaying the 1st path segment + details: `Browsing ${pathSegments[1]}`, + } // board thread play function + const displaySec = (categorys = ' ') => { + presenceData.details = `Viewing${categorys}discussion thread` + } - // main - switch (document.location.hostname) { - // handle subdomain ex novels.dek-d.com - case "www.dek-d.com": { - if (location.pathname === "/") presenceData.details = "Viewing home page"; - else if (Object.keys(sections).includes(pathSegments[1])) { - switch (pathSegments[1]) { - case "board": { - displaySec(" "); - if (sections.board.includes(pathSegments[2])) - displaySec(` ${pathSegments[2]} `); + // main + switch (document.location.hostname) { + // handle subdomain ex novels.dek-d.com + case 'www.dek-d.com': { + if (location.pathname === '/') { + presenceData.details = 'Viewing home page' + } + else if (Object.keys(sections).includes(pathSegments[1])) { + switch (pathSegments[1]) { + case 'board': { + displaySec(' ') + if (sections.board.includes(pathSegments[2])) + displaySec(` ${pathSegments[2]} `) - if (pathSegments[3] !== "") presenceData.state = `${titleText}`; + if (pathSegments[3] !== '') + presenceData.state = `${titleText}` - break; - } - case "tcas": { - presenceData.details = `Viewing ${pathSegments[1]} thread`; - if (!isNaN(Number(pathSegments[2]))) - presenceData.state = `${titleText}`; - else if (sections.tcas.includes(pathSegments[2])) - presenceData.details = `Browsing ${pathSegments[2]} on ${pathSegments[1]} thread`; + break + } + case 'tcas': { + presenceData.details = `Viewing ${pathSegments[1]} thread` + if (!Number.isNaN(Number(pathSegments[2]))) + presenceData.state = `${titleText}` + else if (sections.tcas.includes(pathSegments[2])) + presenceData.details = `Browsing ${pathSegments[2]} on ${pathSegments[1]} thread` - break; - } - case "quiz": { - presenceData.details = `Choosing ${pathSegments[1]}`; - // all quiz type - if ( - sections.quiz.includes(pathSegments[3]) && - pathSegments[2] === "all" - ) - presenceData.details = `Choosing ${pathSegments[3]} ${pathSegments[1]}`; - // every type except all type - else if (pathSegments[2] !== "") { - presenceData.details = `Choosing ${pathSegments[2]}`; - // history page - if (pathSegments[2] === "history") - presenceData.details = `Watching quiz my ${pathSegments[2]}`; - // doing quiz - else if ( - !isNaN(Number(pathSegments[3])) && - pathSegments[3] !== "" - ) { - presenceData.details = `Doing ${pathSegments[2]}`; - presenceData.state = `${titleText}`; - const img = document.querySelector("div.thumb-img .image"); - if (img) { - const urlMatch = window - .getComputedStyle(img) - .getPropertyValue("background-image") - .match(/url\(["']?([^"']*)["']?\)/); - presenceData.largeImageKey = urlMatch ? urlMatch[1] : ""; - } - } else if (sections.quiz.includes(pathSegments[3])) - presenceData.details = `Choosing ${pathSegments[3]} ${pathSegments[2]}`; - } - break; - } - case "activity": { - presenceData.details = `Browsing ${pathSegments[1]}`; - if (pathSegments[2] !== "" && !isNaN(Number(pathSegments[2]))) { - presenceData.state = titleText; - presenceData.largeImageKey = document - .querySelector("a.link img") - .getAttribute("src"); - presenceData.smallImageKey = Assets.Logo; - } else if ( - pathSegments[3] !== "" && - !isNaN(Number(pathSegments[3])) - ) { - const texts = document.querySelector("h2.header"); - presenceData.largeImageKey = document - .querySelector("img.sharethumb") - .getAttribute("src"); - presenceData.smallImageKey = Assets.Logo; - presenceData.details = `Reading ${pathSegments[1]}`; - presenceData.state = `${texts ? texts.textContent : ""}`; - } - break; - } - case "studyabroad": { - presenceData.details = `Browsing ${pathSegments[1]}`; - if (pathSegments[2] !== "" && !isNaN(Number(pathSegments[2]))) { - presenceData.state = titleText; - presenceData.largeImageKey = document - .querySelector(".image img") - .getAttribute("src"); - presenceData.smallImageKey = Assets.Logo; - } else if (sections.studyabroad.includes(pathSegments[2])) - presenceData.details = `Browsing ${pathSegments[2]} on ${pathSegments[1]}`; + break + } + case 'quiz': { + presenceData.details = `Choosing ${pathSegments[1]}` + // all quiz type + if ( + sections.quiz.includes(pathSegments[3]) + && pathSegments[2] === 'all' + ) { + presenceData.details = `Choosing ${pathSegments[3]} ${pathSegments[1]}` + } + // every type except all type + else if (pathSegments[2] !== '') { + presenceData.details = `Choosing ${pathSegments[2]}` + // history page + if (pathSegments[2] === 'history') { + presenceData.details = `Watching quiz my ${pathSegments[2]}` + } + // doing quiz + else if ( + !Number.isNaN(Number(pathSegments[3])) + && pathSegments[3] !== '' + ) { + presenceData.details = `Doing ${pathSegments[2]}` + presenceData.state = `${titleText}` + const img = document.querySelector('div.thumb-img .image') + if (img) { + const urlMatch = window + .getComputedStyle(img) + .getPropertyValue('background-image') + .match(/url\(["']?([^"']*)["']?\)/) + presenceData.largeImageKey = urlMatch ? urlMatch[1] : '' + } + } + else if (sections.quiz.includes(pathSegments[3])) { + presenceData.details = `Choosing ${pathSegments[3]} ${pathSegments[2]}` + } + } + break + } + case 'activity': { + presenceData.details = `Browsing ${pathSegments[1]}` + if (pathSegments[2] !== '' && !Number.isNaN(Number(pathSegments[2]))) { + presenceData.state = titleText + presenceData.largeImageKey = document + .querySelector('a.link img') + ?.getAttribute('src') + presenceData.smallImageKey = Assets.Logo + } + else if ( + pathSegments[3] !== '' + && !Number.isNaN(Number(pathSegments[3])) + ) { + const texts = document.querySelector('h2.header') + presenceData.largeImageKey = document + .querySelector('img.sharethumb') + ?.getAttribute('src') + presenceData.smallImageKey = Assets.Logo + presenceData.details = `Reading ${pathSegments[1]}` + presenceData.state = `${texts ? texts.textContent : ''}` + } + break + } + case 'studyabroad': { + presenceData.details = `Browsing ${pathSegments[1]}` + if (pathSegments[2] !== '' && !Number.isNaN(Number(pathSegments[2]))) { + presenceData.state = titleText + presenceData.largeImageKey = document + .querySelector('.image img') + ?.getAttribute('src') + presenceData.smallImageKey = Assets.Logo + } + else if (sections.studyabroad.includes(pathSegments[2])) { + presenceData.details = `Browsing ${pathSegments[2]} on ${pathSegments[1]}` + } - break; - } - case "nugirl": { - presenceData.details = `Browsing ${pathSegments[1]}`; - if (pathSegments[2] !== "" && !isNaN(Number(pathSegments[2]))) { - presenceData.state = titleText; - presenceData.largeImageKey = document - .querySelector(".image img") - .getAttribute("src"); - presenceData.smallImageKey = Assets.Logo; - } - break; - } - case "teentrends": { - presenceData.details = `Browsing ${pathSegments[1]}`; - if (pathSegments[2] !== "" && !isNaN(Number(pathSegments[2]))) { - const img = document.querySelector(".image img"); - if (img) presenceData.largeImageKey = img.getAttribute("src"); - presenceData.state = titleText; - presenceData.smallImageKey = Assets.Logo; - } - break; - } - case "teentrend": { - presenceData.details = `Browsing ${pathSegments[1]}`; - break; - } - case "loveroom": { - presenceData.details = `Browsing ${pathSegments[1]}`; - break; - } - case "visualnovel": { - if (pathSegments[2] !== "" && !isNaN(Number(pathSegments[2]))) { - presenceData.state = titleText; - presenceData.largeImageKey = document - .querySelector(".image img") - .getAttribute("src"); - presenceData.smallImageKey = Assets.Logo; - } - break; - } - } - } - break; - } - case "novel.dek-d.com": { - presenceData.details = "Choosing novel to read"; - if (Object.keys(sections).includes(pathSegments[1])) - presenceData.details = `Viewing novels ${pathSegments[1]}`; + break + } + case 'nugirl': { + presenceData.details = `Browsing ${pathSegments[1]}` + if (pathSegments[2] !== '' && !Number.isNaN(Number(pathSegments[2]))) { + presenceData.state = titleText + presenceData.largeImageKey = document + .querySelector('.image img') + ?.getAttribute('src') + presenceData.smallImageKey = Assets.Logo + } + break + } + case 'teentrends': { + presenceData.details = `Browsing ${pathSegments[1]}` + if (pathSegments[2] !== '' && !Number.isNaN(Number(pathSegments[2]))) { + const img = document.querySelector('.image img') + if (img) + presenceData.largeImageKey = img.getAttribute('src') + presenceData.state = titleText + presenceData.smallImageKey = Assets.Logo + } + break + } + case 'teentrend': { + presenceData.details = `Browsing ${pathSegments[1]}` + break + } + case 'loveroom': { + presenceData.details = `Browsing ${pathSegments[1]}` + break + } + case 'visualnovel': { + if (pathSegments[2] !== '' && !Number.isNaN(Number(pathSegments[2]))) { + presenceData.state = titleText + presenceData.largeImageKey = document + .querySelector('.image img') + ?.getAttribute('src') + presenceData.smallImageKey = Assets.Logo + } + break + } + } + } + break + } + case 'novel.dek-d.com': { + presenceData.details = 'Choosing novel to read' + if (Object.keys(sections).includes(pathSegments[1])) + presenceData.details = `Viewing novels ${pathSegments[1]}` - switch (pathSegments[1]) { - // admin novel review - case "article": { - const headerTexts = document.querySelector(".special-intro"), - headerT = headerTexts - ? headerTexts.querySelector("h2").textContent - : ""; - presenceData.smallImageKey = Assets.Logo; - presenceData.details = "Reading Admin Novels Review"; - presenceData.largeImageKey = document - .querySelector("div.header-special picture img") - .getAttribute("src"); - // assign the name of the novel to the state - // incase there are white space in infront of the text but it worst for the Novel who have 2 or more words in the title - for (let i = 0; i < headerT.split(" ").length; i++) { - if (headerT.split(" ")[i] !== "") { - presenceData.state = headerT.split(" ")[i]; - break; - } - } - break; - } - // reader novel review - case "novel": { - const novelCoverElement = document.querySelector( - "div.novel-cover-img" - ); - if (novelCoverElement) { - const urlMatch = window - .getComputedStyle(novelCoverElement) - .getPropertyValue("background-image") - .match(/url\(["']?([^"']*)["']?\)/); - presenceData.largeImageKey = urlMatch ? urlMatch[1] : Assets.Logo; - if (presenceData.largeImageKey !== Assets.Logo) - presenceData.smallImageKey = Assets.Logo; - } - presenceData.state = document.querySelector("a.link").textContent; - presenceData.details = "Reader Novels Review"; - break; - } - } - break; - } - case "writer.dek-d.com": { - presenceData.details = "Viewing Novel home page"; + switch (pathSegments[1]) { + // admin novel review + case 'article': { + const headerTexts = document.querySelector('.special-intro') + const headerT = headerTexts + ? headerTexts.querySelector('h2')!.textContent! + : '' + presenceData.smallImageKey = Assets.Logo + presenceData.details = 'Reading Admin Novels Review' + presenceData.largeImageKey = document + .querySelector('div.header-special picture img') + ?.getAttribute('src') + // assign the name of the novel to the state + // incase there are white space in infront of the text but it worst for the Novel who have 2 or more words in the title + for (let i = 0; i < headerT.split(' ').length; i++) { + if (headerT.split(' ')[i] !== '') { + presenceData.state = headerT.split(' ')[i] + break + } + } + break + } + // reader novel review + case 'novel': { + const novelCoverElement = document.querySelector( + 'div.novel-cover-img', + ) + if (novelCoverElement) { + const urlMatch = window + .getComputedStyle(novelCoverElement) + .getPropertyValue('background-image') + .match(/url\(["']?([^"']*)["']?\)/) + presenceData.largeImageKey = urlMatch ? urlMatch[1] : Assets.Logo + if (presenceData.largeImageKey !== Assets.Logo) + presenceData.smallImageKey = Assets.Logo + } + presenceData.state = document.querySelector('a.link')?.textContent + presenceData.details = 'Reader Novels Review' + break + } + } + break + } + case 'writer.dek-d.com': { + presenceData.details = 'Viewing Novel home page' - if ( - pathSegments[2] === "writer" && - document.location.href.includes(document.location.href.split("/")[5]) && - document.location.href.split("/")[5].split(".")[0] === "view" - ) { - const novelCoverElement = document.querySelector("div.novel-cover-img"); - if (novelCoverElement) { - const urlMatch = window - .getComputedStyle(novelCoverElement) - .getPropertyValue("background-image") - .match(/url\(["']?([^"']*)["']?\)/); - presenceData.largeImageKey = urlMatch ? urlMatch[1] : Assets.Logo; - if (presenceData.largeImageKey !== Assets.Logo) - presenceData.smallImageKey = Assets.Logo; - } - presenceData.state = document.querySelector("p.novel-name").textContent; - } - break; - } - // handle in case of no match subdomain - default: { - presenceData.details = "Browsing..."; - } - } - presence.setActivity(presenceData); -}); + if ( + pathSegments[2] === 'writer' + && document.location.href.includes(document.location.href.split('/')[5]) + && document.location.href.split('/')[5].split('.')[0] === 'view' + ) { + const novelCoverElement = document.querySelector('div.novel-cover-img') + if (novelCoverElement) { + const urlMatch = window + .getComputedStyle(novelCoverElement) + .getPropertyValue('background-image') + .match(/url\(["']?([^"']*)["']?\)/) + presenceData.largeImageKey = urlMatch ? urlMatch[1] : Assets.Logo + if (presenceData.largeImageKey !== Assets.Logo) + presenceData.smallImageKey = Assets.Logo + } + presenceData.state = document.querySelector('p.novel-name')?.textContent + } + break + } + // handle in case of no match subdomain + default: { + presenceData.details = 'Browsing...' + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/D/Deno/metadata.json b/websites/D/Deno/metadata.json index 9c5d8314be0f..a920253298dd 100644 --- a/websites/D/Deno/metadata.json +++ b/websites/D/Deno/metadata.json @@ -1,53 +1,53 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dark_Ville", - "id": "638080361179512853" - }, - "contributors": [ - { - "name": "Alexx", - "id": "604182077088202784" - } - ], - "service": "Deno", - "description": { - "en": "Deno is a runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language. It was created by Ryan Dahl, original creator of Node.js, and is focused on productivity.", - "nl": "Deno is een runtime voor JavaScript en TypeScript die gebaseerd is op de V8 JavaScript-engine en de programmeertaal Rust. Het is gemaakt door Ryan Dahl, de oorspronkelijke bedenker van Node.js, en is gericht op productiviteit." - }, - "url": [ - "deno.land", - "doc.deno.land", - "deno.com", - "merch.deno.com", - "denostatus.com", - "deno.news" - ], - "version": "1.1.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/thumbnail.png", - "color": "#f9f9f9", - "category": "other", - "tags": [ - "code", - "informations" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fas fa-user-secret", - "value": false - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true, - "if": { - "privacy": false - } - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dark_Ville", + "id": "638080361179512853" + }, + "contributors": [ + { + "name": "Alexx", + "id": "604182077088202784" + } + ], + "service": "Deno", + "description": { + "en": "Deno is a runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language. It was created by Ryan Dahl, original creator of Node.js, and is focused on productivity.", + "nl": "Deno is een runtime voor JavaScript en TypeScript die gebaseerd is op de V8 JavaScript-engine en de programmeertaal Rust. Het is gemaakt door Ryan Dahl, de oorspronkelijke bedenker van Node.js, en is gericht op productiviteit." + }, + "url": [ + "deno.land", + "doc.deno.land", + "deno.com", + "merch.deno.com", + "denostatus.com", + "deno.news" + ], + "version": "1.1.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/thumbnail.png", + "color": "#f9f9f9", + "category": "other", + "tags": [ + "code", + "informations" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fas fa-user-secret", + "value": false + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true, + "if": { + "privacy": false + } + } + ] +} diff --git a/websites/D/Deno/presence.ts b/websites/D/Deno/presence.ts index c7393235569d..2269f8059782 100644 --- a/websites/D/Deno/presence.ts +++ b/websites/D/Deno/presence.ts @@ -1,213 +1,219 @@ const presence = new Presence({ - clientId: "843058683100266526", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '843058683100266526', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/logo.png", - NewsLogo = "https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/0.png", - MerchLogo = "https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/1.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/logo.png', + NewsLogo = 'https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/0.png', + MerchLogo = 'https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/1.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { href, hash, hostname, pathname } = document.location, - [privacy, buttons] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("buttons"), - ]), - search = document.querySelector('[id="search-input"]'), - pathnameSplit = pathname.split("/"); - if (privacy) { - presenceData.largeImageKey = Assets.Logo; - presenceData.details = "Browsing"; - presence.setActivity(presenceData); - return; - } - switch (hostname) { - case "deno.land": { - if (search?.value) { - presenceData.details = "Searching for"; - presenceData.state = search.value; - presenceData.smallImageKey = Assets.Search; - } else if (pathname.includes("/manual")) { - presenceData.buttons = [ - { - label: "Read Manual", - url: href, - }, - ]; - presenceData.state = "Manual"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - presenceData.details = - document.querySelector('[class="anchor"]').parentElement.textContent; - } else { - switch (pathnameSplit[1]) { - case "": { - presenceData.details = "Viewing homepage"; - break; - } - case "blog": { - presenceData.buttons = [ - { - label: "Read Blog", - url: href, - }, - ]; - presenceData.details = "Reading the blog"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - break; - } - case "x": { - presenceData.buttons = [ - { - label: "Explore Modules", - url: href, - }, - ]; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { href, hash, hostname, pathname } = document.location + const [privacy, buttons] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('buttons'), + ]) + const search = document.querySelector('[id="search-input"]') + const pathnameSplit = pathname.split('/') + if (privacy) { + presenceData.largeImageKey = Assets.Logo + presenceData.details = 'Browsing' + presence.setActivity(presenceData) + return + } + switch (hostname) { + case 'deno.land': { + if (search?.value) { + presenceData.details = 'Searching for' + presenceData.state = search.value + presenceData.smallImageKey = Assets.Search + } + else if (pathname.includes('/manual')) { + presenceData.buttons = [ + { + label: 'Read Manual', + url: href, + }, + ] + presenceData.state = 'Manual' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + presenceData.details = document.querySelector('[class="anchor"]')?.parentElement?.textContent + } + else { + switch (pathnameSplit[1]) { + case '': { + presenceData.details = 'Viewing homepage' + break + } + case 'blog': { + presenceData.buttons = [ + { + label: 'Read Blog', + url: href, + }, + ] + presenceData.details = 'Reading the blog' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + break + } + case 'x': { + presenceData.buttons = [ + { + label: 'Explore Modules', + url: href, + }, + ] - if (document.querySelector('[class="text-default"]')) { - presenceData.details = "Viewing third party module"; - presenceData.state = document - .querySelector("title") - ?.textContent.split("|")[0]; - } else { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - presenceData.details = "Reading about third party modules"; - } - break; - } - } - } - break; - } - case "doc.deno.land": { - presenceData.buttons = [ - { - label: "View Docs", - url: href, - }, - ]; - presenceData.details = `Viewing ${ - !hash ? "deno" : `${hash.replace("#", "")}'s` - } (${document.querySelector('[class="truncate"]').textContent} version)`; - break; - } - case "deno.com": { - switch (pathnameSplit[1]) { - case "": { - presenceData.details = "Viewing homepage"; - break; - } - case "blog": { - presenceData.buttons = [ - { - label: "View Blog", - url: href, - }, - ]; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - if (document.querySelector("article")) { - presenceData.details = "Reading an article about"; - presenceData.state = - document.querySelector("article").firstElementChild.textContent; - } else presenceData.details = "Reading the blog"; - break; - } - case "deploy": { - switch (pathnameSplit[2]) { - case "subhosting": { - presenceData.buttons = [ - { - label: "View Subhosting", - url: href, - }, - ]; - presenceData.details = "Viewing the subhosting page"; - break; - } - case "docs": { - presenceData.buttons = [ - { - label: "View Docs", - url: href, - }, - ]; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading"; - presenceData.details = "Reading an article about"; - presenceData.state = - document.querySelector("article").firstElementChild.textContent; - break; - } - case "pricing": { - presenceData.buttons = [ - { - label: "View Pricing", - url: href, - }, - ]; - presenceData.details = "Viewing deno's pricing"; - break; - } - case "": - default: { - presenceData.buttons = [ - { - label: "View The Deploy Page", - url: href, - }, - ]; - presenceData.details = "Viewing the deploy page"; - break; - } - } - break; - } - } - break; - } - case "deno.news": { - presenceData.buttons = [ - { - label: "View The News", - url: href, - }, - ]; - presenceData.largeImageKey = Assets.NewsLogo; - presenceData.details = "Viewing the news page"; - break; - } - case "denostatus.com": { - presenceData.buttons = [ - { - label: "View Deno's Status", - url: href, - }, - ]; - presenceData.details = "Viewing deno's status"; - break; - } - case "merch.deno.com": { - presenceData.largeImageKey = Assets.MerchLogo; - presenceData.buttons = [ - { - label: "View Merge Store", - url: href, - }, - ]; - presenceData.details = "Viewing deno's merch store"; - break; - } - } - if (!buttons) delete presenceData.buttons; - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (document.querySelector('[class="text-default"]')) { + presenceData.details = 'Viewing third party module' + presenceData.state = document + .querySelector('title') + ?.textContent + ?.split('|')[0] + } + else { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + presenceData.details = 'Reading about third party modules' + } + break + } + } + } + break + } + case 'doc.deno.land': { + presenceData.buttons = [ + { + label: 'View Docs', + url: href, + }, + ] + presenceData.details = `Viewing ${ + !hash ? 'deno' : `${hash.replace('#', '')}'s` + } (${document.querySelector('[class="truncate"]')?.textContent} version)` + break + } + case 'deno.com': { + switch (pathnameSplit[1]) { + case '': { + presenceData.details = 'Viewing homepage' + break + } + case 'blog': { + presenceData.buttons = [ + { + label: 'View Blog', + url: href, + }, + ] + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + if (document.querySelector('article')) { + presenceData.details = 'Reading an article about' + presenceData.state = document.querySelector('article')?.firstElementChild?.textContent + } + else { + presenceData.details = 'Reading the blog' + } + break + } + case 'deploy': { + switch (pathnameSplit[2]) { + case 'subhosting': { + presenceData.buttons = [ + { + label: 'View Subhosting', + url: href, + }, + ] + presenceData.details = 'Viewing the subhosting page' + break + } + case 'docs': { + presenceData.buttons = [ + { + label: 'View Docs', + url: href, + }, + ] + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading' + presenceData.details = 'Reading an article about' + presenceData.state = document.querySelector('article')?.firstElementChild?.textContent + break + } + case 'pricing': { + presenceData.buttons = [ + { + label: 'View Pricing', + url: href, + }, + ] + presenceData.details = 'Viewing deno\'s pricing' + break + } + case '': + default: { + presenceData.buttons = [ + { + label: 'View The Deploy Page', + url: href, + }, + ] + presenceData.details = 'Viewing the deploy page' + break + } + } + break + } + } + break + } + case 'deno.news': { + presenceData.buttons = [ + { + label: 'View The News', + url: href, + }, + ] + presenceData.largeImageKey = Assets.NewsLogo + presenceData.details = 'Viewing the news page' + break + } + case 'denostatus.com': { + presenceData.buttons = [ + { + label: 'View Deno\'s Status', + url: href, + }, + ] + presenceData.details = 'Viewing deno\'s status' + break + } + case 'merch.deno.com': { + presenceData.largeImageKey = Assets.MerchLogo + presenceData.buttons = [ + { + label: 'View Merge Store', + url: href, + }, + ] + presenceData.details = 'Viewing deno\'s merch store' + break + } + } + if (!buttons) + delete presenceData.buttons + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Derpibooru/metadata.json b/websites/D/Derpibooru/metadata.json index df3a46498a1a..42d16e299070 100644 --- a/websites/D/Derpibooru/metadata.json +++ b/websites/D/Derpibooru/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "TheSlowly", - "id": "505071508851523599" - }, - "service": "Derpibooru", - "description": { - "en": "Derpibooru is an image repository which lets people bring together art from all over the internet, annotate the images with tags and an original source URL for easy searching, and discuss the artwork.", - "de": "Derpibooru ist ein Bildarchiv, das es Menschen ermöglicht, Kunst aus dem ganzen Internet zusammenzubringen, die Bilder mit Tags und einer originellen Quell-URL zur einfachen Suche zu kommentieren und über das Kunstwerk zu diskutieren.", - "nl": "Derpibooru is een afbeeldingsrepository waarmee mensen kunst van over het hele internet kunnen samenbrengen, de afbeeldingen kunnen voorzien worden met tags en een originele URL voor eenvoudig zoeken en de kunstwerken te kunnen bespreken." - }, - "url": "derpibooru.org", - "version": "1.2.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Derpibooru/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Derpibooru/assets/thumbnail.png", - "color": "#3D92D0", - "category": "other", - "tags": [ - "pictures" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "TheSlowly", + "id": "505071508851523599" + }, + "service": "Derpibooru", + "description": { + "en": "Derpibooru is an image repository which lets people bring together art from all over the internet, annotate the images with tags and an original source URL for easy searching, and discuss the artwork.", + "de": "Derpibooru ist ein Bildarchiv, das es Menschen ermöglicht, Kunst aus dem ganzen Internet zusammenzubringen, die Bilder mit Tags und einer originellen Quell-URL zur einfachen Suche zu kommentieren und über das Kunstwerk zu diskutieren.", + "nl": "Derpibooru is een afbeeldingsrepository waarmee mensen kunst van over het hele internet kunnen samenbrengen, de afbeeldingen kunnen voorzien worden met tags en een originele URL voor eenvoudig zoeken en de kunstwerken te kunnen bespreken." + }, + "url": "derpibooru.org", + "version": "1.2.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Derpibooru/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Derpibooru/assets/thumbnail.png", + "color": "#3D92D0", + "category": "other", + "tags": [ + "pictures" + ] +} diff --git a/websites/D/Derpibooru/presence.ts b/websites/D/Derpibooru/presence.ts index 6973eb04103f..bc982213bd82 100644 --- a/websites/D/Derpibooru/presence.ts +++ b/websites/D/Derpibooru/presence.ts @@ -1,136 +1,183 @@ const presence = new Presence({ - clientId: "611544256758153225", -}); + clientId: '611544256758153225', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Derpibooru/assets/logo.png", - }; - if (document.location.pathname === "/") - presenceData.details = "Viewing the homepage"; - else if (document.location.pathname.startsWith("/users/sign_in")) - presenceData.details = "Logging in"; - else if (document.location.pathname.startsWith("/users/sign_up")) - presenceData.details = "Registering"; - else if (document.location.pathname.startsWith("/store")) - presenceData.details = "Browsing through the store"; - else if (document.location.pathname.startsWith("/rankings")) - presenceData.details = "Browsing through the rankings"; - else if (document.location.pathname.startsWith("/settings")) - presenceData.details = "Editing settings"; - else if (document.location.pathname.startsWith("/galleries")) - presenceData.details = "Browsing through the Gallerie"; - else if (document.location.pathname.startsWith("/commissions")) - presenceData.details = "Browsing through commissions"; - else if (document.location.pathname.startsWith("/channels")) - presenceData.details = "Browsing through livestreams"; - else if (document.location.pathname.startsWith("/tags/ratings")) - presenceData.details = "Browsing through the tag ratings"; - else if (document.location.pathname.startsWith("/pages/tags")) - presenceData.details = "Looking at the tag guide"; - else if (document.location.pathname.startsWith("/tags/aliases")) - presenceData.details = "Going through the tag aliases"; - else if (document.location.pathname === "/art") - presenceData.details = "Browsing through art chats"; - else if (document.location.pathname.startsWith("/art/")) { - presenceData.details = "Reading the post:"; - presenceData.state = ( - document.querySelector(".layout--narrow h1") as HTMLElement - ).textContent; - } else if (document.location.pathname.startsWith("/writing")) - presenceData.details = "Browsing through Fanfictions"; - else if (document.location.pathname === "/dis") - presenceData.details = "Browsing through Discussions"; - else if (document.location.pathname.startsWith("/dis/")) { - presenceData.details = "Reading the general discussion:"; - presenceData.state = ( - document.querySelector(".layout--narrow h1") as HTMLElement - ).textContent; - } else if (document.location.pathname === "/generals") - presenceData.details = "Looking at general posts"; - else if (document.location.pathname.startsWith("/generals/")) - presenceData.details = "test "; - else if (document.location.pathname === "/pony") - presenceData.details = "Browsing through pony discussion"; - else if (document.location.pathname.startsWith("/pony/")) { - presenceData.details = "Reading the pony discussion:"; - presenceData.state = ( - document.querySelector(".layout--narrow h1") as HTMLElement - ).textContent; - } else if (document.location.pathname === "/rp") - presenceData.details = "Browsing through rp's"; - else if (document.location.pathname.startsWith("/rp/")) { - presenceData.details = "Reading the rp chat:"; - presenceData.state = ( - document.querySelector(".layout--narrow h1") as HTMLElement - ).textContent; - } else if (document.location.pathname === "/meta") - presenceData.details = "Browsing through the website policy"; - else if (document.location.pathname.startsWith("/meta/")) { - presenceData.details = "Reading the information post:"; - presenceData.state = ( - document.querySelector(".layout--narrow h1") as HTMLElement - ).textContent; - } else if (document.location.pathname === "/tagging") - presenceData.details = "Browsing through tagging discussions"; - else if (document.location.pathname.startsWith("/tagging/")) { - presenceData.details = "Reading the tagging discussion:"; - presenceData.state = ( - document.querySelector(".layout--narrow h1") as HTMLElement - ).textContent; - } else if (document.location.pathname === "/uppers") - presenceData.details = "Browsing through uploader discussions"; - else if (document.location.pathname.startsWith("/uppers/")) { - presenceData.details = "Reading the uploader discussion:"; - presenceData.state = ( - document.querySelector(".layout--narrow h1") as HTMLElement - ).textContent; - } else if (document.location.pathname === "/forums") - presenceData.details = "Browsing through the forum"; - else if (document.location.pathname.startsWith("/forums")) { - presenceData.details = "Reading the forum post:"; - presenceData.state = ( - document.querySelector(".layout--narrow h1") as HTMLElement - ).textContent; - } else if (document.location.pathname.startsWith("/activity")) - presenceData.details = "Browsing recently uploaded pictures"; - else if (document.location.pathname.startsWith("/lists")) - presenceData.details = "Browsing through top scores"; - else if (document.location.pathname.startsWith("/posts")) - presenceData.details = "Browsing through global posts"; - else if (document.location.pathname.startsWith("/search")) - presenceData.details = "Searching something"; - else if (document.location.pathname.startsWith("/filters")) - presenceData.details = "Changing their filter settings"; - else if (document.location.pathname.startsWith("/pages/rules")) - presenceData.details = "Reading the rules"; - else if (document.location.pathname.startsWith("/pages/privacy")) - presenceData.details = "Reading the privacy informations"; - else if (document.location.pathname.startsWith("/pages/takedowns")) - presenceData.details = "Reading about takedowns"; - else if (document.location.pathname.startsWith("/dnp")) - presenceData.details = "Reading through the Do-Not-Post List"; - else if (document.location.pathname.startsWith("/changelog")) - presenceData.details = "Reading the changelog"; - else if (document.location.pathname.startsWith("/pages/faq")) - presenceData.details = "Reading the FAQ"; - else if (document.location.pathname.startsWith("/pages/api")) - presenceData.details = "Reading about the API"; - else if (document.location.pathname.startsWith("/pages/shortcuts")) - presenceData.details = "Reading about the keyboard shortcuts"; - else if (document.location.pathname.startsWith("/pages/advertising")) - presenceData.details = "Reading about their advertising"; - else if (document.location.pathname.startsWith("/pages/onion")) - presenceData.details = "Reading about onions"; - else if (document.location.pathname.startsWith("/pages/stats")) - presenceData.details = "Watching the website stats"; - else if (document.location.pathname.startsWith("/pages/staff")) - presenceData.details = "Looking at the staff list"; - else if (document.location.pathname.startsWith("/images")) { - if (document.location.pathname.startsWith("/images/new")) - presenceData.details = "uploading a new picture"; - else presenceData.details = "Browsing through all pictures"; - } - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Derpibooru/assets/logo.png', + } + if (document.location.pathname === '/') { + presenceData.details = 'Viewing the homepage' + } + else if (document.location.pathname.startsWith('/users/sign_in')) { + presenceData.details = 'Logging in' + } + else if (document.location.pathname.startsWith('/users/sign_up')) { + presenceData.details = 'Registering' + } + else if (document.location.pathname.startsWith('/store')) { + presenceData.details = 'Browsing through the store' + } + else if (document.location.pathname.startsWith('/rankings')) { + presenceData.details = 'Browsing through the rankings' + } + else if (document.location.pathname.startsWith('/settings')) { + presenceData.details = 'Editing settings' + } + else if (document.location.pathname.startsWith('/galleries')) { + presenceData.details = 'Browsing through the Gallerie' + } + else if (document.location.pathname.startsWith('/commissions')) { + presenceData.details = 'Browsing through commissions' + } + else if (document.location.pathname.startsWith('/channels')) { + presenceData.details = 'Browsing through livestreams' + } + else if (document.location.pathname.startsWith('/tags/ratings')) { + presenceData.details = 'Browsing through the tag ratings' + } + else if (document.location.pathname.startsWith('/pages/tags')) { + presenceData.details = 'Looking at the tag guide' + } + else if (document.location.pathname.startsWith('/tags/aliases')) { + presenceData.details = 'Going through the tag aliases' + } + else if (document.location.pathname === '/art') { + presenceData.details = 'Browsing through art chats' + } + else if (document.location.pathname.startsWith('/art/')) { + presenceData.details = 'Reading the post:' + presenceData.state = ( + document.querySelector('.layout--narrow h1') as HTMLElement + ).textContent + } + else if (document.location.pathname.startsWith('/writing')) { + presenceData.details = 'Browsing through Fanfictions' + } + else if (document.location.pathname === '/dis') { + presenceData.details = 'Browsing through Discussions' + } + else if (document.location.pathname.startsWith('/dis/')) { + presenceData.details = 'Reading the general discussion:' + presenceData.state = ( + document.querySelector('.layout--narrow h1') as HTMLElement + ).textContent + } + else if (document.location.pathname === '/generals') { + presenceData.details = 'Looking at general posts' + } + else if (document.location.pathname.startsWith('/generals/')) { + presenceData.details = 'test ' + } + else if (document.location.pathname === '/pony') { + presenceData.details = 'Browsing through pony discussion' + } + else if (document.location.pathname.startsWith('/pony/')) { + presenceData.details = 'Reading the pony discussion:' + presenceData.state = ( + document.querySelector('.layout--narrow h1') as HTMLElement + ).textContent + } + else if (document.location.pathname === '/rp') { + presenceData.details = 'Browsing through rp\'s' + } + else if (document.location.pathname.startsWith('/rp/')) { + presenceData.details = 'Reading the rp chat:' + presenceData.state = ( + document.querySelector('.layout--narrow h1') as HTMLElement + ).textContent + } + else if (document.location.pathname === '/meta') { + presenceData.details = 'Browsing through the website policy' + } + else if (document.location.pathname.startsWith('/meta/')) { + presenceData.details = 'Reading the information post:' + presenceData.state = ( + document.querySelector('.layout--narrow h1') as HTMLElement + ).textContent + } + else if (document.location.pathname === '/tagging') { + presenceData.details = 'Browsing through tagging discussions' + } + else if (document.location.pathname.startsWith('/tagging/')) { + presenceData.details = 'Reading the tagging discussion:' + presenceData.state = ( + document.querySelector('.layout--narrow h1') as HTMLElement + ).textContent + } + else if (document.location.pathname === '/uppers') { + presenceData.details = 'Browsing through uploader discussions' + } + else if (document.location.pathname.startsWith('/uppers/')) { + presenceData.details = 'Reading the uploader discussion:' + presenceData.state = ( + document.querySelector('.layout--narrow h1') as HTMLElement + ).textContent + } + else if (document.location.pathname === '/forums') { + presenceData.details = 'Browsing through the forum' + } + else if (document.location.pathname.startsWith('/forums')) { + presenceData.details = 'Reading the forum post:' + presenceData.state = ( + document.querySelector('.layout--narrow h1') as HTMLElement + ).textContent + } + else if (document.location.pathname.startsWith('/activity')) { + presenceData.details = 'Browsing recently uploaded pictures' + } + else if (document.location.pathname.startsWith('/lists')) { + presenceData.details = 'Browsing through top scores' + } + else if (document.location.pathname.startsWith('/posts')) { + presenceData.details = 'Browsing through global posts' + } + else if (document.location.pathname.startsWith('/search')) { + presenceData.details = 'Searching something' + } + else if (document.location.pathname.startsWith('/filters')) { + presenceData.details = 'Changing their filter settings' + } + else if (document.location.pathname.startsWith('/pages/rules')) { + presenceData.details = 'Reading the rules' + } + else if (document.location.pathname.startsWith('/pages/privacy')) { + presenceData.details = 'Reading the privacy informations' + } + else if (document.location.pathname.startsWith('/pages/takedowns')) { + presenceData.details = 'Reading about takedowns' + } + else if (document.location.pathname.startsWith('/dnp')) { + presenceData.details = 'Reading through the Do-Not-Post List' + } + else if (document.location.pathname.startsWith('/changelog')) { + presenceData.details = 'Reading the changelog' + } + else if (document.location.pathname.startsWith('/pages/faq')) { + presenceData.details = 'Reading the FAQ' + } + else if (document.location.pathname.startsWith('/pages/api')) { + presenceData.details = 'Reading about the API' + } + else if (document.location.pathname.startsWith('/pages/shortcuts')) { + presenceData.details = 'Reading about the keyboard shortcuts' + } + else if (document.location.pathname.startsWith('/pages/advertising')) { + presenceData.details = 'Reading about their advertising' + } + else if (document.location.pathname.startsWith('/pages/onion')) { + presenceData.details = 'Reading about onions' + } + else if (document.location.pathname.startsWith('/pages/stats')) { + presenceData.details = 'Watching the website stats' + } + else if (document.location.pathname.startsWith('/pages/staff')) { + presenceData.details = 'Looking at the staff list' + } + else if (document.location.pathname.startsWith('/images')) { + if (document.location.pathname.startsWith('/images/new')) + presenceData.details = 'uploading a new picture' + else presenceData.details = 'Browsing through all pictures' + } + presence.setActivity(presenceData) +}) diff --git a/websites/D/Desmos/metadata.json b/websites/D/Desmos/metadata.json index 502af6d57e4b..9e1657ffadd4 100644 --- a/websites/D/Desmos/metadata.json +++ b/websites/D/Desmos/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Anshroid", - "id": "434312233023963137" - }, - "service": "Desmos", - "description": { - "en": "Desmos Graphing Calculator lets you graph functions, plot data, evaluate equations, explore transformations, and much more— all for free. " - }, - "url": "www.desmos.com", - "version": "1.0.20", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Desmos/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Desmos/assets/thumbnail.png", - "color": "#158f47", - "category": "other", - "tags": [ - "graphing", - "maths", - "calculator" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Anshroid", + "id": "434312233023963137" + }, + "service": "Desmos", + "description": { + "en": "Desmos Graphing Calculator lets you graph functions, plot data, evaluate equations, explore transformations, and much more— all for free. " + }, + "url": "www.desmos.com", + "version": "1.0.20", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Desmos/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Desmos/assets/thumbnail.png", + "color": "#158f47", + "category": "other", + "tags": [ + "graphing", + "maths", + "calculator" + ] +} diff --git a/websites/D/Desmos/presence.ts b/websites/D/Desmos/presence.ts index af023529ca38..95b9ba61c789 100644 --- a/websites/D/Desmos/presence.ts +++ b/websites/D/Desmos/presence.ts @@ -1,76 +1,92 @@ -const presence = new Presence({ clientId: "886254740399349852" }); +const presence = new Presence({ clientId: '886254740399349852' }) let url: string, - graphing: number, - pageType: string, - title: string, - numEquations: number; -const startTime: number = Date.now(); + graphing: number, + pageType: string, + title: string | null, + numEquations: number +const startTime: number = Date.now() -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Desmos/assets/logo.jpg", - startTimestamp: startTime, - }; - // Getting Data - url = document.URL; - if (url[url.length - 1] === "/") url = url.substring(0, url.length - 1); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Desmos/assets/logo.jpg', + startTimestamp: startTime, + } + // Getting Data + url = document.URL + if (url[url.length - 1] === '/') + url = url.substring(0, url.length - 1) - const splitUrl = url.split("/"), - urlPage = splitUrl[splitUrl.length - 1]; - if (urlPage === "www.desmos.com") pageType = "Home Page"; - else pageType = urlPage[0].toUpperCase() + urlPage.substring(1); // Capitalize page title + const splitUrl = url.split('/') + const urlPage = splitUrl[splitUrl.length - 1] + if (urlPage === 'www.desmos.com') + pageType = 'Home Page' + else pageType = urlPage[0].toUpperCase() + urlPage.substring(1) // Capitalize page title - if (url.includes("/calculator")) { - // Graphing Calculator - graphing = 2; // "Plotting a Graph: " - title = document.querySelectorAll(".dcg-variable-title")[0].textContent; - numEquations = document.querySelectorAll(".dcg-template-expressioneach")[0] - .childElementCount; - } else if (url.includes("/geometry")) { - // Geometry Tool - graphing = 1; // "Using Desmos Geometry: " - title = document.querySelectorAll(".dcg-variable-title")[0].textContent; - pageType = "Geometry"; - numEquations = 0; - } else if ( - ["scientific", "fourfunction", "matrix", "practice"].includes(urlPage) - ) { - graphing = 1; // "Using Desmos Scientific/Fourfunction etc. " - if (pageType === "Scientific" || pageType === "Fourfunction") { - // These three use a different container for equations - numEquations = - document.querySelectorAll(".dcg-basic-list")[0].childElementCount; - } else if (pageType === "Matrix") { - numEquations = - document.querySelectorAll(".dcg-matrix-list")[0].childElementCount; - } else numEquations = 0; - } else graphing = 0; - // Setting Presence - if (graphing === 2) { - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Desmos/assets/logo.jpg"; - presenceData.smallImageText = "Desmos Graphing Calculator"; - presenceData.details = "Plotting a Graph: ".concat(title); - presenceData.state = numEquations.toString().concat(" Equation"); - if (numEquations !== 1) presenceData.state += "s"; - } else { - delete presenceData.smallImageKey; - delete presenceData.smallImageText; - if (graphing === 1) { - presenceData.details = "Using Desmos ".concat(pageType); - if (numEquations > 0) { - // Using one of the calculator apps - presenceData.details += " Calculator"; - presenceData.state = numEquations.toString().concat(" Expression"); - if (numEquations !== 1) presenceData.state += "s"; // Plural - } else delete presenceData.state; + if (url.includes('/calculator')) { + // Graphing Calculator + graphing = 2 // "Plotting a Graph: " + title = document.querySelectorAll('.dcg-variable-title')[0].textContent + numEquations = document.querySelectorAll('.dcg-template-expressioneach')[0] + .childElementCount + } + else if (url.includes('/geometry')) { + // Geometry Tool + graphing = 1 // "Using Desmos Geometry: " + title = document.querySelectorAll('.dcg-variable-title')[0].textContent + pageType = 'Geometry' + numEquations = 0 + } + else if ( + ['scientific', 'fourfunction', 'matrix', 'practice'].includes(urlPage) + ) { + graphing = 1 // "Using Desmos Scientific/Fourfunction etc. " + if (pageType === 'Scientific' || pageType === 'Fourfunction') { + // These three use a different container for equations + numEquations = document.querySelectorAll('.dcg-basic-list')[0].childElementCount + } + else if (pageType === 'Matrix') { + numEquations = document.querySelectorAll('.dcg-matrix-list')[0].childElementCount + } + else { + numEquations = 0 + } + } + else { + graphing = 0 + } + // Setting Presence + if (graphing === 2) { + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Desmos/assets/logo.jpg' + presenceData.smallImageText = 'Desmos Graphing Calculator' + presenceData.details = 'Plotting a Graph: '.concat(title ?? '') + presenceData.state = numEquations.toString().concat(' Equation') + if (numEquations !== 1) + presenceData.state += 's' + } + else { + delete presenceData.smallImageKey + delete presenceData.smallImageText + if (graphing === 1) { + presenceData.details = 'Using Desmos '.concat(pageType) + if (numEquations > 0) { + // Using one of the calculator apps + presenceData.details += ' Calculator' + presenceData.state = numEquations.toString().concat(' Expression') + if (numEquations !== 1) + presenceData.state += 's' // Plural + } + else { + delete presenceData.state + } - if (title !== "") - // If using Geometry, add title - presenceData.details += ": ".concat(title); - } else presenceData.details = "Reading ".concat(pageType); - } - presence.setActivity(presenceData); -}); + if (title !== '') + // If using Geometry, add title + presenceData.details += ': '.concat(title ?? '') + } + else { + presenceData.details = 'Reading '.concat(pageType) + } + } + presence.setActivity(presenceData) +}) diff --git a/websites/D/Destiny Item Manager/metadata.json b/websites/D/Destiny Item Manager/metadata.json index 14e8dada0b91..5e7a224dd1ba 100644 --- a/websites/D/Destiny Item Manager/metadata.json +++ b/websites/D/Destiny Item Manager/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Hibanka", - "id": "467658348158779393" - }, - "service": "Destiny Item Manager", - "description": { - "en": "Swap items, check stats, and build the loadout to Become Legend with DIM", - "nl": "Verwissel items, check stats, en bouw de uitrusting om Legend te worden met DIM" - }, - "url": [ - "destinyitemmanager.com", - "app.destinyitemmanager.com" - ], - "version": "1.0.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/thumbnail.jpg", - "color": "#ee6d0d", - "category": "games", - "tags": [ - "destiny2" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Hibanka", + "id": "467658348158779393" + }, + "service": "Destiny Item Manager", + "description": { + "en": "Swap items, check stats, and build the loadout to Become Legend with DIM", + "nl": "Verwissel items, check stats, en bouw de uitrusting om Legend te worden met DIM" + }, + "url": [ + "destinyitemmanager.com", + "app.destinyitemmanager.com" + ], + "version": "1.0.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/thumbnail.jpg", + "color": "#ee6d0d", + "category": "games", + "tags": [ + "destiny2" + ] +} diff --git a/websites/D/Destiny Item Manager/presence.ts b/websites/D/Destiny Item Manager/presence.ts index 2cce18d012e4..4ff6bc0de688 100644 --- a/websites/D/Destiny Item Manager/presence.ts +++ b/websites/D/Destiny Item Manager/presence.ts @@ -1,72 +1,85 @@ const presence = new Presence({ - clientId: "811198714726449183", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '811198714726449183', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/logo.png", - GuardianWarlock = "https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/0.png", - GuardianTitan = "https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/1.png", - GuardianHunter = "https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/2.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/logo.png', + GuardianWarlock = 'https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/0.png', + GuardianTitan = 'https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/1.png', + GuardianHunter = 'https://cdn.rcd.gg/PreMiD/websites/D/Destiny%20Item%20Manager/assets/2.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } - if (window.location.host === "destinyitemmanager.com") - presenceData.details = "Browsing..."; - else if (window.location.host.startsWith("app")) { - if (window.location.pathname.includes("inventory")) { - const guardian = document - .querySelector( - "#content > div.inventory-container.destiny2 > div > div.store-row.store-header > div:nth-child(1) > div:nth-child(1) > div > div._2mo8C > div._1zQrq > div.ohqoA > div.FZBlR" - ) - .textContent.trim(); + if (window.location.host === 'destinyitemmanager.com') { + presenceData.details = 'Browsing...' + } + else if (window.location.host.startsWith('app')) { + if (window.location.pathname.includes('inventory')) { + const guardian = document + .querySelector( + '#content > div.inventory-container.destiny2 > div > div.store-row.store-header > div:nth-child(1) > div:nth-child(1) > div > div._2mo8C > div._1zQrq > div.ohqoA > div.FZBlR', + ) + ?.textContent + ?.trim() - presenceData.details = "Inventory"; - presenceData.state = guardian; - presenceData.smallImageText = `${guardian} - ${document - .querySelector( - "#content > div.inventory-container.destiny2 > div > div.store-row.store-header > div:nth-child(1) > div:nth-child(1) > div > div._2mo8C > div._1zQrq > div.ohqoA > div._1FuuK" - ) - .textContent.trim()}`; + presenceData.details = 'Inventory' + presenceData.state = guardian + presenceData.smallImageText = `${guardian} - ${document + .querySelector( + '#content > div.inventory-container.destiny2 > div > div.store-row.store-header > div:nth-child(1) > div:nth-child(1) > div > div._2mo8C > div._1zQrq > div.ohqoA > div._1FuuK', + ) + ?.textContent + ?.trim()}` - switch (guardian) { - case "Titan": { - presenceData.smallImageKey = Assets.GuardianTitan; - break; - } - case "Warlock": { - presenceData.smallImageKey = Assets.GuardianWarlock; - break; - } - case "Hunter": - { - presenceData.smallImageKey = Assets.GuardianHunter; - // No default - } - break; - } - } else if (window.location.pathname.includes("progress")) - presenceData.details = "Progress"; - else if (window.location.pathname.includes("vendors")) - presenceData.details = "Vendors"; - else if (window.location.pathname.includes("records")) - presenceData.details = "Records"; - else if (window.location.pathname.includes("optimizer")) - presenceData.details = "Loadout Optimizer"; - else if (window.location.pathname.includes("organizer")) - presenceData.details = "Organizer"; - else if (window.location.pathname.includes("settings")) - presenceData.details = "Settings"; - else if (window.location.pathname.includes("about")) - presenceData.details = "About"; - else if (window.location.pathname.includes("whats-new")) - presenceData.details = "DIM Changes"; - } else presenceData.details = "Browsing..."; + switch (guardian) { + case 'Titan': { + presenceData.smallImageKey = Assets.GuardianTitan + break + } + case 'Warlock': { + presenceData.smallImageKey = Assets.GuardianWarlock + break + } + case 'Hunter': { + presenceData.smallImageKey = Assets.GuardianHunter + break + } + } + } + else if (window.location.pathname.includes('progress')) { + presenceData.details = 'Progress' + } + else if (window.location.pathname.includes('vendors')) { + presenceData.details = 'Vendors' + } + else if (window.location.pathname.includes('records')) { + presenceData.details = 'Records' + } + else if (window.location.pathname.includes('optimizer')) { + presenceData.details = 'Loadout Optimizer' + } + else if (window.location.pathname.includes('organizer')) { + presenceData.details = 'Organizer' + } + else if (window.location.pathname.includes('settings')) { + presenceData.details = 'Settings' + } + else if (window.location.pathname.includes('about')) { + presenceData.details = 'About' + } + else if (window.location.pathname.includes('whats-new')) { + presenceData.details = 'DIM Changes' + } + } + else { + presenceData.details = 'Browsing...' + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/D/Destiny.gg/metadata.json b/websites/D/Destiny.gg/metadata.json index 26d137e4499d..d5945da9575b 100644 --- a/websites/D/Destiny.gg/metadata.json +++ b/websites/D/Destiny.gg/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "PreMiD", - "id": "503557087041683458" - }, - "service": "Destiny.gg", - "description": { - "en": "Streaming website for the streamer Steven \"Destiny\" Bonnell II", - "nl": "Streaming website voor de streamer Steven \"Destiny\" Bonnell II" - }, - "url": "www.destiny.gg", - "version": "1.0.23", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/thumbnail.png", - "color": "#568FCA", - "category": "socials", - "tags": [ - "english", - "streamer", - "streaming", - "twitch", - "youtube", - "live" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "PreMiD", + "id": "503557087041683458" + }, + "service": "Destiny.gg", + "description": { + "en": "Streaming website for the streamer Steven \"Destiny\" Bonnell II", + "nl": "Streaming website voor de streamer Steven \"Destiny\" Bonnell II" + }, + "url": "www.destiny.gg", + "version": "1.0.23", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/thumbnail.png", + "color": "#568FCA", + "category": "socials", + "tags": [ + "english", + "streamer", + "streaming", + "twitch", + "youtube", + "live" + ] +} diff --git a/websites/D/Destiny.gg/presence.ts b/websites/D/Destiny.gg/presence.ts index 97c439c96958..584c50daf476 100644 --- a/websites/D/Destiny.gg/presence.ts +++ b/websites/D/Destiny.gg/presence.ts @@ -1,44 +1,50 @@ -const browsingTimestamp = Math.floor(Date.now() / 1000), - presence = new Presence({ - clientId: "759921592926339072", - }); +const browsingTimestamp = Math.floor(Date.now() / 1000) +const presence = new Presence({ + clientId: '759921592926339072', +}) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/logo.png", - SmallImage = "https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/0.png", - Money = "https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/1.png", - Profile = "https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/2.png", - Chat = "https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/3.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/logo.png', + SmallImage = 'https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/0.png', + Money = 'https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/1.png', + Profile = 'https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/2.png', + Chat = 'https://cdn.rcd.gg/PreMiD/websites/D/Destiny.gg/assets/3.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - smallImageKey: Assets.SmallImage, - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + smallImageKey: Assets.SmallImage, + startTimestamp: browsingTimestamp, + } - if ( - document.location.pathname === "/" || - document.location.pathname === "/home/" - ) - presenceData.details = "Viewing the homepage."; - else if (document.location.pathname.includes("/bigscreen")) { - presenceData.details = "Watching Destiny."; - presenceData.smallImageKey = Assets.Play; - } else if (document.location.pathname.includes("/donate")) { - presenceData.details = "Donating to Destiny."; - presenceData.smallImageKey = Assets.Money; - } else if (document.location.pathname.includes("/subscribe")) { - presenceData.details = "Subscribing to Destiny."; - presenceData.smallImageKey = Assets.Money; - } else if (document.location.pathname.includes("/profile")) { - presenceData.details = "Editing D.gg profile."; - presenceData.smallImageKey = Assets.Profile; - } else if (document.location.pathname.includes("/embed/chat")) { - presenceData.details = "Chatting"; - presenceData.smallImageKey = Assets.Chat; - } + if ( + document.location.pathname === '/' + || document.location.pathname === '/home/' + ) { + presenceData.details = 'Viewing the homepage.' + } + else if (document.location.pathname.includes('/bigscreen')) { + presenceData.details = 'Watching Destiny.' + presenceData.smallImageKey = Assets.Play + } + else if (document.location.pathname.includes('/donate')) { + presenceData.details = 'Donating to Destiny.' + presenceData.smallImageKey = Assets.Money + } + else if (document.location.pathname.includes('/subscribe')) { + presenceData.details = 'Subscribing to Destiny.' + presenceData.smallImageKey = Assets.Money + } + else if (document.location.pathname.includes('/profile')) { + presenceData.details = 'Editing D.gg profile.' + presenceData.smallImageKey = Assets.Profile + } + else if (document.location.pathname.includes('/embed/chat')) { + presenceData.details = 'Chatting' + presenceData.smallImageKey = Assets.Chat + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Desu-Online/iframe.ts b/websites/D/Desu-Online/iframe.ts index 3c8cefea1dac..079932746cbc 100644 --- a/websites/D/Desu-Online/iframe.ts +++ b/websites/D/Desu-Online/iframe.ts @@ -1,13 +1,13 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", async () => { - const video = document.querySelector("video"); +iframe.on('UpdateData', async () => { + const video = document.querySelector('video') - if (!isNaN(video?.duration)) { - iframe.send({ - current: video.currentTime, - duration: video.duration, - paused: video.paused, - }); - } -}); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + current: video.currentTime, + duration: video.duration, + paused: video.paused, + }) + } +}) diff --git a/websites/D/Desu-Online/metadata.json b/websites/D/Desu-Online/metadata.json index 62d77ba98b99..d3ec0a56a212 100644 --- a/websites/D/Desu-Online/metadata.json +++ b/websites/D/Desu-Online/metadata.json @@ -1,42 +1,42 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "334411435633541121", - "name": "meffiu" - }, - "service": "Desu-Online", - "description": { - "en": "The best polish anime site! Anime with polish subtitles with good quality and no ads! The best video players!", - "pl": "Najlepsza strona z anime online pl! Anime z polskimi napisami w doskonałej jakości i bez reklam! Najlepsze odtwarzacze video." - }, - "url": "desu-online.pl", - "version": "1.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Desu-Online/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Desu-Online/assets/thumbnail.png", - "color": "#D9910F", - "category": "anime", - "tags": [ - "polish", - "anime" - ], - "iframe": true, - "iFrameRegExp": "cda[.]pl|google[.]com|mega[.nz]|dailymotion[.]com|sibnet[.]ru|fileditchstuff[.]me|yourupload[.]com|vk[.]com|wolfstream[.]tv|ok[.]ru", - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true, - "if": { - "privacy": false - } - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "334411435633541121", + "name": "meffiu" + }, + "service": "Desu-Online", + "description": { + "en": "The best polish anime site! Anime with polish subtitles with good quality and no ads! The best video players!", + "pl": "Najlepsza strona z anime online pl! Anime z polskimi napisami w doskonałej jakości i bez reklam! Najlepsze odtwarzacze video." + }, + "url": "desu-online.pl", + "version": "1.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Desu-Online/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Desu-Online/assets/thumbnail.png", + "color": "#D9910F", + "category": "anime", + "tags": [ + "polish", + "anime" + ], + "iframe": true, + "iFrameRegExp": "cda[.]pl|google[.]com|mega[.nz]|dailymotion[.]com|sibnet[.]ru|fileditchstuff[.]me|yourupload[.]com|vk[.]com|wolfstream[.]tv|ok[.]ru", + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true, + "if": { + "privacy": false + } + } + ] +} diff --git a/websites/D/Desu-Online/presence.ts b/websites/D/Desu-Online/presence.ts index 8eff5b5aaa87..3bb746e3f86f 100644 --- a/websites/D/Desu-Online/presence.ts +++ b/websites/D/Desu-Online/presence.ts @@ -1,189 +1,198 @@ const presence = new Presence({ - clientId: "580032576434077707", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - pages: { [key: string]: { desc: string; image: Assets } } = { - "/": { desc: "Strona Główna", image: Assets.Home }, - "/zakladki/": { desc: "Przegląda zakładki...", image: Assets.Viewing }, - "/gatunki/": { desc: "Przegląda gatunki...", image: Assets.Viewing }, - "/sezony/": { desc: "Przegląda sezony...", image: Assets.Viewing }, - "/polityka-prywatnosci/": { - desc: "Czyta politykę prywatności...", - image: Assets.Reading, - }, - }; - -let video = { - current: 0, - duration: 0, - paused: true, -}; + clientId: '580032576434077707', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Desu-Online/assets/logo.png", - Home = "https://cdn.rcd.gg/PreMiD/websites/D/Desu-Online/assets/0.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Desu-Online/assets/logo.png', + Home = 'https://cdn.rcd.gg/PreMiD/websites/D/Desu-Online/assets/0.png', +} + +const pages: { [key: string]: { desc: string, image: Assets } } = { + '/': { desc: 'Strona Główna', image: Assets.Home }, + '/zakladki/': { desc: 'Przegląda zakładki...', image: Assets.Viewing }, + '/gatunki/': { desc: 'Przegląda gatunki...', image: Assets.Viewing }, + '/sezony/': { desc: 'Przegląda sezony...', image: Assets.Viewing }, + '/polityka-prywatnosci/': { + desc: 'Czyta politykę prywatności...', + image: Assets.Reading, + }, +} + +let video = { + current: 0, + duration: 0, + paused: true, } presence.on( - "iFrameData", - (data: { current: number; duration: number; paused: boolean }) => { - video = data; - } -); + 'iFrameData', + (data: unknown) => { + video = data as typeof video + }, +) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - type: ActivityType.Watching, - name: "Desu-Online", - }, - { pathname, search, href } = document.location, - [privacy, buttons] = [ - await presence.getSetting("privacy"), - await presence.getSetting("buttons"), - ]; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + type: ActivityType.Watching, + name: 'Desu-Online', + } + const { pathname, search, href } = document.location + const [privacy, buttons] = [ + await presence.getSetting('privacy'), + await presence.getSetting('buttons'), + ] - presenceData.smallImageKey = Assets.Viewing; + presenceData.smallImageKey = Assets.Viewing - if (search) { - presenceData.details = "Używa zaawansowanej wyszukiwarki..."; - const searchvalues = search.split("&"); - for (const searchvalue of searchvalues) { - if (searchvalue.startsWith("s=")) { - presenceData.details = "Wyszukuje po frazie"; - presenceData.state = searchvalue - .substring(2, searchvalue.length) - .replace(/(%20)(\+)/gm, " "); - } else if (searchvalue.startsWith("?s=")) { - presenceData.details = "Wyszukuje po frazie"; - presenceData.state = searchvalue - .substring(3, searchvalue.length) - .replace(/(%20)(\+)/gm, " "); - } - } - } else { - switch (pathname) { - case pathname.startsWith("/anime/") ? pathname : null: - if (pathname === "/anime/") presenceData.details = "Przegląda serie..."; - else if (pathname === "/anime/list-mode/") - presenceData.details = "Przegląda listę serii..."; - else { - presenceData.details = "Przegląda serię"; - presenceData.state = - document.querySelector("h1.entry-title").textContent; - presenceData.largeImageKey = document - .querySelector("img.ts-post-image") - .getAttribute("src"); - presenceData.buttons = [ - { - label: "Odwiedź", - url: href, - }, - ]; - } - break; - case pathname.startsWith("/blog/") ? pathname : null: - if (pathname === "/blog/") { - presenceData.details = "Przegląda bloga"; - presenceData.state = "Strona 1"; - } else if (pathname.startsWith("/blog/page/")) { - presenceData.details = "Przegląda bloga:"; - presenceData.state = `Strona ${pathname.split("/")[3]}`; - } else { - presenceData.details = "Czyta bloga"; - presenceData.state = document - .querySelectorAll("h1")[0] - .textContent.replace("\n", ""); - presenceData.buttons = [{ label: "Czytaj", url: href }]; - } - break; - case pathname.startsWith("/season/") ? pathname : null: - presenceData.details = "Przegląda sezon"; - presenceData.state = - document.querySelector("div.newseason > h1").textContent; - break; - case pathname.startsWith("/label/") ? pathname : null: - if (pathname === "/label/news/") - presenceData.details = "Przegląda newsy..."; - else if (pathname === "/label/recenzja/") - presenceData.details = "Przegląda recenzje..."; - break; - case pathname.startsWith("/genres/") ? pathname : null: - presenceData.details = "Przegląda gatunek"; - presenceData.state = `${ - document.querySelector("div.releases > h1 > span").textContent - }`; - if (pathname.includes("page")) - presenceData.state += ` (Strona ${pathname.split("/")[4]})`; - break; - case pathname.startsWith("/studio/") ? pathname : null: - presenceData.details = "Przegląda studio"; - presenceData.state = `${ - document.querySelector("div.releases > h1 > span").textContent - }`; - if (pathname.includes("page")) - presenceData.state += ` (Strona ${pathname.split("/")[4]})`; - break; - case document.querySelector("div.video-content") ? pathname : null: { - privacy - ? (presenceData.name = "Desu-Online") - : (presenceData.name = - document.querySelector("div.det > h3").textContent); - const playinfo = document - .querySelector("li.selected > a > div.playinfo > span") - .textContent.split("-"), - episodenum = playinfo[0].replace("Odc", ""); - privacy - ? (presenceData.details = "Ogląda anime") - : (presenceData.details = isNaN(parseInt(episodenum)) - ? episodenum - : `Odcinek:${playinfo[0].replace("Odc", "")}`); - if (playinfo.length > 2) { - presenceData.state = document - .querySelector("li.selected > a > div.playinfo > span") - .textContent.match(/-.*-/gm) - .toString() - .slice(2, -2); - } + if (search) { + presenceData.details = 'Używa zaawansowanej wyszukiwarki...' + const searchvalues = search.split('&') + for (const searchvalue of searchvalues) { + if (searchvalue.startsWith('s=')) { + presenceData.details = 'Wyszukuje po frazie' + presenceData.state = searchvalue + .substring(2, searchvalue.length) + .replace(/(%20)(\+)/g, ' ') + } + else if (searchvalue.startsWith('?s=')) { + presenceData.details = 'Wyszukuje po frazie' + presenceData.state = searchvalue + .substring(3, searchvalue.length) + .replace(/(%20)(\+)/g, ' ') + } + } + } + else { + switch (pathname) { + case pathname.startsWith('/anime/') ? pathname : null: + if (pathname === '/anime/') { + presenceData.details = 'Przegląda serie...' + } + else if (pathname === '/anime/list-mode/') { + presenceData.details = 'Przegląda listę serii...' + } + else { + presenceData.details = 'Przegląda serię' + presenceData.state = document.querySelector('h1.entry-title')?.textContent + presenceData.largeImageKey = document + .querySelector('img.ts-post-image') + ?.getAttribute('src') + presenceData.buttons = [ + { + label: 'Odwiedź', + url: href, + }, + ] + } + break + case pathname.startsWith('/blog/') ? pathname : null: + if (pathname === '/blog/') { + presenceData.details = 'Przegląda bloga' + presenceData.state = 'Strona 1' + } + else if (pathname.startsWith('/blog/page/')) { + presenceData.details = 'Przegląda bloga:' + presenceData.state = `Strona ${pathname.split('/')[3]}` + } + else { + presenceData.details = 'Czyta bloga' + presenceData.state = document + .querySelectorAll('h1')[0] + ?.textContent + ?.replace('\n', '') + presenceData.buttons = [{ label: 'Czytaj', url: href }] + } + break + case pathname.startsWith('/season/') ? pathname : null: + presenceData.details = 'Przegląda sezon' + presenceData.state = document.querySelector('div.newseason > h1')?.textContent + break + case pathname.startsWith('/label/') ? pathname : null: + if (pathname === '/label/news/') + presenceData.details = 'Przegląda newsy...' + else if (pathname === '/label/recenzja/') + presenceData.details = 'Przegląda recenzje...' + break + case pathname.startsWith('/genres/') ? pathname : null: + presenceData.details = 'Przegląda gatunek' + presenceData.state = `${ + document.querySelector('div.releases > h1 > span')?.textContent + }` + if (pathname.includes('page')) + presenceData.state += ` (Strona ${pathname.split('/')[4]})` + break + case pathname.startsWith('/studio/') ? pathname : null: + presenceData.details = 'Przegląda studio' + presenceData.state = `${ + document.querySelector('div.releases > h1 > span')?.textContent + }` + if (pathname.includes('page')) + presenceData.state += ` (Strona ${pathname.split('/')[4]})` + break + case document.querySelector('div.video-content') ? pathname : null: { + privacy + ? (presenceData.name = 'Desu-Online') + : (presenceData.name = document.querySelector('div.det > h3')!.textContent!) + const playinfo = document + .querySelector('li.selected > a > div.playinfo > span') + ?.textContent + ?.split('-') + const episodenum = playinfo?.[0]?.replace('Odc', '') + privacy + ? (presenceData.details = 'Ogląda anime') + : (presenceData.details = Number.isNaN(Number.parseInt(episodenum ?? '')) + ? episodenum + : `Odcinek:${playinfo?.[0].replace('Odc', '')}`) + if (playinfo && playinfo.length > 2) { + presenceData.state = document + .querySelector('li.selected > a > div.playinfo > span') + ?.textContent + ?.match(/-.*-/g) + ?.toString() + ?.slice(2, -2) + } - presenceData.buttons = [ - { label: "Oglądaj", url: document.URL }, - { - label: "Cała seria", - url: document - .querySelector("div.det > h3 > a") - .getAttribute("href"), - }, - ]; - presenceData.largeImageKey = document - .querySelector("img.ts-post-image") - .getAttribute("src"); - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(video.current, video.duration); + presenceData.buttons = [ + { label: 'Oglądaj', url: document.URL }, + { + label: 'Cała seria', + url: document + .querySelector('div.det > h3 > a') + ?.getAttribute('href') ?? '', + }, + ] + presenceData.largeImageKey = document + .querySelector('img.ts-post-image') + ?.getAttribute('src'); + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(video.current, video.duration) - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Odtwarzanie"; - if (video.paused) { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = "Wstrzymano"; - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - break; - } - default: - presenceData.details = pages[pathname].desc || "Nieznana aktywność 🤨"; - presenceData.smallImageKey = pages[pathname].image || Assets.Viewing; - break; - } - } + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Odtwarzanie' + if (video.paused) { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Wstrzymano' + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + break + } + default: + presenceData.details = pages[pathname].desc || 'Nieznana aktywność 🤨' + presenceData.smallImageKey = pages[pathname].image || Assets.Viewing + break + } + } - if (!buttons || privacy) delete presenceData.buttons; - if (privacy) { - presenceData.largeImageKey = Assets.Logo; - delete presenceData.state; - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (!buttons || privacy) + delete presenceData.buttons + if (privacy) { + presenceData.largeImageKey = Assets.Logo + delete presenceData.state + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/DeviantArt/metadata.json b/websites/D/DeviantArt/metadata.json index e41bc929e361..1f041358b294 100644 --- a/websites/D/DeviantArt/metadata.json +++ b/websites/D/DeviantArt/metadata.json @@ -1,51 +1,51 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Hans5958", - "id": "279855717203050496" - }, - "service": "DeviantArt", - "description": { - "en": "Founded in August 2000, DeviantArt is the largest online social network for artists and art enthusiasts, and a platform for emerging and established artists to exhibit, promote, and share their works with an enthusiastic, art-centric community.", - "nl": "DeviantArt, opgericht in augustus 2000, is het grootste online sociaal netwerk voor kunstenaars en kunstliefhebbers, en een platform voor opkomende en gevestigde kunstenaars om hun werken tentoon te stellen, te promoten en te delen met een enthousiaste, kunst-georiënteerde gemeenschap.", - "vi_VN": "Được thành lập vào Tháng 8 Năm 2000, DeviantArt là mạng xã hội lớn nhất dành cho hoạ sĩ và người yêu thích hội hoạ, và là một nền tảng cho các hoạ sĩ mới bắt đầu và đã thành đạt trưng bày, giới thiệu, và chia sẻ các tác phẩm của họ cho một cộng đồng yêu thích hội hoạ." - }, - "url": [ - "www.deviantart.com", - "chat.deviantart.com", - "groups.deviantart.com", - "portfolio.deviantart.com", - "shop.deviantart.com", - "www.deviantartsupport.com", - "deviantartads.com", - "sta.sh" - ], - "version": "1.2.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DeviantArt/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DeviantArt/assets/thumbnail.png", - "color": "#05cc47", - "category": "other", - "tags": [ - "art", - "fandom", - "drawing", - "creative", - "literature", - "deviation" - ], - "settings": [ - { - "id": "chatChannelNames", - "title": "Show chat channel names", - "icon": "fas fa-comments", - "value": true - }, - { - "id": "detailedSettings", - "title": "Show detailed settings pages info", - "icon": "fas fa-wrench", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Hans5958", + "id": "279855717203050496" + }, + "service": "DeviantArt", + "description": { + "en": "Founded in August 2000, DeviantArt is the largest online social network for artists and art enthusiasts, and a platform for emerging and established artists to exhibit, promote, and share their works with an enthusiastic, art-centric community.", + "nl": "DeviantArt, opgericht in augustus 2000, is het grootste online sociaal netwerk voor kunstenaars en kunstliefhebbers, en een platform voor opkomende en gevestigde kunstenaars om hun werken tentoon te stellen, te promoten en te delen met een enthousiaste, kunst-georiënteerde gemeenschap.", + "vi_VN": "Được thành lập vào Tháng 8 Năm 2000, DeviantArt là mạng xã hội lớn nhất dành cho hoạ sĩ và người yêu thích hội hoạ, và là một nền tảng cho các hoạ sĩ mới bắt đầu và đã thành đạt trưng bày, giới thiệu, và chia sẻ các tác phẩm của họ cho một cộng đồng yêu thích hội hoạ." + }, + "url": [ + "www.deviantart.com", + "chat.deviantart.com", + "groups.deviantart.com", + "portfolio.deviantart.com", + "shop.deviantart.com", + "www.deviantartsupport.com", + "deviantartads.com", + "sta.sh" + ], + "version": "1.2.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DeviantArt/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DeviantArt/assets/thumbnail.png", + "color": "#05cc47", + "category": "other", + "tags": [ + "art", + "fandom", + "drawing", + "creative", + "literature", + "deviation" + ], + "settings": [ + { + "id": "chatChannelNames", + "title": "Show chat channel names", + "icon": "fas fa-comments", + "value": true + }, + { + "id": "detailedSettings", + "title": "Show detailed settings pages info", + "icon": "fas fa-wrench", + "value": true + } + ] +} diff --git a/websites/D/DeviantArt/presence.ts b/websites/D/DeviantArt/presence.ts index 29aab47d8819..6a9651963647 100644 --- a/websites/D/DeviantArt/presence.ts +++ b/websites/D/DeviantArt/presence.ts @@ -1,796 +1,842 @@ const presence = new Presence({ - clientId: "664057766809436161", -}); + clientId: '664057766809436161', +}) -let currentURL = new URL(document.location.href), - currentPath = currentURL.pathname.replace(/^\/|\/$/g, "").split("/"); -const browsingTimestamp = Math.floor(Date.now() / 1000); +let currentURL = new URL(document.location.href) +let currentPath = currentURL.pathname.replace(/^\/|\/$/g, '').split('/') +const browsingTimestamp = Math.floor(Date.now() / 1000) let presenceData: PresenceData = { - details: "Viewing an unsupported page", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DeviantArt/assets/logo.png", - startTimestamp: browsingTimestamp, -}; + details: 'Viewing an unsupported page', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DeviantArt/assets/logo.png', + startTimestamp: browsingTimestamp, +} const updateCallback = { - _function: null as () => void, - get function(): () => void { - return this._function; - }, - set function(parameter) { - this._function = parameter; - }, - get present(): boolean { - return this._function !== null; - }, - }, - /** - * Initialize/reset presenceData. - */ - resetData = ( - defaultData: PresenceData = { - details: "Viewing an unsupported page", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DeviantArt/assets/logo.png", - startTimestamp: browsingTimestamp, - } - ): void => { - currentURL = new URL(document.location.href); - currentPath = currentURL.pathname.replace(/^\/|\/$/g, "").split("/"); - presenceData = { ...defaultData }; - }, - /** - * Function definitions for logging-related things. - */ - logHandler = { - /** - * Handles not supported pages. - * @param isCritical If the URL is essential to the operation, this should be true, so it will output an error, not a warning. - */ - pageNotSupported(isCritical = false): void { - if (isCritical) { - presence.error( - "Whoops. It seems that this page is not supported. \nPlease report this to Hans5958#0969 on Discord." - ); - } else { - presence.error( - "It seems that this page is not fully supported. \nPlease report this to Hans5958#0969 on Discord." - ); - } - presence.info(currentURL.href); - }, - /** - * Handles fatal errors. - * @param error The error that it threw. - */ - fatalError(error: string): void { - presence.error( - "Fatal error! Terminating.\nPlease report this to Hans5958#0969 on Discord." - ); - presence.info(currentURL.href); - presence.info(error); - }, - }, - /** - * Search for URL parameters. - * @param urlParam The parameter that you want to know about the value. - */ - getURLParam = (urlParam: string): string => { - return currentURL.searchParams.get(urlParam); - }, - prepare = async (): Promise => { - /* - - For future developers: - - These domains are supported. - - www.deviantart.com - - about.deviantart.com - - chat.deviantart.com - - forum.deviantart.com - - groups.deviantart.com - - portfolio.deviantart.com - - shop.deviantart.com - - www.deviantartsupport.com - - www.eclipsefeedback.com - - deviantartads.com - - sta.sh - - wallpaper.deviantart.com (redirects to https://www.deviantart.com/customization/wallpaper/) - - These domains will be supported in the future. - - *.daportfolio.com - - */ - - const presenceSettings = { - chatChannelNames: await presence.getSetting("chatChannelNames"), - detailedSettings: await presence.getSetting("detailedSettings"), - }; - - switch (currentURL.hostname) { - case "www.deviantart.com": { - let loadedPath: string, - forceUpdate = false, - presenceDataPlaced: PresenceData = {}, - retries = 0, - profileType: string; - - /* This one decides if the current page belongs to an user or a group */ - if (document.querySelector("#group")) profileType = "group"; - else profileType = "user"; - - const lastItem = (array: NodeList | unknown[]): unknown => { - return array[array.length - 1]; - }, - getName = (override = false): string => { - try { - if (!override) { - try { - return document.querySelector( - "#content-container > div > div > div > div > div > a.user-link" - ).textContent; - } catch { - return document.querySelector( - "#root > main > div > div > div > div > div > div > div > div > span > a.user-link" - ).textContent; - } - } else { - try { - return ( - lastItem( - document.querySelectorAll("h1 .author .u .u") - ) as Element - ).textContent; - } catch { - return document.querySelector("h1 .u .u").textContent; - } - } - } catch { - if ( - currentPath[0].toLowerCase() === - document - .querySelector("title") - .textContent.split(" ")[0] - .toLowerCase() - ) { - return document - .querySelector("title") - .textContent.split(" ")[0]; - } else if ( - currentPath[0].toLowerCase() === - document - .querySelector("title") - .textContent.split(" by ")[1] - .split(" ")[0] - .toLowerCase() - ) { - [presenceData.state] = document - .querySelector("title") - .textContent.split(" by ")[1] - .split(" "); - return; - } - } - }; - - updateCallback.function = (): void => { - if (loadedPath !== currentURL.pathname || forceUpdate) { - loadedPath = currentURL.pathname; - - try { - /* - - Section 1 - This section includes the homepage and similar pages. - - */ - - if (currentPath[0] === "") - presenceData.details = "Viewing the home page"; - /* This needs to be on the top since the 404 errors has no fixed URL. */ else if ( - document.querySelector(".error-400") || - document.querySelector(".error-401") || - document.querySelector(".error-403") || - document.querySelector(".error-404") || - document.querySelector(".error-405") || - document.querySelector(".error-500") || - document.querySelector(".error-503") || - document.querySelector(".error-banned") || - document.querySelector(".error-beta") || - document.querySelector(".error-blocked") || - document.querySelector(".error-blockedbyuser") || - document.querySelector(".error-contentblockedbyuser") || - document.querySelector(".error-deactivated") || - document.querySelector(".error-noreferrer") || - document.querySelector(".error-pageflooder") || - document.querySelector(".error-suspended") || - document.querySelector(".error-threadflooder") || - document.querySelector("#error-400") || - document.querySelector("#error-401") || - document.querySelector("#error-403") || - document.querySelector("#error-404") || - document.querySelector("#error-405") || - document.querySelector("#error-500") || - document.querySelector("#error-503") || - document.querySelector("#error-banned") || - document.querySelector("#error-beta") || - document.querySelector("#error-blocked") || - document.querySelector("#error-blockedbyuser") || - document.querySelector("#error-contentblockedbyuser") || - document.querySelector("#error-deactivated") || - document.querySelector("#error-noreferrer") || - document.querySelector("#error-pageflooder") || - document.querySelector("#error-suspended") || - document.querySelector("#error-threadflooder") - ) - presenceData.details = "On a non-existent page"; - /* The functions below is only valid on the Eclipse theme. */ else { - switch (currentPath[0]) { - case "deviations": { - presenceData.details = "Viewing deviations"; - presenceData.state = currentPath - .slice(1) - .concat(getURLParam("order") ?? []) - .join(" > ") - .trim() - .replaceAll("-", " ") - .toLowerCase() - .split(" ") - .map(w => w.replace(w[0], w[0].toUpperCase())) - .join(" "); - - break; - } - case "daily-deviations": { - presenceData.details = "Viewing daily deviations"; - presenceData.state = - document.querySelector( - "#daily-deviation-picker" - ).textContent; - - break; - } - case "journals": { - presenceData.details = "Viewing daily deviations"; - if (currentPath[1]) { - presenceData.state = currentPath[1].replace( - currentPath[1], - currentPath[1].toUpperCase() - ); - } else presenceData.state = "All"; - - break; - } - case "status-updates": { - presenceData.details = "Viewing status updates"; - break; - } - case "polls": { - presenceData.details = "Viewing polls"; - break; - } - case "commissions": { - presenceData.details = "Viewing commissions"; - break; - } - case "tag": { - presenceData.details = "Viewing a tag"; - presenceData.state = `#${currentPath[1]}`; - - break; - } - case "search": { - presenceData.details = "Searching something"; - presenceData.state = getURLParam("q"); - - break; - } - case "notifications": { - /* Detailed infos, such as what section does the user sees, might be implemented but disabled by default. */ - if (currentPath[1] === "notes") - presenceData.details = "Reading notes"; - if (currentPath[1] === "watch") - presenceData.details = "Viewing the watch list"; - else presenceData.details = "Reading notifications"; - - break; - } - case "settings": { - /* Detailed infos might be disabled by default. */ - presenceData.details = "Doing some settings"; - if (presenceSettings.detailedSettings) { - presenceData.state = document.querySelector( - "ul.menu_holder li > a.active" - ).textContent; - } - - break; - } - case "account": { - /* This might expose some stuff, because the page shows orders, points, and earnings. Additional infos might be disabled by default. */ - presenceData.details = "Viewing the account pages"; - // presenceSettings.detailedAccount - - break; - } - case "checkout": { - /* This might be disabled by default. */ - presenceData.details = "On the checkout"; - - break; - } - case "wishlist": { - presenceData.details = "Viewing their wishlist"; - break; - } - case "core-membership": { - presenceData.details = "Viewing a page"; - presenceData.state = "Core Membership"; - - break; - } - case "timeline": { - presenceData.details = "Viewing a page"; - presenceData.state = "Timeline"; - - break; - } - case "makeagroup": { - presenceData.details = "Making a group"; - break; - } - default: - if ( - currentPath[0] === "users" && - currentPath[1] === "login" - ) - presenceData.details = "Logging in"; - else { - switch (currentPath[0]) { - case "join": { - presenceData.details = "Registering an account"; - break; - } - case "forum": { - if (currentPath[2]) { - if (currentPath[3]) { - presenceData.details = "Viewing a topic"; - presenceData.state = - document.querySelector("h1").textContent; - } else { - presenceData.details = "Viewing a topic category"; - presenceData.state = - document.querySelector("h1").textContent; - } - } else presenceData.details = "Viewing the forums"; - - break; - } - case "about": { - presenceData.details = "Viewing the about pages"; - - if (currentPath[1] === "") - presenceData.state = "About"; - else if (currentPath[1] === "policy") { - if (currentPath[2] === "etiquette") - presenceData.state = "Etiquette Policy"; - if (currentPath[2] === "privacy") - presenceData.state = "Privacy Policy"; - if (currentPath[2] === "service") - presenceData.state = "Terms of Service"; - if (currentPath[2] === "copyright") - presenceData.state = "Copyright Policy"; - } else logHandler.pageNotSupported(false); - - break; - } - case "watch": { - presenceData.details = "Viewing the watch list"; - break; - } - default: - switch (currentPath[1]) { - case "art": { - presenceData.details = document - .querySelector("title") - .textContent.split(" by ") - .slice(0, -1) - .join(" - "); - [presenceData.state] = document - .querySelector("title") - .textContent.split(" by ") - .pop() - .split(" "); - /* I actually wanted to get it using the visible elements, but well, it's complicated. */ - if ( - presenceData.details === - presenceDataPlaced.details && - presenceData.state === presenceDataPlaced.state - ) { - throw new Error( - "Current status is the same as the previous." - ); - } - if (presenceData.details === "") { - throw new Error( - "No art title detected and user is from the homepage." - ); - } - - /* The functions below are valid for users and groups. */ - - break; - } - case "gallery": - case "favourites": { - if (currentPath[1] === "gallery") - presenceData.details = `Viewing a ${profileType}'s gallery`; - else - presenceData.details = `Viewing a ${profileType}'s favourites`; - if (profileType === "user") { - presenceData.state = `${ - document.querySelector("h2.uUWfu").textContent - } by ${getName()}`; - } else if ( - profileType === "group" && - !currentPath[2] - ) - presenceData.state = getName(true); - else if ( - !document.querySelector(".gallery .active") - ) { - presenceData.state = `${ - document.querySelector(".folder-title") - .textContent - } by ${getName(true)}`; - } else if ( - document - .querySelector(".gallery .active") - .textContent.slice(1) === "Featured" - ) { - presenceData.state = `Featured by ${getName( - true - )}`; - } else if ( - document - .querySelector(".gallery .active") - .textContent.slice(1) === "All" - ) - presenceData.state = `All by ${getName(true)}`; - - /* The functions below are vaild for users only. */ - - break; - } - case "print": { - presenceData.details = - document.querySelector("h1 .title").textContent; - presenceData.state = getName(true); - - break; - } - case "prints": { - presenceData.details = "Viewing a user's prints"; - presenceData.state = getName(); - - break; - } - case "posts": { - /* This part is only valid on the Eclipse theme. */ - presenceData.details = { - All: "Viewing a user's posts", - Journals: "Viewing a user's journals", - "Status Updates": "Viewing a user's statuses", - Polls: "Viewing a user's polls", - }[ - document.querySelector( - "._3xmU1 div a" - ).textContent - ]; - presenceData.state = getName(); - - break; - } - case "journal": { - if (currentPath[2]) { - presenceData.details = - document.querySelector("._2-k1X").textContent; - presenceData.state = `${getName()} (journal)`; - } else { - /* This part is only valid on the old theme. */ - presenceData.details = - "Viewing a user's journals"; - presenceData.state = getName(); - } - - break; - } - case "poll": { - try { - presenceData.details = - document.querySelector("._1ddsf").textContent; - } catch { - presenceData.details = - document.querySelector(".gfMBk").textContent; - } - presenceData.state = getName(); - - break; - } - case "critique": { - if (currentPath[2]) { - presenceData.details = "Viewing a critique"; - presenceData.state = `from ${getName()}, ${document - .querySelector("h2") - .textContent.trim()} ${document - .querySelector("h4") - .textContent.trim()}`; - } else { - presenceData.details = - "Viewing a user's critiques"; - presenceData.state = getName(); - } - - break; - } - case "wishlist": { - presenceData.details = - "Viewing a user's wishlist"; - presenceData.state = getName(); - - break; - } - case "dds": { - presenceData.details = - "Viewing a user's daily deviations"; - presenceData.state = getName(); - - break; - } - case "badges": { - /* This part is only valid on the old theme. (not quite sure) */ - if (currentPath[2]) { - presenceData.details = "Viewing a badge"; - presenceData.state = `${ - document.querySelector("h3").textContent - } from ${getName()}`; - } else { - presenceData.details = `Viewing a ${profileType}'s badges`; - presenceData.state = getName(true); - } - - /* The functions below are valid for groups only. */ - - break; - } - case "aboutus": { - presenceData.details = - "Viewing a group's about page"; - presenceData.state = getName(true); - - break; - } - case "blog": { - presenceData.details = "Viewing a group's blog"; - presenceData.state = getName(true); - - /* The function below are valid for users and groups. */ - - break; - } - default: - if ( - currentPath[0] && - !currentPath[1] && - getName() - ) { - presenceData.details = `Viewing a ${profileType}'s profile`; - if (profileType === "group") - presenceData.state = getName(true); - else presenceData.state = getName(); - - /* The page is not supported. Whoops. */ - } else logHandler.pageNotSupported(true); - } - } - } - } - } - - presence.success("Done!"); - presenceDataPlaced = presenceData; - forceUpdate = false; - retries = 0; - } catch (error) { - forceUpdate = true; - retries++; - resetData(); - presenceData.details = "Loading..."; - if (retries === 30) { - updateCallback.function = (): void => void 0; - logHandler.fatalError(error); - } - } - } else presenceData = presenceDataPlaced; - }; - - break; - } - case "chat.deviantart.com": { - if (currentPath[0] === "") - presenceData.details = "Viewing the chat room list"; - else if (currentPath[0] === "chat") { - presenceData.details = "On a chat room"; - - if (presenceSettings.chatChannelNames) { - const channel = (): string => - document.querySelector(".damnc-tabbar strong").textContent; - let loadedChannel = "", - forceUpdate = false, - presenceDataPlaced: PresenceData = {}, - retries = 0; - - updateCallback.function = (): void => { - if (loadedChannel !== channel() || forceUpdate) { - loadedChannel = channel(); - try { - presenceData.state = channel(); - presenceDataPlaced = presenceData; - forceUpdate = false; - retries = 0; - } catch (error) { - forceUpdate = true; - retries++; - resetData(); - presenceData.details = "Loading..."; - if (retries === 30) { - updateCallback.function = (): void => void 0; - logHandler.fatalError(error); - } - } - } else presenceData = presenceDataPlaced; - }; - } - } - - break; - } - case "groups.deviantart.com": { - presenceData.details = "Looking for a group"; - break; - } - case "portfolio.deviantart.com": { - presenceData.details = "Creating a portfolio"; - break; - } - case "shop.deviantart.com": { - if (getURLParam("q")) { - presenceData.details = "Searching something on the shop"; - presenceData.state = getURLParam("q"); - } else { - presenceData.details = "Viewing deviations on the shop"; - const li = document.querySelectorAll( - ".browse-facet-product ul li .selected" - ); - for (const v of li) { - if (!presenceData.state) presenceData.state = v.textContent; - else presenceData.state += ` > ${v.textContent}`; - } - } - - break; - } - case "www.deviantartsupport.com": { - let currentTitle = "", - presenceDataPlaced: PresenceData = {}; - - updateCallback.function = (): void => { - if (currentTitle !== document.title.split(" - ")[0]) { - [currentTitle] = document.title.split(" - "); - presenceData.details = "Viewing the help center/KB"; - presenceData.state = currentTitle; - presenceDataPlaced = presenceData; - } else presenceData = presenceDataPlaced; - }; - - break; - } - case "www.eclipsefeedback.com": { - presenceData.details = "Giving feedback about Eclipse"; - break; - } - case "deviantartads.com": { - presenceData.details = "Viewing the media kit"; - break; - } - case "sta.sh": { - let loadedPath: string, - forceUpdate = false, - presenceDataPlaced: PresenceData = {}, - retries = 0; - - updateCallback.function = (): void => { - if (loadedPath !== currentURL.pathname || forceUpdate) { - loadedPath = currentURL.pathname; - - try { - switch (currentPath[0]) { - case "": - presenceData.details = "On Sta.sh"; - presenceData.state = "Index"; - break; - - case "my": - if (currentPath[1] === "settings") { - presenceData.details = "On Sta.sh"; - presenceData.state = "Settings"; - } - // else { - // logHandler.pageNotSupported(true) - // } - break; - - case "writer": - presenceData.details = "On Sta.sh"; - presenceData.state = "Sta.sh Writer"; - break; - - case "muro": - presenceData.details = "On Sta.sh"; - presenceData.state = "DeviantArt muro"; - break; - - default: - presenceData.details = document - .querySelector("title") - .textContent.split(" - ") - .slice(0, -1) - .join(" - "); - presenceData.state = `${ - document - .querySelector("title") - .textContent.split(" - ") - .pop() - .split("'s")[0] - } (sta.sh)`; - if (presenceData.details === "") - throw new Error("No title found on Sta.sh"); - } - - presenceDataPlaced = presenceData; - forceUpdate = false; - retries = 0; - } catch (error) { - forceUpdate = true; - retries++; - resetData(); - presenceData.details = "Loading..."; - if (retries === 30) { - updateCallback.function = (): void => void 0; - logHandler.fatalError(error); - } - } - } else presenceData = presenceDataPlaced; - }; - - break; - } - // No default - } - }; + _function: null as unknown as () => void, + get function(): () => void { + return this._function + }, + set function(parameter) { + this._function = parameter + }, + get present(): boolean { + return this._function !== null + }, +} +/** + * Initialize/reset presenceData. + */ +function resetData(defaultData: PresenceData = { + details: 'Viewing an unsupported page', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DeviantArt/assets/logo.png', + startTimestamp: browsingTimestamp, +}): void { + currentURL = new URL(document.location.href) + currentPath = currentURL.pathname.replace(/^\/|\/$/g, '').split('/') + presenceData = { ...defaultData } +} +/** + * Function definitions for logging-related things. + */ +const logHandler = { + /** + * Handles not supported pages. + * @param isCritical If the URL is essential to the operation, this should be true, so it will output an error, not a warning. + */ + pageNotSupported(isCritical = false): void { + if (isCritical) { + presence.error( + 'Whoops. It seems that this page is not supported. \nPlease report this to Hans5958#0969 on Discord.', + ) + } + else { + presence.error( + 'It seems that this page is not fully supported. \nPlease report this to Hans5958#0969 on Discord.', + ) + } + presence.info(currentURL.href) + }, + /** + * Handles fatal errors. + * @param error The error that it threw. + */ + fatalError(error: string): void { + presence.error( + 'Fatal error! Terminating.\nPlease report this to Hans5958#0969 on Discord.', + ) + presence.info(currentURL.href) + presence.info(error) + }, +} +/** + * Search for URL parameters. + * @param urlParam The parameter that you want to know about the value. + */ +function getURLParam(urlParam: string): string { + return currentURL.searchParams.get(urlParam)! +} +async function prepare(): Promise { + /* + + For future developers: + + These domains are supported. + - www.deviantart.com + - about.deviantart.com + - chat.deviantart.com + - forum.deviantart.com + - groups.deviantart.com + - portfolio.deviantart.com + - shop.deviantart.com + - www.deviantartsupport.com + - www.eclipsefeedback.com + - deviantartads.com + - sta.sh + - wallpaper.deviantart.com (redirects to https://www.deviantart.com/customization/wallpaper/) + + These domains will be supported in the future. + - *.daportfolio.com + + */ + + const presenceSettings = { + chatChannelNames: await presence.getSetting('chatChannelNames'), + detailedSettings: await presence.getSetting('detailedSettings'), + } + + switch (currentURL.hostname) { + case 'www.deviantart.com': { + let loadedPath: string + let forceUpdate = false + let presenceDataPlaced: PresenceData = {} + let retries = 0 + let profileType: string + + /* This one decides if the current page belongs to an user or a group */ + if (document.querySelector('#group')) + profileType = 'group' + else profileType = 'user' + + const lastItem = (array: NodeList | unknown[]): unknown => { + return array[array.length - 1] + } + const getName = (override = false): string | undefined => { + try { + if (!override) { + try { + return document.querySelector( + '#content-container > div > div > div > div > div > a.user-link', + )!.textContent! + } + catch { + return document.querySelector( + '#root > main > div > div > div > div > div > div > div > div > span > a.user-link', + )!.textContent! + } + } + else { + try { + return ( + lastItem( + document.querySelectorAll('h1 .author .u .u'), + ) as Element + )!.textContent! + } + catch { + return document.querySelector('h1 .u .u')!.textContent! + } + } + } + catch { + if ( + currentPath[0].toLowerCase() + === document + .querySelector('title') + ?.textContent + ?.split(' ')[0] + ?.toLowerCase() + ) { + return document + .querySelector('title') + ?.textContent + ?.split(' ')[0] + } + else if ( + currentPath[0].toLowerCase() + === document + .querySelector('title') + ?.textContent + ?.split(' by ')[1] + ?.split(' ')[0] + ?.toLowerCase() + ) { + [presenceData.state] = document + .querySelector('title') + ?.textContent + ?.split(' by ')[1] + ?.split(' ') ?? [] + } + } + } + + updateCallback.function = (): void => { + if (loadedPath !== currentURL.pathname || forceUpdate) { + loadedPath = currentURL.pathname + + try { + /* + + Section 1 + This section includes the homepage and similar pages. + + */ + + if (currentPath[0] === '') { + presenceData.details = 'Viewing the home page' + } + /* This needs to be on the top since the 404 errors has no fixed URL. */ else if ( + document.querySelector('.error-400') + || document.querySelector('.error-401') + || document.querySelector('.error-403') + || document.querySelector('.error-404') + || document.querySelector('.error-405') + || document.querySelector('.error-500') + || document.querySelector('.error-503') + || document.querySelector('.error-banned') + || document.querySelector('.error-beta') + || document.querySelector('.error-blocked') + || document.querySelector('.error-blockedbyuser') + || document.querySelector('.error-contentblockedbyuser') + || document.querySelector('.error-deactivated') + || document.querySelector('.error-noreferrer') + || document.querySelector('.error-pageflooder') + || document.querySelector('.error-suspended') + || document.querySelector('.error-threadflooder') + || document.querySelector('#error-400') + || document.querySelector('#error-401') + || document.querySelector('#error-403') + || document.querySelector('#error-404') + || document.querySelector('#error-405') + || document.querySelector('#error-500') + || document.querySelector('#error-503') + || document.querySelector('#error-banned') + || document.querySelector('#error-beta') + || document.querySelector('#error-blocked') + || document.querySelector('#error-blockedbyuser') + || document.querySelector('#error-contentblockedbyuser') + || document.querySelector('#error-deactivated') + || document.querySelector('#error-noreferrer') + || document.querySelector('#error-pageflooder') + || document.querySelector('#error-suspended') + || document.querySelector('#error-threadflooder') + ) { + presenceData.details = 'On a non-existent page' + } + /* The functions below is only valid on the Eclipse theme. */ else { + switch (currentPath[0]) { + case 'deviations': { + presenceData.details = 'Viewing deviations' + presenceData.state = currentPath + .slice(1) + .concat(getURLParam('order') ?? []) + .join(' > ') + .trim() + .replaceAll('-', ' ') + .toLowerCase() + .split(' ') + .map(w => w.replace(w[0], w[0].toUpperCase())) + .join(' ') + + break + } + case 'daily-deviations': { + presenceData.details = 'Viewing daily deviations' + presenceData.state = document.querySelector( + '#daily-deviation-picker', + )?.textContent + + break + } + case 'journals': { + presenceData.details = 'Viewing daily deviations' + if (currentPath[1]) { + presenceData.state = currentPath[1].replace( + currentPath[1], + currentPath[1].toUpperCase(), + ) + } + else { + presenceData.state = 'All' + } + + break + } + case 'status-updates': { + presenceData.details = 'Viewing status updates' + break + } + case 'polls': { + presenceData.details = 'Viewing polls' + break + } + case 'commissions': { + presenceData.details = 'Viewing commissions' + break + } + case 'tag': { + presenceData.details = 'Viewing a tag' + presenceData.state = `#${currentPath[1]}` + + break + } + case 'search': { + presenceData.details = 'Searching something' + presenceData.state = getURLParam('q') + + break + } + case 'notifications': { + /* Detailed infos, such as what section does the user sees, might be implemented but disabled by default. */ + if (currentPath[1] === 'notes') + presenceData.details = 'Reading notes' + if (currentPath[1] === 'watch') + presenceData.details = 'Viewing the watch list' + else presenceData.details = 'Reading notifications' + + break + } + case 'settings': { + /* Detailed infos might be disabled by default. */ + presenceData.details = 'Doing some settings' + if (presenceSettings.detailedSettings) { + presenceData.state = document.querySelector( + 'ul.menu_holder li > a.active', + )?.textContent + } + + break + } + case 'account': { + /* This might expose some stuff, because the page shows orders, points, and earnings. Additional infos might be disabled by default. */ + presenceData.details = 'Viewing the account pages' + // presenceSettings.detailedAccount + + break + } + case 'checkout': { + /* This might be disabled by default. */ + presenceData.details = 'On the checkout' + + break + } + case 'wishlist': { + presenceData.details = 'Viewing their wishlist' + break + } + case 'core-membership': { + presenceData.details = 'Viewing a page' + presenceData.state = 'Core Membership' + + break + } + case 'timeline': { + presenceData.details = 'Viewing a page' + presenceData.state = 'Timeline' + + break + } + case 'makeagroup': { + presenceData.details = 'Making a group' + break + } + default: + if ( + currentPath[0] === 'users' + && currentPath[1] === 'login' + ) { + presenceData.details = 'Logging in' + } + else { + switch (currentPath[0]) { + case 'join': { + presenceData.details = 'Registering an account' + break + } + case 'forum': { + if (currentPath[2]) { + if (currentPath[3]) { + presenceData.details = 'Viewing a topic' + presenceData.state = document.querySelector('h1')?.textContent + } + else { + presenceData.details = 'Viewing a topic category' + presenceData.state = document.querySelector('h1')?.textContent + } + } + else { + presenceData.details = 'Viewing the forums' + } + + break + } + case 'about': { + presenceData.details = 'Viewing the about pages' + + if (currentPath[1] === '') { + presenceData.state = 'About' + } + else if (currentPath[1] === 'policy') { + if (currentPath[2] === 'etiquette') + presenceData.state = 'Etiquette Policy' + if (currentPath[2] === 'privacy') + presenceData.state = 'Privacy Policy' + if (currentPath[2] === 'service') + presenceData.state = 'Terms of Service' + if (currentPath[2] === 'copyright') + presenceData.state = 'Copyright Policy' + } + else { + logHandler.pageNotSupported(false) + } + + break + } + case 'watch': { + presenceData.details = 'Viewing the watch list' + break + } + default: + switch (currentPath[1]) { + case 'art': { + presenceData.details = document + .querySelector('title') + ?.textContent + ?.split(' by ') + ?.slice(0, -1) + ?.join(' - '); + [presenceData.state] = document + .querySelector('title') + ?.textContent + ?.split(' by ') + ?.pop() + ?.split(' ') ?? [] + /* I actually wanted to get it using the visible elements, but well, it's complicated. */ + if ( + presenceData.details + === presenceDataPlaced.details + && presenceData.state === presenceDataPlaced.state + ) { + throw new Error( + 'Current status is the same as the previous.', + ) + } + if (presenceData.details === '') { + throw new Error( + 'No art title detected and user is from the homepage.', + ) + } + + /* The functions below are valid for users and groups. */ + + break + } + case 'gallery': + case 'favourites': { + if (currentPath[1] === 'gallery') + presenceData.details = `Viewing a ${profileType}'s gallery` + else + presenceData.details = `Viewing a ${profileType}'s favourites` + if (profileType === 'user') { + presenceData.state = `${ + document.querySelector('h2.uUWfu')?.textContent + } by ${getName()}` + } + else if ( + profileType === 'group' + && !currentPath[2] + ) { + presenceData.state = getName(true) + } + else if ( + !document.querySelector('.gallery .active') + ) { + presenceData.state = `${ + document.querySelector('.folder-title') + ?.textContent + } by ${getName(true)}` + } + else if ( + document + .querySelector('.gallery .active') + ?.textContent + ?.slice(1) === 'Featured' + ) { + presenceData.state = `Featured by ${getName( + true, + )}` + } + else if ( + document + .querySelector('.gallery .active') + ?.textContent + ?.slice(1) === 'All' + ) { + presenceData.state = `All by ${getName(true)}` + } + + /* The functions below are vaild for users only. */ + + break + } + case 'print': { + presenceData.details = document.querySelector('h1 .title')?.textContent + presenceData.state = getName(true) + + break + } + case 'prints': { + presenceData.details = 'Viewing a user\'s prints' + presenceData.state = getName() + + break + } + case 'posts': { + /* This part is only valid on the Eclipse theme. */ + presenceData.details = { + 'All': 'Viewing a user\'s posts', + 'Journals': 'Viewing a user\'s journals', + 'Status Updates': 'Viewing a user\'s statuses', + 'Polls': 'Viewing a user\'s polls', + }[ + document.querySelector( + '._3xmU1 div a', + )?.textContent ?? '' + ] + presenceData.state = getName() + + break + } + case 'journal': { + if (currentPath[2]) { + presenceData.details = document.querySelector('._2-k1X')?.textContent + presenceData.state = `${getName()} (journal)` + } + else { + /* This part is only valid on the old theme. */ + presenceData.details = 'Viewing a user\'s journals' + presenceData.state = getName() + } + + break + } + case 'poll': { + try { + presenceData.details = document.querySelector('._1ddsf')?.textContent + } + catch { + presenceData.details = document.querySelector('.gfMBk')?.textContent + } + presenceData.state = getName() + + break + } + case 'critique': { + if (currentPath[2]) { + presenceData.details = 'Viewing a critique' + presenceData.state = `from ${getName()}, ${document + .querySelector('h2') + ?.textContent + ?.trim()} ${document + .querySelector('h4') + ?.textContent + ?.trim()}` + } + else { + presenceData.details = 'Viewing a user\'s critiques' + presenceData.state = getName() + } + + break + } + case 'wishlist': { + presenceData.details = 'Viewing a user\'s wishlist' + presenceData.state = getName() + + break + } + case 'dds': { + presenceData.details = 'Viewing a user\'s daily deviations' + presenceData.state = getName() + + break + } + case 'badges': { + /* This part is only valid on the old theme. (not quite sure) */ + if (currentPath[2]) { + presenceData.details = 'Viewing a badge' + presenceData.state = `${ + document.querySelector('h3')?.textContent + } from ${getName()}` + } + else { + presenceData.details = `Viewing a ${profileType}'s badges` + presenceData.state = getName(true) + } + + /* The functions below are valid for groups only. */ + + break + } + case 'aboutus': { + presenceData.details = 'Viewing a group\'s about page' + presenceData.state = getName(true) + + break + } + case 'blog': { + presenceData.details = 'Viewing a group\'s blog' + presenceData.state = getName(true) + + /* The function below are valid for users and groups. */ + + break + } + default: + if ( + currentPath[0] + && !currentPath[1] + && getName() + ) { + presenceData.details = `Viewing a ${profileType}'s profile` + if (profileType === 'group') + presenceData.state = getName(true) + else presenceData.state = getName() + + /* The page is not supported. Whoops. */ + } + else { + logHandler.pageNotSupported(true) + } + } + } + } + } + } + + presence.success('Done!') + presenceDataPlaced = presenceData + forceUpdate = false + retries = 0 + } + catch (error) { + forceUpdate = true + retries++ + resetData() + presenceData.details = 'Loading...' + if (retries === 30) { + updateCallback.function = (): void => void 0 + logHandler.fatalError(error as string) + } + } + } + else { + presenceData = presenceDataPlaced + } + } + + break + } + case 'chat.deviantart.com': { + if (currentPath[0] === '') { + presenceData.details = 'Viewing the chat room list' + } + else if (currentPath[0] === 'chat') { + presenceData.details = 'On a chat room' + + if (presenceSettings.chatChannelNames) { + const channel = (): string => + document.querySelector('.damnc-tabbar strong')!.textContent! + let loadedChannel = '' + let forceUpdate = false + let presenceDataPlaced: PresenceData = {} + let retries = 0 + + updateCallback.function = (): void => { + if (loadedChannel !== channel() || forceUpdate) { + loadedChannel = channel() + try { + presenceData.state = channel() + presenceDataPlaced = presenceData + forceUpdate = false + retries = 0 + } + catch (error) { + forceUpdate = true + retries++ + resetData() + presenceData.details = 'Loading...' + if (retries === 30) { + updateCallback.function = (): void => void 0 + logHandler.fatalError(error as string) + } + } + } + else { + presenceData = presenceDataPlaced + } + } + } + } + + break + } + case 'groups.deviantart.com': { + presenceData.details = 'Looking for a group' + break + } + case 'portfolio.deviantart.com': { + presenceData.details = 'Creating a portfolio' + break + } + case 'shop.deviantart.com': { + if (getURLParam('q')) { + presenceData.details = 'Searching something on the shop' + presenceData.state = getURLParam('q') + } + else { + presenceData.details = 'Viewing deviations on the shop' + const li = document.querySelectorAll( + '.browse-facet-product ul li .selected', + ) + for (const v of li) { + if (!presenceData.state) + presenceData.state = v.textContent + else presenceData.state += ` > ${v.textContent}` + } + } + + break + } + case 'www.deviantartsupport.com': { + let currentTitle = '' + let presenceDataPlaced: PresenceData = {} + + updateCallback.function = (): void => { + if (currentTitle !== document.title.split(' - ')[0]) { + [currentTitle] = document.title.split(' - ') + presenceData.details = 'Viewing the help center/KB' + presenceData.state = currentTitle + presenceDataPlaced = presenceData + } + else { + presenceData = presenceDataPlaced + } + } + + break + } + case 'www.eclipsefeedback.com': { + presenceData.details = 'Giving feedback about Eclipse' + break + } + case 'deviantartads.com': { + presenceData.details = 'Viewing the media kit' + break + } + case 'sta.sh': { + let loadedPath: string + let forceUpdate = false + let presenceDataPlaced: PresenceData = {} + let retries = 0 + + updateCallback.function = (): void => { + if (loadedPath !== currentURL.pathname || forceUpdate) { + loadedPath = currentURL.pathname + + try { + switch (currentPath[0]) { + case '': + presenceData.details = 'On Sta.sh' + presenceData.state = 'Index' + break + + case 'my': + if (currentPath[1] === 'settings') { + presenceData.details = 'On Sta.sh' + presenceData.state = 'Settings' + } + // else { + // logHandler.pageNotSupported(true) + // } + break + + case 'writer': + presenceData.details = 'On Sta.sh' + presenceData.state = 'Sta.sh Writer' + break + + case 'muro': + presenceData.details = 'On Sta.sh' + presenceData.state = 'DeviantArt muro' + break + + default: + presenceData.details = document + .querySelector('title') + ?.textContent + ?.split(' - ') + ?.slice(0, -1) + ?.join(' - ') + presenceData.state = `${ + document + .querySelector('title') + ?.textContent + ?.split(' - ') + ?.pop() + ?.split('\'s')[0] + } (sta.sh)` + if (presenceData.details === '') + throw new Error('No title found on Sta.sh') + } + + presenceDataPlaced = presenceData + forceUpdate = false + retries = 0 + } + catch (error) { + forceUpdate = true + retries++ + resetData() + presenceData.details = 'Loading...' + if (retries === 30) { + updateCallback.function = (): void => void 0 + logHandler.fatalError(error as string) + } + } + } + else { + presenceData = presenceDataPlaced + } + } + + break + } + } +} (async (): Promise => { - await prepare(); - - if (updateCallback.present) { - const defaultData = { ...presenceData }; - presence.on("UpdateData", async () => { - resetData(defaultData); - updateCallback.function(); - presence.setActivity(presenceData); - }); - } else { - presence.on("UpdateData", async () => { - presence.setActivity(presenceData); - }); - } -})(); + await prepare() + + if (updateCallback.present) { + const defaultData = { ...presenceData } + presence.on('UpdateData', async () => { + resetData(defaultData) + updateCallback.function() + presence.setActivity(presenceData) + }) + } + else { + presence.on('UpdateData', async () => { + presence.setActivity(presenceData) + }) + } +})() diff --git a/websites/D/Di.FM/metadata.json b/websites/D/Di.FM/metadata.json index f70661c4e7c7..041a089b7722 100644 --- a/websites/D/Di.FM/metadata.json +++ b/websites/D/Di.FM/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Callum", - "id": "506899274748133376" - }, - "service": "Di.FM", - "description": { - "en": "Di.FM is an Internet radio broadcaster consisting of over 90 channels dedicated exclusively to electronic music, such as house, trance, techno, drum and bass, and dubstep.", - "ga_IE": "Di.FM is craoltóir raidió Idirlín é atá comhdhéanta de níos mó ná 90 cainéal atá tiomnaithe go heisiach do cheol leictreonach, amhail teach, trance, techno, druma agus dord, agus dubstep.", - "nl": "Di.FM is een internetradiozender met meer dan 90 kanalen die uitsluitend gewijd zijn aan elektronische muziek, zoals house, trance, techno, drum and bass, en dubstep." - }, - "url": "di.fm", - "regExp": "([a-z0-9-]+[.])*di[.]fm[/]", - "version": "1.5.8", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Di.FM/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Di.FM/assets/thumbnail.png", - "color": "#3aa154", - "category": "music", - "tags": [ - "music", - "radio" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Callum", + "id": "506899274748133376" + }, + "service": "Di.FM", + "description": { + "en": "Di.FM is an Internet radio broadcaster consisting of over 90 channels dedicated exclusively to electronic music, such as house, trance, techno, drum and bass, and dubstep.", + "ga_IE": "Di.FM is craoltóir raidió Idirlín é atá comhdhéanta de níos mó ná 90 cainéal atá tiomnaithe go heisiach do cheol leictreonach, amhail teach, trance, techno, druma agus dord, agus dubstep.", + "nl": "Di.FM is een internetradiozender met meer dan 90 kanalen die uitsluitend gewijd zijn aan elektronische muziek, zoals house, trance, techno, drum and bass, en dubstep." + }, + "url": "di.fm", + "regExp": "([a-z0-9-]+[.])*di[.]fm[/]", + "version": "1.5.8", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Di.FM/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Di.FM/assets/thumbnail.png", + "color": "#3aa154", + "category": "music", + "tags": [ + "music", + "radio" + ] +} diff --git a/websites/D/Di.FM/presence.ts b/websites/D/Di.FM/presence.ts index 906159fddf59..b031d783e337 100644 --- a/websites/D/Di.FM/presence.ts +++ b/websites/D/Di.FM/presence.ts @@ -1,27 +1,28 @@ const presence = new Presence({ - clientId: "630542731701387276", -}); + clientId: '630542731701387276', +}) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/D/Di.FM/assets/logo.png", - }; - if ( - document.querySelector("#webplayer-region").getAttribute("data-state") === - "playing" - ) { - presenceData.details = document - .querySelectorAll(".artist-name")[0] - .textContent.replace("-", ""); - presenceData.state = - document.querySelectorAll(".track-name")[0].textContent; - presenceData.smallImageKey = Assets.Play; - presenceData.largeImageKey = document.querySelector( - "div > section.track-region.col > div > div.artwork > div > img" - ).src; - } else { - presenceData.state = "Browsing..."; - presenceData.smallImageKey = Assets.Pause; - } - presence.setActivity(presenceData); -}); +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Di.FM/assets/logo.png', + } + if ( + document.querySelector('#webplayer-region')?.getAttribute('data-state') + === 'playing' + ) { + presenceData.details = document + .querySelectorAll('.artist-name')[0] + ?.textContent + ?.replace('-', '') + presenceData.state = document.querySelectorAll('.track-name')[0]?.textContent + presenceData.smallImageKey = Assets.Play + presenceData.largeImageKey = document.querySelector( + 'div > section.track-region.col > div > div.artwork > div > img', + )?.src + } + else { + presenceData.state = 'Browsing...' + presenceData.smallImageKey = Assets.Pause + } + presence.setActivity(presenceData) +}) diff --git a/websites/D/Dice Sweden/metadata.json b/websites/D/Dice Sweden/metadata.json index 75e7df87b4cc..9d50fd14992b 100644 --- a/websites/D/Dice Sweden/metadata.json +++ b/websites/D/Dice Sweden/metadata.json @@ -1,36 +1,36 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "The Gamerzs", - "id": "730142125181894657" - }, - "service": "Dice Sweden", - "description": { - "en": "At DICE, we all share the passion to create exceptional games.", - "nl": "Bij DICE delen we allemaal de passie om uitzonderlijke games te maken." - }, - "url": "www.dice.se", - "version": "1.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dice%20Sweden/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dice%20Sweden/assets/thumbnail.png", - "color": "#000", - "category": "games", - "tags": [ - "gaming" - ], - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - }, - { - "id": "timestamps", - "title": "Show Elapsed Time", - "icon": "fad fa-stopwatch", - "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": "Dice Sweden", + "description": { + "en": "At DICE, we all share the passion to create exceptional games.", + "nl": "Bij DICE delen we allemaal de passie om uitzonderlijke games te maken." + }, + "url": "www.dice.se", + "version": "1.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dice%20Sweden/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dice%20Sweden/assets/thumbnail.png", + "color": "#000", + "category": "games", + "tags": [ + "gaming" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + }, + { + "id": "timestamps", + "title": "Show Elapsed Time", + "icon": "fad fa-stopwatch", + "value": true + } + ] +} diff --git a/websites/D/Dice Sweden/presence.ts b/websites/D/Dice Sweden/presence.ts index e9445214805a..90a022eaeccb 100644 --- a/websites/D/Dice Sweden/presence.ts +++ b/websites/D/Dice Sweden/presence.ts @@ -1,174 +1,175 @@ const presence = new Presence({ - clientId: "837754527217877003", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '837754527217877003', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let articleTitle: string, - articleDate: string, - gameTitle: string, - profileTitle: string, - profileStatus: string; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Dice%20Sweden/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const showButtons = await presence.getSetting('buttons') + const showTimestamps = await presence.getSetting('timestamps') -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Dice%20Sweden/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - showButtons = await presence.getSetting("buttons"), - showTimestamps = await presence.getSetting("timestamps"); + switch (window.location.pathname) { + case '/': + presenceData.details = 'Home' + break + case '/games': + presenceData.details = 'Games' + presenceData.buttons = [ + { label: 'View Games', url: 'https://www.dice.se/games' }, + ] + break + case '/life-at-dice': + presenceData.details = 'Life At Dice' + presenceData.buttons = [ + { label: 'Life At Dice', url: 'https://www.dice.se/life-at-dice' }, + ] + break + case '/our-values': + presenceData.details = 'Our Values' + presenceData.buttons = [ + { label: 'Our Values', url: 'https://www.dice.se/our-values' }, + ] + break + case '/how-we-work-how-we-play': + presenceData.details = 'How We Work' + presenceData.state = 'How We Play' - switch (window.location.pathname) { - case "/": - presenceData.details = "Home"; - break; - case "/games": - presenceData.details = "Games"; - presenceData.buttons = [ - { label: "View Games", url: "https://www.dice.se/games" }, - ]; - break; - case "/life-at-dice": - presenceData.details = "Life At Dice"; - presenceData.buttons = [ - { label: "Life At Dice", url: "https://www.dice.se/life-at-dice" }, - ]; - break; - case "/our-values": - presenceData.details = "Our Values"; - presenceData.buttons = [ - { label: "Our Values", url: "https://www.dice.se/our-values" }, - ]; - break; - case "/how-we-work-how-we-play": - presenceData.details = "How We Work"; - presenceData.state = "How We Play"; + presenceData.buttons = [ + { + label: 'How We Work', + url: 'https://www.dice.se/how-we-work-how-we-play', + }, + { + label: 'How We Play', + url: 'https://www.dice.se/how-we-work-how-we-play#how-we-play', + }, + ] + break + case '/our-crafts': + presenceData.details = 'Our Crafts' + presenceData.buttons = [ + { label: 'Our Crafts', url: 'https://www.dice.se/our-crafts' }, + ] + break + case '/careers': + presenceData.details = 'Careers' + presenceData.buttons = [ + { label: 'View Careers', url: 'https://www.dice.se/careers' }, + ] + break + case '/perks-benefits': + presenceData.details = 'Perks & Benefits' + presenceData.buttons = [ + { + label: 'View Perks & Benefits', + url: 'https://www.dice.se/perks-benefits', + }, + ] + break + case '/living-in-sweden': + presenceData.details = 'Living In Sweden' + presenceData.buttons = [ + { + label: 'Living In Sweden', + url: 'https://www.dice.se/living-in-sweden', + }, + ] + break + case '/latest': + presenceData.details = 'Latest News' + presenceData.buttons = [ + { + label: 'Latest News', + url: 'https://www.dice.se/latest', + }, + ] + break + case '/news-article': + presenceData.details = 'News' + presenceData.buttons = [ + { + label: 'News', + url: 'https://www.dice.se/news-articles', + }, + ] + break + case '/contact': + presenceData.details = 'Contacts' + presenceData.buttons = [ + { + label: 'View Contacts', + url: 'https://www.dice.se/contact', + }, + ] + break + case '/students': + presenceData.details = 'Students' + presenceData.buttons = [ + { + label: 'Students', + url: 'https://www.dice.se/students', + }, + ] + break + } - presenceData.buttons = [ - { - label: "How We Work", - url: "https://www.dice.se/how-we-work-how-we-play", - }, - { - label: "How We Play", - url: "https://www.dice.se/how-we-work-how-we-play#how-we-play", - }, - ]; - break; - case "/our-crafts": - presenceData.details = "Our Crafts"; - presenceData.buttons = [ - { label: "Our Crafts", url: "https://www.dice.se/our-crafts" }, - ]; - break; - case "/careers": - presenceData.details = "Careers"; - presenceData.buttons = [ - { label: "View Careers", url: "https://www.dice.se/careers" }, - ]; - break; - case "/perks-benefits": - presenceData.details = "Perks & Benefits"; - presenceData.buttons = [ - { - label: "View Perks & Benefits", - url: "https://www.dice.se/perks-benefits", - }, - ]; - break; - case "/living-in-sweden": - presenceData.details = "Living In Sweden"; - presenceData.buttons = [ - { - label: "Living In Sweden", - url: "https://www.dice.se/living-in-sweden", - }, - ]; - break; - case "/latest": - presenceData.details = "Latest News"; - presenceData.buttons = [ - { - label: "Latest News", - url: "https://www.dice.se/latest", - }, - ]; - break; - case "/news-article": - presenceData.details = "News"; - presenceData.buttons = [ - { - label: "News", - url: "https://www.dice.se/news-articles", - }, - ]; - break; - case "/contact": - presenceData.details = "Contacts"; - presenceData.buttons = [ - { - label: "View Contacts", - url: "https://www.dice.se/contact", - }, - ]; - break; - case "/students": - presenceData.details = "Students"; - presenceData.buttons = [ - { - label: "Students", - url: "https://www.dice.se/students", - }, - ]; - break; - } + if (window.location.pathname.includes('/news-articles/')) { + const articleTitle = document.querySelector('.BlogItem-title')?.textContent?.trim() + const articleDate = document + .querySelector('.BlogItem-meta > time') + ?.textContent + ?.trim() - if (window.location.pathname.includes("/news-articles/")) { - articleTitle = document.querySelector(".BlogItem-title").textContent.trim(); - articleDate = document - .querySelector(".BlogItem-meta > time") - .textContent.trim(); + presenceData.details = articleTitle + presenceData.state = articleDate - presenceData.details = articleTitle; - presenceData.state = articleDate; + delete presenceData.buttons + presenceData.buttons = [ + { label: 'View Article', url: window.location.href }, + ] + } + else if (window.location.pathname.includes('/game/')) { + const gameTitle = document.querySelector('.BlogItem-title')?.textContent?.trim() - delete presenceData.buttons; - presenceData.buttons = [ - { label: "View Article", url: window.location.href }, - ]; - } else if (window.location.pathname.includes("/game/")) { - gameTitle = document.querySelector(".BlogItem-title").textContent.trim(); + presenceData.details = gameTitle - presenceData.details = gameTitle; + presenceData.buttons = [ + { label: `View ${gameTitle}`, url: window.location.href }, + ] + } + else if (window.location.pathname.includes('/people/')) { + const profileTitle = document + .querySelector('.BlogItem-title') + ?.textContent + ?.trim() + const profileStatus = document + .querySelector('.sqs-row > div > div:nth-child(3) > div > p') + ?.textContent + ?.trim() + ?? document + .querySelector('.sqs-row > div > div:nth-child(2) > div > p') + ?.textContent + ?.trim() - presenceData.buttons = [ - { label: `View ${gameTitle}`, url: window.location.href }, - ]; - } else if (window.location.pathname.includes("/people/")) { - profileTitle = document - .querySelector(".BlogItem-title") - ?.textContent.trim(); - profileStatus = - document - .querySelector(".sqs-row > div > div:nth-child(3) > div > p") - .textContent.trim() ?? - document - .querySelector(".sqs-row > div > div:nth-child(2) > div > p") - .textContent.trim(); + presenceData.details = profileTitle + presenceData.state = profileStatus - presenceData.details = profileTitle; - presenceData.state = profileStatus; + delete presenceData.buttons + presenceData.buttons = [ + { label: `View ${profileTitle}`, url: window.location.href }, + ] + } - delete presenceData.buttons; - presenceData.buttons = [ - { label: `View ${profileTitle}`, url: window.location.href }, - ]; - } + if (!showButtons && presenceData.buttons) + delete presenceData.buttons - if (!showButtons && presenceData.buttons) delete presenceData.buttons; + if (!showTimestamps) + delete presenceData.startTimestamp - if (!showTimestamps) delete presenceData.startTimestamp; - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Discogs/metadata.json b/websites/D/Discogs/metadata.json index c3c04d8ad450..7bf814b79536 100644 --- a/websites/D/Discogs/metadata.json +++ b/websites/D/Discogs/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "193714715631812608", - "name": "theusaf" - }, - "service": "Discogs", - "description": { - "en": "Discover music on Discogs, the largest online music database. Buy and sell music with collectors in the Marketplace." - }, - "url": "www.discogs.com", - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discogs/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discogs/assets/thumbnail.png", - "color": "#333", - "category": "music", - "tags": [ - "database", - "collection", - "vinyl", - "discography" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "193714715631812608", + "name": "theusaf" + }, + "service": "Discogs", + "description": { + "en": "Discover music on Discogs, the largest online music database. Buy and sell music with collectors in the Marketplace." + }, + "url": "www.discogs.com", + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discogs/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discogs/assets/thumbnail.png", + "color": "#333", + "category": "music", + "tags": [ + "database", + "collection", + "vinyl", + "discography" + ] +} diff --git a/websites/D/Discogs/presence.ts b/websites/D/Discogs/presence.ts index 351db23673f0..86635a1b3f9a 100644 --- a/websites/D/Discogs/presence.ts +++ b/websites/D/Discogs/presence.ts @@ -1,425 +1,453 @@ const presence = new Presence({ - clientId: "1042567470738837534", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - slideshow = presence.createSlideshow(), - shortenedURLs: Record = {}; + clientId: '1042567470738837534', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const slideshow = presence.createSlideshow() +const shortenedURLs: Record = {} async function getShortURL(url: string) { - if (url.length < 256) return url; - if (shortenedURLs[url]) return shortenedURLs[url]; - try { - const pdURL = await ( - await fetch(`https://pd.premid.app/create/${url}`) - ).text(); - shortenedURLs[url] = pdURL; - return pdURL; - } catch (err) { - presence.error(err); - return url; - } + if (url.length < 256) + return url + if (shortenedURLs[url]) + return shortenedURLs[url] + try { + const pdURL = await ( + await fetch(`https://pd.premid.app/create/${url}`) + ).text() + shortenedURLs[url] = pdURL + return pdURL + } + catch (err) { + presence.error(err as string) + return url + } } function combineChildTexts(parent: HTMLElement) { - return [...parent.childNodes] - .map(node => node.textContent.replace(/\n/g, "").trim()) - .join(" ") - .replace(/(?<=\s)\s+/g, " "); + return [...parent.childNodes] + .map(node => node.textContent?.replace(/\n/g, '').trim()) + .join(' ') + .replace(/(?<=\s)\s+/g, ' ') } async function createImageSlideshow(type: string) { - for (const [i, image] of document - .querySelectorAll("#view_images img") - .entries()) { - slideshow.addSlide( - i.toString(), - { - details: `Viewing ${type} images`, - state: document.querySelector("#page_content h2 > a").textContent, - largeImageKey: await getShortURL(image.src), - }, - 5000 - ); - } + for (const [i, image] of document + .querySelectorAll('#view_images img') + .entries()) { + slideshow.addSlide( + i.toString(), + { + details: `Viewing ${type} images`, + state: document.querySelector('#page_content h2 > a')?.textContent, + largeImageKey: await getShortURL(image.src), + }, + 5000, + ) + } } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Discogs/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { href, pathname, hash } = window.location, - pathSplit = pathname.split("/").filter(Boolean), - lastPath = pathSplit[pathSplit.length - 1], - pageTitle = document.querySelector("h1"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Discogs/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { href, pathname, hash } = window.location + const pathSplit = pathname.split('/').filter(Boolean) + const lastPath = pathSplit[pathSplit.length - 1] + const pageTitle = document.querySelector('h1') - switch (pathSplit[0] ?? "") { - case "": { - presenceData.details = "Browsing home page"; - break; - } - case "artist": { - if (lastPath === "images") await createImageSlideshow("artist"); - else { - presenceData.details = "Viewing an artist"; - presenceData.state = pageTitle.textContent; - presenceData.largeImageKey = await getShortURL( - document.querySelector(".thumbnail_link img").src - ); - presenceData.buttons = [{ label: "View Artist", url: href }]; - } - break; - } - case "developer": { - const [, currentPage, currentHeader] = - hash.match(/page:([^,]+).*?header:([^,]+)/) ?? []; - let state = ""; - presenceData.details = "Viewing API documentation"; - if (currentPage) { - state += document.querySelector( - `#${currentPage}` - ).textContent; - if (currentHeader) { - state += ` - ${ - document.querySelector(`#${currentHeader}`) - .textContent - }`; - } - } - if (state) presenceData.state = state; - break; - } - case "digs": { - if (pathSplit[2]) { - presenceData.details = "Viewing a dig"; - presenceData.state = pageTitle.textContent; - presenceData.buttons = [{ label: "View Dig", url: href }]; - } else if (pathSplit[1]) { - presenceData.details = "Browsing digs"; - presenceData.state = pageTitle.textContent; - } else presenceData.details = "Browsing digs"; - break; - } - case "forum": { - switch (pathSplit[1] ?? "") { - case "": { - presenceData.details = "Browsing the forums"; - break; - } - case "thread": { - if (pathSplit[2] === "new") - presenceData.details = "Creating a new forum thread"; - else { - presenceData.details = "Viewing a forum thread"; - presenceData.state = pageTitle.textContent; - presenceData.buttons = [{ label: "View Thread", url: href }]; - } - break; - } - case "topic": { - presenceData.details = "Viewing a forum topic"; - presenceData.state = pageTitle.textContent.trim(); - break; - } - case "search": { - presenceData.details = "Searching the forums"; - presenceData.state = document.querySelector( - ".search_table_field" - ).value; - break; - } - } - break; - } - case "genre": { - presenceData.details = "Viewing a genre"; - const title = pageTitle.textContent.trim().split(" "); - presenceData.state = title.slice(0, title.length - 1).join(" "); - presenceData.buttons = [{ label: "View Genre", url: href }]; - break; - } - case "group": { - switch (pathSplit[1] ?? "") { - case "": - case "browse": { - presenceData.details = "Browsing groups"; - break; - } - case "create": { - presenceData.details = "Creating a group"; - break; - } - case "posted": { - presenceData.details = "Viewing threads they posted in"; - break; - } - case "recent": { - presenceData.details = "Viewing recent group activity"; - break; - } - case "saved": { - presenceData.details = "Viewing saved threads"; - break; - } - case "search": { - presenceData.details = "Searching groups"; - presenceData.state = document.querySelector( - ".search_table_field" - ).value; - break; - } - case "started": { - presenceData.details = "Viewing threads they started"; - break; - } - case "thread": { - presenceData.details = "Viewing a group thread"; - presenceData.state = pageTitle.textContent; - presenceData.buttons = [{ label: "View Thread", url: href }]; - break; - } - case "watched": { - presenceData.details = "Viewing watched threads"; - break; - } - default: { - if (lastPath === "admin") presenceData.details = "Managing a group"; - else if (lastPath === "members") - presenceData.details = "Viewing group members"; - else { - presenceData.details = "Viewing a group"; - presenceData.buttons = [{ label: "View Group", url: href }]; - } - presenceData.state = document - .querySelector("h1") - .firstChild.textContent.trim(); - } - } - break; - } - case "hc": { - switch (pathSplit[2] ?? "") { - case "": { - presenceData.details = "Browsing the help center"; - break; - } - case "articles": { - presenceData.details = "Reading a help article"; - presenceData.state = pageTitle.textContent; - presenceData.buttons = [{ label: "Read Article", url: href }]; - break; - } - case "categories": - case "sections": { - presenceData.details = "Browsing a help center category"; - presenceData.state = pageTitle.textContent; - break; - } - case "search": { - presenceData.details = "Searching the help center"; - presenceData.state = - document.querySelector("#query").value; - break; - } - } - break; - } - case "label": { - if (lastPath === "images") await createImageSlideshow("label"); - else { - presenceData.details = "Viewing a label"; - presenceData.state = pageTitle.textContent; - presenceData.largeImageKey = await getShortURL( - document.querySelector(".thumbnail_link img").src - ); - presenceData.buttons = [{ label: "View Label", url: href }]; - } - break; - } - case "leaderboard": { - presenceData.details = "Viewing the leaderboard"; - break; - } - case "marketplace": { - if (pathSplit[1] === "offers") - presenceData.details = "Viewing their offers"; - else presenceData.details = "Browsing the marketplace"; - break; - } - case "master": { - if (pathSplit[1] === "stats") { - presenceData.details = "Viewing stats for a master release"; - presenceData.state = document.querySelector("h1 > a").textContent; - } else if (pathSplit[1] === "create") - presenceData.details = "Creating a master release"; - else if (lastPath === "images") await createImageSlideshow("master"); - else { - presenceData.details = "Viewing a master release"; - presenceData.state = pageTitle.textContent; - presenceData.largeImageKey = await getShortURL( - document.querySelector("picture > img").src - ); - presenceData.buttons = [{ label: "View Release", url: href }]; - } - break; - } - case "messages": { - if (pathSplit[1] === "compose") - presenceData.details = "Composing a message"; - else presenceData.details = "Viewing messages"; - break; - } - case "my": { - presenceData.details = "Viewing dashboard"; - break; - } - case "release": { - if (pathSplit[1] === "stats") { - presenceData.details = "Viewing stats for release"; - presenceData.state = document.querySelector("h1 > a").textContent; - } else if (pathSplit[2] === "videos") { - presenceData.details = "Editing videos for release"; - presenceData.state = combineChildTexts(pageTitle); - } else if (lastPath === "images") await createImageSlideshow("release"); - else { - presenceData.details = "Viewing a release"; - presenceData.state = pageTitle.textContent; - presenceData.largeImageKey = await getShortURL( - document.querySelector("picture > img").src - ); - presenceData.buttons = [{ label: "View Release", url: href }]; - } - break; - } - case "sell": { - switch (pathSplit[1] ?? "") { - case "": { - presenceData.details = "Searching for an item to sell"; - break; - } - case "billing": { - presenceData.details = "Viewing billing information"; - break; - } - case "cart": { - presenceData.details = "Viewing their cart"; - break; - } - case "history": { - presenceData.details = "Viewing price history"; - presenceData.state = document.querySelector("h3").textContent.trim(); - break; - } - case "inventory": { - presenceData.details = "Viewing their inventory"; - break; - } - case "mywants": { - presenceData.details = "Viewing their wishlist"; - break; - } - case "list": { - presenceData.details = "Viewing items for sale"; - presenceData.state = pageTitle.textContent; - break; - } - case "orders": { - presenceData.details = "Viewing their orders"; - break; - } - case "post": { - presenceData.details = "Posting an item for sale"; - presenceData.state = combineChildTexts(document.querySelector("h2")); - break; - } - case "purchases": { - presenceData.details = "Viewing their purchases"; - break; - } - case "seller_feedback": { - presenceData.details = "Viewing seller feedback"; - presenceData.state = pageTitle.textContent.trim(); - break; - } - default: { - presenceData.details = "Viewing an item"; - presenceData.state = combineChildTexts(pageTitle); - presenceData.largeImageKey = await getShortURL( - document.querySelector(".thumbnail_link img").src - ); - presenceData.buttons = [{ label: "View Item", url: href }]; - break; - } - } - break; - } - case "settings": { - presenceData.details = `Managing ${document - .querySelector(".menu-item.current") - .textContent.trim()} settings`; - break; - } - case "style": { - presenceData.details = "Viewing a style"; - const title = pageTitle.textContent.trim().split(" "); - presenceData.state = title.slice(0, title.length - 1).join(" "); - presenceData.buttons = [{ label: "View Style", url: href }]; - break; - } - case "submissions": { - presenceData.details = "Browsing submissions"; - break; - } - case "user": { - switch (lastPath) { - case "reviews": { - presenceData.details = "Viewing reviews by user"; - break; - } - case "collection": { - presenceData.details = "Viewing user collection"; - break; - } - case "drafts": { - presenceData.details = "Viewing user drafts"; - break; - } - case "export": { - presenceData.details = "Viewing user export options"; - break; - } - default: { - presenceData.details = "Viewing a user"; - presenceData.state = pageTitle.textContent.trim(); - presenceData.smallImageKey = await getShortURL( - document.querySelector(".user_avatar > img").src - ); - presenceData.buttons = [{ label: "View User", url: href }]; - } - } - break; - } - case "users": { - presenceData.details = "Viewing their friends"; - break; - } - case "wantlist": { - presenceData.details = "Viewing their wantlist"; - break; - } - default: { - presenceData.details = "Browsing"; - presenceData.state = document.title.match(/^(.*?)( \| Discogs)?$/)[1]; - } - } + switch (pathSplit[0] ?? '') { + case '': { + presenceData.details = 'Browsing home page' + break + } + case 'artist': { + if (lastPath === 'images') { + await createImageSlideshow('artist') + } + else { + presenceData.details = 'Viewing an artist' + presenceData.state = pageTitle?.textContent + presenceData.largeImageKey = await getShortURL( + document.querySelector('.thumbnail_link img')!.src, + ) + presenceData.buttons = [{ label: 'View Artist', url: href }] + } + break + } + case 'developer': { + // eslint-disable-next-line regexp/no-super-linear-backtracking + const [, currentPage, currentHeader] = hash.match(/page:([^,]+).*?header:([^,]+)/) ?? [] + let state = '' + presenceData.details = 'Viewing API documentation' + if (currentPage) { + state += document.querySelector( + `#${currentPage}`, + )?.textContent + if (currentHeader) { + state += ` - ${ + document.querySelector(`#${currentHeader}`) + ?.textContent + }` + } + } + if (state) + presenceData.state = state + break + } + case 'digs': { + if (pathSplit[2]) { + presenceData.details = 'Viewing a dig' + presenceData.state = pageTitle?.textContent + presenceData.buttons = [{ label: 'View Dig', url: href }] + } + else if (pathSplit[1]) { + presenceData.details = 'Browsing digs' + presenceData.state = pageTitle?.textContent + } + else { + presenceData.details = 'Browsing digs' + } + break + } + case 'forum': { + switch (pathSplit[1] ?? '') { + case '': { + presenceData.details = 'Browsing the forums' + break + } + case 'thread': { + if (pathSplit[2] === 'new') { + presenceData.details = 'Creating a new forum thread' + } + else { + presenceData.details = 'Viewing a forum thread' + presenceData.state = pageTitle?.textContent + presenceData.buttons = [{ label: 'View Thread', url: href }] + } + break + } + case 'topic': { + presenceData.details = 'Viewing a forum topic' + presenceData.state = pageTitle?.textContent?.trim() + break + } + case 'search': { + presenceData.details = 'Searching the forums' + presenceData.state = document.querySelector( + '.search_table_field', + )?.value + break + } + } + break + } + case 'genre': { + presenceData.details = 'Viewing a genre' + const title = pageTitle?.textContent?.trim().split(' ') + presenceData.state = title?.slice(0, title.length - 1).join(' ') + presenceData.buttons = [{ label: 'View Genre', url: href }] + break + } + case 'group': { + switch (pathSplit[1] ?? '') { + case '': + case 'browse': { + presenceData.details = 'Browsing groups' + break + } + case 'create': { + presenceData.details = 'Creating a group' + break + } + case 'posted': { + presenceData.details = 'Viewing threads they posted in' + break + } + case 'recent': { + presenceData.details = 'Viewing recent group activity' + break + } + case 'saved': { + presenceData.details = 'Viewing saved threads' + break + } + case 'search': { + presenceData.details = 'Searching groups' + presenceData.state = document.querySelector( + '.search_table_field', + )?.value + break + } + case 'started': { + presenceData.details = 'Viewing threads they started' + break + } + case 'thread': { + presenceData.details = 'Viewing a group thread' + presenceData.state = pageTitle?.textContent + presenceData.buttons = [{ label: 'View Thread', url: href }] + break + } + case 'watched': { + presenceData.details = 'Viewing watched threads' + break + } + default: { + if (lastPath === 'admin') { + presenceData.details = 'Managing a group' + } + else if (lastPath === 'members') { + presenceData.details = 'Viewing group members' + } + else { + presenceData.details = 'Viewing a group' + presenceData.buttons = [{ label: 'View Group', url: href }] + } + presenceData.state = document + .querySelector('h1') + ?.firstChild + ?.textContent + ?.trim() + } + } + break + } + case 'hc': { + switch (pathSplit[2] ?? '') { + case '': { + presenceData.details = 'Browsing the help center' + break + } + case 'articles': { + presenceData.details = 'Reading a help article' + presenceData.state = pageTitle?.textContent + presenceData.buttons = [{ label: 'Read Article', url: href }] + break + } + case 'categories': + case 'sections': { + presenceData.details = 'Browsing a help center category' + presenceData.state = pageTitle?.textContent + break + } + case 'search': { + presenceData.details = 'Searching the help center' + presenceData.state = document.querySelector('#query')?.value + break + } + } + break + } + case 'label': { + if (lastPath === 'images') { + await createImageSlideshow('label') + } + else { + presenceData.details = 'Viewing a label' + presenceData.state = pageTitle?.textContent + presenceData.largeImageKey = await getShortURL( + document.querySelector('.thumbnail_link img')!.src, + ) + presenceData.buttons = [{ label: 'View Label', url: href }] + } + break + } + case 'leaderboard': { + presenceData.details = 'Viewing the leaderboard' + break + } + case 'marketplace': { + if (pathSplit[1] === 'offers') + presenceData.details = 'Viewing their offers' + else presenceData.details = 'Browsing the marketplace' + break + } + case 'master': { + if (pathSplit[1] === 'stats') { + presenceData.details = 'Viewing stats for a master release' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + else if (pathSplit[1] === 'create') { + presenceData.details = 'Creating a master release' + } + else if (lastPath === 'images') { + await createImageSlideshow('master') + } + else { + presenceData.details = 'Viewing a master release' + presenceData.state = pageTitle?.textContent + presenceData.largeImageKey = await getShortURL( + document.querySelector('picture > img')!.src, + ) + presenceData.buttons = [{ label: 'View Release', url: href }] + } + break + } + case 'messages': { + if (pathSplit[1] === 'compose') + presenceData.details = 'Composing a message' + else presenceData.details = 'Viewing messages' + break + } + case 'my': { + presenceData.details = 'Viewing dashboard' + break + } + case 'release': { + if (pathSplit[1] === 'stats') { + presenceData.details = 'Viewing stats for release' + presenceData.state = document.querySelector('h1 > a')?.textContent + } + else if (pathSplit[2] === 'videos') { + presenceData.details = 'Editing videos for release' + presenceData.state = combineChildTexts(pageTitle!) + } + else if (lastPath === 'images') { + await createImageSlideshow('release') + } + else { + presenceData.details = 'Viewing a release' + presenceData.state = pageTitle?.textContent + presenceData.largeImageKey = await getShortURL( + document.querySelector('picture > img')!.src, + ) + presenceData.buttons = [{ label: 'View Release', url: href }] + } + break + } + case 'sell': { + switch (pathSplit[1] ?? '') { + case '': { + presenceData.details = 'Searching for an item to sell' + break + } + case 'billing': { + presenceData.details = 'Viewing billing information' + break + } + case 'cart': { + presenceData.details = 'Viewing their cart' + break + } + case 'history': { + presenceData.details = 'Viewing price history' + presenceData.state = document.querySelector('h3')?.textContent?.trim() + break + } + case 'inventory': { + presenceData.details = 'Viewing their inventory' + break + } + case 'mywants': { + presenceData.details = 'Viewing their wishlist' + break + } + case 'list': { + presenceData.details = 'Viewing items for sale' + presenceData.state = pageTitle?.textContent + break + } + case 'orders': { + presenceData.details = 'Viewing their orders' + break + } + case 'post': { + presenceData.details = 'Posting an item for sale' + presenceData.state = combineChildTexts(document.querySelector('h2')!) + break + } + case 'purchases': { + presenceData.details = 'Viewing their purchases' + break + } + case 'seller_feedback': { + presenceData.details = 'Viewing seller feedback' + presenceData.state = pageTitle?.textContent?.trim() + break + } + default: { + presenceData.details = 'Viewing an item' + presenceData.state = combineChildTexts(pageTitle!) + presenceData.largeImageKey = await getShortURL( + document.querySelector('.thumbnail_link img')!.src, + ) + presenceData.buttons = [{ label: 'View Item', url: href }] + break + } + } + break + } + case 'settings': { + presenceData.details = `Managing ${document + .querySelector('.menu-item.current') + ?.textContent + ?.trim()} settings` + break + } + case 'style': { + presenceData.details = 'Viewing a style' + const title = pageTitle?.textContent?.trim().split(' ') + presenceData.state = title?.slice(0, title.length - 1).join(' ') + presenceData.buttons = [{ label: 'View Style', url: href }] + break + } + case 'submissions': { + presenceData.details = 'Browsing submissions' + break + } + case 'user': { + switch (lastPath) { + case 'reviews': { + presenceData.details = 'Viewing reviews by user' + break + } + case 'collection': { + presenceData.details = 'Viewing user collection' + break + } + case 'drafts': { + presenceData.details = 'Viewing user drafts' + break + } + case 'export': { + presenceData.details = 'Viewing user export options' + break + } + default: { + presenceData.details = 'Viewing a user' + presenceData.state = pageTitle?.textContent?.trim() + presenceData.smallImageKey = await getShortURL( + document.querySelector('.user_avatar > img')!.src, + ) + presenceData.buttons = [{ label: 'View User', url: href }] + } + } + break + } + case 'users': { + presenceData.details = 'Viewing their friends' + break + } + case 'wantlist': { + presenceData.details = 'Viewing their wantlist' + break + } + default: { + presenceData.details = 'Browsing' + presenceData.state = document.title?.match(/^(.*?)( \| Discogs)?$/)?.[1] + } + } - if (presenceData.details) { - slideshow.deleteAllSlides(); - presence.setActivity(presenceData); - } else if (slideshow.getSlides().length) presence.setActivity(slideshow); - else { - slideshow.deleteAllSlides(); - presence.setActivity(); - } -}); + if (presenceData.details) { + slideshow.deleteAllSlides() + presence.setActivity(presenceData) + } + else if (slideshow.getSlides().length) { + presence.setActivity(slideshow) + } + else { + slideshow.deleteAllSlides() + presence.setActivity() + } +}) diff --git a/websites/D/Discohook/metadata.json b/websites/D/Discohook/metadata.json index c634c3a67f80..7c93aac226f9 100644 --- a/websites/D/Discohook/metadata.json +++ b/websites/D/Discohook/metadata.json @@ -1,24 +1,24 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "150987570715688960", - "name": "Ninja" - }, - "service": "Discohook", - "description": { - "en": "Discohook is a free tool that allows you to personalise your server to make your server stand out from the crowd." - }, - "url": "discohook.org", - "version": "1.0.11", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discohook/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discohook/assets/thumbnail.png", - "color": "#58b9ff", - "category": "other", - "tags": [ - "discord", - "webhook", - "discohook", - "tools" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "150987570715688960", + "name": "Ninja" + }, + "service": "Discohook", + "description": { + "en": "Discohook is a free tool that allows you to personalise your server to make your server stand out from the crowd." + }, + "url": "discohook.org", + "version": "1.0.11", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discohook/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discohook/assets/thumbnail.png", + "color": "#58b9ff", + "category": "other", + "tags": [ + "discord", + "webhook", + "discohook", + "tools" + ] +} diff --git a/websites/D/Discohook/presence.ts b/websites/D/Discohook/presence.ts index d59fab384002..d3c6d9ff8775 100644 --- a/websites/D/Discohook/presence.ts +++ b/websites/D/Discohook/presence.ts @@ -1,24 +1,22 @@ const presence = new Presence({ - clientId: "1036322932932218880", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1036322932932218880', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Discohook/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - webhookCount = document.querySelectorAll(".evedhr > .dWrjaT").length, - messageCount = document.querySelectorAll(".jQDPRQ").length, - embedCount = document.querySelectorAll(".jQDPPo > section").length; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Discohook/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const webhookCount = document.querySelectorAll('.evedhr > .dWrjaT').length + const messageCount = document.querySelectorAll('.jQDPRQ').length + const embedCount = document.querySelectorAll('.jQDPPo > section').length - presenceData.details = - webhookCount > 1 ? `Editing ${webhookCount} webhooks` : "Editing a webhook"; + presenceData.details = webhookCount > 1 ? `Editing ${webhookCount} webhooks` : 'Editing a webhook' - presenceData.state = `${messageCount} message${ - messageCount > 1 ? "s" : "" - } - ${embedCount} embed${embedCount > 1 || embedCount === 0 ? "s" : ""}`; + presenceData.state = `${messageCount} message${ + messageCount > 1 ? 's' : '' + } - ${embedCount} embed${embedCount > 1 || embedCount === 0 ? 's' : ''}` - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/D/Discord Bot List/metadata.json b/websites/D/Discord Bot List/metadata.json index 8cdf163bb7f2..78cb8fe552a1 100644 --- a/websites/D/Discord Bot List/metadata.json +++ b/websites/D/Discord Bot List/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Eren", - "id": "478937019758673931" - }, - "service": "Discord Bot List", - "description": { - "en": "Discord Bot List is listing discord bots.", - "tr": "Discord Bot List bir bot listesidir.", - "nl": "Discord Bot List is een lijst van discord bots." - }, - "url": "discordbotlist.com", - "version": "1.2.25", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bot%20List/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bot%20List/assets/thumbnail.png", - "color": "#10C0E7", - "category": "other", - "tags": [ - "discord", - "bot", - "discord-bot-list" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Eren", + "id": "478937019758673931" + }, + "service": "Discord Bot List", + "description": { + "en": "Discord Bot List is listing discord bots.", + "tr": "Discord Bot List bir bot listesidir.", + "nl": "Discord Bot List is een lijst van discord bots." + }, + "url": "discordbotlist.com", + "version": "1.2.25", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bot%20List/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bot%20List/assets/thumbnail.png", + "color": "#10C0E7", + "category": "other", + "tags": [ + "discord", + "bot", + "discord-bot-list" + ] +} diff --git a/websites/D/Discord Bot List/presence.ts b/websites/D/Discord Bot List/presence.ts index 93f0c02e5bf9..cc8e1d5d3a34 100644 --- a/websites/D/Discord Bot List/presence.ts +++ b/websites/D/Discord Bot List/presence.ts @@ -1,46 +1,52 @@ const presence = new Presence({ - clientId: "653644508507930645", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '653644508507930645', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bot%20List/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bot%20List/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (window.location.pathname.endsWith("top")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Top Voted Bots"; - } else if (window.location.pathname.endsWith("add")) - presenceData.details = "Adding a new bot"; - else if (window.location.pathname.endsWith("mine")) - presenceData.details = "Viewing their bot(s)"; - else if (window.location.pathname.startsWith("/bots/")) { - presenceData.details = "Viewing a bot:"; - presenceData.state = document - .querySelector( - "#__layout > div > div.main-content > div > div > div.row > div.col-12.col-md-6 > h1" - ) - .textContent.replace( - document.querySelector( - "#__layout > div > div.main-content > div > div > div.row > div.col-12.col-md-6 > h1 > a" - ).textContent, - "" - ); - } else if (window.location.pathname.startsWith("/tags/")) { - presenceData.details = "Viewing a tag:"; - presenceData.state = document.querySelector( - "#__layout > div > div.main-content > div > div > div:nth-child(1) > div.col-12.col-md-4 > h2" - ).textContent; - } else if (window.location.pathname.includes("/users/")) { - presenceData.details = "Viewing a user:"; - presenceData.state = document.querySelector( - "#__layout > div > div.main-content > div > div > div.user-bar.text-center > h2" - ).textContent; - } + if (window.location.pathname.endsWith('top')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Top Voted Bots' + } + else if (window.location.pathname.endsWith('add')) { + presenceData.details = 'Adding a new bot' + } + else if (window.location.pathname.endsWith('mine')) { + presenceData.details = 'Viewing their bot(s)' + } + else if (window.location.pathname.startsWith('/bots/')) { + presenceData.details = 'Viewing a bot:' + presenceData.state = document + .querySelector( + '#__layout > div > div.main-content > div > div > div.row > div.col-12.col-md-6 > h1', + ) + ?.textContent + ?.replace( + document.querySelector( + '#__layout > div > div.main-content > div > div > div.row > div.col-12.col-md-6 > h1 > a', + )?.textContent || '', + '', + ) + } + else if (window.location.pathname.startsWith('/tags/')) { + presenceData.details = 'Viewing a tag:' + presenceData.state = document.querySelector( + '#__layout > div > div.main-content > div > div > div:nth-child(1) > div.col-12.col-md-4 > h2', + )?.textContent + } + else if (window.location.pathname.includes('/users/')) { + presenceData.details = 'Viewing a user:' + presenceData.state = document.querySelector( + '#__layout > div > div.main-content > div > div > div.user-bar.text-center > h2', + )?.textContent + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Discord BotList/metadata.json b/websites/D/Discord BotList/metadata.json index 43053745354e..2ac0c2789da6 100644 --- a/websites/D/Discord BotList/metadata.json +++ b/websites/D/Discord BotList/metadata.json @@ -1,44 +1,44 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "OGMatrix", - "id": "657290880947978241" - }, - "service": "Discord BotList", - "description": { - "en": "discord-botlist.eu - your Discord Bot List! We give you the availability to apply your bot and give your bot a page on our website.", - "de": "discord-botlist.eu - Ihre Discord Bot List! Wir geben Ihnen die Möglichkeit, Ihren Bot anzuwenden und Ihrem Bot eine Seite auf unserer Website zu geben.", - "fr": "discord-botlist.eu - votre liste de robots Discord! Nous vous donnons la possibilité d'appliquer votre bot et de donner à votre bot une page sur notre site Web.", - "nl": "discord-botlist.eu - uw Discord Bot Lijst! Wij geven je de mogelijkheid om je bot aan te melden en je bot een pagina te geven op onze website." - }, - "url": [ - "docs.discord-botlist.eu", - "discord-botlist.eu" - ], - "version": "1.0.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20BotList/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20BotList/assets/thumbnail.png", - "color": "#3563ed", - "category": "other", - "tags": [ - "discord", - "botlist", - "list", - "discord-botlist" - ], - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "value": true, - "icon": "fas fa-compress-arrows-alt" - }, - { - "id": "submitP", - "title": "Show Submit Page", - "value": true, - "icon": "fas fa-plus" - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "OGMatrix", + "id": "657290880947978241" + }, + "service": "Discord BotList", + "description": { + "en": "discord-botlist.eu - your Discord Bot List! We give you the availability to apply your bot and give your bot a page on our website.", + "de": "discord-botlist.eu - Ihre Discord Bot List! Wir geben Ihnen die Möglichkeit, Ihren Bot anzuwenden und Ihrem Bot eine Seite auf unserer Website zu geben.", + "fr": "discord-botlist.eu - votre liste de robots Discord! Nous vous donnons la possibilité d'appliquer votre bot et de donner à votre bot une page sur notre site Web.", + "nl": "discord-botlist.eu - uw Discord Bot Lijst! Wij geven je de mogelijkheid om je bot aan te melden en je bot een pagina te geven op onze website." + }, + "url": [ + "docs.discord-botlist.eu", + "discord-botlist.eu" + ], + "version": "1.0.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20BotList/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20BotList/assets/thumbnail.png", + "color": "#3563ed", + "category": "other", + "tags": [ + "discord", + "botlist", + "list", + "discord-botlist" + ], + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "value": true, + "icon": "fas fa-compress-arrows-alt" + }, + { + "id": "submitP", + "title": "Show Submit Page", + "value": true, + "icon": "fas fa-plus" + } + ] +} diff --git a/websites/D/Discord BotList/presence.ts b/websites/D/Discord BotList/presence.ts index 3eb1027240fe..969008e6593a 100644 --- a/websites/D/Discord BotList/presence.ts +++ b/websites/D/Discord BotList/presence.ts @@ -1,142 +1,150 @@ const presence = new Presence({ - clientId: "819122551435296818", - }), - botBrowsing = Math.floor(Date.now() / 1000); + clientId: '819122551435296818', +}) +const botBrowsing = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20BotList/assets/logo.jpg", - startTimestamp: botBrowsing, - }, - botPage = document.location.pathname, - botHost = document.location.hostname, - buttons = await presence.getSetting("buttons"), - sSubmit = await presence.getSetting("submitP"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20BotList/assets/logo.jpg', + startTimestamp: botBrowsing, + } + const botPage = document.location.pathname + const botHost = document.location.hostname + const buttons = await presence.getSetting('buttons') + const sSubmit = await presence.getSetting('submitP') - if (botHost === "discord-botlist.eu") { - switch (botPage) { - case "/": { - presenceData.details = "Browsing"; - break; - } - case "/search": { - presenceData.details = "Searching Bot:"; - presenceData.state = document - .querySelector("[name='search']") - .getAttribute("value"); - presenceData.buttons = [ - { - label: "View Search", - url: document.URL, - }, - ]; + if (botHost === 'discord-botlist.eu') { + switch (botPage) { + case '/': { + presenceData.details = 'Browsing' + break + } + case '/search': { + presenceData.details = 'Searching Bot:' + presenceData.state = document + .querySelector('[name=\'search\']') + ?.getAttribute('value') + presenceData.buttons = [ + { + label: 'View Search', + url: document.URL, + }, + ] - break; - } - case "/bots/tag": { - presenceData.details = "Searching Tag:"; - presenceData.state = new URLSearchParams(window.location.search).get( - "tag" - ); - presenceData.buttons = [ - { - label: "View Tag", - url: document.URL, - }, - ]; + break + } + case '/bots/tag': { + presenceData.details = 'Searching Tag:' + presenceData.state = new URLSearchParams(window.location.search).get( + 'tag', + ) + presenceData.buttons = [ + { + label: 'View Tag', + url: document.URL, + }, + ] - break; - } - case "/login_err/": { - presenceData.details = "Login In Page"; - break; - } - default: - if (botPage.includes("/users/")) { - presenceData.details = "Viewing Profile:"; - presenceData.state = document.querySelector("#Username").textContent; - presenceData.buttons = [ - { - label: "View Profile", - url: document.URL, - }, - ]; - } else if (botPage.includes("/bots/")) { - if (botPage.includes("/new")) presenceData.details = "Adding a Bot"; - else if (botPage.includes("/vote")) { - const voteBotName: string = document - .querySelector("#vote1 > h1") - .textContent.replace("Vote for ", ""); - presenceData.details = "Voting for:"; - presenceData.state = voteBotName; - presenceData.buttons = [ - { - label: `Vote for ${voteBotName}`, - url: document.URL, - }, - ]; - } else if (botPage.includes("/edit")) - presenceData.details = "Editing a Bot"; - else if (botPage.includes("/all")) { - presenceData.details = "Viewing all Bots"; - presenceData.buttons = [ - { - label: "View Bots", - url: document.URL, - }, - ]; - } else { - presenceData.details = "Viewing Bot:"; - presenceData.state = document.querySelector("#botname").textContent; - presenceData.buttons = [ - { - label: "View Bot", - url: document.URL, - }, - ]; - } - } else { - switch (botPage) { - case "/apply/certification/": { - presenceData.details = "Viewing Certification Page"; - break; - } - case "/apply/certification/application": { - presenceData.details = "Applying for Certification"; - break; - } - case "/tos/": { - presenceData.details = "Viewing ToS"; - break; - } - case "/privacypolicy/": { - presenceData.details = "Viewing Privacy Policy"; - break; - } - case "/Imprint/": - { - presenceData.details = "Viewing Imprint"; - // No default - } - break; - } - } - } - } else if (botHost === "docs.discord-botlist.eu") { - presenceData.details = "Viewing Docs"; - presenceData.state = `Page: ${ - document.querySelector( - "#__GITBOOK__ROOT__CLIENT__ > div.reset-3c756112--body-68cac36c > div.reset-3c756112--bodyContent-2f98451b > div > div.reset-3c756112--wholeContentBody-554be184 > div.reset-3c756112--wholeContentPage-6c3f1fc5 > div > div.reset-3c756112--pageContainer-544d6e9c > div.reset-3c756112 > div.reset-3c756112--pageHeader-15724735 > div > div > div.reset-3c756112--horizontalFlex-5a0077e0 > div.reset-3c756112--pageHeaderIntro-0c1463da > h1 > span" - ).textContent - }`; - } + break + } + case '/login_err/': { + presenceData.details = 'Login In Page' + break + } + default: + if (botPage.includes('/users/')) { + presenceData.details = 'Viewing Profile:' + presenceData.state = document.querySelector('#Username')?.textContent + presenceData.buttons = [ + { + label: 'View Profile', + url: document.URL, + }, + ] + } + else if (botPage.includes('/bots/')) { + if (botPage.includes('/new')) { + presenceData.details = 'Adding a Bot' + } + else if (botPage.includes('/vote')) { + const voteBotName = document + .querySelector('#vote1 > h1') + ?.textContent + ?.replace('Vote for ', '') + presenceData.details = 'Voting for:' + presenceData.state = voteBotName + presenceData.buttons = [ + { + label: `Vote for ${voteBotName}`, + url: document.URL, + }, + ] + } + else if (botPage.includes('/edit')) { + presenceData.details = 'Editing a Bot' + } + else if (botPage.includes('/all')) { + presenceData.details = 'Viewing all Bots' + presenceData.buttons = [ + { + label: 'View Bots', + url: document.URL, + }, + ] + } + else { + presenceData.details = 'Viewing Bot:' + presenceData.state = document.querySelector('#botname')?.textContent + presenceData.buttons = [ + { + label: 'View Bot', + url: document.URL, + }, + ] + } + } + else { + switch (botPage) { + case '/apply/certification/': { + presenceData.details = 'Viewing Certification Page' + break + } + case '/apply/certification/application': { + presenceData.details = 'Applying for Certification' + break + } + case '/tos/': { + presenceData.details = 'Viewing ToS' + break + } + case '/privacypolicy/': { + presenceData.details = 'Viewing Privacy Policy' + break + } + case '/Imprint/': { + presenceData.details = 'Viewing Imprint' + break + } + } + } + } + } + else if (botHost === 'docs.discord-botlist.eu') { + presenceData.details = 'Viewing Docs' + presenceData.state = `Page: ${ + document.querySelector( + '#__GITBOOK__ROOT__CLIENT__ > div.reset-3c756112--body-68cac36c > div.reset-3c756112--bodyContent-2f98451b > div > div.reset-3c756112--wholeContentBody-554be184 > div.reset-3c756112--wholeContentPage-6c3f1fc5 > div > div.reset-3c756112--pageContainer-544d6e9c > div.reset-3c756112 > div.reset-3c756112--pageHeader-15724735 > div > div > div.reset-3c756112--horizontalFlex-5a0077e0 > div.reset-3c756112--pageHeaderIntro-0c1463da > h1 > span', + )?.textContent + }` + } - if (!sSubmit && presenceData.details === "Adding a Bot") - delete presenceData.details; + if (!sSubmit && presenceData.details === 'Adding a Bot') + delete presenceData.details - if (!buttons) delete presenceData.buttons; + if (!buttons) + delete presenceData.buttons - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/D/Discord Bots/metadata.json b/websites/D/Discord Bots/metadata.json index 68501e90aefb..d440ae514d14 100644 --- a/websites/D/Discord Bots/metadata.json +++ b/websites/D/Discord Bots/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Eren", - "id": "478937019758673931" - }, - "service": "Discord Bots", - "description": { - "en": "Discord bots is a website that lists discord bots.", - "tr": "Discord bots, bütün botları listeleyen bir sistemdir.", - "nl": "Discord bots is een website die discord bots opsomt." - }, - "url": "discord.bots.gg", - "version": "1.2.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bots/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bots/assets/thumbnail.png", - "color": "#1C48D1", - "category": "other", - "tags": [ - "discord", - "bot", - "discord-bot-list" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Eren", + "id": "478937019758673931" + }, + "service": "Discord Bots", + "description": { + "en": "Discord bots is a website that lists discord bots.", + "tr": "Discord bots, bütün botları listeleyen bir sistemdir.", + "nl": "Discord bots is een website die discord bots opsomt." + }, + "url": "discord.bots.gg", + "version": "1.2.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bots/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bots/assets/thumbnail.png", + "color": "#1C48D1", + "category": "other", + "tags": [ + "discord", + "bot", + "discord-bot-list" + ] +} diff --git a/websites/D/Discord Bots/presence.ts b/websites/D/Discord Bots/presence.ts index 9625a73368e7..45507b40cb69 100644 --- a/websites/D/Discord Bots/presence.ts +++ b/websites/D/Discord Bots/presence.ts @@ -1,39 +1,47 @@ const presence = new Presence({ - clientId: "656175238412763163", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '656175238412763163', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bots/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - page = window.location.pathname; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Bots/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const page = window.location.pathname - if (page.includes("search")) presenceData.details = "Searching something"; - else if (page.endsWith("/add")) presenceData.details = "Adding a new bot"; - else if (page.startsWith("/bots/")) { - presenceData.details = "Viewing a bot:"; - presenceData.state = document.querySelector( - "#__layout > div > main > div > section.bot__header > div > div > div > div.bot__name" - ).textContent; - } else if (page.includes("profile")) { - presenceData.details = "Viewing a profile:"; - presenceData.state = document.querySelector( - "#__layout > div > main > div > section.profile__header > div > div > div" - ).textContent; - } else if (page.includes("terms")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Terms of Service"; - } else if (page.startsWith("/about")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "About"; - } else if (page.includes("docs")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "API Documentation"; - } + if (page.includes('search')) { + presenceData.details = 'Searching something' + } + else if (page.endsWith('/add')) { + presenceData.details = 'Adding a new bot' + } + else if (page.startsWith('/bots/')) { + presenceData.details = 'Viewing a bot:' + presenceData.state = document.querySelector( + '#__layout > div > main > div > section.bot__header > div > div > div > div.bot__name', + )?.textContent + } + else if (page.includes('profile')) { + presenceData.details = 'Viewing a profile:' + presenceData.state = document.querySelector( + '#__layout > div > main > div > section.profile__header > div > div > div', + )?.textContent + } + else if (page.includes('terms')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Terms of Service' + } + else if (page.startsWith('/about')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'About' + } + else if (page.includes('docs')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'API Documentation' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Discord Extreme List/metadata.json b/websites/D/Discord Extreme List/metadata.json index 10322f2ed0f7..3af191ab91a8 100644 --- a/websites/D/Discord Extreme List/metadata.json +++ b/websites/D/Discord Extreme List/metadata.json @@ -1,58 +1,58 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Cairo", - "id": "208105877838888960" - }, - "service": "Discord Extreme List", - "description": { - "de": "Discord's unbefangene Liste, gibt Bots und Server aller grössen eine grosse Chance!", - "en": "Discord's unbiased list, giving bots and servers of all sizes a big chance!", - "es": "¡Lista imparcial de Discord, que ofrece a los bots y servidores de todos los tamaños una gran oportunidad!", - "fr": "La liste impartiale de Discord, qui donne une grande chance aux bots et aux serveurs de toutes tailles !", - "he_IL": "הרשימה הבלתי משוחדת של דיסקורד, נותנת הזדמנות שווה לשרתים ובוטים בכל הגדלים!", - "hu": "Discord-nak elfogulatlan listája, megadja a botoknak és a szervereknek a nagy lehetőséget!", - "id": "List Discord tidak ber-bias, memberikan bot dan server peluang yang sama!", - "is": "Óhlutdrægur listi Discord, sem gefur vélum og netþjónum af öllum stærðum stór tækifæri!", - "nl": "Discord's onbevooroordeelde lijst, die bots en servers van elke omvang een grote kans geeft!", - "pl": "Niezależna lista Discord, która daje dużą szansę botom i serwerom każdej wielkości!", - "pt": "Lista de discord imparcial, dá a bots e servidores de todos os tamanhos uma grande chance!", - "sv_SE": "Discords opartiska lista, ger alla bots och servrar en stor chans!", - "tr": "Discord'un tarafsız bot listesi, büyüklüğü ne olursa olsun bütün botlara ve sunuculara büyük bir şans veriyor!" - }, - "url": [ - "discordextremelist.xyz", - "staging.discordextremelist.xyz", - "discordextremelist.gay", - "staging.discordextremelist.gay" - ], - "version": "1.0.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Extreme%20List/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Extreme%20List/assets/thumbnail.png", - "color": "#b114ff", - "category": "other", - "tags": [ - "discord", - "bot", - "del", - "discord-bot-list", - "discord-bots", - "discord-servers", - "discord-templates" - ], - "settings": [ - { - "id": "incognito", - "title": "Hide Presence", - "icon": "fas fa-user-secret", - "value": false - }, - { - "id": "showTimestamp", - "title": "Display Timestamp", - "icon": "fas fa-stopwatch", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Cairo", + "id": "208105877838888960" + }, + "service": "Discord Extreme List", + "description": { + "de": "Discord's unbefangene Liste, gibt Bots und Server aller grössen eine grosse Chance!", + "en": "Discord's unbiased list, giving bots and servers of all sizes a big chance!", + "es": "¡Lista imparcial de Discord, que ofrece a los bots y servidores de todos los tamaños una gran oportunidad!", + "fr": "La liste impartiale de Discord, qui donne une grande chance aux bots et aux serveurs de toutes tailles !", + "he_IL": "הרשימה הבלתי משוחדת של דיסקורד, נותנת הזדמנות שווה לשרתים ובוטים בכל הגדלים!", + "hu": "Discord-nak elfogulatlan listája, megadja a botoknak és a szervereknek a nagy lehetőséget!", + "id": "List Discord tidak ber-bias, memberikan bot dan server peluang yang sama!", + "is": "Óhlutdrægur listi Discord, sem gefur vélum og netþjónum af öllum stærðum stór tækifæri!", + "nl": "Discord's onbevooroordeelde lijst, die bots en servers van elke omvang een grote kans geeft!", + "pl": "Niezależna lista Discord, która daje dużą szansę botom i serwerom każdej wielkości!", + "pt": "Lista de discord imparcial, dá a bots e servidores de todos os tamanhos uma grande chance!", + "sv_SE": "Discords opartiska lista, ger alla bots och servrar en stor chans!", + "tr": "Discord'un tarafsız bot listesi, büyüklüğü ne olursa olsun bütün botlara ve sunuculara büyük bir şans veriyor!" + }, + "url": [ + "discordextremelist.xyz", + "staging.discordextremelist.xyz", + "discordextremelist.gay", + "staging.discordextremelist.gay" + ], + "version": "1.0.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Extreme%20List/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Extreme%20List/assets/thumbnail.png", + "color": "#b114ff", + "category": "other", + "tags": [ + "discord", + "bot", + "del", + "discord-bot-list", + "discord-bots", + "discord-servers", + "discord-templates" + ], + "settings": [ + { + "id": "incognito", + "title": "Hide Presence", + "icon": "fas fa-user-secret", + "value": false + }, + { + "id": "showTimestamp", + "title": "Display Timestamp", + "icon": "fas fa-stopwatch", + "value": true + } + ] +} diff --git a/websites/D/Discord Extreme List/presence.ts b/websites/D/Discord Extreme List/presence.ts index 06c9f2771d8e..2098fbaa8307 100644 --- a/websites/D/Discord Extreme List/presence.ts +++ b/websites/D/Discord Extreme List/presence.ts @@ -1,20 +1,19 @@ const presence = new Presence({ - clientId: "568254611354419211", -}); + clientId: '568254611354419211', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Extreme%20List/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Extreme%20List/assets/logo.png', + } - if ((await presence.getSetting("incognito")) === false) { - presenceData.details = - document.querySelector("#premidPageInfo").textContent; - if ((await presence.getSetting("showTimestamp")) === true) - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - } + if ((await presence.getSetting('incognito')) === false) { + presenceData.details = document.querySelector('#premidPageInfo')?.textContent + if ((await presence.getSetting('showTimestamp')) === true) + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Discord ID/metadata.json b/websites/D/Discord ID/metadata.json index 7821e924875f..07c2ccaa18f5 100644 --- a/websites/D/Discord ID/metadata.json +++ b/websites/D/Discord ID/metadata.json @@ -1,48 +1,48 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dark_Ville", - "id": "638080361179512853" - }, - "service": "Discord ID", - "description": { - "en": "Lookup a Discord User or Bot ID." - }, - "url": [ - "wiki.discord.id", - "discord.id" - ], - "version": "1.1.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20ID/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20ID/assets/thumbnail.png", - "color": "#7289da", - "category": "other", - "tags": [ - "discord", - "id" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "idAndUsername", - "title": "Disable Username/ID Mode", - "icon": "fad fa-hashtag-lock", - "value": true - }, - { - "id": "covers", - "if": { - "privacy": false - }, - "title": "Show Cover", - "icon": "fad fa-album", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dark_Ville", + "id": "638080361179512853" + }, + "service": "Discord ID", + "description": { + "en": "Lookup a Discord User or Bot ID." + }, + "url": [ + "wiki.discord.id", + "discord.id" + ], + "version": "1.1.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20ID/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20ID/assets/thumbnail.png", + "color": "#7289da", + "category": "other", + "tags": [ + "discord", + "id" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "idAndUsername", + "title": "Disable Username/ID Mode", + "icon": "fad fa-hashtag-lock", + "value": true + }, + { + "id": "covers", + "if": { + "privacy": false + }, + "title": "Show Cover", + "icon": "fad fa-album", + "value": false + } + ] +} diff --git a/websites/D/Discord ID/presence.ts b/websites/D/Discord ID/presence.ts index 7602d1f4c344..bb406113222c 100644 --- a/websites/D/Discord ID/presence.ts +++ b/websites/D/Discord ID/presence.ts @@ -1,105 +1,111 @@ const presence = new Presence({ - clientId: "1003206856958816296", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1003206856958816296', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20ID/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20ID/assets/logo.png', } -function getEl(el: HTMLElement) { - return ( - el?.closest("p")?.querySelector(".resulth > span")?.textContent ?? - el?.closest("p")?.querySelector(".resulth")?.textContent ?? - "Unknown" - ); +function getEl(el: HTMLElement | null) { + return ( + el?.closest('p')?.querySelector('.resulth > span')?.textContent + ?? el?.closest('p')?.querySelector('.resulth')?.textContent + ?? 'Unknown' + ) } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { hostname, href } = document.location, - [privacy, covers, idAndUsername] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("covers"), - presence.getSetting("idAndUsername"), - ]); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { hostname, href } = document.location + const [privacy, covers, idAndUsername] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('covers'), + presence.getSetting('idAndUsername'), + ]) - switch (true) { - case hostname.includes("wiki.discord.id"): { - const search = document.querySelector( - '[placeholder="Search content…"]' - ); - switch (true) { - case privacy: { - presenceData.details = "Browsing the wiki"; - break; - } - case !!search.value: { - presenceData.details = "Searching for"; - presenceData.smallImageKey = Assets.Search; - presenceData.state = search.value; - break; - } - default: { - presenceData.details = "Reading"; - presenceData.state = document.querySelector( - '[data-testid="page.title"]' - ).textContent; - presenceData.smallImageKey = Assets.Reading; - break; - } - } - break; - } - case hostname === "discord.id": { - if (privacy) presenceData.details = "Browsing Lookup"; - else { - const id = getEl(document.querySelector(".fas.fa-user")), - username = getEl(document.querySelector(".fas.fa-hashtag")), - badge = document.querySelectorAll(".badgepng"); - if ( - document.querySelector("#inputid").value && - !document.querySelector("#captchaPopup___BV_modal_header_") - ) { - if (badge.length > 0) { - presenceData.smallImageKey = `${href}${badge[ - badge.length - 1 - ].getAttribute("src")}`; - presenceData.smallImageText = `Created on: ${getEl( - document.querySelector(".fas.fa-asterisk") - )}`; - } - presenceData.largeImageKey = - document.querySelector(".avyimg") ?? Assets.Logo; - switch (true) { - case idAndUsername: { - if (!username) presenceData.details = "Viewing IDs"; - else presenceData.details = "Viewing user"; - break; - } - case !!id && !!username: { - presenceData.details = "Viewing user"; - presenceData.state = `${username} (${id})`; - break; - } - case !!id && !username: { - presenceData.details = "Viewing id"; - presenceData.state = id; - break; - } - } - } else presenceData.details = "Browsing"; - } - break; - } - } + switch (true) { + case hostname.includes('wiki.discord.id'): { + const search = document.querySelector( + '[placeholder="Search content…"]', + ) + switch (true) { + case privacy: { + presenceData.details = 'Browsing the wiki' + break + } + case search && !!search.value: { + presenceData.details = 'Searching for' + presenceData.smallImageKey = Assets.Search + presenceData.state = search.value + break + } + default: { + presenceData.details = 'Reading' + presenceData.state = document.querySelector( + '[data-testid="page.title"]', + )?.textContent + presenceData.smallImageKey = Assets.Reading + break + } + } + break + } + case hostname === 'discord.id': { + if (privacy) { + presenceData.details = 'Browsing Lookup' + } + else { + const id = getEl(document.querySelector('.fas.fa-user')) + const username = getEl(document.querySelector('.fas.fa-hashtag')) + const badge = document.querySelectorAll('.badgepng') + if ( + document.querySelector('#inputid')?.value + && !document.querySelector('#captchaPopup___BV_modal_header_') + ) { + if (badge.length > 0) { + presenceData.smallImageKey = `${href}${badge[ + badge.length - 1 + ].getAttribute('src')}` + presenceData.smallImageText = `Created on: ${getEl( + document.querySelector('.fas.fa-asterisk'), + )}` + } + presenceData.largeImageKey = document.querySelector('.avyimg') ?? Assets.Logo + switch (true) { + case idAndUsername: { + if (!username) + presenceData.details = 'Viewing IDs' + else presenceData.details = 'Viewing user' + break + } + case !!id && !!username: { + presenceData.details = 'Viewing user' + presenceData.state = `${username} (${id})` + break + } + case !!id && !username: { + presenceData.details = 'Viewing id' + presenceData.state = id + break + } + } + } + else { + presenceData.details = 'Browsing' + } + } + break + } + } - if (!covers && presenceData.largeImageKey !== Assets.Logo) - presenceData.largeImageKey = Assets.Logo; + if (!covers && presenceData.largeImageKey !== Assets.Logo) + presenceData.largeImageKey = Assets.Logo - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Discord Resources/metadata.json b/websites/D/Discord Resources/metadata.json index 399c461f4401..8d0d95c69c80 100644 --- a/websites/D/Discord Resources/metadata.json +++ b/websites/D/Discord Resources/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "2Lost4Discord", - "id": "421991668556759042" - }, - "service": "Discord Resources", - "description": { - "en": "A list of tons of useful Discord resources and utilities for all types of users, from beginners to power users." - }, - "url": "discordresources.com", - "version": "1.0.14", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/thumbnail.png", - "color": "#ba6ec4", - "category": "other", - "tags": [ - "wiki", - "resources", - "discord" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "2Lost4Discord", + "id": "421991668556759042" + }, + "service": "Discord Resources", + "description": { + "en": "A list of tons of useful Discord resources and utilities for all types of users, from beginners to power users." + }, + "url": "discordresources.com", + "version": "1.0.14", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/thumbnail.png", + "color": "#ba6ec4", + "category": "other", + "tags": [ + "wiki", + "resources", + "discord" + ] +} diff --git a/websites/D/Discord Resources/presence.ts b/websites/D/Discord Resources/presence.ts index 7e56077880fb..91a79850cd30 100644 --- a/websites/D/Discord Resources/presence.ts +++ b/websites/D/Discord Resources/presence.ts @@ -1,76 +1,82 @@ const presence = new Presence({ - clientId: "973710731549745152", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '973710731549745152', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Drw = "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/0.png", - Wiki = "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/1.png", - Blog = "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/2.png", - Unsupported = "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/3.png", + Drw = 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/0.png', + Wiki = 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/1.png', + Blog = 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/2.png', + Unsupported = 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/3.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname, search } = window.location; - switch (true) { - case pathname.includes("/resources/"): { - presenceData.smallImageKey = Assets.Wiki; - presenceData.smallImageText = "Wiki"; - presenceData.details = "Reading a wiki page"; - presenceData.state = document.title.split("|")[0]; - presenceData.buttons = [ - { - label: "Read Page", - url: location.href, - }, - ]; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Resources/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname, search } = window.location + switch (true) { + case pathname.includes('/resources/'): { + presenceData.smallImageKey = Assets.Wiki + presenceData.smallImageText = 'Wiki' + presenceData.details = 'Reading a wiki page' + presenceData.state = document.title.split('|')[0] + presenceData.buttons = [ + { + label: 'Read Page', + url: location.href, + }, + ] - break; - } - case pathname.includes("/blog"): { - presenceData.smallImageKey = Assets.Blog; - presenceData.smallImageText = "Blog"; - if (document.title === "Blog | Discord Resources") - presenceData.details = "Viewing the main page"; - else if (pathname.includes("/tags/")) { - const pSplit = pathname.split("/"); - presenceData.details = "Looking for posts tagged with:"; - presenceData.state = `"${pSplit[pSplit.length - 1]}"`; - } else { - presenceData.details = "Reading a Post"; - presenceData.state = document.title.split("|")[0]; - presenceData.buttons = [ - { - label: "Read Post", - url: location.href, - }, - ]; - } - break; - } - case pathname === "/search": { - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Searching..."; - if (search) { - presenceData.details = "Searching for:"; - presenceData.state = document - .querySelector( - "#__docusaurus > div.main-wrapper > div > h1" - ) - .textContent.split("Search results for ")[1]; - } else presenceData.details = "Searching for something..."; - break; - } - default: { - presenceData.smallImageKey = Assets.Unsupported; - presenceData.smallImageText = "Unknown"; - presenceData.details = "Viewing an unsupported page"; - } - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + break + } + case pathname.includes('/blog'): { + presenceData.smallImageKey = Assets.Blog + presenceData.smallImageText = 'Blog' + if (document.title === 'Blog | Discord Resources') { + presenceData.details = 'Viewing the main page' + } + else if (pathname.includes('/tags/')) { + const pSplit = pathname.split('/') + presenceData.details = 'Looking for posts tagged with:' + presenceData.state = `"${pSplit[pSplit.length - 1]}"` + } + else { + presenceData.details = 'Reading a Post' + presenceData.state = document.title.split('|')[0] + presenceData.buttons = [ + { + label: 'Read Post', + url: location.href, + }, + ] + } + break + } + case pathname === '/search': { + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Searching...' + if (search) { + presenceData.details = 'Searching for:' + presenceData.state = document + .querySelector( + '#__docusaurus > div.main-wrapper > div > h1', + ) + ?.textContent + ?.split('Search results for ')[1] + } + else { + presenceData.details = 'Searching for something...' + } + break + } + default: { + presenceData.smallImageKey = Assets.Unsupported + presenceData.smallImageText = 'Unknown' + presenceData.details = 'Viewing an unsupported page' + } + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Discord SFX/metadata.json b/websites/D/Discord SFX/metadata.json index 6c880665c1c3..dc92a8883647 100644 --- a/websites/D/Discord SFX/metadata.json +++ b/websites/D/Discord SFX/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "957840712404193290", - "name": "can" - }, - "service": "Discord SFX", - "description": { - "en": "Discord SFX lists some sound files uploaded by other site users that you can download and use for the soundboard of your Discord server, and also allows you to share your own." - }, - "url": "discordsfx.com", - "version": "1.1.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20SFX/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20SFX/assets/thumbnail.png", - "color": "#171717", - "category": "other", - "tags": [ - "discord", - "sfx", - "soundboard" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "957840712404193290", + "name": "can" + }, + "service": "Discord SFX", + "description": { + "en": "Discord SFX lists some sound files uploaded by other site users that you can download and use for the soundboard of your Discord server, and also allows you to share your own." + }, + "url": "discordsfx.com", + "version": "1.1.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20SFX/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20SFX/assets/thumbnail.png", + "color": "#171717", + "category": "other", + "tags": [ + "discord", + "sfx", + "soundboard" + ] +} diff --git a/websites/D/Discord SFX/presence.ts b/websites/D/Discord SFX/presence.ts index a42ac97e61ce..a5a281766453 100644 --- a/websites/D/Discord SFX/presence.ts +++ b/websites/D/Discord SFX/presence.ts @@ -1,111 +1,113 @@ const presence = new Presence({ - clientId: "1119009771538882740", -}); + clientId: '1119009771538882740', +}) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20SFX/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20SFX/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - details: "Browsing", - largeImageKey: Assets.Logo, - }, - { pathname } = document.location; - - switch (pathname) { - case "/": - presenceData.details = "Browsing"; - break; - - case "/search": { - presenceData.details = "Browsing the search page"; - - const sorting = document.querySelector( - "[aria-haspopup='menu']" - ); - let sortingValue: string | null = null; - - if (sorting) sortingValue = sorting.textContent; - if (sortingValue) - presenceData.state = `Looking for ${sortingValue} sounds`; - else presenceData.state = "Looking for sounds"; - - const searchingElement = document.querySelector( - "#searching-for-text" - ); - if (searchingElement) { - const searchQuery = searchingElement.textContent?.split( - "Currently searching for " - )[1]; - if (searchQuery) { - const resultCount = searchingElement - .querySelector("#results-text") - ?.textContent?.split(" results)")[0] - .split("(")[1]; - if (resultCount) presenceData.state = `${resultCount} results`; - - presenceData.details = `Looking for ${searchQuery.replace( - `(${resultCount} results)`, - "" - )}`; - } - } - - if (document.querySelector("#result-state-not-found")) - presenceData.state = "No results found"; - - if (document.querySelector("#result-state-loading")) - presenceData.state = "Loading results"; - break; - } - } - - if (pathname.startsWith("/sounds/")) { - presenceData.details = "Viewing Sound"; - presenceData.state = document.title.split(" | Sound ")[1]; - - presenceData.buttons = [ - { - label: "View Sound", - url: `https://discordsfx.com/sounds/${pathname.split("/")[2]}`, - }, - ]; - } - - if (pathname.startsWith("/users/")) { - presenceData.details = `Viewing ${ - document.title.split(" Profile")[0].split(" | ")[1] - } profile`; - - const imgEl = document.querySelector( - '[data-premid-id="avatar"]' - )?.src; - presenceData.largeImageKey = - (imgEl ? new URL(imgEl) : null)?.searchParams?.get("url") ?? Assets.Logo; - } - - const isPlayingSound = document.querySelector( - "button[data-state='playing']" - ); - if (isPlayingSound) { - const { name, id } = isPlayingSound.dataset; - let newState = ""; - - if (name) { - newState = `Listening to ${name}.mp3`; - if (id) { - presenceData.buttons = [ - { - label: "View Sound", - url: `https://discordsfx.com/sounds/${id}`, - }, - ]; - } - } - - presenceData.state = newState; - } - - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + details: 'Browsing', + largeImageKey: Assets.Logo, + } + const { pathname } = document.location + + switch (pathname) { + case '/': + presenceData.details = 'Browsing' + break + + case '/search': { + presenceData.details = 'Browsing the search page' + + const sorting = document.querySelector( + '[aria-haspopup=\'menu\']', + ) + let sortingValue: string | null = null + + if (sorting) + sortingValue = sorting.textContent + if (sortingValue) + presenceData.state = `Looking for ${sortingValue} sounds` + else presenceData.state = 'Looking for sounds' + + const searchingElement = document.querySelector( + '#searching-for-text', + ) + if (searchingElement) { + const searchQuery = searchingElement.textContent?.split( + 'Currently searching for ', + )[1] + if (searchQuery) { + const resultCount = searchingElement + .querySelector('#results-text') + ?.textContent + ?.split(' results)')[0] + .split('(')[1] + if (resultCount) + presenceData.state = `${resultCount} results` + + presenceData.details = `Looking for ${searchQuery.replace( + `(${resultCount} results)`, + '', + )}` + } + } + + if (document.querySelector('#result-state-not-found')) + presenceData.state = 'No results found' + + if (document.querySelector('#result-state-loading')) + presenceData.state = 'Loading results' + break + } + } + + if (pathname.startsWith('/sounds/')) { + presenceData.details = 'Viewing Sound' + presenceData.state = document.title.split(' | Sound ')[1] + + presenceData.buttons = [ + { + label: 'View Sound', + url: `https://discordsfx.com/sounds/${pathname.split('/')[2]}`, + }, + ] + } + + if (pathname.startsWith('/users/')) { + presenceData.details = `Viewing ${ + document.title.split(' Profile')[0].split(' | ')[1] + } profile` + + const imgEl = document.querySelector( + '[data-premid-id="avatar"]', + )?.src + presenceData.largeImageKey = (imgEl ? new URL(imgEl) : null)?.searchParams?.get('url') ?? Assets.Logo + } + + const isPlayingSound = document.querySelector( + 'button[data-state=\'playing\']', + ) + if (isPlayingSound) { + const { name, id } = isPlayingSound.dataset + let newState = '' + + if (name) { + newState = `Listening to ${name}.mp3` + if (id) { + presenceData.buttons = [ + { + label: 'View Sound', + url: `https://discordsfx.com/sounds/${id}`, + }, + ] + } + } + + presenceData.state = newState + } + + presence.setActivity(presenceData) +}) diff --git a/websites/D/Discord Turkiye/metadata.json b/websites/D/Discord Turkiye/metadata.json index 480eacd76f44..113c79086159 100644 --- a/websites/D/Discord Turkiye/metadata.json +++ b/websites/D/Discord Turkiye/metadata.json @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "nowongame", - "id": "686990422198845452" - }, - "service": "Discord Turkiye", - "description": { - "en": "Discord Turkiye is the largest Forum/Discord community in Turkey, which contains updates, news, servers, bots, trades and many categories.", - "tr": "Discord Turkiye, güncellemeler, haberler, sunucular, botlar, ticaret ve birçok kategoriyi içerisinde barındıran Türkiye'nin en büyük forum/Discord topluluğudur." - }, - "url": "discordturkiye.com", - "version": "1.0.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Turkiye/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Turkiye/assets/thumbnail.png", - "color": "#57F287", - "category": "socials", - "tags": [ - "forum", - "discord" - ], - "settings": [ - { - "id": "privacy_mode", - "value": false, - "title": "Gizlilik Modu", - "icon": "fas fa-user-lock" - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "nowongame", + "id": "686990422198845452" + }, + "service": "Discord Turkiye", + "description": { + "en": "Discord Turkiye is the largest Forum/Discord community in Turkey, which contains updates, news, servers, bots, trades and many categories.", + "tr": "Discord Turkiye, güncellemeler, haberler, sunucular, botlar, ticaret ve birçok kategoriyi içerisinde barındıran Türkiye'nin en büyük forum/Discord topluluğudur." + }, + "url": "discordturkiye.com", + "version": "1.0.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Turkiye/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Turkiye/assets/thumbnail.png", + "color": "#57F287", + "category": "socials", + "tags": [ + "forum", + "discord" + ], + "settings": [ + { + "id": "privacy_mode", + "value": false, + "title": "Gizlilik Modu", + "icon": "fas fa-user-lock" + } + ] +} diff --git a/websites/D/Discord Turkiye/presence.ts b/websites/D/Discord Turkiye/presence.ts index 77146c924ebf..be6ea2e2c634 100644 --- a/websites/D/Discord Turkiye/presence.ts +++ b/websites/D/Discord Turkiye/presence.ts @@ -1,124 +1,132 @@ -const presence = new Presence({ clientId: "890757020393816064" }), - startTimestamp = Math.floor(Date.now() / 1000); +const presence = new Presence({ clientId: '890757020393816064' }) +const startTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Turkiye/assets/logo.png", - details: "Geziniyor", - startTimestamp, - }, - { pathname } = document.location, - privacyMode = await presence.getSetting("privacy_mode").catch(() => false); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Turkiye/assets/logo.png', + details: 'Geziniyor', + startTimestamp, + } + const { pathname } = document.location + const privacyMode = await presence.getSetting('privacy_mode').catch(() => false) - if (document.querySelector('[href="/login/"]')) { - presenceData.smallImageText = "Misafir Modu"; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Turkiye/assets/0.png"; - } else if (document.querySelector("span.avatar.avatar--xxs > img")) { - presenceData.smallImageText = document - .querySelector("span.avatar.avatar--xxs > img") - .getAttribute("alt"); - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Turkiye/assets/0.png"; - } + if (document.querySelector('[href="/login/"]')) { + presenceData.smallImageText = 'Misafir Modu' + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Turkiye/assets/0.png' + } + else if (document.querySelector('span.avatar.avatar--xxs > img')) { + presenceData.smallImageText = document + .querySelector('span.avatar.avatar--xxs > img') + ?.getAttribute('alt') + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Discord%20Turkiye/assets/0.png' + } - switch (pathname) { - case "/": - presenceData.details = "Anasayfayı görüntülüyor"; - break; - case "/hesabim": - presenceData.details = "Kişisel detaylarını görüntülüyor"; - break; - case "/kullanicilar/": - presenceData.details = "Kullanıcıları görüntülüyor"; - break; - case "/araclar/": - presenceData.details = "Araçları görüntülüyor"; - delete presenceData.smallImageKey; - break; + switch (pathname) { + case '/': + presenceData.details = 'Anasayfayı görüntülüyor' + break + case '/hesabim': + presenceData.details = 'Kişisel detaylarını görüntülüyor' + break + case '/kullanicilar/': + presenceData.details = 'Kullanıcıları görüntülüyor' + break + case '/araclar/': + presenceData.details = 'Araçları görüntülüyor' + delete presenceData.smallImageKey + break - case "/araclar/davet/": - delete presenceData.smallImageKey; - if (privacyMode) presenceData.details = "Davet görüntülüyor"; - else if ( - document.querySelector("div.tag > div.name").textContent - ) { - presenceData.details = "Daveti görüntülüyor:"; - presenceData.state = - document.querySelector("div.tag > div.name").textContent; - presenceData.largeImageKey = document - .querySelector("div.icon") - .style.backgroundImage.split('url("')[1] - .split('");')[0]; - } - break; - case "/konular/": - presenceData.details = "Konuyu görüntülüyor:"; - presenceData.state = document.title.split(" | ")[0]; - if ( - document - .querySelector("div.fr-element.fr-view > p") - ?.textContent.trim() - ) { - presenceData.details = "Konuya yorum yazıyor:"; - presenceData.state = document.title.split(" | ")[0]; - } - break; - case "/araclar/kullanici/": - delete presenceData.smallImageKey; - if (privacyMode) presenceData.details = "Kullanıcı görüntülüyor"; - else if (document.querySelector("div.tag").textContent) { - presenceData.details = "Kullanıcı görüntülüyor:"; - presenceData.state = `${ - document.querySelector("div.tag > div.username") - .textContent - }${ - document.querySelector("div.tag > div.discriminator") - .textContent - }`; - presenceData.largeImageKey = document - .querySelector("div.avatar") - .style.backgroundImage.split('url("')[1] - .split('");')[0]; - } - break; - case "/konusmalar/": - presenceData.details = "Konuşmalarını görüntülüyor"; - break; - case "/tags/": - presenceData.details = "Etiketi görüntülüyor:"; - presenceData.state = document.title.split(" | ")[0]; - break; - case "/tags": - presenceData.details = "Etiketleri görüntülüyor"; - break; - case "/post-thread": - presenceData.details = "Kategoride konu açıyor:"; - presenceData.state = document.querySelector( - '[itemprop="itemListElement"]:last-child span[itemprop="name"]' - ).textContent; - break; - } + case '/araclar/davet/': + delete presenceData.smallImageKey + if (privacyMode) { + presenceData.details = 'Davet görüntülüyor' + } + else if ( + document.querySelector('div.tag > div.name')?.textContent + ) { + presenceData.details = 'Daveti görüntülüyor:' + presenceData.state = document.querySelector('div.tag > div.name')?.textContent + presenceData.largeImageKey = document + .querySelector('div.icon') + ?.style + ?.backgroundImage + ?.split('url("')[1] + ?.split('");')[0] + } + break + case '/konular/': + presenceData.details = 'Konuyu görüntülüyor:' + presenceData.state = document.title.split(' | ')[0] + if ( + document + .querySelector('div.fr-element.fr-view > p') + ?.textContent + ?.trim() + ) { + presenceData.details = 'Konuya yorum yazıyor:' + presenceData.state = document.title.split(' | ')[0] + } + break + case '/araclar/kullanici/': + delete presenceData.smallImageKey + if (privacyMode) { + presenceData.details = 'Kullanıcı görüntülüyor' + } + else if (document.querySelector('div.tag')?.textContent) { + presenceData.details = 'Kullanıcı görüntülüyor:' + presenceData.state = `${ + document.querySelector('div.tag > div.username') + ?.textContent + }${ + document.querySelector('div.tag > div.discriminator') + ?.textContent + }` + presenceData.largeImageKey = document + .querySelector('div.avatar') + ?.style + ?.backgroundImage + ?.split('url("')[1] + ?.split('");')[0] + } + break + case '/konusmalar/': + presenceData.details = 'Konuşmalarını görüntülüyor' + break + case '/tags/': + presenceData.details = 'Etiketi görüntülüyor:' + presenceData.state = document.title.split(' | ')[0] + break + case '/tags': + presenceData.details = 'Etiketleri görüntülüyor' + break + case '/post-thread': + presenceData.details = 'Kategoride konu açıyor:' + presenceData.state = document.querySelector( + '[itemprop="itemListElement"]:last-child span[itemprop="name"]', + )?.textContent + break + } - if (document.querySelector("span.username > span")) { - presenceData.details = "Kullanıcıyı görüntülüyor:"; - presenceData.state = document.title.split(" | ")[0]; - } + if (document.querySelector('span.username > span')) { + presenceData.details = 'Kullanıcıyı görüntülüyor:' + presenceData.state = document.title.split(' | ')[0] + } - if (document.querySelector("div.tag").textContent) { - presenceData.details = "Kullanıcı görüntülüyor:"; - presenceData.state = `${ - document.querySelector("div.tag > div.username").textContent - }${ - document.querySelector("div.tag > div.discriminator") - .textContent - }`; - presenceData.largeImageKey = document - .querySelector("div.avatar") - .style.backgroundImage.split('url("')[1] - .split('");')[0]; - } + if (document.querySelector('div.tag')?.textContent) { + presenceData.details = 'Kullanıcı görüntülüyor:' + presenceData.state = `${ + document.querySelector('div.tag > div.username')?.textContent + }${ + document.querySelector('div.tag > div.discriminator') + ?.textContent + }` + presenceData.largeImageKey = document + .querySelector('div.avatar') + ?.style + ?.backgroundImage + ?.split('url("')[1] + ?.split('");')[0] + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/D/Discord/metadata.json b/websites/D/Discord/metadata.json index 3f8d385f667e..1633e4fedceb 100644 --- a/websites/D/Discord/metadata.json +++ b/websites/D/Discord/metadata.json @@ -1,93 +1,93 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "contributors": [ - { - "name": "Scypter", - "id": "782251080179253250" - } - ], - "service": "Discord", - "description": { - "en": "All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.", - "ga_IE": "Comhrá guth agus téacs uile-i-amháin le haghaidh gamers atá saor, slán, agus a oibríonn ar do dheasc agus ar do ghuthán.", - "nl": "Een alles-in-één spraak- en tekstchat voor gamers die gratis en veilig is en op zowel je computer als je telefoon werkt.", - "tr": "Discord; ücretsiz, güvenli ve hem masaüstünüzde hem de telefonunuzda çalışan oyuncular için hepsi bir arada sesli ve yazılı sohbet uygulamasıdır.", - "zh_TW": "Discord是一款專為電子遊戲社區設計的免費網路即時通話軟體與數位發行平台。", - "zh_CN": "Discord是一款专为电子游戏社区设计的免费网络实时通话软件与数字发行平台。", - "vi_VN": "Phần mềm nhắn tin và trò chuyện tất cả trong một dành cho gamer. Miễn phí, bảo mật, và dùng được trên cả máy tính và điện thoại.", - "ko_KR": "Discord는 게이머를 위한 음성 및 채팅 프로그램으로, 데스크톱과 핸드폰 모두에서 무료로 안전하게 작동합니다." - }, - "url": "discord.com", - "regExp": "([a-z0-9-]+[.])*(discord[.]com|discord[.]gg|discordapp[.]com|discordmerch[.]com|discordstatus[.]com)[/]", - "version": "3.0.35", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord/assets/thumbnail.png", - "color": "#7289DA", - "category": "socials", - "tags": [ - "chat", - "gaming", - "voice" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "browse", - "title": "Show Browsing Status", - "icon": "fad fa-book-reader", - "value": true - }, - { - "id": "call", - "title": "Show Calling Status", - "icon": "fad fa-phone-volume", - "value": true - }, - { - "id": "invite", - "title": "Show Invite Links", - "icon": "fad fa-link", - "value": true - }, - { - "id": "timestamp", - "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 - }, - { - "id": "logo", - "title": "Icon", - "icon": "fab fa-discord", - "value": 0, - "values": [ - "White", - "Blurple", - "Black" - ] - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "contributors": [ + { + "name": "Scypter", + "id": "782251080179253250" + } + ], + "service": "Discord", + "description": { + "en": "All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.", + "ga_IE": "Comhrá guth agus téacs uile-i-amháin le haghaidh gamers atá saor, slán, agus a oibríonn ar do dheasc agus ar do ghuthán.", + "nl": "Een alles-in-één spraak- en tekstchat voor gamers die gratis en veilig is en op zowel je computer als je telefoon werkt.", + "tr": "Discord; ücretsiz, güvenli ve hem masaüstünüzde hem de telefonunuzda çalışan oyuncular için hepsi bir arada sesli ve yazılı sohbet uygulamasıdır.", + "zh_TW": "Discord是一款專為電子遊戲社區設計的免費網路即時通話軟體與數位發行平台。", + "zh_CN": "Discord是一款专为电子游戏社区设计的免费网络实时通话软件与数字发行平台。", + "vi_VN": "Phần mềm nhắn tin và trò chuyện tất cả trong một dành cho gamer. Miễn phí, bảo mật, và dùng được trên cả máy tính và điện thoại.", + "ko_KR": "Discord는 게이머를 위한 음성 및 채팅 프로그램으로, 데스크톱과 핸드폰 모두에서 무료로 안전하게 작동합니다." + }, + "url": "discord.com", + "regExp": "([a-z0-9-]+[.])*(discord[.]com|discord[.]gg|discordapp[.]com|discordmerch[.]com|discordstatus[.]com)[/]", + "version": "3.0.35", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discord/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discord/assets/thumbnail.png", + "color": "#7289DA", + "category": "socials", + "tags": [ + "chat", + "gaming", + "voice" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "browse", + "title": "Show Browsing Status", + "icon": "fad fa-book-reader", + "value": true + }, + { + "id": "call", + "title": "Show Calling Status", + "icon": "fad fa-phone-volume", + "value": true + }, + { + "id": "invite", + "title": "Show Invite Links", + "icon": "fad fa-link", + "value": true + }, + { + "id": "timestamp", + "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 + }, + { + "id": "logo", + "title": "Icon", + "icon": "fab fa-discord", + "value": 0, + "values": [ + "White", + "Blurple", + "Black" + ] + } + ] +} diff --git a/websites/D/Discord/presence.ts b/websites/D/Discord/presence.ts index 18928dcd1220..51e273a84048 100644 --- a/websites/D/Discord/presence.ts +++ b/websites/D/Discord/presence.ts @@ -1,776 +1,776 @@ const presence = new Presence({ - clientId: "616940877042155531", -}); + clientId: '616940877042155531', +}) async function getStrings() { - return presence.getStrings( - { - browse: "general.browsing", - writing: "general.writing", - reading: "general.reading", - channelReading: "discord.channelReading", - channelTyping: "discord.channelTyping", - dmReading: "discord.dmReading", - dmTyping: "discord.dmTyping", - dmGroupReading: "discord.dmGroupReading", - dmGroupTyping: "discord.dmGroupTyping", - friends: "discord.friends", - nitro: "discord.nitro", - voiceConnectedWith: "discord.voiceConnectedWith", - voiceConnectedTo: "discord.voiceConnectedTo", - inCall: "general.inCall", - calling: "general.calling", - settings: "discord.settings", - serverSettings: "discord.serverSettings", - invite: "discord.invite", - inviteServer: "discord.inviteServer", - buttonInvite: "discord.buttonInvite", - browseThrough: "discord.browseThrough", - download: "discord.download", - why: "discord.why", - safety: "discord.safety", - jobs: "discord.jobs", - company: "discord.company", - branding: "discord.branding", - inspiration: "discord.inspiration", - college: "discord.college", - newsroom: "discord.newsroom", - partner: "discord.partner", - verification: "discord.verification", - streamkit: "discord.streamkit", - opensource: "discord.opensource", - security: "discord.security", - moderation: "discord.moderation", - rpc: "discord.rpc", - policies: "discord.policies", - portal: "discord.devs.portal", - appsBrowse: "discord.devs.appsBrowse", - appsEdit: "discord.devs.appsEdit", - teamsBrowse: "discord.devs.teamsBrowse", - teamsEdit: "discord.devs.teamsEdit", - serversBrowse: "discord.devs.serversBrowse", - serversEdit: "discord.devs.serversEdit", - docs: "discord.devs.docs", - status: "discord.status", - viewing: "general.viewing", - uptime: "general.uptimeHistory", - incident: "general.incidentHistory", - viewAnIncident: "general.viewAnIncident", - helpCenter: "discord.support", - viewCategory: "general.viewCategory", - searchFor: "general.searchFor", - searching: "general.search", - readingArticle: "general.readingArticle", - blog: "discord.blog", - merch: "discord.merch", - product: "general.viewProduct", - collection: "discord.merch.collection", - viewPage: "general.viewPage", - shopCart: "general.shopCart", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + browse: 'general.browsing', + writing: 'general.writing', + reading: 'general.reading', + channelReading: 'discord.channelReading', + channelTyping: 'discord.channelTyping', + dmReading: 'discord.dmReading', + dmTyping: 'discord.dmTyping', + dmGroupReading: 'discord.dmGroupReading', + dmGroupTyping: 'discord.dmGroupTyping', + friends: 'discord.friends', + nitro: 'discord.nitro', + voiceConnectedWith: 'discord.voiceConnectedWith', + voiceConnectedTo: 'discord.voiceConnectedTo', + inCall: 'general.inCall', + calling: 'general.calling', + settings: 'discord.settings', + serverSettings: 'discord.serverSettings', + invite: 'discord.invite', + inviteServer: 'discord.inviteServer', + buttonInvite: 'discord.buttonInvite', + browseThrough: 'discord.browseThrough', + download: 'discord.download', + why: 'discord.why', + safety: 'discord.safety', + jobs: 'discord.jobs', + company: 'discord.company', + branding: 'discord.branding', + inspiration: 'discord.inspiration', + college: 'discord.college', + newsroom: 'discord.newsroom', + partner: 'discord.partner', + verification: 'discord.verification', + streamkit: 'discord.streamkit', + opensource: 'discord.opensource', + security: 'discord.security', + moderation: 'discord.moderation', + rpc: 'discord.rpc', + policies: 'discord.policies', + portal: 'discord.devs.portal', + appsBrowse: 'discord.devs.appsBrowse', + appsEdit: 'discord.devs.appsEdit', + teamsBrowse: 'discord.devs.teamsBrowse', + teamsEdit: 'discord.devs.teamsEdit', + serversBrowse: 'discord.devs.serversBrowse', + serversEdit: 'discord.devs.serversEdit', + docs: 'discord.devs.docs', + status: 'discord.status', + viewing: 'general.viewing', + uptime: 'general.uptimeHistory', + incident: 'general.incidentHistory', + viewAnIncident: 'general.viewAnIncident', + helpCenter: 'discord.support', + viewCategory: 'general.viewCategory', + searchFor: 'general.searchFor', + searching: 'general.search', + readingArticle: 'general.readingArticle', + blog: 'discord.blog', + merch: 'discord.merch', + product: 'general.viewProduct', + collection: 'discord.merch.collection', + viewPage: 'general.viewPage', + shopCart: 'general.shopCart', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } -let browsingTimestamp = Math.floor(Date.now() / 1000), - prevUrl = document.location.href, - strings: Awaited>, - oldLang: string = null; +let browsingTimestamp = Math.floor(Date.now() / 1000) +let prevUrl = document.location.href +let strings: Awaited> +let oldLang: string | null = null const enum Assets { - DiscordBlack = "https://cdn.rcd.gg/PreMiD/websites/D/Discord/assets/0.png", - Discord = "https://cdn.rcd.gg/PreMiD/websites/D/Discord/assets/1.png", - DiscordWhite = "https://cdn.rcd.gg/PreMiD/websites/D/Discord/assets/2.png", + DiscordBlack = 'https://cdn.rcd.gg/PreMiD/websites/D/Discord/assets/0.png', + Discord = 'https://cdn.rcd.gg/PreMiD/websites/D/Discord/assets/1.png', + DiscordWhite = 'https://cdn.rcd.gg/PreMiD/websites/D/Discord/assets/2.png', } -presence.on("UpdateData", async () => { - const [ - showBrowsing, - showTimestamp, - showButtons, - showInvites, - privacy, - showCalls, - newLang, - logo, - ] = await Promise.all([ - presence.getSetting("browse"), - presence.getSetting("timestamp"), - presence.getSetting("buttons"), - presence.getSetting("invite"), - presence.getSetting("privacy"), - presence.getSetting("call"), - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("logo"), - ]); +presence.on('UpdateData', async () => { + const [ + showBrowsing, + showTimestamp, + showButtons, + showInvites, + privacy, + showCalls, + newLang, + logo, + ] = await Promise.all([ + presence.getSetting('browse'), + presence.getSetting('timestamp'), + presence.getSetting('buttons'), + presence.getSetting('invite'), + presence.getSetting('privacy'), + presence.getSetting('call'), + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('logo'), + ]) - let presenceData: PresenceData = { - largeImageKey: - [Assets.DiscordWhite, Assets.Discord, Assets.DiscordBlack][logo] || - Assets.DiscordWhite, - }; + let presenceData: PresenceData = { + largeImageKey: [Assets.DiscordWhite, Assets.Discord, Assets.DiscordBlack][logo] + || Assets.DiscordWhite, + } - if (document.location.href !== prevUrl) { - prevUrl = document.location.href; - browsingTimestamp = Math.floor(Date.now() / 1000); - } + if (document.location.href !== prevUrl) { + prevUrl = document.location.href + browsingTimestamp = Math.floor(Date.now() / 1000) + } - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - switch (document.location.hostname) { - case "discord.com": { - const dmsTyping = - Array.from( - document.querySelectorAll("div[contenteditable=true]") - ).find(c => - Object.values(c.attributes).find(a => - a.textContent?.includes(document.querySelector("h3")?.textContent) - ) - )?.parentElement.children.length === 1 - ? true - : false, - groupDm = document.querySelector("input[name=channel_name]") - ? true - : false, - dmsUserGroupName = groupDm - ? ( - document.querySelector( - "input[name=channel_name]" - ) as HTMLInputElement - )?.value || "Undefined" - : `${ - document.querySelector("head > title")?.textContent === "Discord" - ? "" - : `@${document.querySelector("head > title")?.textContent}` - }`, - serverTyping = - Array.from( - document.querySelectorAll("div[contenteditable=true]") - ).find(c => - c.attributes[0].textContent?.includes( - Array.from(document.querySelectorAll("h3")).find(c => - c.className?.includes("title") - )?.textContent - ) - )?.parentElement.children.length === 1 - ? true - : false, - serverChannel = `#${ - document - .querySelectorAll("title")[0] - ?.textContent.split("| #")[1] - ?.split("|")[0] || "Undefined" - }`, - serverServerName = - document.querySelectorAll("title")[0]?.textContent.split("|")[2] || - "Undefined", - statics: { - [name: string]: PresenceData; - } = { - "/": { - details: strings.browse, - }, - "/channels/(\\d*)/(\\d*)/": { - details: serverTyping - ? strings.channelTyping - .split("{0}")[0] - .replace("{1}", serverChannel) - .replace("{2}", serverServerName) - : strings.channelReading - .split("{0}")[0] - .replace("{1}", serverChannel) - .replace("{2}", serverServerName), - state: serverTyping - ? strings.channelTyping - .split("{0}")[1] - ?.replace("{1}", serverChannel) - .replace("{2}", serverServerName) - : strings.channelReading - .split("{0}")[1] - ?.replace("{1}", serverChannel) - .replace("{2}", serverServerName), - smallImageKey: serverTyping ? Assets.Writing : Assets.Reading, - smallImageText: serverTyping ? strings.writing : strings.reading, - }, - "/channels/@me/": { - details: strings.friends, - }, - "/channels/@me/(\\d*)/": { - details: dmsTyping - ? groupDm - ? strings.dmGroupTyping - .split("{0}")[0] - .replace("{1}", dmsUserGroupName) - : strings.dmTyping - .split("{0}")[0] - .replace("{1}", dmsUserGroupName) - : groupDm - ? document.querySelector("head > title")?.textContent === - "Discord" - ? "" - : strings.dmGroupReading - .split("{0}")[0] - .replace("{1}", dmsUserGroupName) - : document.querySelector("head > title")?.textContent === - "Discord" - ? "" - : strings.dmReading - .split("{0}")[0] - .replace("{1}", dmsUserGroupName), - state: dmsTyping - ? groupDm - ? strings.dmGroupTyping - .split("{0}")[1] - ?.replace("{1}", dmsUserGroupName) - : strings.dmTyping - .split("{0}")[1] - ?.replace("{1}", dmsUserGroupName) - : groupDm - ? document.querySelector("head > title")?.textContent === - "Discord" - ? "" - : strings.dmGroupReading - .split("{0}")[1] - ?.replace("{1}", dmsUserGroupName) - : document.querySelector("head > title")?.textContent === - "Discord" - ? "" - : strings.dmReading - .split("{0}")[1] - ?.replace("{1}", dmsUserGroupName), - smallImageKey: dmsTyping ? Assets.Writing : Assets.Reading, - smallImageText: dmsTyping ? strings.writing : strings.reading, - }, - "/invite/(\\w*\\d*)/": { - details: showInvites - ? strings.invite - .split("{0}")[0] - .replace("{1}", document.URL.split("/")[4]) - .replace("{2}", document.title) - : strings.inviteServer - .split("{0}")[0] - .replace("{1}", document.title), - state: showInvites - ? strings.invite - .split("{0}")[1] - ?.replace("{1}", document.URL.split("/")[4]) - .replace("{2}", document.title) - : strings.inviteServer - .split("{0}")[1] - ?.replace("{1}", document.title), - smallImageKey: Assets.Reading, - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - //@ts-expect-error - buttons: showInvites - ? [ - { - label: strings.buttonInvite, - url: document.URL, - }, - ] - : [], - }, - "/store/": { - details: strings.nitro, - }, - "/nitro/": { - details: strings.nitro, - }, - "/download/": { - details: strings.browseThrough, - state: strings.download, - }, - "/why-discord-is-different/": { - details: strings.browseThrough, - state: strings.why, - }, - "/safety/": { - details: strings.browseThrough, - state: strings.safety, - }, - "/jobs/": { - details: strings.browseThrough, - state: strings.jobs, - }, - "/company/": { - details: strings.browseThrough, - state: strings.company, - }, - "/branding/": { - details: strings.browseThrough, - state: strings.branding, - }, - "/inspiration/": { - details: strings.browseThrough, - state: strings.inspiration, - }, - "/college/": { - details: strings.browseThrough, - state: strings.college, - }, - "/newsroom/": { - details: strings.browseThrough, - state: strings.newsroom, - }, - "/partners/": { - details: strings.browseThrough, - state: strings.partner, - }, - "/verification/": { - details: strings.browseThrough, - state: strings.verification, - }, - "/streamkit/": { - details: strings.browseThrough, - state: strings.streamkit, - }, - "/open-source/": { - details: strings.browseThrough, - state: strings.opensource, - }, - "/security/": { - details: strings.browseThrough, - state: strings.security, - }, - "/moderation/": { - details: strings.browseThrough, - state: strings.moderation, - }, - "/rich-presence/": { - details: strings.browseThrough, - state: strings.rpc, - }, - "/terms/": { - details: strings.browseThrough, - state: strings.policies, - }, - "/privacy/": { - details: strings.browseThrough, - state: strings.policies, - }, - "/guidelines/": { - details: strings.browseThrough, - state: strings.policies, - }, - "/acknowledgements/": { - details: strings.browseThrough, - state: strings.policies, - }, - "/licenses/": { - details: strings.browseThrough, - state: strings.policies, - }, - "/developers/applications/": { - details: strings.portal, - state: strings.appsBrowse, - }, - "/developers/applications/(\\d*)/": { - details: strings.portal, - state: strings.appsEdit.replace( - "{0}", - Array.from(document.querySelectorAll("div")).find(c => - c.className?.includes("appDetails") - )?.textContent - ), - smallImageKey: Assets.Writing, - }, - "/developers/teams/": { - details: strings.portal, - state: strings.teamsBrowse, - }, - "/developers/teams/(\\d*)/": { - details: strings.portal, - state: strings.teamsEdit.replace( - "{0}", - document.querySelector("div.Select-value")?.textContent - ), - smallImageKey: Assets.Writing, - }, - "/developers/servers/": { - details: strings.portal, - state: strings.serversBrowse, - }, - "/developers/servers/(\\d*)/": { - details: strings.portal, - state: strings.serversEdit.replace( - "{0}", - Array.from(document.querySelectorAll("div")).find(c => - c.className.includes("itemName") - )?.textContent - ), - smallImageKey: Assets.Reading, - }, - "/developers/docs/": { - details: strings.portal, - state: strings.docs, - smallImageKey: Assets.Reading, - smallImageText: strings.reading, - }, - }; + switch (document.location.hostname) { + case 'discord.com': { + const dmsTyping = Array.from( + document.querySelectorAll('div[contenteditable=true]'), + )?.find(c => + Object.values(c.attributes).find(a => + a.textContent?.includes(document.querySelector('h3')?.textContent || ''), + ), + )?.parentElement?.children.length === 1 + const groupDm = !!document.querySelector('input[name=channel_name]') + const dmsUserGroupName = groupDm + ? ( + document.querySelector( + 'input[name=channel_name]', + ) as HTMLInputElement + )?.value || 'Undefined' + : `${ + document.querySelector('head > title')?.textContent === 'Discord' + ? '' + : `@${document.querySelector('head > title')?.textContent}` + }` + const serverTyping = Array.from( + document.querySelectorAll('div[contenteditable=true]'), + )?.find(c => + c.attributes[0].textContent?.includes( + Array.from(document.querySelectorAll('h3')).find(c => + c.className?.includes('title'), + )?.textContent || '', + ), + )?.parentElement?.children.length === 1 + const serverChannel = `#${ + document + .querySelectorAll('title')[0] + ?.textContent + ?.split('| #')[1] + ?.split('|')[0] || 'Undefined' + }` + const serverServerName = document.querySelectorAll('title')[0]?.textContent?.split('|')[2] + || 'Undefined' + const statics: { + [name: string]: PresenceData + } = { + '/': { + details: strings.browse, + }, + '/channels/(\\d*)/(\\d*)/': { + details: serverTyping + ? strings.channelTyping + .split('{0}')[0] + .replace('{1}', serverChannel) + .replace('{2}', serverServerName) + : strings.channelReading + .split('{0}')[0] + .replace('{1}', serverChannel) + .replace('{2}', serverServerName), + state: serverTyping + ? strings.channelTyping + .split('{0}')[1] + ?.replace('{1}', serverChannel) + .replace('{2}', serverServerName) + : strings.channelReading + .split('{0}')[1] + ?.replace('{1}', serverChannel) + .replace('{2}', serverServerName), + smallImageKey: serverTyping ? Assets.Writing : Assets.Reading, + smallImageText: serverTyping ? strings.writing : strings.reading, + }, + '/channels/@me/': { + details: strings.friends, + }, + '/channels/@me/(\\d*)/': { + details: dmsTyping + ? groupDm + ? strings.dmGroupTyping + .split('{0}')[0] + .replace('{1}', dmsUserGroupName) + : strings.dmTyping + .split('{0}')[0] + .replace('{1}', dmsUserGroupName) + : groupDm + ? document.querySelector('head > title')?.textContent + === 'Discord' + ? '' + : strings.dmGroupReading + .split('{0}')[0] + .replace('{1}', dmsUserGroupName) + : document.querySelector('head > title')?.textContent + === 'Discord' + ? '' + : strings.dmReading + .split('{0}')[0] + .replace('{1}', dmsUserGroupName), + state: dmsTyping + ? groupDm + ? strings.dmGroupTyping + .split('{0}')[1] + ?.replace('{1}', dmsUserGroupName) + : strings.dmTyping + .split('{0}')[1] + ?.replace('{1}', dmsUserGroupName) + : groupDm + ? document.querySelector('head > title')?.textContent + === 'Discord' + ? '' + : strings.dmGroupReading + .split('{0}')[1] + ?.replace('{1}', dmsUserGroupName) + : document.querySelector('head > title')?.textContent + === 'Discord' + ? '' + : strings.dmReading + .split('{0}')[1] + ?.replace('{1}', dmsUserGroupName), + smallImageKey: dmsTyping ? Assets.Writing : Assets.Reading, + smallImageText: dmsTyping ? strings.writing : strings.reading, + }, + '/invite/(\\w*\\d*)/': { + details: showInvites + ? strings.invite + .split('{0}')[0] + .replace('{1}', document.URL.split('/')[4]) + .replace('{2}', document.title) + : strings.inviteServer + .split('{0}')[0] + .replace('{1}', document.title), + state: showInvites + ? strings.invite + .split('{0}')[1] + ?.replace('{1}', document.URL.split('/')[4]) + .replace('{2}', document.title) + : strings.inviteServer + .split('{0}')[1] + ?.replace('{1}', document.title), + smallImageKey: Assets.Reading, + buttons: showInvites + ? [ + { + label: strings.buttonInvite, + url: document.URL, + }, + ] + : undefined, + }, + '/store/': { + details: strings.nitro, + }, + '/nitro/': { + details: strings.nitro, + }, + '/download/': { + details: strings.browseThrough, + state: strings.download, + }, + '/why-discord-is-different/': { + details: strings.browseThrough, + state: strings.why, + }, + '/safety/': { + details: strings.browseThrough, + state: strings.safety, + }, + '/jobs/': { + details: strings.browseThrough, + state: strings.jobs, + }, + '/company/': { + details: strings.browseThrough, + state: strings.company, + }, + '/branding/': { + details: strings.browseThrough, + state: strings.branding, + }, + '/inspiration/': { + details: strings.browseThrough, + state: strings.inspiration, + }, + '/college/': { + details: strings.browseThrough, + state: strings.college, + }, + '/newsroom/': { + details: strings.browseThrough, + state: strings.newsroom, + }, + '/partners/': { + details: strings.browseThrough, + state: strings.partner, + }, + '/verification/': { + details: strings.browseThrough, + state: strings.verification, + }, + '/streamkit/': { + details: strings.browseThrough, + state: strings.streamkit, + }, + '/open-source/': { + details: strings.browseThrough, + state: strings.opensource, + }, + '/security/': { + details: strings.browseThrough, + state: strings.security, + }, + '/moderation/': { + details: strings.browseThrough, + state: strings.moderation, + }, + '/rich-presence/': { + details: strings.browseThrough, + state: strings.rpc, + }, + '/terms/': { + details: strings.browseThrough, + state: strings.policies, + }, + '/privacy/': { + details: strings.browseThrough, + state: strings.policies, + }, + '/guidelines/': { + details: strings.browseThrough, + state: strings.policies, + }, + '/acknowledgements/': { + details: strings.browseThrough, + state: strings.policies, + }, + '/licenses/': { + details: strings.browseThrough, + state: strings.policies, + }, + '/developers/applications/': { + details: strings.portal, + state: strings.appsBrowse, + }, + '/developers/applications/(\\d*)/': { + details: strings.portal, + state: strings.appsEdit.replace( + '{0}', + Array.from(document.querySelectorAll('div')).find(c => + c.className?.includes('appDetails'), + )?.textContent || '', + ), + smallImageKey: Assets.Writing, + }, + '/developers/teams/': { + details: strings.portal, + state: strings.teamsBrowse, + }, + '/developers/teams/(\\d*)/': { + details: strings.portal, + state: strings.teamsEdit.replace( + '{0}', + document.querySelector('div.Select-value')?.textContent || '', + ), + smallImageKey: Assets.Writing, + }, + '/developers/servers/': { + details: strings.portal, + state: strings.serversBrowse, + }, + '/developers/servers/(\\d*)/': { + details: strings.portal, + state: strings.serversEdit.replace( + '{0}', + Array.from(document.querySelectorAll('div')).find(c => + c.className.includes('itemName'), + )?.textContent || '', + ), + smallImageKey: Assets.Reading, + }, + '/developers/docs/': { + details: strings.portal, + state: strings.docs, + smallImageKey: Assets.Reading, + smallImageText: strings.reading, + }, + } - if ( - showCalls && - Array.from(document.querySelectorAll("div")).find(c => - c.className?.includes("rtcConnectionStatus") - ) - ) { - if (privacy) { - presenceData.details = strings.inCall; - presenceData.smallImageKey = Assets.Call; - presenceData.smallImageText = strings.calling; - } else { - const connectedTo = Array.from( - Array.from(document.querySelectorAll("div")) - .find(c => c.className?.includes("rtcConnectionStatus")) - ?.parentElement.querySelector("a")?.children || [] - ).find(c => c.className?.includes("channel")), - connectedToDm = ( - connectedTo?.parentElement as HTMLLinkElement - )?.href.includes("/@me/") - ? true - : false; + if ( + showCalls + && Array.from(document.querySelectorAll('div')).find(c => + c.className?.includes('rtcConnectionStatus'), + ) + ) { + if (privacy) { + presenceData.details = strings.inCall + presenceData.smallImageKey = Assets.Call + presenceData.smallImageText = strings.calling + } + else { + const connectedTo = Array.from( + Array.from(document.querySelectorAll('div')) + .find(c => c.className?.includes('rtcConnectionStatus')) + ?.parentElement + ?.querySelector('a') + ?.children || [], + ).find(c => c.className?.includes('channel')) + const connectedToDm = !!( + connectedTo?.parentElement as HTMLLinkElement + )?.href.includes('/@me/') - if (!connectedTo) { - return presence.error( - "An error occurred while stripping data off the page. Please contact Bas950 on the PreMiD Discord support server (https://discord.premid.app/), and send him a screenshot of this error. ID: connectedTo === undefined/null" - ); - } + if (!connectedTo) { + return presence.error( + 'An error occurred while stripping data off the page. Please contact Bas950 on the PreMiD Discord support server (https://discord.premid.app/), and send him a screenshot of this error. ID: connectedTo === undefined/null', + ) + } - presenceData.details = connectedToDm - ? strings.voiceConnectedWith - .split("{0}")[0] - .replace("{1}", connectedTo.textContent) - : strings.voiceConnectedTo - .split("{0}")[0] - .replace( - "{1}", - connectedTo.textContent.replace( - ` / ${connectedTo.textContent.split(" / ").pop()}`, - "" - ) - ) - .replace("{2}", connectedTo.textContent.split(" / ").pop()); - presenceData.state = connectedToDm - ? strings.voiceConnectedWith - .split("{0}")[1] - ?.replace("{1}", connectedTo.textContent) - : strings.voiceConnectedTo - .split("{0}")[1] - ?.replace( - "{1}", - connectedTo.textContent.replace( - ` / ${connectedTo.textContent.split(" / ").pop()}`, - "" - ) - ) - .replace("{2}", connectedTo.textContent.split(" / ").pop()); - presenceData.smallImageKey = Assets.Call; - presenceData.smallImageText = strings.calling; - } - //* Normal browsing status - } else if (showBrowsing) { - if (privacy) { - presenceData.details = strings.browse; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } else if ( - Array.from(document.querySelectorAll("div[aria-controls]")).find(c => - Object.values(c.attributes).find( - a => a.textContent === "My Account-tab" - ) - ) - ) { - presenceData.details = strings.settings; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } else if ( - Array.from(document.querySelectorAll("div[aria-controls]")).find(c => - Object.values(c.attributes).find( - a => a.textContent === "OVERVIEW-tab" - ) - ) - ) { - const server = - Array.from(document.querySelectorAll("h1")).find(c => - c.className?.includes("name") - )?.textContent || "Undefined"; - presenceData.details = strings.serverSettings - .split("{0}")[0] - .replace("{1}", server); - presenceData.state = strings.serverSettings - .split("{0}")[1] - ?.replace("{1}", server); - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } else { - for (const [k, v] of Object.entries(statics)) { - if ( - location.href - .replace(/\/?$/, "/") - .replace(`https://${document.location.hostname}`, "") - .replace("?", "/") - .replace("=", "/") - .match(k) - ) { - presenceData = { ...presenceData, ...v }; - if (!presenceData.smallImageKey) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } - } - } - } - } + presenceData.details = connectedToDm + ? strings.voiceConnectedWith + .split('{0}')[0] + .replace('{1}', connectedTo.textContent || '') + : strings.voiceConnectedTo + .split('{0}')[0] + .replace( + '{1}', + (connectedTo.textContent || '').replace( + ` / ${connectedTo.textContent?.split(' / ').pop()}`, + '', + ), + ) + .replace('{2}', (connectedTo.textContent || '').split(' / ').pop() || '') + presenceData.state = connectedToDm + ? strings.voiceConnectedWith + .split('{0}')[1] + ?.replace('{1}', (connectedTo.textContent || '')) + : strings.voiceConnectedTo + .split('{0}')[1] + ?.replace( + '{1}', + (connectedTo.textContent || '').replace( + ` / ${connectedTo.textContent?.split(' / ').pop()}`, + '', + ), + ) + .replace('{2}', (connectedTo.textContent || '').split(' / ').pop() || '') + presenceData.smallImageKey = Assets.Call + presenceData.smallImageText = strings.calling + } + //* Normal browsing status + } + else if (showBrowsing) { + if (privacy) { + presenceData.details = strings.browse + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + else if ( + Array.from(document.querySelectorAll('div[aria-controls]')).find(c => + Object.values(c.attributes).find( + a => a.textContent === 'My Account-tab', + ), + ) + ) { + presenceData.details = strings.settings + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + else if ( + Array.from(document.querySelectorAll('div[aria-controls]')).find(c => + Object.values(c.attributes).find( + a => a.textContent === 'OVERVIEW-tab', + ), + ) + ) { + const server = Array.from(document.querySelectorAll('h1')).find(c => + c.className?.includes('name'), + )?.textContent || 'Undefined' + presenceData.details = strings.serverSettings + .split('{0}')[0] + .replace('{1}', server) + presenceData.state = strings.serverSettings + .split('{0}')[1] + ?.replace('{1}', server) + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + else { + for (const [k, v] of Object.entries(statics)) { + if ( + location.href + .replace(/\/?$/, '/') + .replace(`https://${document.location.hostname}`, '') + .replace('?', '/') + .replace('=', '/') + .match(k) + ) { + presenceData = { ...presenceData, ...v } as PresenceData + if (!presenceData.smallImageKey) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + } + } + } + } - break; - } - case "discordstatus.com": { - const statics: { - [name: string]: PresenceData; - } = { - "/": { - details: strings.status, - state: strings.browse, - }, - "/uptime/": { - details: strings.status, - state: `${strings.viewing} ${strings.uptime}`, - }, - "/history/": { - details: strings.status, - state: `${strings.viewing} ${strings.incident}`, - }, - "/incidents/": { - details: strings.status, - state: strings.viewAnIncident, - }, - }; - if (showBrowsing) { - if (privacy) { - presenceData.details = strings.status; - presenceData.state = strings.browse; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } else { - for (const [k, v] of Object.entries(statics)) { - if ( - location.href - .replace(/\/?$/, "/") - .replace(`https://${document.location.hostname}`, "") - .replace("?", "/") - .replace("=", "/") - .match(k) - ) { - presenceData = { ...presenceData, ...v }; - if (!presenceData.smallImageKey) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } - } - } - } - } + break + } + case 'discordstatus.com': { + const statics: { + [name: string]: PresenceData + } = { + '/': { + details: strings.status, + state: strings.browse, + }, + '/uptime/': { + details: strings.status, + state: `${strings.viewing} ${strings.uptime}`, + }, + '/history/': { + details: strings.status, + state: `${strings.viewing} ${strings.incident}`, + }, + '/incidents/': { + details: strings.status, + state: strings.viewAnIncident, + }, + } + if (showBrowsing) { + if (privacy) { + presenceData.details = strings.status + presenceData.state = strings.browse + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + else { + for (const [k, v] of Object.entries(statics)) { + if ( + location.href + .replace(/\/?$/, '/') + .replace(`https://${document.location.hostname}`, '') + .replace('?', '/') + .replace('=', '/') + .match(k) + ) { + presenceData = { ...presenceData, ...v } as PresenceData + if (!presenceData.smallImageKey) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + } + } + } + } - break; - } - case "support.discord.com": { - const statics: { - [name: string]: PresenceData; - } = { - "/": { - details: strings.helpCenter, - state: strings.browse, - }, - "/categories/": { - details: strings.helpCenter, - state: `${strings.viewCategory} ${ - document.querySelector("h1")?.textContent - }`, - }, - "/search/": { - details: strings.helpCenter, - state: `${strings.searchFor} ${ - (document.querySelector("#query") as HTMLInputElement)?.value - }`, - smallImageKey: Assets.Search, - smallImageText: strings.searching, - }, - "/articles/": { - details: strings.helpCenter, - state: `${strings.readingArticle} ${document - .querySelector("h1") - ?.textContent.trim()}`, - smallImageKey: Assets.Reading, - smallImageText: strings.reading, - }, - }; - if (showBrowsing) { - if (privacy) { - presenceData.details = strings.helpCenter; - presenceData.state = strings.browse; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } else { - for (const [k, v] of Object.entries(statics)) { - if ( - location.href - .replace(/\/?$/, "/") - .replace(`https://${document.location.hostname}`, "") - .replace("?", "/") - .replace("=", "/") - .match(k) - ) { - presenceData = { ...presenceData, ...v }; - if (!presenceData.smallImageKey) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } - } - } - } - } + break + } + case 'support.discord.com': { + const statics: { + [name: string]: PresenceData + } = { + '/': { + details: strings.helpCenter, + state: strings.browse, + }, + '/categories/': { + details: strings.helpCenter, + state: `${strings.viewCategory} ${ + document.querySelector('h1')?.textContent + }`, + }, + '/search/': { + details: strings.helpCenter, + state: `${strings.searchFor} ${ + (document.querySelector('#query') as HTMLInputElement)?.value + }`, + smallImageKey: Assets.Search, + smallImageText: strings.searching, + }, + '/articles/': { + details: strings.helpCenter, + state: `${strings.readingArticle} ${document + .querySelector('h1') + ?.textContent + ?.trim()}`, + smallImageKey: Assets.Reading, + smallImageText: strings.reading, + }, + } + if (showBrowsing) { + if (privacy) { + presenceData.details = strings.helpCenter + presenceData.state = strings.browse + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + else { + for (const [k, v] of Object.entries(statics)) { + if ( + location.href + .replace(/\/?$/, '/') + .replace(`https://${document.location.hostname}`, '') + .replace('?', '/') + .replace('=', '/') + .match(k) + ) { + presenceData = { ...presenceData, ...v } as PresenceData + if (!presenceData.smallImageKey) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + } + } + } + } - break; - } - case "blog.discord.com": { - const statics: { - [name: string]: PresenceData; - } = { - "/": { - details: strings.blog, - state: - document.querySelector("h1")?.textContent !== "Discord Blog" - ? `${strings.readingArticle} ${ - document.querySelector("h1").textContent - }` - : strings.browse, - }, - "/product-posts/": { - details: strings.blog, - state: `${strings.viewCategory} Product posts`, - }, - "/company-posts/": { - details: strings.blog, - state: `${strings.viewCategory} Company posts`, - }, - "/education-posts/": { - details: strings.blog, - state: `${strings.viewCategory} Education posts`, - }, - "/community-posts/": { - details: strings.blog, - state: `${strings.viewCategory} Community posts`, - }, - "/engineering-posts/": { - details: strings.blog, - state: `${strings.viewCategory} Engineering posts`, - }, - }; - if (showBrowsing) { - if (privacy) { - presenceData.details = strings.blog; - presenceData.state = strings.browse; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } else { - for (const [k, v] of Object.entries(statics)) { - if ( - location.href - .replace(/\/?$/, "/") - .replace(`https://${document.location.hostname}`, "") - .replace("?", "/") - .replace("=", "/") - .match(k) - ) { - presenceData = { ...presenceData, ...v }; - if (!presenceData.smallImageKey) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } - } - } - } - } + break + } + case 'blog.discord.com': { + const statics: { + [name: string]: PresenceData + } = { + '/': { + details: strings.blog, + state: document.querySelector('h1')?.textContent !== 'Discord Blog' + ? `${strings.readingArticle} ${ + document.querySelector('h1')?.textContent + }` + : strings.browse, + }, + '/product-posts/': { + details: strings.blog, + state: `${strings.viewCategory} Product posts`, + }, + '/company-posts/': { + details: strings.blog, + state: `${strings.viewCategory} Company posts`, + }, + '/education-posts/': { + details: strings.blog, + state: `${strings.viewCategory} Education posts`, + }, + '/community-posts/': { + details: strings.blog, + state: `${strings.viewCategory} Community posts`, + }, + '/engineering-posts/': { + details: strings.blog, + state: `${strings.viewCategory} Engineering posts`, + }, + } + if (showBrowsing) { + if (privacy) { + presenceData.details = strings.blog + presenceData.state = strings.browse + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + else { + for (const [k, v] of Object.entries(statics)) { + if ( + location.href + .replace(/\/?$/, '/') + .replace(`https://${document.location.hostname}`, '') + .replace('?', '/') + .replace('=', '/') + .match(k) + ) { + presenceData = { ...presenceData, ...v } as PresenceData + if (!presenceData.smallImageKey) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + } + } + } + } - break; - } - case "discordmerch.com": { - const statics: { - [name: string]: PresenceData; - } = { - "/": { - details: strings.merch, - state: strings.browse, - }, - "/products/": { - details: strings.merch, - state: `${strings.product} ${ - document.querySelector("h1")?.textContent - }`, - }, - "/collections/": { - details: strings.merch, - state: `${strings.collection} ${ - document.querySelector("h1")?.textContent - }`, - }, - "/pages/": { - details: strings.merch, - state: `${strings.viewPage} ${ - document.querySelector("h1")?.textContent - }`, - }, - "/cart/": { - details: strings.merch, - state: `${strings.viewing} ${strings.shopCart}`, - }, - "/search/": { - details: strings.merch, - state: `${strings.searchFor} ${ - (document.querySelector("input") as HTMLInputElement)?.value - }`, - smallImageKey: Assets.Search, - smallImageText: strings.searching, - }, - }; - if (showBrowsing) { - if (privacy) { - presenceData.details = strings.status; - presenceData.state = strings.browse; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } else { - for (const [k, v] of Object.entries(statics)) { - if ( - location.href - .replace(/\/?$/, "/") - .replace(`https://${document.location.hostname}`, "") - .replace("?", "/") - .replace("=", "/") - .match(k) - ) { - presenceData = { ...presenceData, ...v }; - if (!presenceData.smallImageKey) { - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = strings.browse; - } - } - } - } - } + break + } + case 'discordmerch.com': { + const statics: { + [name: string]: PresenceData + } = { + '/': { + details: strings.merch, + state: strings.browse, + }, + '/products/': { + details: strings.merch, + state: `${strings.product} ${ + document.querySelector('h1')?.textContent + }`, + }, + '/collections/': { + details: strings.merch, + state: `${strings.collection} ${ + document.querySelector('h1')?.textContent + }`, + }, + '/pages/': { + details: strings.merch, + state: `${strings.viewPage} ${ + document.querySelector('h1')?.textContent + }`, + }, + '/cart/': { + details: strings.merch, + state: `${strings.viewing} ${strings.shopCart}`, + }, + '/search/': { + details: strings.merch, + state: `${strings.searchFor} ${ + (document.querySelector('input') as HTMLInputElement)?.value + }`, + smallImageKey: Assets.Search, + smallImageText: strings.searching, + }, + } + if (showBrowsing) { + if (privacy) { + presenceData.details = strings.status + presenceData.state = strings.browse + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + else { + for (const [k, v] of Object.entries(statics)) { + if ( + location.href + .replace(/\/?$/, '/') + .replace(`https://${document.location.hostname}`, '') + .replace('?', '/') + .replace('=', '/') + .match(k) + ) { + presenceData = { ...presenceData, ...v } as PresenceData + if (!presenceData.smallImageKey) { + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = strings.browse + } + } + } + } + } - break; - } - // No default - } + break + } + } - if (!presenceData.buttons?.length) delete presenceData.buttons; - if (!showButtons) delete presenceData.buttons; - if (showTimestamp) presenceData.startTimestamp = browsingTimestamp; + if (!presenceData.buttons?.length) + delete presenceData.buttons + if (!showButtons) + delete presenceData.buttons + if (showTimestamp) + presenceData.startTimestamp = browsingTimestamp - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/DiscordJS Guide/metadata.json b/websites/D/DiscordJS Guide/metadata.json index e6281be98bb6..b3520b35a860 100644 --- a/websites/D/DiscordJS Guide/metadata.json +++ b/websites/D/DiscordJS Guide/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "OGMatrix", - "id": "657290880947978241" - }, - "service": "DiscordJS Guide", - "description": { - "en": "A guide made by the community of discord.js for its users.", - "de": "Ein Leitfaden der Community von discord.js für ihre Benutzer.", - "nl": "Een gids gemaakt door de gemeenschap van discord.js voor haar gebruikers." - }, - "url": "discordjs.guide", - "version": "1.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DiscordJS%20Guide/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DiscordJS%20Guide/assets/thumbnail.png", - "color": "#20f856", - "category": "other", - "tags": [ - "discordjs", - "discord", - "guide" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "OGMatrix", + "id": "657290880947978241" + }, + "service": "DiscordJS Guide", + "description": { + "en": "A guide made by the community of discord.js for its users.", + "de": "Ein Leitfaden der Community von discord.js für ihre Benutzer.", + "nl": "Een gids gemaakt door de gemeenschap van discord.js voor haar gebruikers." + }, + "url": "discordjs.guide", + "version": "1.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DiscordJS%20Guide/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DiscordJS%20Guide/assets/thumbnail.png", + "color": "#20f856", + "category": "other", + "tags": [ + "discordjs", + "discord", + "guide" + ] +} diff --git a/websites/D/DiscordJS Guide/presence.ts b/websites/D/DiscordJS Guide/presence.ts index 2a8136a7e49b..edb1d9d56ea3 100644 --- a/websites/D/DiscordJS Guide/presence.ts +++ b/websites/D/DiscordJS Guide/presence.ts @@ -1,20 +1,21 @@ const presence = new Presence({ - clientId: "819865300173324288", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '819865300173324288', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DiscordJS%20Guide/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DiscordJS%20Guide/assets/logo.png', + startTimestamp: browsingTimestamp, + } - presenceData.details = "Viewing Docs"; - presenceData.state = `Page: ${document - .querySelectorAll("h1")[0] - .textContent.replace("#", "")}`; + presenceData.details = 'Viewing Docs' + presenceData.state = `Page: ${document + .querySelectorAll('h1')[0] + ?.textContent + ?.replace('#', '')}` - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/D/DiscordLabs.org/metadata.json b/websites/D/DiscordLabs.org/metadata.json index e5caccf5f03e..d98800cb8f57 100644 --- a/websites/D/DiscordLabs.org/metadata.json +++ b/websites/D/DiscordLabs.org/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dominik", - "id": "594491170248458250" - }, - "service": "DiscordLabs.org", - "description": { - "en": "Check our our amazing list of lab approved discord bots!", - "pl": "Sprawdź naszą niesamowitą listę zatwierdzonych przez laboratorium botów discord!", - "nl": "Bekijk onze geweldige lijst van lab goedgekeurde discord bots!" - }, - "url": "bots.discordlabs.org", - "version": "1.2.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DiscordLabs.org/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DiscordLabs.org/assets/thumbnail.png", - "color": "#6a0dad", - "category": "other", - "tags": [ - "bots", - "discord", - "list" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dominik", + "id": "594491170248458250" + }, + "service": "DiscordLabs.org", + "description": { + "en": "Check our our amazing list of lab approved discord bots!", + "pl": "Sprawdź naszą niesamowitą listę zatwierdzonych przez laboratorium botów discord!", + "nl": "Bekijk onze geweldige lijst van lab goedgekeurde discord bots!" + }, + "url": "bots.discordlabs.org", + "version": "1.2.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DiscordLabs.org/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DiscordLabs.org/assets/thumbnail.png", + "color": "#6a0dad", + "category": "other", + "tags": [ + "bots", + "discord", + "list" + ] +} diff --git a/websites/D/DiscordLabs.org/presence.ts b/websites/D/DiscordLabs.org/presence.ts index 89ec3a686f47..94c04db260a8 100644 --- a/websites/D/DiscordLabs.org/presence.ts +++ b/websites/D/DiscordLabs.org/presence.ts @@ -1,49 +1,54 @@ const presence = new Presence({ - clientId: "660894911331172372", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '660894911331172372', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let priceEls; +let priceEls -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DiscordLabs.org/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DiscordLabs.org/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (document.location.hostname === "bots.discordlabs.org") { - presenceData.details = "Viewing Page:"; - presenceData.state = "DiscordLabs Bot List"; + if (document.location.hostname === 'bots.discordlabs.org') { + presenceData.details = 'Viewing Page:' + presenceData.state = 'DiscordLabs Bot List' - if (document.location.pathname.includes("/partners")) { - presenceData.details = "Viewing Page:"; - presenceData.state = "DiscordLabs Partners"; - } else if (document.location.pathname.includes("/profile/")) { - priceEls = document.querySelectorAll(".uname"); - for (const priceEl of priceEls) { - presenceData.details = "Viewing a profile:"; - presenceData.state = (priceEl as HTMLElement).textContent; - } - } else if (document.location.pathname.includes("/submit/")) { - presenceData.details = "Viewing Page:"; - presenceData.state = "DiscordLabs Bot Sumbit"; - } else if (document.location.pathname.includes("/submit")) { - presenceData.details = "Viewing Page:"; - presenceData.state = "DiscordLabs Bot Sumbit"; - } else if (document.location.pathname.includes("/search/")) { - presenceData.details = "Search for:"; - presenceData.state = window.location.href - .slice(39) - .replaceAll("+|%20", " "); - } else if (document.location.pathname.includes("/bot/")) { - priceEls = document.querySelectorAll(".botname"); - for (const priceEl of priceEls) { - presenceData.details = "Viewing a Discord bot:"; - presenceData.state = (priceEl as HTMLElement).textContent; - } - } - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (document.location.pathname.includes('/partners')) { + presenceData.details = 'Viewing Page:' + presenceData.state = 'DiscordLabs Partners' + } + else if (document.location.pathname.includes('/profile/')) { + priceEls = document.querySelectorAll('.uname') + for (const priceEl of priceEls) { + presenceData.details = 'Viewing a profile:' + presenceData.state = (priceEl as HTMLElement).textContent + } + } + else if (document.location.pathname.includes('/submit/')) { + presenceData.details = 'Viewing Page:' + presenceData.state = 'DiscordLabs Bot Sumbit' + } + else if (document.location.pathname.includes('/submit')) { + presenceData.details = 'Viewing Page:' + presenceData.state = 'DiscordLabs Bot Sumbit' + } + else if (document.location.pathname.includes('/search/')) { + presenceData.details = 'Search for:' + presenceData.state = window.location.href + .slice(39) + .replaceAll('+|%20', ' ') + } + else if (document.location.pathname.includes('/bot/')) { + priceEls = document.querySelectorAll('.botname') + for (const priceEl of priceEls) { + presenceData.details = 'Viewing a Discord bot:' + presenceData.state = (priceEl as HTMLElement).textContent + } + } + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Discords.com/metadata.json b/websites/D/Discords.com/metadata.json index 3557b263bbdd..da9bd845d7f0 100644 --- a/websites/D/Discords.com/metadata.json +++ b/websites/D/Discords.com/metadata.json @@ -1,51 +1,51 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Anaxes", - "id": "567885938160697377" - }, - "contributors": [ - { - "name": "EGGSY", - "id": "162969778699501569" - }, - { - "name": "MauriceX", - "id": "268768664411439115" - } - ], - "service": "Discords.com", - "description": { - "en": "Find discord servers using the most advanced public index." - }, - "url": "discords.com", - "version": "1.1.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/thumbnail.png", - "color": "#23283B", - "category": "socials", - "tags": [ - "discord", - "discord-service", - "discord-invite", - "discords", - "discord-bio", - "discord-servers", - "discord-templates" - ], - "settings": [ - { - "id": "timestamp", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Anaxes", + "id": "567885938160697377" + }, + "contributors": [ + { + "name": "EGGSY", + "id": "162969778699501569" + }, + { + "name": "MauriceX", + "id": "268768664411439115" + } + ], + "service": "Discords.com", + "description": { + "en": "Find discord servers using the most advanced public index." + }, + "url": "discords.com", + "version": "1.1.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/thumbnail.png", + "color": "#23283B", + "category": "socials", + "tags": [ + "discord", + "discord-service", + "discord-invite", + "discords", + "discord-bio", + "discord-servers", + "discord-templates" + ], + "settings": [ + { + "id": "timestamp", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/D/Discords.com/presence.ts b/websites/D/Discords.com/presence.ts index 497a265c05ea..8de8d94a0fdb 100644 --- a/websites/D/Discords.com/presence.ts +++ b/websites/D/Discords.com/presence.ts @@ -1,365 +1,404 @@ const presence = new Presence({ - clientId: "843791837273391104", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '843791837273391104', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/logo.png", - Discordbio = "https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/0.png", - Discordtemplates = "https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/1.png", - Botsfordiscord = "https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/2.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/logo.png', + Discordbio = 'https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/0.png', + Discordtemplates = 'https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/1.png', + Botsfordiscord = 'https://cdn.rcd.gg/PreMiD/websites/D/Discords.com/assets/2.png', } -presence.on("UpdateData", async () => { - const showTimestamp = await presence.getSetting("timestamp"), - showButtons = await presence.getSetting("buttons"), - presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }; +presence.on('UpdateData', async () => { + const showTimestamp = await presence.getSetting('timestamp') + const showButtons = await presence.getSetting('buttons') + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } - if (document.location.pathname === "/") - presenceData.details = "Viewing home page"; - else if (document.location.pathname === "/servers/search") { - presenceData.details = `🔍 Searching for: ${ - document - .querySelector("h1.text-center") - ?.textContent.replace("Discord Servers", " ") || "Nothing" - }`; - presenceData.state = `📖 Page ${ - document.querySelector("li.page-item.active")?.textContent - }`; - presenceData.buttons = [ - { - label: "View Results", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/servers/tag/")) { - presenceData.details = `Viewing 📛 ${ - document - .querySelector("h1.text-center") - ?.textContent.replace("Discord Servers", " ") || "Nothing" - } tag`; - presenceData.state = `📖 Page ${ - document.querySelector("li.page-item.active")?.textContent - }`; - presenceData.buttons = [ - { - label: "View Tag", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/servers/tags/")) { - presenceData.details = `Viewing 🔑 ${ - document - .querySelector("h1.text-center") - ?.textContent.replace("Discord Servers", " ") || "Nothing" - } keyword`; - presenceData.state = `📖 Page ${ - document.querySelector("li.page-item.active")?.textContent - }`; - presenceData.buttons = [ - { - label: "View Keyword", - url: document.location.href, - }, - ]; - } else if (document.location.pathname === "/servers/top-100") { - presenceData.details = "Viewing 🏅 top-100 servers"; - presenceData.state = `📖 Page ${ - document.querySelector("li.page-item.active")?.textContent - }`; - presenceData.buttons = [ - { - label: "View Top-100", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/join")) { - const serverNameJoin = document.querySelector("h2.mt-4")?.textContent; - presenceData.details = `Looking at 🚦 ${ - serverNameJoin || "N/A" - }'s join page`; - if (serverNameJoin) { - presenceData.buttons = [ - { - label: `Join ${serverNameJoin}`, - url: document.location.href, - }, - ]; - } - } else if (document.location.pathname.includes("/upvote")) { - const serverNameUpvote = document.querySelector( - "h1.JoinUpvote_clickable-server-name__3l6Es" - )?.textContent; - presenceData.details = `Upvoting 🗳️ ${serverNameUpvote || "N/A"} `; - if (serverNameUpvote) { - presenceData.buttons = [ - { - label: `Upvote ${serverNameUpvote}`, - url: document.location.href, - }, - ]; - } - } else if (document.location.pathname.includes("/servers/")) { - presenceData.details = `Viewing 🎨 ${document - .querySelector("h1.servernameh1") - ?.textContent.replace("PREMIUM", " ")}`; - presenceData.state = `${ - document - .querySelectorAll("span.mr-2")[0] - ?.textContent.replace( - `${document.querySelectorAll("span.mr-2")[0]?.textContent}`, - `${`👥 ${document.querySelectorAll("span.mr-2")[0]?.textContent}`}` - ) || "0 members online" - }, ${ - document - .querySelectorAll("span.mr-2")[1] - ?.textContent.replace( - `${document.querySelectorAll("span.mr-2")[1]?.textContent}`, - `${`🎁 ${document.querySelectorAll("span.mr-2")[1]?.textContent}`}` - ) || "0 members" - }, ${ - document - .querySelectorAll("span.mr-2")[2] - ?.textContent.replace( - `${document.querySelectorAll("span.mr-2")[2]?.textContent}`, - `${`💎 ${document.querySelectorAll("span.mr-2")[2]?.textContent}`}` - ) || "0 boosts" - }`; - presenceData.buttons = [ - { - label: "View Page", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/about")) { - presenceData.details = "Viewing 🎫 about page"; - presenceData.buttons = [ - { - label: "View Page", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/payment")) { - presenceData.details = "Purchasing 💳 premium"; - presenceData.buttons = [ - { - label: "Purchase Premium", - url: document.location.href, - }, - ]; - } else if (document.location.pathname === "/premium/") { - presenceData.details = "Viewing 💎 premium plans"; - presenceData.buttons = [ - { - label: "View Premium", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/partners")) { - presenceData.details = "Viewing 🤝 partners"; - presenceData.buttons = [ - { - label: "View Partners", - url: document.location.href, - }, - ]; - } else { - switch (document.location.pathname) { - case "/u/dashboard": { - presenceData.details = "Viewing 👤 dashboard"; - break; - } - case "/emoji-list": { - presenceData.details = "Viewing 😃 Emoji list"; - presenceData.buttons = [ - { - label: "View Emojis", - url: document.location.href, - }, - ]; + if (document.location.pathname === '/') { + presenceData.details = 'Viewing home page' + } + else if (document.location.pathname === '/servers/search') { + presenceData.details = `🔍 Searching for: ${ + document + .querySelector('h1.text-center') + ?.textContent + ?.replace('Discord Servers', ' ') || 'Nothing' + }` + presenceData.state = `📖 Page ${ + document.querySelector('li.page-item.active')?.textContent + }` + presenceData.buttons = [ + { + label: 'View Results', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/servers/tag/')) { + presenceData.details = `Viewing 📛 ${ + document + .querySelector('h1.text-center') + ?.textContent + ?.replace('Discord Servers', ' ') || 'Nothing' + } tag` + presenceData.state = `📖 Page ${ + document.querySelector('li.page-item.active')?.textContent + }` + presenceData.buttons = [ + { + label: 'View Tag', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/servers/tags/')) { + presenceData.details = `Viewing 🔑 ${ + document + .querySelector('h1.text-center') + ?.textContent + ?.replace('Discord Servers', ' ') || 'Nothing' + } keyword` + presenceData.state = `📖 Page ${ + document.querySelector('li.page-item.active')?.textContent + }` + presenceData.buttons = [ + { + label: 'View Keyword', + url: document.location.href, + }, + ] + } + else if (document.location.pathname === '/servers/top-100') { + presenceData.details = 'Viewing 🏅 top-100 servers' + presenceData.state = `📖 Page ${ + document.querySelector('li.page-item.active')?.textContent + }` + presenceData.buttons = [ + { + label: 'View Top-100', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/join')) { + const serverNameJoin = document.querySelector('h2.mt-4')?.textContent + presenceData.details = `Looking at 🚦 ${ + serverNameJoin || 'N/A' + }'s join page` + if (serverNameJoin) { + presenceData.buttons = [ + { + label: `Join ${serverNameJoin}`, + url: document.location.href, + }, + ] + } + } + else if (document.location.pathname.includes('/upvote')) { + const serverNameUpvote = document.querySelector( + 'h1.JoinUpvote_clickable-server-name__3l6Es', + )?.textContent + presenceData.details = `Upvoting 🗳️ ${serverNameUpvote || 'N/A'} ` + if (serverNameUpvote) { + presenceData.buttons = [ + { + label: `Upvote ${serverNameUpvote}`, + url: document.location.href, + }, + ] + } + } + else if (document.location.pathname.includes('/servers/')) { + presenceData.details = `Viewing 🎨 ${document + .querySelector('h1.servernameh1') + ?.textContent + ?.replace('PREMIUM', ' ')}` + presenceData.state = `${ + document + .querySelectorAll('span.mr-2')[0] + ?.textContent + ?.replace( + `${document.querySelectorAll('span.mr-2')[0]?.textContent}`, + `${`👥 ${document.querySelectorAll('span.mr-2')[0]?.textContent}`}`, + ) || '0 members online' + }, ${ + document + .querySelectorAll('span.mr-2')[1] + ?.textContent + ?.replace( + `${document.querySelectorAll('span.mr-2')[1]?.textContent}`, + `${`🎁 ${document.querySelectorAll('span.mr-2')[1]?.textContent}`}`, + ) || '0 members' + }, ${ + document + .querySelectorAll('span.mr-2')[2] + ?.textContent + ?.replace( + `${document.querySelectorAll('span.mr-2')[2]?.textContent}`, + `${`💎 ${document.querySelectorAll('span.mr-2')[2]?.textContent}`}`, + ) || '0 boosts' + }` + presenceData.buttons = [ + { + label: 'View Page', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/about')) { + presenceData.details = 'Viewing 🎫 about page' + presenceData.buttons = [ + { + label: 'View Page', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/payment')) { + presenceData.details = 'Purchasing 💳 premium' + presenceData.buttons = [ + { + label: 'Purchase Premium', + url: document.location.href, + }, + ] + } + else if (document.location.pathname === '/premium/') { + presenceData.details = 'Viewing 💎 premium plans' + presenceData.buttons = [ + { + label: 'View Premium', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/partners')) { + presenceData.details = 'Viewing 🤝 partners' + presenceData.buttons = [ + { + label: 'View Partners', + url: document.location.href, + }, + ] + } + else { + switch (document.location.pathname) { + case '/u/dashboard': { + presenceData.details = 'Viewing 👤 dashboard' + break + } + case '/emoji-list': { + presenceData.details = 'Viewing 😃 Emoji list' + presenceData.buttons = [ + { + label: 'View Emojis', + url: document.location.href, + }, + ] - break; - } - case "/emoji-list/search": { - presenceData.details = `🔍 Searching for emoji: ${ - document - .querySelector("h2.EmoList_heading1__3KEr_") - ?.textContent.replace("Emoji List", " ") || "N/A" - }`; - presenceData.state = `📖 Page ${ - document.querySelector("li.page-item.active")?.textContent - }`; - presenceData.buttons = [ - { - label: "View Results", - url: document.location.href, - }, - ]; + break + } + case '/emoji-list/search': { + presenceData.details = `🔍 Searching for emoji: ${ + document + .querySelector('h2.EmoList_heading1__3KEr_') + ?.textContent + ?.replace('Emoji List', ' ') || 'N/A' + }` + presenceData.state = `📖 Page ${ + document.querySelector('li.page-item.active')?.textContent + }` + presenceData.buttons = [ + { + label: 'View Results', + url: document.location.href, + }, + ] - break; - } - default: - if (document.location.pathname.includes("/emoji-list/tag/")) { - presenceData.details = `Looking at 📛 ${ - document - .querySelector("h2.EmoList_heading1__3KEr_") - ?.textContent.replace("Emoji List", " ") || "N/A" - } emoji tag`; - presenceData.state = `📖 Page ${ - document.querySelector("li.page-item.active")?.textContent - }`; - presenceData.buttons = [ - { - label: "View Emoji Tag", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/termsofservice")) { - presenceData.details = "Viewing 👩‍⚖️ Terms of Service"; - presenceData.buttons = [ - { - label: "View Page", - url: document.location.href, - }, - ]; - // discord.bio - } else if (document.location.pathname.includes("/profiles")) { - presenceData.largeImageKey = Assets.Discordbio; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Browsing..."; - presenceData.details = "Browsing top bios"; - presenceData.buttons = [ - { - label: "View Bios", - url: document.location.href, - }, - ]; - } else if (document.location.pathname === "/bio/premium") { - presenceData.largeImageKey = Assets.Discordbio; - presenceData.details = "Viewing 💎 premium plans"; - presenceData.buttons = [ - { - label: "View Premium Plans", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/customise")) { - presenceData.largeImageKey = Assets.Discordbio; - presenceData.details = "Editing bio"; - } else if (document.location.pathname.includes("/settings")) { - presenceData.largeImageKey = Assets.Discordbio; - presenceData.details = "Viewing ⚙️ settings"; - } else if (document.location.pathname.includes("/p/")) { - presenceData.largeImageKey = Assets.Discordbio; - const profileName = document.querySelector( - "span.text-white.font-bold.text-2xl" - )?.textContent; - presenceData.details = `Viewing ${ - profileName - ? profileName.endsWith("s") - ? `${`${profileName}'`}` - : `${`${profileName}'s`}` - : "Unknown" - } bio`; - presenceData.state = `${ - document.querySelector( - "div.text-xs.uppercase.tracking-widest.font-bold.text-blue-300" - )?.textContent - ? "💎 Premium User" - : "🎟️ Normal User" - }`; - presenceData.buttons = [ - { - label: "View Bio", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/bio")) { - presenceData.largeImageKey = Assets.Discordbio; - presenceData.details = "Viewing home page"; - // discord templates - } else if (document.location.pathname.includes("/edit")) { - presenceData.largeImageKey = Assets.Discordtemplates; - presenceData.details = "Editing a template"; - presenceData.buttons = [ - { - label: "View Template", - url: document.location.href.split("/edit")[0], - }, - ]; - } else if (document.location.pathname.includes("/templates/id/new")) { - presenceData.largeImageKey = Assets.Discordtemplates; - presenceData.details = "Creating New Template:"; - presenceData.state = `${ - document.querySelector("h5.font-semibold.text-lg.truncate") - ?.textContent ?? "Unknown" - }`; - } else if (document.location.pathname.includes("/templates/id/top")) { - presenceData.largeImageKey = Assets.Discordtemplates; - presenceData.details = "Viewing Top-10 templates"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Browsing..."; - presenceData.buttons = [ - { - label: "View Top-10", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/templates/id/")) { - presenceData.largeImageKey = Assets.Discordtemplates; - presenceData.details = "Viewing Template:"; - presenceData.state = `${ - document.querySelector("h1.font-semibold.truncate")?.textContent ?? - "Unknown" - }`; - presenceData.buttons = [ - { - label: "View Template", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/templates/users/")) { - presenceData.largeImageKey = Assets.Discordtemplates; - presenceData.details = "Viewing User:"; - presenceData.state = `${ - document.querySelector("h1.text-3xl.font-semibold")?.textContent ?? - "Unknown" - }`; - presenceData.buttons = [ - { - label: "View User", - url: document.location.href, - }, - ]; - } else if (document.location.pathname.includes("/templates/search/")) { - presenceData.largeImageKey = Assets.Discordtemplates; - presenceData.details = "Searching for:"; - presenceData.state = `${ - document.location.pathname.split("/templates/search/")[1] ?? - "Unknown" - }`; - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Searching..."; - } else if (document.location.pathname.includes("/templates/tags/")) { - presenceData.largeImageKey = Assets.Discordtemplates; - presenceData.details = "Searching by tag:"; - presenceData.state = `${ - document.location.pathname.split("/templates/tags/")[1] ?? "Unknown" - }`; - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Searching..."; - } else if (document.location.pathname.includes("/templates")) { - presenceData.largeImageKey = Assets.Discordtemplates; - presenceData.details = "Viewing home page"; - } - } - } + break + } + default: + if (document.location.pathname.includes('/emoji-list/tag/')) { + presenceData.details = `Looking at 📛 ${ + document + .querySelector('h2.EmoList_heading1__3KEr_') + ?.textContent + ?.replace('Emoji List', ' ') || 'N/A' + } emoji tag` + presenceData.state = `📖 Page ${ + document.querySelector('li.page-item.active')?.textContent + }` + presenceData.buttons = [ + { + label: 'View Emoji Tag', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/termsofservice')) { + presenceData.details = 'Viewing 👩‍⚖️ Terms of Service' + presenceData.buttons = [ + { + label: 'View Page', + url: document.location.href, + }, + ] + // discord.bio + } + else if (document.location.pathname.includes('/profiles')) { + presenceData.largeImageKey = Assets.Discordbio + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Browsing...' + presenceData.details = 'Browsing top bios' + presenceData.buttons = [ + { + label: 'View Bios', + url: document.location.href, + }, + ] + } + else if (document.location.pathname === '/bio/premium') { + presenceData.largeImageKey = Assets.Discordbio + presenceData.details = 'Viewing 💎 premium plans' + presenceData.buttons = [ + { + label: 'View Premium Plans', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/customise')) { + presenceData.largeImageKey = Assets.Discordbio + presenceData.details = 'Editing bio' + } + else if (document.location.pathname.includes('/settings')) { + presenceData.largeImageKey = Assets.Discordbio + presenceData.details = 'Viewing ⚙️ settings' + } + else if (document.location.pathname.includes('/p/')) { + presenceData.largeImageKey = Assets.Discordbio + const profileName = document.querySelector( + 'span.text-white.font-bold.text-2xl', + )?.textContent + presenceData.details = `Viewing ${ + profileName + ? profileName.endsWith('s') + ? `${`${profileName}'`}` + : `${`${profileName}'s`}` + : 'Unknown' + } bio` + presenceData.state = `${ + document.querySelector( + 'div.text-xs.uppercase.tracking-widest.font-bold.text-blue-300', + )?.textContent + ? '💎 Premium User' + : '🎟️ Normal User' + }` + presenceData.buttons = [ + { + label: 'View Bio', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/bio')) { + presenceData.largeImageKey = Assets.Discordbio + presenceData.details = 'Viewing home page' + // discord templates + } + else if (document.location.pathname.includes('/edit')) { + presenceData.largeImageKey = Assets.Discordtemplates + presenceData.details = 'Editing a template' + presenceData.buttons = [ + { + label: 'View Template', + url: document.location.href.split('/edit')[0], + }, + ] + } + else if (document.location.pathname.includes('/templates/id/new')) { + presenceData.largeImageKey = Assets.Discordtemplates + presenceData.details = 'Creating New Template:' + presenceData.state = `${ + document.querySelector('h5.font-semibold.text-lg.truncate') + ?.textContent ?? 'Unknown' + }` + } + else if (document.location.pathname.includes('/templates/id/top')) { + presenceData.largeImageKey = Assets.Discordtemplates + presenceData.details = 'Viewing Top-10 templates' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Browsing...' + presenceData.buttons = [ + { + label: 'View Top-10', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/templates/id/')) { + presenceData.largeImageKey = Assets.Discordtemplates + presenceData.details = 'Viewing Template:' + presenceData.state = `${ + document.querySelector('h1.font-semibold.truncate')?.textContent + ?? 'Unknown' + }` + presenceData.buttons = [ + { + label: 'View Template', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/templates/users/')) { + presenceData.largeImageKey = Assets.Discordtemplates + presenceData.details = 'Viewing User:' + presenceData.state = `${ + document.querySelector('h1.text-3xl.font-semibold')?.textContent + ?? 'Unknown' + }` + presenceData.buttons = [ + { + label: 'View User', + url: document.location.href, + }, + ] + } + else if (document.location.pathname.includes('/templates/search/')) { + presenceData.largeImageKey = Assets.Discordtemplates + presenceData.details = 'Searching for:' + presenceData.state = `${ + document.location.pathname.split('/templates/search/')[1] + ?? 'Unknown' + }` + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Searching...' + } + else if (document.location.pathname.includes('/templates/tags/')) { + presenceData.largeImageKey = Assets.Discordtemplates + presenceData.details = 'Searching by tag:' + presenceData.state = `${ + document.location.pathname.split('/templates/tags/')[1] ?? 'Unknown' + }` + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Searching...' + } + else if (document.location.pathname.includes('/templates')) { + presenceData.largeImageKey = Assets.Discordtemplates + presenceData.details = 'Viewing home page' + } + } + } - if (!showButtons) delete presenceData.buttons; - if (showTimestamp) presenceData.startTimestamp = browsingTimestamp; + if (!showButtons) + delete presenceData.buttons + if (showTimestamp) + presenceData.startTimestamp = browsingTimestamp - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Discovery/metadata.json b/websites/D/Discovery/metadata.json index 8dd6ac909f72..897655e282d7 100644 --- a/websites/D/Discovery/metadata.json +++ b/websites/D/Discovery/metadata.json @@ -1,59 +1,59 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "638080361179512853", - "name": "Dark_Ville#2756" - }, - "service": "Discovery", - "description": { - "en": "Watch HGTV, Food Network, TLC, ID and more plus exclusive originals, all in one place. Start your 7-day free trial today.", - "nl": "Welkom bij discovery, the home of real-life entertainment en sport. Abonneer nu en volg volledige seizoenen, bekijk programma’s alvast vooruit of kijk terug wat je hebt gemist." - }, - "url": [ - "discoveryplus.com", - "www.discoveryplus.com", - "go.discovery.com", - "www.go.discovery.com" - ], - "version": "1.0.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discovery/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discovery/assets/thumbnail.png", - "color": "#2175d9", - "category": "videos", - "tags": [ - "discoveryplus", - "discovery", - "video" - ], - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fas fa-user-secret", - "value": false - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true, - "if": { - "privacy": false - } - }, - { - "id": "covers", - "title": "Show Cover", - "icon": "fad fa-images", - "value": false, - "if": { - "privacy": false - } - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "638080361179512853", + "name": "Dark_Ville#2756" + }, + "service": "Discovery", + "description": { + "en": "Watch HGTV, Food Network, TLC, ID and more plus exclusive originals, all in one place. Start your 7-day free trial today.", + "nl": "Welkom bij discovery, the home of real-life entertainment en sport. Abonneer nu en volg volledige seizoenen, bekijk programma’s alvast vooruit of kijk terug wat je hebt gemist." + }, + "url": [ + "discoveryplus.com", + "www.discoveryplus.com", + "go.discovery.com", + "www.go.discovery.com" + ], + "version": "1.0.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Discovery/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Discovery/assets/thumbnail.png", + "color": "#2175d9", + "category": "videos", + "tags": [ + "discoveryplus", + "discovery", + "video" + ], + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fas fa-user-secret", + "value": false + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true, + "if": { + "privacy": false + } + }, + { + "id": "covers", + "title": "Show Cover", + "icon": "fad fa-images", + "value": false, + "if": { + "privacy": false + } + } + ] +} diff --git a/websites/D/Discovery/presence.ts b/websites/D/Discovery/presence.ts index 06a987af824d..cddccd0b4a80 100644 --- a/websites/D/Discovery/presence.ts +++ b/websites/D/Discovery/presence.ts @@ -1,350 +1,367 @@ const presence = new Presence({ - clientId: "1034382710589898882", - }), - browingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1034382710589898882', +}) +const browingTimestamp = Math.floor(Date.now() / 1000) async function getStrings() { - return presence.getStrings( - { - browse: "general.browsing", - buttonWatchVideo: "general.buttonWatchVideo", - paused: "general.paused", - play: "general.playing", - search: "general.searchFor", - viewCategory: "general.viewCategory", - viewHome: "general.viewHome", - viewShow: "general.viewShow", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + browse: 'general.browsing', + buttonWatchVideo: 'general.buttonWatchVideo', + paused: 'general.paused', + play: 'general.playing', + search: 'general.searchFor', + viewCategory: 'general.viewCategory', + viewHome: 'general.viewHome', + viewShow: 'general.viewShow', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } async function capitalizeFirstLetter(string: string) { - const stringTrimmed = string.trim(); - return stringTrimmed.charAt(0).toUpperCase() + stringTrimmed.slice(1); + const stringTrimmed = string.trim() + return stringTrimmed.charAt(0).toUpperCase() + stringTrimmed.slice(1) } const enum Assets { - Loading = "https://cdn.rcd.gg/PreMiD/websites/D/Discovery/assets/0.gif", - LogoDiscoveryPlus = "https://cdn.rcd.gg/PreMiD/websites/D/Discovery/assets/1.png", - LogoDiscovery = "https://cdn.rcd.gg/PreMiD/websites/D/Discovery/assets/logo.png", + Loading = 'https://cdn.rcd.gg/PreMiD/websites/D/Discovery/assets/0.gif', + LogoDiscoveryPlus = 'https://cdn.rcd.gg/PreMiD/websites/D/Discovery/assets/1.png', + LogoDiscovery = 'https://cdn.rcd.gg/PreMiD/websites/D/Discovery/assets/logo.png', } -let strings: Awaited>, - oldLang: string = null; +let strings: Awaited> +let oldLang: string | null = null -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.LogoDiscovery, - startTimestamp: browingTimestamp, - }, - video = document.querySelector("video"), - search = document.querySelector('input[type="text"]'), - { hostname, href, pathname } = document.location, - [newLang, privacy, buttons, covers] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("privacy"), - presence.getSetting("buttons"), - presence.getSetting("covers"), - ]), - hostnameReplaced = hostname.replace("www.", ""), - current = document.querySelector('[aria-current="true"]')?.textContent, - titleSplit: string | string[] = document - .querySelector('[property="og:title"]') - ?.getAttribute("content") - .toLowerCase() - ?.replace( - document - .querySelector('[aria-current="true"]') - ?.textContent?.toLowerCase() ?? "", - "" - ) - .split("|"), - titleSplit2 = []; - if (titleSplit) { - for (const element of titleSplit) - if (element !== " " && element !== " ") titleSplit2.push(element.trim()); - } - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.LogoDiscovery, + startTimestamp: browingTimestamp, + } + const video = document.querySelector('video') + const search = document.querySelector('input[type="text"]') + const { hostname, href, pathname } = document.location + const [newLang, privacy, buttons, covers] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('privacy'), + presence.getSetting('buttons'), + presence.getSetting('covers'), + ]) + const hostnameReplaced = hostname.replace('www.', '') + const current = document.querySelector('[aria-current="true"]')?.textContent + const titleSplit: string[] | undefined = document + .querySelector('[property="og:title"]') + ?.getAttribute('content') + ?.toLowerCase() + ?.replace( + document + .querySelector('[aria-current="true"]') + ?.textContent + ?.toLowerCase() ?? '', + '', + ) + .split('|') + const titleSplit2 = [] + if (titleSplit) { + for (const element of titleSplit) { + if (element !== ' ' && element !== ' ') + titleSplit2.push(element.trim()) + } + } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - if (privacy) { - presenceData.details = strings.browse; - presence.setActivity(presenceData); - return; - } - if (search?.value || pathname.includes("search")) { - presenceData.details = strings.search; - presenceData.state = search?.value || "Nothing"; - presenceData.smallImageKey = Assets.Search; - } else { - switch (hostnameReplaced) { - case "go.discovery.com": { - presenceData.largeImageKey = Assets.LogoDiscovery; - switch (pathname.split("/")[1]) { - case "": { - presenceData.details = strings.viewHome; - break; - } - case "my-list": { - presenceData.details = `Viewing ${ - document - .querySelector('li[class*="selected-"]') - ?.textContent?.trim() - .toLowerCase() ?? "" - }`; - break; - } - case "shows": { - presenceData.details = `Viewing all ${ - document - .querySelector('[class*="selected-"]') - ?.getAttribute("id") - .split("tab-")[1] - ?.replace("All", "") - .toLowerCase() ?? "" - } shows`; - presenceData.state = `Sorted by ${ - document - .querySelector('li[class*="selected-"]') - ?.textContent?.toLowerCase() ?? "" - }`; - presenceData.buttons = [ - { - label: "View Shows", - url: href, - }, - ]; - break; - } - case "show": { - presenceData.details = `${strings.viewShow} ${ - document.querySelector("title")?.textContent?.split("-")[0] - }`; - presenceData.state = document.querySelector( - '[aria-controls="season-dropdown"]' - )?.textContent; - presenceData.largeImageKey = - document - .querySelector('[class*="showLogo-"]') - ?.getAttribute("src") - .split("?")[0] ?? Assets.LogoDiscovery; - presenceData.buttons = [ - { - label: "View Show", - url: href, - }, - ]; - break; - } - case "video": { - delete presenceData.startTimestamp; - presenceData.details = document - .querySelector("title") - ?.textContent.split("-")[0]; - presenceData.state = document.querySelector( - '[class*="seasonEpisode"]' - )?.textContent; - presenceData.largeImageKey = document - .querySelector('[class*="RemoteSenderBackgroundContainer"]') - .querySelector("img") - ?.getAttribute("src"); - if (video && !isNaN(video.duration)) { - presenceData.smallImageKey = video.paused - ? Assets.Pause - : Assets.Play; - presenceData.smallImageText = video.paused - ? strings.paused - : strings.play; - presenceData.buttons = [ - { - label: strings.buttonWatchVideo, - url: href, - }, - ]; - if ( - document - .querySelector('[class*="PlayPauseButtonS"]') - ?.innerHTML.includes(" { - if (e.data.type === "pmd-receive-image-id") ({ imageId } = e.data); -}); -const script = document.createElement("script"); +let imageId: string | undefined +window.addEventListener('message', (e) => { + if (e.data.type === 'pmd-receive-image-id') + ({ imageId } = e.data as { imageId?: string }) +}) + +const script = document.createElement('script') script.textContent = ` setInterval(() => { - window.postMessage({ type: "pmd-receive-image-id", imageId: document.querySelector("disney-web-player")?.mediaPlayer?.mediaPlaybackCriteria?.metadata?.images_experience?.standard?.tile["1.00"]?.imageId }, "*"); + window.postMessage({ type: "pmd-receive-image-id", imageId: document.querySelector("disney-web-player")?.mediaPlayer?.mediaPlaybackCriteria?.metadata?.images_experience?.standard?.tile["1.00"]?.imageId }, "*"); }, 100); -`; -document.head.appendChild(script); +` +document.head.appendChild(script) const presence: Presence = new Presence({ - clientId: "630236276829716483", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '630236276829716483', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) async function getStrings() { - return presence.getStrings( - { - play: "general.playing", - pause: "general.paused", - browsing: "general.browsing", - watchingMovie: "general.watchingMovie", - watchingSeries: "general.watchingSeries", - watchEpisode: "general.buttonViewEpisode", - watchVideo: "general.buttonWatchVideo", - searchFor: "general.searchFor", - searchSomething: "general.searchSomething", - }, - await presence.getSetting("lang").catch(() => "en") - ); + return presence.getStrings( + { + play: 'general.playing', + pause: 'general.paused', + browsing: 'general.browsing', + watchingMovie: 'general.watchingMovie', + watchingSeries: 'general.watchingSeries', + watchEpisode: 'general.buttonViewEpisode', + watchVideo: 'general.buttonWatchVideo', + searchFor: 'general.searchFor', + searchSomething: 'general.searchSomething', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) } -let strings: Awaited>, - oldLang: string = null, - title: string, - subtitle: string, - imageId: string; +let strings: Awaited> +let oldLang: string | null = null -presence.on("UpdateData", async () => { - const [newLang, privacy, time, buttons] = await Promise.all([ - presence.getSetting("lang").catch(() => "en"), - presence.getSetting("privacy"), - presence.getSetting("time"), - presence.getSetting("buttons"), - ]), - { hostname, href, pathname } = document.location, - presenceData: PresenceData & { - partySize?: number; - partyMax?: number; - } = { startTimestamp: browsingTimestamp, type: ActivityType.Watching }; +presence.on('UpdateData', async () => { + const [newLang, privacy, time, buttons] = await Promise.all([ + presence.getSetting('lang').catch(() => 'en'), + presence.getSetting('privacy'), + presence.getSetting('time'), + presence.getSetting('buttons'), + ]) + const { hostname, href, pathname } = document.location + const presenceData: PresenceData & { + partySize?: number + partyMax?: number + } = { startTimestamp: browsingTimestamp, type: ActivityType.Watching } - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } - switch (true) { - case /(www\.)?disneyplus\.com/.test(hostname): { - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Disney+/assets/logo.png"; - switch (true) { - case pathname.includes("play"): { - const video = - document.querySelector("video#hivePlayer"); + switch (true) { + case /(?:www\.)?disneyplus\.com/.test(hostname): { + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Disney+/assets/logo.png' + switch (true) { + case pathname.includes('play'): { + const video = document.querySelector('video#hivePlayer') - //* Wait for elements to load to prevent setactivity spam - if (!imageId || !video) return; + //* Wait for elements to load to prevent setactivity spam + if (!imageId || !video) + return - presenceData.largeImageKey = `https://disney.images.edge.bamgrid.com/ripcut-delivery/v2/variant/disney/${imageId}/compose?format=png&width=512`; + presenceData.largeImageKey = `https://disney.images.edge.bamgrid.com/ripcut-delivery/v2/variant/disney/${imageId}/compose?format=png&width=512` - if (!privacy) { - if (presenceData.startTimestamp) delete presenceData.startTimestamp; - presenceData.details = document.querySelector( - ".title-field.body-copy" - )?.textContent; + if (!privacy) { + if (presenceData.startTimestamp) + delete presenceData.startTimestamp + presenceData.details = document.querySelector( + '.title-field.body-copy', + )?.textContent - const { paused } = video; + const { paused } = video - if (!paused) { - const sliderEl = document.querySelector( - ".progress-bar .slider-container" - ), - timestamps = presence.getTimestamps( - parseInt(sliderEl.getAttribute("aria-valuenow")), - parseInt(sliderEl.getAttribute("aria-valuemax")) - ); - presenceData.startTimestamp = timestamps[0]; - presenceData.endTimestamp = timestamps[1]; - } else { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = strings.pause; - } + if (!paused) { + const sliderEl = document.querySelector( + '.progress-bar .slider-container', + ) + const timestamps = presence.getTimestamps( + Number.parseInt(sliderEl?.getAttribute('aria-valuenow') ?? '0'), + Number.parseInt(sliderEl?.getAttribute('aria-valuemax') ?? '0'), + ) + presenceData.startTimestamp = timestamps[0] + presenceData.endTimestamp = timestamps[1] + } + else { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = strings.pause + } - const parts = document - .querySelector(".subtitle-field") - ?.textContent.match(/S(\d+):E(\d+) /); - if (parts?.length > 2) - presenceData.largeImageText = `Season ${parts[1]}, Episode ${parts[2]}`; + const parts = document + .querySelector('.subtitle-field') + ?.textContent + ?.match(/S(\d+):E(\d+) /) + if (parts && parts.length > 2) + presenceData.largeImageText = `Season ${parts[1]}, Episode ${parts[2]}` - presenceData.state = document - .querySelector(".subtitle-field") - ?.textContent.replace(/S(\d+):E(\d+) /, ""); + presenceData.state = document + .querySelector('.subtitle-field') + ?.textContent + ?.replace(/S(\d+):E(\d+) /, '') - presenceData.buttons = [ - { - label: parts?.length > 2 ? "Watch Episode" : "Watch Movie", - url: href, - }, - ]; - } else presenceData.details = "Watching content"; - break; - } - case pathname.includes("entity"): { - if (document.querySelector("#episodes_control") !== null) { - presenceData.details = privacy - ? "Viewing a series" - : "Viewing series"; - presenceData.buttons = [ - { - label: "View Series", - url: href, - }, - ]; - } else { - presenceData.details = privacy - ? "Viewing a movie" - : "Viewing movie"; - presenceData.buttons = [ - { - label: "View Movie", - url: href, - }, - ]; - } - const titleImg = document.querySelector( - '[data-testid="details-title-treatment"] img, .explore-ui-main-content-container img' - ); - if (titleImg) presenceData.state = titleImg.getAttribute("alt"); - else if (document.title.includes("|")) - presenceData.state = document.title.split("|")[0].trim(); - else presenceData.state = document.title; - break; - } - case pathname.includes("search"): { - const search = document.querySelector( - 'input[type="search"]' - ); - if (search?.value) { - presenceData.details = privacy - ? strings.searchSomething - : strings.searchFor; - presenceData.state = search.value; - presenceData.smallImageKey = Assets.Search; - } else presenceData.details = strings.browsing; - break; - } - case pathname.includes("home"): { - presenceData.details = strings.browsing; - break; - } - case pathname.includes("watchlist"): { - presenceData.details = privacy - ? strings.browsing - : "Browsing their watchlist"; + presenceData.buttons = [ + { + label: parts && parts.length > 2 ? 'Watch Episode' : 'Watch Movie', + url: href, + }, + ] + } + else { + presenceData.details = 'Watching content' + } + break + } + case pathname.includes('entity'): { + if (document.querySelector('#episodes_control') !== null) { + presenceData.details = privacy + ? 'Viewing a series' + : 'Viewing series' + presenceData.buttons = [ + { + label: 'View Series', + url: href, + }, + ] + } + else { + presenceData.details = privacy + ? 'Viewing a movie' + : 'Viewing movie' + presenceData.buttons = [ + { + label: 'View Movie', + url: href, + }, + ] + } + const titleImg = document.querySelector( + '[data-testid="details-title-treatment"] img, .explore-ui-main-content-container img', + ) + if (titleImg) + presenceData.state = titleImg.getAttribute('alt') + else if (document.title.includes('|')) + presenceData.state = document.title.split('|')[0].trim() + else presenceData.state = document.title + break + } + case pathname.includes('search'): { + const search = document.querySelector( + 'input[type="search"]', + ) + if (search?.value) { + presenceData.details = privacy + ? strings.searchSomething + : strings.searchFor + presenceData.state = search.value + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = strings.browsing + } + break + } + case pathname.includes('home'): { + presenceData.details = strings.browsing + break + } + case pathname.includes('watchlist'): { + presenceData.details = privacy + ? strings.browsing + : 'Browsing their watchlist' - break; - } - case pathname.includes("series"): { - presenceData.details = privacy ? strings.browsing : "Browsing series"; - const sortingChoice = document - .querySelector( - '[id="explore-ui-main-content-container"] div div [aria-selected="true"]' - ) - ?.textContent?.toLowerCase(); - if (sortingChoice !== null) - presenceData.state = `Sorted by ${sortingChoice}`; - break; - } - case pathname.includes("movies"): { - presenceData.details = privacy ? strings.browsing : "Browsing movies"; - const sortingChoice = document - .querySelector( - '[id="explore-ui-main-content-container"] div div [aria-selected="true"]' - ) - ?.textContent?.toLowerCase(); - if (sortingChoice !== null) - presenceData.state = `Sorted by ${sortingChoice}`; - break; - } - case pathname.includes("page"): { - presenceData.details = privacy - ? "Browsing videos" - : `Viewing ${document.title - ?.match( - /(pixar)|(marvel)|(star wars)|(national geographic)|(star)|(disney)/im - )[0] - ?.toLowerCase()} content`; - break; - } - default: { - if (!privacy) { - if (document.title.includes("|")) { - presenceData.details = `Page: ${document.title - .split("|")[0] - .trim()}`; - } else presenceData.details = `Page: ${document.title}`; - } else presenceData.details = "No information"; - break; - } - } - break; - } - case /(www\.)?hotstar\.com/.test(hostname): { - const video = document.querySelector("video"); - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Disney+/assets/0.png"; + break + } + case pathname.includes('series'): { + presenceData.details = privacy ? strings.browsing : 'Browsing series' + const sortingChoice = document + .querySelector( + '[id="explore-ui-main-content-container"] div div [aria-selected="true"]', + ) + ?.textContent + ?.toLowerCase() + if (sortingChoice !== null) + presenceData.state = `Sorted by ${sortingChoice}` + break + } + case pathname.includes('movies'): { + presenceData.details = privacy ? strings.browsing : 'Browsing movies' + const sortingChoice = document + .querySelector( + '[id="explore-ui-main-content-container"] div div [aria-selected="true"]', + ) + ?.textContent + ?.toLowerCase() + if (sortingChoice !== null) + presenceData.state = `Sorted by ${sortingChoice}` + break + } + case pathname.includes('page'): { + presenceData.details = privacy + ? 'Browsing videos' + : `Viewing ${document.title + ?.match( + /(pixar)|(marvel)|(star wars)|(national geographic)|(star)|(disney)/i, + )?.[0] + ?.toLowerCase()} content` + break + } + default: { + if (!privacy) { + if (document.title.includes('|')) { + presenceData.details = `Page: ${document.title + .split('|')[0] + .trim()}` + } + else { + presenceData.details = `Page: ${document.title}` + } + } + else { + presenceData.details = 'No information' + } + break + } + } + break + } + case /(?:www\.)?hotstar\.com/.test(hostname): { + const video = document.querySelector('video') + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Disney+/assets/0.png' - if (video && !isNaN(video.duration)) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); + if (video && !Number.isNaN(video.duration)) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) - title = document.querySelector( - "h1.ON_IMAGE.BUTTON1_MEDIUM" - )?.textContent; - subtitle = document.querySelector( - "p.ON_IMAGE_ALT2.BUTTON3_MEDIUM" - )?.textContent; + const title = document.querySelector( + 'h1.ON_IMAGE.BUTTON1_MEDIUM', + )?.textContent + const subtitle = document.querySelector( + 'p.ON_IMAGE_ALT2.BUTTON3_MEDIUM', + )?.textContent - if (!title) presence.error("Unable to get the title"); + if (!title) + presence.error('Unable to get the title') - if (privacy) { - presenceData.state = subtitle - ? strings.watchingSeries - : strings.watchingMovie; - } else { - presenceData.details = title; - presenceData.state = subtitle || "Movie"; - } - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? strings.pause - : strings.play; + if (privacy) { + presenceData.state = subtitle + ? strings.watchingSeries + : strings.watchingMovie + } + else { + presenceData.details = title + presenceData.state = subtitle || 'Movie' + } + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? strings.pause + : strings.play - if (video.paused || !time) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } + if (video.paused || !time) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } - if (!privacy && buttons) { - presenceData.buttons = [ - { - label: strings.watchVideo, - url: href, - }, - ]; - } + if (!privacy && buttons) { + presenceData.buttons = [ + { + label: strings.watchVideo, + url: href, + }, + ] + } - if (title) presence.setActivity(presenceData, !video.paused); - } - break; - } - } - if ((presenceData.startTimestamp || presenceData.endTimestamp) && !time) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - if (privacy && presenceData.state) delete presenceData.state; - if ((!buttons || privacy) && presenceData.buttons) - delete presenceData.buttons; + if (title) + presence.setActivity(presenceData, !video.paused) + } + break + } + } + if ((presenceData.startTimestamp || presenceData.endTimestamp) && !time) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + if (privacy && presenceData.state) + delete presenceData.state + if ((!buttons || privacy) && presenceData.buttons) + delete presenceData.buttons - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Distrokid/metadata.json b/websites/D/Distrokid/metadata.json index de65b004b290..a823b427ddff 100644 --- a/websites/D/Distrokid/metadata.json +++ b/websites/D/Distrokid/metadata.json @@ -1,21 +1,21 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "998540395455717376", - "name": "veraont" - }, - "service": "DistroKid", - "description": { - "en": "DistroKid" - }, - "url": "distrokid.com", - "version": "1.0.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Distrokid/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Distrokid/assets/thumbnail.png", - "color": "#FFFF00", - "category": "music", - "tags": [ - "distrokid" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "998540395455717376", + "name": "veraont" + }, + "service": "DistroKid", + "description": { + "en": "DistroKid" + }, + "url": "distrokid.com", + "version": "1.0.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Distrokid/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Distrokid/assets/thumbnail.png", + "color": "#FFFF00", + "category": "music", + "tags": [ + "distrokid" + ] +} diff --git a/websites/D/Distrokid/presence.ts b/websites/D/Distrokid/presence.ts index 622f822776c7..6a23db39d506 100644 --- a/websites/D/Distrokid/presence.ts +++ b/websites/D/Distrokid/presence.ts @@ -1,51 +1,49 @@ const presence = new Presence({ - clientId: "1261851627003056139", - }), - pages: { [key: string]: [string, number] } = { - "/mymusic/": ["Uploaded tracks", 0], - "/account/": ["Account Details", 0], - "/stats/": ["Daily Streaming Stats", 0], - "/bank/": ["Bank Details", 0], - "/new/": ["Uploading a new track", 1], - "/dashboard/album/": ["Browsing a track", 2], - "/dashboard/album/edit/": ["Editing a track", 2], - }, - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1261851627003056139', +}) +const pages: { [key: string]: [string, number] } = { + '/mymusic/': ['Uploaded tracks', 0], + '/account/': ['Account Details', 0], + '/stats/': ['Daily Streaming Stats', 0], + '/bank/': ['Bank Details', 0], + '/new/': ['Uploading a new track', 1], + '/dashboard/album/': ['Browsing a track', 2], + '/dashboard/album/edit/': ['Editing a track', 2], +} +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Distrokid/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - { pathname } = document.location; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Distrokid/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const { pathname } = document.location - switch (true) { - case pathname === "/": { - presenceData.details = "Viewing the homepage"; - break; - } - case pathname.includes("/help"): { - presenceData.details = "Viewing support pages"; - break; - } - case !!pages[pathname]: - case !!pages[pathname.slice(0, -1)]: { - presenceData.details = "Browsing on page"; - presenceData.state = - pages[pathname]?.[0] ?? pages[pathname.slice(0, -1)]?.[0]; - break; - } - default: { - presenceData.details = - document.querySelector(".albumTitleBig > span:nth-child(1)") - ?.textContent ?? - document.querySelector(".songTitlePreview")?.textContent ?? - ""; - if (presenceData.details) presenceData.state = "Browsing a page:"; - else presenceData.details = "Browsing..."; - } - } + switch (true) { + case pathname === '/': { + presenceData.details = 'Viewing the homepage' + break + } + case pathname.includes('/help'): { + presenceData.details = 'Viewing support pages' + break + } + case !!pages[pathname]: + case !!pages[pathname.slice(0, -1)]: { + presenceData.details = 'Browsing on page' + presenceData.state = pages[pathname]?.[0] ?? pages[pathname.slice(0, -1)]?.[0] + break + } + default: { + presenceData.details = document.querySelector('.albumTitleBig > span:nth-child(1)') + ?.textContent + ?? document.querySelector('.songTitlePreview')?.textContent + ?? '' + if (presenceData.details) + presenceData.state = 'Browsing a page:' + else presenceData.details = 'Browsing...' + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/D/DiziBOX/iframe.ts b/websites/D/DiziBOX/iframe.ts index ef24996aa9d8..b06a41e76d93 100644 --- a/websites/D/DiziBOX/iframe.ts +++ b/websites/D/DiziBOX/iframe.ts @@ -1,18 +1,19 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -setInterval(function () { - const video = document.querySelector("video") as HTMLVideoElement; +setInterval(() => { + const video = document.querySelector('video') as HTMLVideoElement - if (video) { - iframe.send({ - error: false, - currentTime: video.currentTime, - duration: video.duration, - paused: video.paused, - }); - } else { - iframe.send({ - error: true, - }); - } -}, 100); + if (video) { + iframe.send({ + error: false, + currentTime: video.currentTime, + duration: video.duration, + paused: video.paused, + }) + } + else { + iframe.send({ + error: true, + }) + } +}, 100) diff --git a/websites/D/DiziBOX/metadata.json b/websites/D/DiziBOX/metadata.json index 69470c7562db..87d13cf8d341 100644 --- a/websites/D/DiziBOX/metadata.json +++ b/websites/D/DiziBOX/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "EGGSY", - "id": "162969778699501569" - }, - "service": "DiziBOX", - "description": { - "en": "DiziBOX is one of the biggest Turkish foreign TV show providers on internet.", - "tr": "DiziBOX, son çıkan, güncel ve bir çok yabancı diziyi izleyebileceğiniz bir yabancı dizi sitesidir.", - "nl": "DiziBOX is een van de grootste aanbieders van Turkse buitenlandse TV-programma's op internet." - }, - "url": [ - "www.dizibox.tv", - "diziboxx.com" - ], - "version": "1.1.31", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/thumbnail.png", - "color": "#212426", - "category": "videos", - "tags": [ - "video", - "tvshows", - "turkish" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "EGGSY", + "id": "162969778699501569" + }, + "service": "DiziBOX", + "description": { + "en": "DiziBOX is one of the biggest Turkish foreign TV show providers on internet.", + "tr": "DiziBOX, son çıkan, güncel ve bir çok yabancı diziyi izleyebileceğiniz bir yabancı dizi sitesidir.", + "nl": "DiziBOX is een van de grootste aanbieders van Turkse buitenlandse TV-programma's op internet." + }, + "url": [ + "www.dizibox.tv", + "diziboxx.com" + ], + "version": "1.1.31", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/thumbnail.png", + "color": "#212426", + "category": "videos", + "tags": [ + "video", + "tvshows", + "turkish" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git a/websites/D/DiziBOX/presence.ts b/websites/D/DiziBOX/presence.ts index 6d2f6ed701b2..aadaa3f28f37 100644 --- a/websites/D/DiziBOX/presence.ts +++ b/websites/D/DiziBOX/presence.ts @@ -1,176 +1,173 @@ const presence = new Presence({ - clientId: "643788489871196161", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }), - pages: { [k: string]: string } = { - "/": "Ana Sayfa", - "/arsiv": "Dizi Arşivi", - "/diziler": "Dizi Arşivi", - "/dizi-takvimi": "Dizi Takvimi", - "/iletisim": "İletişim", - "/efsane-diziler": "Efsane Diziler", - "/tum-bolumler": "Tüm Bölümler", - "/favorilerim": "Favorilerim", - "/izlediklerim": "İzlediklerim", - "/izleyeceklerim": "İzleyeceklerim", - "/yorumlarim": "Yorumlarım", - "/hesap-ayarlari": "Hesap Ayarları", - }, - video: { - dataAvailable?: boolean; - currentTime?: number; - duration?: number; - paused?: boolean; - } = {}; + clientId: '643788489871196161', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) +const pages: { [k: string]: string } = { + '/': 'Ana Sayfa', + '/arsiv': 'Dizi Arşivi', + '/diziler': 'Dizi Arşivi', + '/dizi-takvimi': 'Dizi Takvimi', + '/iletisim': 'İletişim', + '/efsane-diziler': 'Efsane Diziler', + '/tum-bolumler': 'Tüm Bölümler', + '/favorilerim': 'Favorilerim', + '/izlediklerim': 'İzlediklerim', + '/izleyeceklerim': 'İzleyeceklerim', + '/yorumlarim': 'Yorumlarım', + '/hesap-ayarlari': 'Hesap Ayarları', +} +const video: { + dataAvailable?: boolean + currentTime?: number + duration?: number + paused?: boolean +} = {} presence.on( - "iFrameData", - (data: { - error?: boolean; - currentTime: number; - duration: number; - paused: boolean; - }) => { - if (!data.error) { - video.dataAvailable = true; - video.currentTime = data.currentTime; - video.duration = data.duration; - video.paused = data.paused; - } - } -); + 'iFrameData', + (inc: unknown) => { + const data = inc as { + error?: boolean + currentTime: number + duration: number + paused: boolean + } + if (!data.error) { + video.dataAvailable = true + video.currentTime = data.currentTime + video.duration = data.duration + video.paused = data.paused + } + }, +) -presence.on("UpdateData", async () => { - const page = document.location.pathname, - isVideoData = Object.keys(video).length > 0 ? true : false, - _video = document.querySelector("video"); +presence.on('UpdateData', async () => { + const page = document.location.pathname + const isVideoData = Object.keys(video).length > 0 + const _video = document.querySelector('video') - if (!_video && !isVideoData) { - if ( - (page.includes("/diziler/") && - document.location.pathname !== "/diziler/") || - (page.includes("/diziler") && document.location.pathname !== "/diziler") - ) { - const showName = document.querySelector( - "#single-diziler > div.tv-overview.bg-dark > div.title-terms > h1 > a" - ); + if (!_video && !isVideoData) { + if ( + (page.includes('/diziler/') + && document.location.pathname !== '/diziler/') + || (page.includes('/diziler') && document.location.pathname !== '/diziler') + ) { + const showName = document.querySelector( + '#single-diziler > div.tv-overview.bg-dark > div.title-terms > h1 > a', + ) - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png", - details: "Bir diziye göz atıyor:", - state: - showName && showName.textContent !== "" - ? showName.textContent - : "Belirsiz", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (document.location.search.includes("?s=")) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png", - details: "Bir dizi arıyor:", - state: - document.querySelector( - "#search > div.title > h1 > span.text-muted" - ) && - document.querySelector("#search > div.title > h1 > span.text-muted") - .textContent - ? document - .querySelector("#search > div.title > h1 > span.text-muted") - .textContent.replace("(", "") - .replace(")", "") - : null || "Belirsiz", - smallImageKey: Assets.Search, - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (page.includes("/author/")) { - const user = document.querySelector( - "#main-wrapper > div.content-wrapper > address > div.user-summary > strong" - ); + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png', + details: 'Bir diziye göz atıyor:', + state: showName && showName.textContent !== '' + ? showName.textContent + : 'Belirsiz', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (document.location.search.includes('?s=')) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png', + details: 'Bir dizi arıyor:', + state: document.querySelector( + '#search > div.title > h1 > span.text-muted', + ) + && document.querySelector('#search > div.title > h1 > span.text-muted') + ?.textContent + ? document + .querySelector('#search > div.title > h1 > span.text-muted') + ?.textContent + ?.replace('(', '') + .replace(')', '') + : 'Belirsiz', + smallImageKey: Assets.Search, + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (page.includes('/author/')) { + const user = document.querySelector( + '#main-wrapper > div.content-wrapper > address > div.user-summary > strong', + ) - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png", - details: "Bir üyenin profiline bakıyor:", - state: user && user.textContent ? user.textContent : "Belirsiz", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (pages[page] || pages[page.slice(0, -1)]) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/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 if (_video && _video.currentTime) { - const title = document.querySelector( - "#main-wrapper > div.content-wrapper > div.title > h1 > span.tv-title-archive > span" - ), - episode = document.querySelector( - "#main-wrapper > div.content-wrapper > div.title > h1 > span.tv-title-episode" - ), - timestamps = presence.getTimestamps( - Math.floor(_video.currentTime), - Math.floor(_video.duration) - ), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png", - details: title && title.textContent ? title.textContent : "Belirsiz", - state: - episode && episode.textContent ? episode.textContent : "Belirsiz", - smallImageKey: _video.paused ? Assets.Pause : Assets.Play, - smallImageText: _video.paused - ? (await strings).pause - : (await strings).play, - }; + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png', + details: 'Bir üyenin profiline bakıyor:', + state: user && user.textContent ? user.textContent : 'Belirsiz', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (pages[page] || pages[page.slice(0, -1)]) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/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 if (_video && _video.currentTime) { + const title = document.querySelector( + '#main-wrapper > div.content-wrapper > div.title > h1 > span.tv-title-archive > span', + ) + const episode = document.querySelector( + '#main-wrapper > div.content-wrapper > div.title > h1 > span.tv-title-episode', + ) + const timestamps = presence.getTimestamps( + Math.floor(_video.currentTime), + Math.floor(_video.duration), + ) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png', + details: title && title.textContent ? title.textContent : 'Belirsiz', + state: episode && episode.textContent ? episode.textContent : 'Belirsiz', + 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); - } else if (isVideoData && video && video.currentTime) { - const title = document.querySelector( - "#main-wrapper > div.content-wrapper > div.title > h1 > span.tv-title-archive > span" - ), - episode = document.querySelector( - "#main-wrapper > div.content-wrapper > div.title > h1 > span.tv-title-episode" - ), - timestamps = presence.getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png", - details: title && title.textContent ? title.textContent : "Belirsiz", - state: - episode && episode.textContent ? episode.textContent : "Belirsiz", - smallImageKey: video.paused ? Assets.Pause : Assets.Play, - smallImageText: video.paused - ? (await strings).pause - : (await strings).play, - }; + presence.setActivity(presenceData) + } + else if (isVideoData && video && video.currentTime) { + const title = document.querySelector( + '#main-wrapper > div.content-wrapper > div.title > h1 > span.tv-title-archive > span', + ) + const episode = document.querySelector( + '#main-wrapper > div.content-wrapper > div.title > h1 > span.tv-title-episode', + ) + const timestamps = presence.getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration ?? 0), + ) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DiziBOX/assets/logo.png', + details: title && title.textContent ? title.textContent : 'Belirsiz', + state: episode && episode.textContent ? episode.textContent : 'Belirsiz', + 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/D/Dizilla/iframe.ts b/websites/D/Dizilla/iframe.ts index 16e44406c9d3..6fb836172537 100644 --- a/websites/D/Dizilla/iframe.ts +++ b/websites/D/Dizilla/iframe.ts @@ -1,13 +1,13 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", () => { - const video: HTMLVideoElement = document.querySelector("video.jw-video"); +iframe.on('UpdateData', () => { + const video = document.querySelector('video.jw-video') - if (video && !isNaN(video.duration) && !isNaN(video.currentTime)) { - return iframe.send({ - duration: video.duration, - currentTime: video.currentTime, - paused: video.paused, - }); - } -}); + if (video && !Number.isNaN(video.duration) && !Number.isNaN(video.currentTime)) { + return iframe.send({ + duration: video.duration, + currentTime: video.currentTime, + paused: video.paused, + }) + } +}) diff --git a/websites/D/Dizilla/metadata.json b/websites/D/Dizilla/metadata.json index e481f8bae6db..35c364dcf771 100644 --- a/websites/D/Dizilla/metadata.json +++ b/websites/D/Dizilla/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "EGGSY", - "id": "162969778699501569" - }, - "service": "Dizilla", - "description": { - "en": "Dizilla is one of the most beautiful and populer Turkish TV series website.", - "tr": "Dizilla, Türkiye'de hizmet veren yerel bir dizi yayın platformudur.", - "nl": "Dizilla is één van de mooiste en populairste Turkse TV series website." - }, - "url": "dizilla4.com", - "regExp": "(dizilla[0-9][.][a-z]{3})", - "version": "1.1.15", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dizilla/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dizilla/assets/thumbnail.png", - "color": "#d32028", - "category": "videos", - "tags": [ - "dizilla", - "video", - "tv-series", - "turkish" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "EGGSY", + "id": "162969778699501569" + }, + "service": "Dizilla", + "description": { + "en": "Dizilla is one of the most beautiful and populer Turkish TV series website.", + "tr": "Dizilla, Türkiye'de hizmet veren yerel bir dizi yayın platformudur.", + "nl": "Dizilla is één van de mooiste en populairste Turkse TV series website." + }, + "url": "dizilla4.com", + "regExp": "(dizilla[0-9][.][a-z]{3})", + "version": "1.1.15", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dizilla/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dizilla/assets/thumbnail.png", + "color": "#d32028", + "category": "videos", + "tags": [ + "dizilla", + "video", + "tv-series", + "turkish" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git a/websites/D/Dizilla/presence.ts b/websites/D/Dizilla/presence.ts index 2ce0911f34d0..3b0d980674ad 100644 --- a/websites/D/Dizilla/presence.ts +++ b/websites/D/Dizilla/presence.ts @@ -1,124 +1,126 @@ const presence = new Presence({ - clientId: "712838005165129728", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }), - pages: { [k: string]: string } = { - "/": "Ana Sayfa", - "/giris-yap": "Giriş Yap", - "/kayit-ol": "Kayıt Ol", - "/favorilerim": "Favorilerim", - "/favori-oyuncularim": "Favori Oyuncularım", - "/izleyeceklerim": "İzleyeceklerim", - "/izlediklerim": "İzlediklerim", - "/profilim": "Profilim", - "/duyurular": "Duyurular", - "/altyazili-bolumler": "Altyazılı Bölümler", - "/turkce-dublaj-bolumler": "Türkçe Dublajlı Bölümler", - "/trend": "Trendler", - "/imdb-top-100": "IMDb Top 100", - "/kanallar": "Kanallar", - "/dizi-onerileri": "Dizi Önerileri", - "/iletisim": "İletişim", - }; + clientId: '712838005165129728', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) +const pages: { [k: string]: string } = { + '/': 'Ana Sayfa', + '/giris-yap': 'Giriş Yap', + '/kayit-ol': 'Kayıt Ol', + '/favorilerim': 'Favorilerim', + '/favori-oyuncularim': 'Favori Oyuncularım', + '/izleyeceklerim': 'İzleyeceklerim', + '/izlediklerim': 'İzlediklerim', + '/profilim': 'Profilim', + '/duyurular': 'Duyurular', + '/altyazili-bolumler': 'Altyazılı Bölümler', + '/turkce-dublaj-bolumler': 'Türkçe Dublajlı Bölümler', + '/trend': 'Trendler', + '/imdb-top-100': 'IMDb Top 100', + '/kanallar': 'Kanallar', + '/dizi-onerileri': 'Dizi Önerileri', + '/iletisim': 'İletişim', +} interface IframeData { - duration: number; - currentTime: number; - paused: boolean; + duration: number + currentTime: number + paused: boolean } -let video: IframeData; -presence.on("iFrameData", (data: IframeData) => { - video = data; -}); +let video: IframeData +presence.on('iFrameData', (data: unknown) => { + video = data as IframeData +}) -presence.on("UpdateData", async () => { - const path: string = document.location.pathname, - showName = document.querySelector( - "div.content > div > div.top-sticky-content h1 > a" - )?.firstChild, - episode: HTMLSpanElement = document.querySelector( - "div.content > div > div.top-sticky-content span.text-white.text-small" - ), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Dizilla/assets/logo.png", - startTimestamp: Math.floor(Date.now() / 1000), - }; +presence.on('UpdateData', async () => { + const path: string = document.location.pathname + const showName = document.querySelector( + 'div.content > div > div.top-sticky-content h1 > a', + )?.firstChild + const episode = document.querySelector( + 'div.content > div > div.top-sticky-content span.text-white.text-small', + ) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Dizilla/assets/logo.png', + startTimestamp: Math.floor(Date.now() / 1000), + } - if (path.startsWith("/dizi/")) { - presenceData.details = "Bir diziye göz atıyor:"; - presenceData.state = - document.querySelector( - "div.content > div > div.top-sticky-content div > h1 > a" - )?.textContent || "Bilinmeyen Dizi"; - } else if (path.startsWith("/oyuncular/")) { - presenceData.details = "Bir oyuncuya göz atıyor:"; - presenceData.state = - document.querySelector( - "div.content > div > div.top-sticky-content div > span" - )?.textContent || "Bilinmeyen Oyuncu"; - } else if (path.startsWith("/dizi-turu/")) { - presenceData.details = "Bir türe göz atıyor:"; - presenceData.state = - document.querySelector( - "div.content > div > div.top-sticky-content div > h1" - )?.textContent || "Bilinmeyen Tür"; - } else if (path.startsWith("/kanal/")) { - presenceData.details = "Bir kanala göz atıyor:"; - presenceData.state = - document.title.slice(0, document.title.indexOf("arşivleri")) || - "Bilinmeyen Kanal"; - } else if (path.startsWith("/arsiv/")) { - const query = new URL(document.location.href).searchParams.get("q"); + if (path.startsWith('/dizi/')) { + presenceData.details = 'Bir diziye göz atıyor:' + presenceData.state = document.querySelector( + 'div.content > div > div.top-sticky-content div > h1 > a', + )?.textContent || 'Bilinmeyen Dizi' + } + else if (path.startsWith('/oyuncular/')) { + presenceData.details = 'Bir oyuncuya göz atıyor:' + presenceData.state = document.querySelector( + 'div.content > div > div.top-sticky-content div > span', + )?.textContent || 'Bilinmeyen Oyuncu' + } + else if (path.startsWith('/dizi-turu/')) { + presenceData.details = 'Bir türe göz atıyor:' + presenceData.state = document.querySelector( + 'div.content > div > div.top-sticky-content div > h1', + )?.textContent || 'Bilinmeyen Tür' + } + else if (path.startsWith('/kanal/')) { + presenceData.details = 'Bir kanala göz atıyor:' + presenceData.state = document.title.slice(0, document.title.indexOf('arşivleri')) + || 'Bilinmeyen Kanal' + } + else if (path.startsWith('/arsiv/')) { + const query = new URL(document.location.href).searchParams.get('q') - if (query) { - presenceData.details = "Bir şey arıyor:"; - presenceData.state = - query[0].toUpperCase() + query.slice(1).toLowerCase(); - presenceData.smallImageKey = Assets.Search; - } else { - presenceData.details = "Bir sayfaya göz atıyor:"; - presenceData.state = "Arşiv"; - } - } else if (pages[path] || pages[path.slice(0, -1)]) { - presenceData.details = "Bir sayfaya göz atıyor:"; - presenceData.state = - pages[path] || pages[path.slice(0, -1)] || "Bilinmeyen Sayfa"; - } else if ( - !isNaN(video?.duration) && - showName?.textContent && - episode?.textContent - ) { - const [, endTimestamp] = presence.getTimestamps( - Math.floor(video?.currentTime), - Math.floor(video?.duration) - ); + if (query) { + presenceData.details = 'Bir şey arıyor:' + presenceData.state = query[0].toUpperCase() + query.slice(1).toLowerCase() + presenceData.smallImageKey = Assets.Search + } + else { + presenceData.details = 'Bir sayfaya göz atıyor:' + presenceData.state = 'Arşiv' + } + } + else if (pages[path] || pages[path.slice(0, -1)]) { + presenceData.details = 'Bir sayfaya göz atıyor:' + presenceData.state = pages[path] || pages[path.slice(0, -1)] || 'Bilinmeyen Sayfa' + } + else if ( + !Number.isNaN(video?.duration) + && showName?.textContent + && episode?.textContent + ) { + const [, endTimestamp] = presence.getTimestamps( + Math.floor(video?.currentTime), + Math.floor(video?.duration), + ) - presenceData.details = showName?.textContent || "Bilinmeyen Dizi"; - presenceData.state = episode?.textContent || "Bilinmeyen Bölüm"; + presenceData.details = showName?.textContent || 'Bilinmeyen Dizi' + presenceData.state = episode?.textContent || 'Bilinmeyen Bölüm' - presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video?.paused - ? (await strings).pause - : (await strings).play; + presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video?.paused + ? (await strings).pause + : (await strings).play - if (!isNaN(endTimestamp)) presenceData.endTimestamp = endTimestamp; + if (!Number.isNaN(endTimestamp)) + presenceData.endTimestamp = endTimestamp - if (video.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else if (showName?.textContent && episode?.textContent) { - presenceData.details = - `${showName.textContent - .charAt(0) - .toUpperCase()}${showName.textContent.slice(0)}` || "Bilinmeyen Dizi"; - presenceData.state = episode?.textContent || "Bilinmeyen Bölüm"; - } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else if (showName?.textContent && episode?.textContent) { + presenceData.details = `${showName.textContent + .charAt(0) + .toUpperCase()}${showName.textContent.slice(0)}` || 'Bilinmeyen Dizi' + presenceData.state = episode?.textContent || 'Bilinmeyen Bölüm' + } + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Diziroll/iframe.ts b/websites/D/Diziroll/iframe.ts index 3e5cb33ab7d4..5e4d64ba03cc 100644 --- a/websites/D/Diziroll/iframe.ts +++ b/websites/D/Diziroll/iframe.ts @@ -1,12 +1,12 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", () => { - const vidyo: HTMLVideoElement = document.querySelector("video"); - if (vidyo && !isNaN(vidyo.duration) && !isNaN(vidyo.currentTime)) { - return iframe.send({ - duration: vidyo.duration, - currentTime: vidyo.currentTime, - paused: vidyo.paused, - }); - } -}); +iframe.on('UpdateData', () => { + const vidyo = document.querySelector('video') + if (vidyo && !Number.isNaN(vidyo.duration) && !Number.isNaN(vidyo.currentTime)) { + return iframe.send({ + duration: vidyo.duration, + currentTime: vidyo.currentTime, + paused: vidyo.paused, + }) + } +}) diff --git a/websites/D/Diziroll/metadata.json b/websites/D/Diziroll/metadata.json index 8b311a826021..4c7a6ac2e0dc 100644 --- a/websites/D/Diziroll/metadata.json +++ b/websites/D/Diziroll/metadata.json @@ -1,31 +1,31 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "erdem", - "id": "292692556809109534" - }, - "service": "Diziroll", - "description": { - "en": "Diziroll is a website that you can watch series.", - "tr": "Diziroll bir dizi izleme sitesidir.", - "nl": "Diziroll is een website waar je series kunt kijken." - }, - "url": [ - "diziroll.com", - "www.diziroll.com" - ], - "version": "1.0.26", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Diziroll/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Diziroll/assets/thumbnail.jpg", - "color": "#1a1d30", - "category": "videos", - "tags": [ - "diziroll", - "video", - "tv-series", - "turkish" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "erdem", + "id": "292692556809109534" + }, + "service": "Diziroll", + "description": { + "en": "Diziroll is a website that you can watch series.", + "tr": "Diziroll bir dizi izleme sitesidir.", + "nl": "Diziroll is een website waar je series kunt kijken." + }, + "url": [ + "diziroll.com", + "www.diziroll.com" + ], + "version": "1.0.26", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Diziroll/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Diziroll/assets/thumbnail.jpg", + "color": "#1a1d30", + "category": "videos", + "tags": [ + "diziroll", + "video", + "tv-series", + "turkish" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git a/websites/D/Diziroll/presence.ts b/websites/D/Diziroll/presence.ts index d3ee5a1f34c1..2c67fd4075a8 100644 --- a/websites/D/Diziroll/presence.ts +++ b/websites/D/Diziroll/presence.ts @@ -1,70 +1,74 @@ -const presence = new Presence({ clientId: "818550584994168934" }); +const presence = new Presence({ clientId: '818550584994168934' }) -let stream: { duration: number; currentTime: number; paused: boolean }; +let stream: { duration: number, currentTime: number, paused: boolean } presence.on( - "iFrameData", - (data: { duration: number; currentTime: number; paused: boolean }) => { - stream = data; - } -); + 'iFrameData', + (data: unknown) => { + stream = data as { duration: number, currentTime: number, paused: boolean } + }, +) -presence.on("UpdateData", async () => { - const path: string = document.location.pathname, - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Diziroll/assets/logo.png", - }; - presenceData.startTimestamp = Date.now(); - if (path.startsWith("/arsiv")) { - presenceData.details = "Bir sayfaya bakıyor:"; - presenceData.state = "Arşiv"; - } else if (path.startsWith("/listeler")) { - presenceData.details = "Bir sayfaya bakıyor:"; - presenceData.state = "Listeler"; - } else if (path.startsWith("/hesabim")) { - presenceData.details = "Bir sayfaya bakıyor:"; - presenceData.state = "Hesabım"; - } else if (path === "/") { - presenceData.details = "Bir sayfaya bakıyor:"; - presenceData.state = "Ana Sayfa"; - } else if (document.querySelector("#archive-page")) { - presenceData.details = "Bir dizi türünü inceliyor: "; - presenceData.state = document.querySelector("div.title").textContent; - } else if (document.querySelector("#series-page")) { - presenceData.details = "Bir diziyi inceliyor:"; - presenceData.state = document.querySelector("div.top > h1").textContent; - } else if (document.querySelectorAll(".episode-detail").length > 0) { - presenceData.details = - document.querySelectorAll(".series-name")[0].title || - "Bulunamadı"; - presenceData.state = `${ - document.querySelector("div.select-season > a").textContent ?? - "Bulunamadı" - }- ${ - document.querySelector("div.select-episode > a").textContent ?? - "Bulunamadı" - }`; - presenceData.buttons = [ - { label: "İzle", url: document.location.href }, - { - label: "Diziyi Görüntüle", - url: `${document.location.origin}/${ - document.location.pathname.split("/")[1] - }`, - }, - ]; - presenceData.smallImageKey = stream.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = stream.paused ? "Durduruldu" : "Oynatılıyor"; - if (!stream.paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - stream.currentTime ? Math.floor(stream.currentTime) : null, - stream.duration ? Math.floor(stream.duration) : null - ); - } - } else { - presenceData.details = "Bir sayfayı inceliyor:"; - presenceData.state = "Bilinmeyen Sayfa"; - } - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const path: string = document.location.pathname + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Diziroll/assets/logo.png', + } + presenceData.startTimestamp = Date.now() + if (path.startsWith('/arsiv')) { + presenceData.details = 'Bir sayfaya bakıyor:' + presenceData.state = 'Arşiv' + } + else if (path.startsWith('/listeler')) { + presenceData.details = 'Bir sayfaya bakıyor:' + presenceData.state = 'Listeler' + } + else if (path.startsWith('/hesabim')) { + presenceData.details = 'Bir sayfaya bakıyor:' + presenceData.state = 'Hesabım' + } + else if (path === '/') { + presenceData.details = 'Bir sayfaya bakıyor:' + presenceData.state = 'Ana Sayfa' + } + else if (document.querySelector('#archive-page')) { + presenceData.details = 'Bir dizi türünü inceliyor: ' + presenceData.state = document.querySelector('div.title')?.textContent + } + else if (document.querySelector('#series-page')) { + presenceData.details = 'Bir diziyi inceliyor:' + presenceData.state = document.querySelector('div.top > h1')?.textContent + } + else if (document.querySelectorAll('.episode-detail').length > 0) { + presenceData.details = document.querySelectorAll('.series-name')[0].title + || 'Bulunamadı' + presenceData.state = `${ + document.querySelector('div.select-season > a')?.textContent + ?? 'Bulunamadı' + }- ${ + document.querySelector('div.select-episode > a')?.textContent + ?? 'Bulunamadı' + }` + presenceData.buttons = [ + { label: 'İzle', url: document.location.href }, + { + label: 'Diziyi Görüntüle', + url: `${document.location.origin}/${ + document.location.pathname.split('/')[1] + }`, + }, + ] + presenceData.smallImageKey = stream.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = stream.paused ? 'Durduruldu' : 'Oynatılıyor' + if (!stream.paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + stream.currentTime ? Math.floor(stream.currentTime) : 0, + stream.duration ? Math.floor(stream.duration) : 0, + ) + } + } + else { + presenceData.details = 'Bir sayfayı inceliyor:' + presenceData.state = 'Bilinmeyen Sayfa' + } + presence.setActivity(presenceData) +}) diff --git a/websites/D/Docchi/iframe.ts b/websites/D/Docchi/iframe.ts index 3c8cefea1dac..079932746cbc 100644 --- a/websites/D/Docchi/iframe.ts +++ b/websites/D/Docchi/iframe.ts @@ -1,13 +1,13 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", async () => { - const video = document.querySelector("video"); +iframe.on('UpdateData', async () => { + const video = document.querySelector('video') - if (!isNaN(video?.duration)) { - iframe.send({ - current: video.currentTime, - duration: video.duration, - paused: video.paused, - }); - } -}); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + current: video.currentTime, + duration: video.duration, + paused: video.paused, + }) + } +}) diff --git a/websites/D/Docchi/metadata.json b/websites/D/Docchi/metadata.json index 58dcb847c080..5f62e06ac7f0 100644 --- a/websites/D/Docchi/metadata.json +++ b/websites/D/Docchi/metadata.json @@ -1,44 +1,44 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "334411435633541121", - "name": "meffiu" - }, - "service": "Docchi", - "description": { - "en": "Polish anime site with a lot of series, best video players, good quality.", - "pl": "Polska strona anime z wieloma seriami, najlepsze odtwarzacze wideo, dobra jakość." - }, - "url": "docchi.pl", - "version": "1.0.15", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Docchi/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Docchi/assets/thumbnail.png", - "color": "#07BF67", - "category": "anime", - "tags": [ - "polish", - "anime", - "video", - "subs" - ], - "iframe": true, - "iFrameRegExp": "cda[.]pl|google[.]com|mega[.]nz|dailymotion[.]com|video[.]sibnet[.]ru|vk[.]com|www[.]lycoris[.]cafe|ok[.]ru", - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fad fa-user-secret", - "value": false - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true, - "if": { - "privacy": false - } - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "334411435633541121", + "name": "meffiu" + }, + "service": "Docchi", + "description": { + "en": "Polish anime site with a lot of series, best video players, good quality.", + "pl": "Polska strona anime z wieloma seriami, najlepsze odtwarzacze wideo, dobra jakość." + }, + "url": "docchi.pl", + "version": "1.0.15", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Docchi/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Docchi/assets/thumbnail.png", + "color": "#07BF67", + "category": "anime", + "tags": [ + "polish", + "anime", + "video", + "subs" + ], + "iframe": true, + "iFrameRegExp": "cda[.]pl|google[.]com|mega[.]nz|dailymotion[.]com|video[.]sibnet[.]ru|vk[.]com|www[.]lycoris[.]cafe|ok[.]ru", + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true, + "if": { + "privacy": false + } + } + ] +} diff --git a/websites/D/Docchi/presence.ts b/websites/D/Docchi/presence.ts index c099071e8eae..0e9e5d2a1dea 100644 --- a/websites/D/Docchi/presence.ts +++ b/websites/D/Docchi/presence.ts @@ -1,221 +1,237 @@ const presence = new Presence({ - clientId: "1204425198741491742", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - pages: { [key: string]: { desc: string; image: Assets } } = { - "/": { desc: "Strona Główna", image: Assets.Viewing }, - "/schedule": { desc: "Przegląda harmonogram...", image: Assets.Viewing }, - "/stats": { desc: "Przegląda statystyki...", image: Assets.Viewing }, - "/monitoring": { - desc: "Przegląda monitorowane serie...", - image: Assets.Viewing, - }, - "/contact": { - desc: "Przegląda stronę kontaktową...", - image: Assets.Viewing, - }, - "/rules": { desc: "Czyta regulamin...", image: Assets.Reading }, - "/privacy": { - desc: "Czyta politykę prywatności...", - image: Assets.Reading, - }, - "/alternatives": { - desc: "Przegląda listę stron alternatywnych...", - image: Assets.Viewing, - }, - "/my": { desc: "Przegląda swoją stronę...", image: Assets.Viewing }, - }; + clientId: '1204425198741491742', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Docchi/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Docchi/assets/logo.png', +} + +const pages: { [key: string]: { desc: string, image: Assets } } = { + '/': { desc: 'Strona Główna', image: Assets.Viewing }, + '/schedule': { desc: 'Przegląda harmonogram...', image: Assets.Viewing }, + '/stats': { desc: 'Przegląda statystyki...', image: Assets.Viewing }, + '/monitoring': { + desc: 'Przegląda monitorowane serie...', + image: Assets.Viewing, + }, + '/contact': { + desc: 'Przegląda stronę kontaktową...', + image: Assets.Viewing, + }, + '/rules': { desc: 'Czyta regulamin...', image: Assets.Reading }, + '/privacy': { + desc: 'Czyta politykę prywatności...', + image: Assets.Reading, + }, + '/alternatives': { + desc: 'Przegląda listę stron alternatywnych...', + image: Assets.Viewing, + }, + '/my': { desc: 'Przegląda swoją stronę...', image: Assets.Viewing }, } let video = { - current: 0, - duration: 0, - paused: true, -}; + current: 0, + duration: 0, + paused: true, +} presence.on( - "iFrameData", - (data: { current: number; duration: number; paused: boolean }) => { - video = data; - } -); + 'iFrameData', + (data: unknown) => { + video = data as typeof video + }, +) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - type: ActivityType.Watching, - name: "Docchi", - }, - { pathname, href, origin } = document.location, - [privacy, buttons] = [ - await presence.getSetting("privacy"), - await presence.getSetting("buttons"), - ]; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + type: ActivityType.Watching, + name: 'Docchi', + } + const { pathname, href, origin } = document.location + const [privacy, buttons] = [ + await presence.getSetting('privacy'), + await presence.getSetting('buttons'), + ] - presenceData.smallImageKey = Assets.Viewing; + presenceData.smallImageKey = Assets.Viewing - const production = pathname.startsWith("/production/as") ? pathname : null, - community = pathname.startsWith("/community") ? pathname : null, - panel = pathname.startsWith("/panel") ? pathname : null, - ht = pathname.startsWith("/hentai") ? pathname : null; - switch (pathname) { - case pathname.startsWith("/settings") ? pathname : null: - presenceData.details = "Przegląda ustawienia"; - presenceData.state = - document - .querySelector("div.text-sm-start") - .querySelector("span.navbar-item-active").textContent || - "Nieznana zakładka"; - break; - case pathname.startsWith("/profile") ? pathname : null: - privacy - ? (presenceData.details = "Przegląda profil") - : (presenceData.details = `Przegląda profil - ${ - document.querySelector("h1").textContent - }`); - presenceData.state = `Zakładka: ${ - document - .querySelector("div.profile_nav") - .querySelector("span.navbar-item-active").textContent - }`; - presenceData.largeImageKey = document - .querySelector("img.profile_page_profile_avatar__NwKeS") - .getAttribute("src"); - presenceData.buttons = [{ label: "Zobacz Profil", url: href }]; - break; - case community: - presenceData.smallImageKey = Assets.Reading; - if (community.split("/").length === 3) { - presenceData.details = "Przegląda post na forum"; - presenceData.state = document.querySelector("h1").textContent; - presenceData.buttons = [{ label: "Zobacz Post", url: href }]; - } else presenceData.details = "Przegląda forum..."; - break; - case production: - if (production.endsWith("movies")) - presenceData.details = "Przegląda filmy anime..."; - else if (production.endsWith("list")) - presenceData.details = "Przegląda serie anime..."; - else { - presenceData.largeImageKey = document - .querySelector("img.shadow-sm") - .getAttribute("src"); - if (!document.querySelector("iframe[title='Odtwarzacz']")) { - presenceData.details = "Przegląda serię"; - presenceData.state = document.querySelector( - "a[mal_sync='title']" - ).textContent; - presenceData.buttons = [{ label: "Zobacz Serię", url: href }]; - } else { - const animetype = [...document.querySelectorAll("h4")].find( - h4 => h4.textContent.trim() === "Rodzaj" - ).nextElementSibling.textContent; - if (animetype === "Movie") { - privacy - ? (presenceData.name = "Film anime") - : (presenceData.name = document.querySelector( - "a[mal_sync='title']" - ).textContent); - presenceData.buttons = [{ label: "Oglądaj", url: href }]; - } else { - privacy - ? (presenceData.name = "Anime") - : (presenceData.name = document.querySelector( - "a[mal_sync='title']" - ).textContent); - presenceData.details = `Odcinek: ${ - document.querySelector("a[mal_sync='episode']").textContent - }`; - presenceData.buttons = [ - { label: "Oglądaj", url: href }, - { - label: "Cała Seria", - url: `${origin}${document - .querySelector("a[mal_sync='episode']") - .getAttribute("href")}`, - }, - ]; - } - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(video.current, video.duration); + const production = pathname.startsWith('/production/as') ? pathname : null + const community = pathname.startsWith('/community') ? pathname : null + const panel = pathname.startsWith('/panel') ? pathname : null + const ht = pathname.startsWith('/hentai') ? pathname : null + switch (pathname) { + case pathname.startsWith('/settings') ? pathname : null: + presenceData.details = 'Przegląda ustawienia' + presenceData.state = document + .querySelector('div.text-sm-start') + ?.querySelector('span.navbar-item-active') + ?.textContent + || 'Nieznana zakładka' + break + case pathname.startsWith('/profile') ? pathname : null: + privacy + ? (presenceData.details = 'Przegląda profil') + : (presenceData.details = `Przegląda profil - ${ + document.querySelector('h1')?.textContent + }`) + presenceData.state = `Zakładka: ${ + document + ?.querySelector('div.profile_nav') + ?.querySelector('span.navbar-item-active') + ?.textContent + }` + presenceData.largeImageKey = document + ?.querySelector('img.profile_page_profile_avatar__NwKeS') + ?.getAttribute('src') + presenceData.buttons = [{ label: 'Zobacz Profil', url: href }] + break + case community: + presenceData.smallImageKey = Assets.Reading + if (community!.split('/').length === 3) { + presenceData.details = 'Przegląda post na forum' + presenceData.state = document.querySelector('h1')?.textContent + presenceData.buttons = [{ label: 'Zobacz Post', url: href }] + } + else { + presenceData.details = 'Przegląda forum...' + } + break + case production: + if (production!.endsWith('movies')) { + presenceData.details = 'Przegląda filmy anime...' + } + else if (production!.endsWith('list')) { + presenceData.details = 'Przegląda serie anime...' + } + else { + presenceData.largeImageKey = document + .querySelector('img.shadow-sm') + ?.getAttribute('src') + if (!document.querySelector('iframe[title=\'Odtwarzacz\']')) { + presenceData.details = 'Przegląda serię' + presenceData.state = document.querySelector( + 'a[mal_sync=\'title\']', + )?.textContent + presenceData.buttons = [{ label: 'Zobacz Serię', url: href }] + } + else { + const animetype = [...document.querySelectorAll('h4')].find( + h4 => h4.textContent?.trim() === 'Rodzaj', + )?.nextElementSibling?.textContent + if (animetype === 'Movie') { + privacy + ? (presenceData.name = 'Film anime') + : (presenceData.name = document.querySelector( + 'a[mal_sync=\'title\']', + )!.textContent!) + presenceData.buttons = [{ label: 'Oglądaj', url: href }] + } + else { + privacy + ? (presenceData.name = 'Anime') + : (presenceData.name = document.querySelector( + 'a[mal_sync=\'title\']', + )!.textContent!) + presenceData.details = `Odcinek: ${ + document.querySelector('a[mal_sync=\'episode\']')?.textContent + }` + presenceData.buttons = [ + { label: 'Oglądaj', url: href }, + { + label: 'Cała Seria', + url: `${origin}${document + .querySelector('a[mal_sync=\'episode\']')! + .getAttribute('href')}`, + }, + ] + } + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(video.current, video.duration) - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Odtwarzanie"; - if (video.paused) { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = "Wstrzymano"; - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } - } - break; - case panel: - presenceData.details = document - .querySelector("div.text-sm-start") - .querySelector("span.navbar-item-active").textContent; - presenceData.smallImageKey = Assets.Writing; - if (panel.startsWith("/panel/anime")) { - const title = [...document.querySelectorAll("p")] - .find(p => p.textContent.trim() === "Tytuł") - .nextElementSibling.getAttribute("value"); - presenceData.state = title; - } else if (panel.startsWith("/panel/episode")) { - const title = [...document.querySelectorAll("p")] - .find(p => p.textContent.trim() === "Anime") - .nextElementSibling.getAttribute("value"); - presenceData.state = title.replace(/-/g, " "); - } - break; - case ht: - if (ht.endsWith("list")) - presenceData.details = "Przegląda listę hentai..."; - else { - presenceData.largeImageKey = document - .querySelector("img.shadow-sm") - .getAttribute("src"); - if (!document.querySelector("iframe[title='Odtwarzacz']")) { - presenceData.details = "Przegląda serię"; - presenceData.state = document.querySelector( - "a[mal_sync='title']" - ).textContent; - presenceData.buttons = [{ label: "Zobacz Serię", url: href }]; - } else { - privacy - ? (presenceData.details = "Ogląda anime") - : (presenceData.details = document.querySelector( - "a[mal_sync='title']" - ).textContent); - presenceData.state = `Odcinek: ${ - document.querySelector("a[mal_sync='episode']").textContent - }`; - presenceData.buttons = [ - { label: "Oglądaj", url: href }, - { - label: "Cała Seria", - url: `${origin}${document - .querySelector("a[mal_sync='episode']") - .getAttribute("href")}`, - }, - ]; - } - } - break; - default: - presenceData.details = pages[pathname].desc || "Nieznana aktywność 🤨"; - presenceData.smallImageKey = pages[pathname].image || Assets.Viewing; - break; - } + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Odtwarzanie' + if (video.paused) { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Wstrzymano' + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + } + break + case panel: + presenceData.details = document + .querySelector('div.text-sm-start') + ?.querySelector('span.navbar-item-active') + ?.textContent + presenceData.smallImageKey = Assets.Writing + if (panel!.startsWith('/panel/anime')) { + const title = [...document.querySelectorAll('p')] + .find(p => p.textContent?.trim() === 'Tytuł') + ?.nextElementSibling + ?.getAttribute('value') + presenceData.state = title + } + else if (panel!.startsWith('/panel/episode')) { + const title = [...document.querySelectorAll('p')] + .find(p => p.textContent?.trim() === 'Anime') + ?.nextElementSibling + ?.getAttribute('value') + presenceData.state = title?.replace(/-/g, ' ') + } + break + case ht: + if (ht!.endsWith('list')) { + presenceData.details = 'Przegląda listę hentai...' + } + else { + presenceData.largeImageKey = document + ?.querySelector('img.shadow-sm') + ?.getAttribute('src') + if (!document.querySelector('iframe[title=\'Odtwarzacz\']')) { + presenceData.details = 'Przegląda serię' + presenceData.state = document + .querySelector('a[mal_sync=\'title\']') + ?.textContent + presenceData.buttons = [{ label: 'Zobacz Serię', url: href }] + } + else { + privacy + ? (presenceData.details = 'Ogląda anime') + : (presenceData.details = document + .querySelector('a[mal_sync=\'title\']') + ?.textContent) + presenceData.state = `Odcinek: ${ + document.querySelector('a[mal_sync=\'episode\']')?.textContent + }` + presenceData.buttons = [ + { label: 'Oglądaj', url: href }, + { + label: 'Cała Seria', + url: `${origin}${document + .querySelector('a[mal_sync=\'episode\']') + ?.getAttribute('href')}`, + }, + ] + } + } + break + default: + presenceData.details = pages[pathname].desc || 'Nieznana aktywność 🤨' + presenceData.smallImageKey = pages[pathname].image || Assets.Viewing + break + } - if (!buttons || privacy) delete presenceData.buttons; - if (privacy) { - presenceData.largeImageKey = Assets.Logo; - delete presenceData.state; - } - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); + if (!buttons || privacy) + delete presenceData.buttons + if (privacy) { + presenceData.largeImageKey = Assets.Logo + delete presenceData.state + } + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/D/DockerHub/metadata.json b/websites/D/DockerHub/metadata.json index 180ae60cf2be..ba7b9f57c810 100644 --- a/websites/D/DockerHub/metadata.json +++ b/websites/D/DockerHub/metadata.json @@ -1,22 +1,22 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Non Serviam", - "id": "154651965022928896" - }, - "service": "DockerHub", - "description": { - "en": "Docker Hub is a service provided by Docker for finding and sharing container images with your team.", - "nl": "Docker Hub is een dienst van Docker om container images te vinden en te delen met je team." - }, - "url": "hub.docker.com", - "version": "1.1.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DockerHub/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DockerHub/assets/thumbnail.png", - "color": "#099CEC", - "category": "other", - "tags": [ - "docker" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Non Serviam", + "id": "154651965022928896" + }, + "service": "DockerHub", + "description": { + "en": "Docker Hub is a service provided by Docker for finding and sharing container images with your team.", + "nl": "Docker Hub is een dienst van Docker om container images te vinden en te delen met je team." + }, + "url": "hub.docker.com", + "version": "1.1.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DockerHub/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DockerHub/assets/thumbnail.png", + "color": "#099CEC", + "category": "other", + "tags": [ + "docker" + ] +} diff --git a/websites/D/DockerHub/presence.ts b/websites/D/DockerHub/presence.ts index 6e9153d132b5..f4595dc128dd 100644 --- a/websites/D/DockerHub/presence.ts +++ b/websites/D/DockerHub/presence.ts @@ -1,183 +1,201 @@ const presence = new Presence({ - clientId: "685611188306051093", - }), - browsingTimestamp = Math.floor(Date.now() / 1000), - searchItems = { - arch: "architecture", - edition: "offering", - os: "operating_system", - page: "page", - query: "q", - tab: "tab", - type: "type", - }, - /** - * Lambda function to ucFirst - * @param s string to capitalize - */ - capitalize = (s: string): string => { - return s.charAt(0).toUpperCase() + s.slice(1); - }; - -let match: string[]; - -presence.on("UpdateData", async () => { - let url: URL, - params: URLSearchParams, - selector: Node, - arch: string, - owner: string, - name: string, - page: string, - tab: string; - - const presenceData: PresenceData = { - details: "Unknown page", // Left here as a clue to find missing possible states - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DockerHub/assets/logo.png", - }; - - if (document.location.host === "hub.docker.com") { - presenceData.startTimestamp = browsingTimestamp; - - if (document.location.pathname.match(/^\/(repositories)?$/)) - presenceData.details = "Bowsing own repositories"; - else if (document.location.pathname.match(/^\/settings/)) - presenceData.details = "On settings page"; - else if (document.location.pathname.match(/^\/search/)) { - url = new URL(document.location.href); - params = url.searchParams; - - const query: string = params.get(searchItems.query); - let type: string = params.get(searchItems.type); - type = (type && decodeURIComponent(type)) || "image"; - - let edition: string = params.get(searchItems.edition); - edition = (edition && decodeURIComponent(edition)) || ""; - - let os: string = params.get(searchItems.os); - os = (os && decodeURIComponent(os)) || null; - - arch = params.get(searchItems.arch); - arch = (arch && decodeURIComponent(arch)) || null; - - presenceData.details = `Searching for${ - query ? `: ${query}` : ` ${edition} ${type}s` - }`; - - if (query && edition) - presenceData.state = `${capitalize(edition)} ${type}s`; - if (os || arch) { - presenceData.state = `${os ? `${capitalize(os)} ` : ""}${ - arch ? arch.toUpperCase() : "" - }`; - } - } else if (document.location.pathname.match(/^\/orgs$/)) - presenceData.details = "Browsing organizations"; - else if ( - document.location.pathname.match(/^\/orgs\/([^/]+)(?:\/([^/]+))?/) - ) { - [, name, tab] = document.location.pathname.match( - /^\/orgs\/([^/]+)(?:\/([^/]+))?/ - ); - tab = tab || "members"; - presenceData.details = `On org ${tab}page`; - presenceData.state = `${name}`; - } else if (document.location.pathname.match(/^\/_\/([^?]+)/)) { - url = new URL(document.location.href); - params = url.searchParams; - - [, name] = document.location.pathname.match(/^\/_\/([^?]+)/); - - tab = params.get(searchItems.tab); - - presenceData.details = `On image ${tab ? `${tab} ` : ""}page`; - presenceData.state = `${name}`; - } else if ( - document.location.pathname.match(/^\/r\/([^/]+)\/([^/]+)(?:\/([^?]+))?/) - ) { - url = new URL(document.location.href); - params = url.searchParams; - - [, owner, name, tab] = document.location.pathname.match( - /^\/r\/([^/]+)\/([^/]+)(?:\/([^?]+))?/ - ); - - page = params.get(searchItems.page); - - presenceData.details = `On image ${tab ?? ""} page${ - page ? ` ${page}` : "" - }`; - presenceData.state = `${owner}/${name}`; - } else if ( - document.location.pathname.match(/^\/layers\/([^/]+)\/([^/]+)\/([^/]+)/) - ) { - match = document.location.pathname.match( - /^\/layers\/([^/]+)\/([^/]+)\/([^/]+)/ - ); - url = new URL(document.location.href); - params = url.searchParams; - - const context: string = params.get("context"); - if (context && context === "repo") { - presenceData.details = "On personal repository"; - presenceData.state = "Image history"; - } else { - [, owner, name] = match; - selector = document.querySelector(".Select-value") || null; - arch = (selector && selector.textContent) || null; - - presenceData.details = "On image history"; - presenceData.state = `${owner}/${name}:${match[3]} ${arch ?? ""}`; - } - } else if ( - document.location.pathname.match(/^\/u\/([^/]+)(?:\/([^/]+))?/) - ) { - tab = match[2] || "repositories"; - presenceData.details = `On profile ${tab} page`; - [, presenceData.state] = document.location.pathname.match( - /^\/u\/([^/]+)(?:\/([^/]+))?/ - ); - } else if (document.location.pathname.match(/^\/repository\/create/)) - presenceData.details = "Creating repository"; - else if (document.location.pathname.match(/^\/repository(?:\/([^/?]+))+/)) { - url = new URL(document.location.href); - params = url.searchParams; - - presenceData.details = "On personal repository"; - - [, tab] = document.location.pathname.match( - /^\/repository(?:\/([^/?]+))+/ - ); - - page = params.get(searchItems.page); - selector = document.querySelector( - "#contextNav > div > div.styles__breadcrumbs___18Yr8 > div:nth-child(2) > a" - ); - const breadcrum: string = (selector && selector.textContent) || null; - - if (breadcrum && breadcrum.match(tab)) tab = "general"; - else if (document.location.pathname.match(/\/builds\//)) tab = "builds"; - - presenceData.state = `${capitalize(tab)}${page ? ` ${page}` : ""}`; - } else if ( - document.location.pathname.match(/^\/support\/(?:(doc)?(contact)?)/) - ) { - match = document.location.pathname.match( - /^\/support\/(?:(doc)?(contact)?)/ - ); - presenceData.details = "Reading FAQ"; - if (match[1] && true) { - selector = - document.querySelector( - "#gatsby-focus-wrapper > div > main > div > div.MuiCardHeader-root > div > span" - ) || null; - presenceData.state = (selector && selector.textContent) || null; - } else if (match[2] && true) presenceData.details = "Contact page"; - } else if (document.location.pathname.match(/^\/billing/)) - presenceData.details = "Checking billing info"; - } - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + clientId: '685611188306051093', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) +const searchItems = { + arch: 'architecture', + edition: 'offering', + os: 'operating_system', + page: 'page', + query: 'q', + tab: 'tab', + type: 'type', +} +/** + * Lambda function to ucFirst + * @param s string to capitalize + */ +function capitalize(s: string): string { + return s.charAt(0).toUpperCase() + s.slice(1) +} + +let match: string[] + +presence.on('UpdateData', async () => { + let url: URL, + params: URLSearchParams, + selector: Node | null, + arch: string | null, + owner: string, + name: string, + page: string | null, + tab: string | null + + const presenceData: PresenceData = { + details: 'Unknown page', // Left here as a clue to find missing possible states + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DockerHub/assets/logo.png', + } + + if (document.location.host === 'hub.docker.com') { + presenceData.startTimestamp = browsingTimestamp + + if (document.location.pathname.match(/^\/(repositories)?$/)) { + presenceData.details = 'Bowsing own repositories' + } + else if (document.location.pathname.match(/^\/settings/)) { + presenceData.details = 'On settings page' + } + else if (document.location.pathname.match(/^\/search/)) { + url = new URL(document.location.href) + params = url.searchParams + + const query = params.get(searchItems.query) + let type = params.get(searchItems.type) + type = (type && decodeURIComponent(type)) || 'image' + + let edition = params.get(searchItems.edition) + edition = (edition && decodeURIComponent(edition)) || '' + + let os = params.get(searchItems.os) + os = (os && decodeURIComponent(os)) || null + + arch = params.get(searchItems.arch) + arch = (arch && decodeURIComponent(arch)) || null + + presenceData.details = `Searching for${ + query ? `: ${query}` : ` ${edition} ${type}s` + }` + + if (query && edition) + presenceData.state = `${capitalize(edition)} ${type}s` + if (os || arch) { + presenceData.state = `${os ? `${capitalize(os)} ` : ''}${ + arch ? arch.toUpperCase() : '' + }` + } + } + else if (document.location.pathname.match(/^\/orgs$/)) { + presenceData.details = 'Browsing organizations' + } + else if ( + document.location.pathname.match(/^\/orgs\/([^/]+)(?:\/([^/]+))?/) + ) { + [, name, tab] = document.location.pathname.match( + /^\/orgs\/([^/]+)(?:\/([^/]+))?/, + ) ?? [] + tab = tab || 'members' + presenceData.details = `On org ${tab}page` + presenceData.state = `${name}` + } + else if (document.location.pathname.match(/^\/_\/([^?]+)/)) { + url = new URL(document.location.href) + params = url.searchParams; + + [, name] = document.location.pathname.match(/^\/_\/([^?]+)/) ?? [] + + tab = params.get(searchItems.tab) + + presenceData.details = `On image ${tab ? `${tab} ` : ''}page` + presenceData.state = `${name}` + } + else if ( + document.location.pathname.match(/^\/r\/([^/]+)\/([^/]+)(?:\/([^?]+))?/) + ) { + url = new URL(document.location.href) + params = url.searchParams; + + [, owner, name, tab] = document.location.pathname.match( + /^\/r\/([^/]+)\/([^/]+)(?:\/([^?]+))?/, + ) ?? [] + + page = params.get(searchItems.page) + + presenceData.details = `On image ${tab ?? ''} page${ + page ? ` ${page}` : '' + }` + presenceData.state = `${owner}/${name}` + } + else if ( + document.location.pathname.match(/^\/layers\/([^/]+)\/([^/]+)\/([^/]+)/) + ) { + match = document.location.pathname.match( + /^\/layers\/([^/]+)\/([^/]+)\/([^/]+)/, + ) ?? [] + url = new URL(document.location.href) + params = url.searchParams + + const context = params.get('context') + if (context && context === 'repo') { + presenceData.details = 'On personal repository' + presenceData.state = 'Image history' + } + else { + [, owner, name] = match + selector = document.querySelector('.Select-value') || null + arch = (selector && selector.textContent) || null + + presenceData.details = 'On image history' + presenceData.state = `${owner}/${name}:${match[3]} ${arch ?? ''}` + } + } + else if ( + document.location.pathname.match(/^\/u\/([^/]+)(?:\/([^/]+))?/) + ) { + tab = match[2] || 'repositories' + presenceData.details = `On profile ${tab} page`; + [, presenceData.state] = document.location.pathname.match( + /^\/u\/([^/]+)(?:\/([^/]+))?/, + ) + } + else if (document.location.pathname.match(/^\/repository\/create/)) { + presenceData.details = 'Creating repository' + } + else if (document.location.pathname.match(/^\/repository(?:\/([^/?]+))+/)) { + url = new URL(document.location.href) + params = url.searchParams + + presenceData.details = 'On personal repository'; + + [, tab] = document.location.pathname.match( + /^\/repository(?:\/([^/?]+))+/, + ) + + page = params.get(searchItems.page) + selector = document.querySelector( + '#contextNav > div > div.styles__breadcrumbs___18Yr8 > div:nth-child(2) > a', + ) + const breadcrum = (selector && selector.textContent) || null + + if (breadcrum && breadcrum.match(tab!)) + tab = 'general' + else if (document.location.pathname.match(/\/builds\//)) + tab = 'builds' + + presenceData.state = `${capitalize(tab!)}${page ? ` ${page}` : ''}` + } + else if ( + document.location.pathname.match(/^\/support\/(doc)?(contact)?/) + ) { + match = document.location.pathname.match( + /^\/support\/(doc)?(contact)?/, + ) ?? [] + presenceData.details = 'Reading FAQ' + if (match[1] && true) { + selector = document.querySelector( + '#gatsby-focus-wrapper > div > main > div > div.MuiCardHeader-root > div > span', + ) || null + presenceData.state = (selector && selector.textContent) || null + } + else if (match[2] && true) { + presenceData.details = 'Contact page' + } + } + else if (document.location.pathname.match(/^\/billing/)) { + presenceData.details = 'Checking billing info' + } + } + + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Dominion Online/metadata.json b/websites/D/Dominion Online/metadata.json index 0f4c5934cbaa..700fc357fea9 100644 --- a/websites/D/Dominion Online/metadata.json +++ b/websites/D/Dominion Online/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Nep", - "id": "187577389419724800" - }, - "service": "Dominion Online", - "description": { - "en": "Dominion Online, developed by Shuffle iT, is the official platform to play Dominion, the award-winning deckbuilding card game created by Donald X. Vaccarino." - }, - "url": "dominion.games", - "version": "1.0.17", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dominion%20Online/assets/logo.jpg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dominion%20Online/assets/thumbnail.jpg", - "color": "#468c01", - "category": "games", - "tags": [ - "card", - "game", - "dominion" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Nep", + "id": "187577389419724800" + }, + "service": "Dominion Online", + "description": { + "en": "Dominion Online, developed by Shuffle iT, is the official platform to play Dominion, the award-winning deckbuilding card game created by Donald X. Vaccarino." + }, + "url": "dominion.games", + "version": "1.0.17", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dominion%20Online/assets/logo.jpg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dominion%20Online/assets/thumbnail.jpg", + "color": "#468c01", + "category": "games", + "tags": [ + "card", + "game", + "dominion" + ] +} diff --git a/websites/D/Dominion Online/presence.ts b/websites/D/Dominion Online/presence.ts index b78913930cc5..7f7f7e2339e5 100644 --- a/websites/D/Dominion Online/presence.ts +++ b/websites/D/Dominion Online/presence.ts @@ -1,67 +1,73 @@ const presence = new Presence({ - clientId: "849684658563055627", - }), - logRegex = /^.+ - \w+$/, - generalStartTime = Math.floor(Date.now() / 1000); -let lobbyStartTime: number, gameStartTime: number; + clientId: '849684658563055627', +}) +const logRegex = /^.+ - \w+$/ +const generalStartTime = Math.floor(Date.now() / 1000) +let lobbyStartTime: number, gameStartTime: number -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Dominion%20Online/assets/logo.jpg", - startTimestamp: generalStartTime, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Dominion%20Online/assets/logo.jpg', + startTimestamp: generalStartTime, + } - if ( - document.querySelector(".my-table") || - document.querySelector(".score-page") - ) { - if (lobbyStartTime === 0) lobbyStartTime = Math.floor(Date.now() / 1000); - gameStartTime = 0; + if ( + document.querySelector('.my-table') + || document.querySelector('.score-page') + ) { + if (lobbyStartTime === 0) + lobbyStartTime = Math.floor(Date.now() / 1000) + gameStartTime = 0 - presenceData.details = `In Lobby: ${document - .querySelector(".participant-list-label") - .textContent.trim()}`; - presenceData.state = - document.querySelector(".rules-editor") || - document.querySelector('button[ng-click="$ctrl.editTable()"]') - ? "Host" - : null; - presenceData.startTimestamp = lobbyStartTime; - } else if (document.querySelector(".game-page")) { - if (gameStartTime === 0) gameStartTime = Math.floor(Date.now() / 1000); - lobbyStartTime = 0; + presenceData.details = `In Lobby: ${document + .querySelector('.participant-list-label') + ?.textContent + ?.trim()}` + presenceData.state = document.querySelector('.rules-editor') + || document.querySelector('button[ng-click="$ctrl.editTable()"]') + ? 'Host' + : null + presenceData.startTimestamp = lobbyStartTime + } + else if (document.querySelector('.game-page')) { + if (gameStartTime === 0) + gameStartTime = Math.floor(Date.now() / 1000) + lobbyStartTime = 0 - const logs = document.querySelectorAll(".actual-log"); + const logs = document.querySelectorAll('.actual-log') - // Find last turn log from end - for (let i = logs.length - 1; i >= 0; i--) { - if (!logs[i]) continue; + // Find last turn log from end + for (let i = logs.length - 1; i >= 0; i--) { + if (!logs[i]) + continue - const logText = logs[i].textContent.trim(); + const logText = logs[i].textContent?.trim() - // Append turn - if (logRegex.test(logText)) { - presenceData.state = logText; - break; - } - } + // Append turn + if (logRegex.test(logText!)) { + presenceData.state = logText + break + } + } - presenceData.details = `In Game (${ - document.querySelectorAll(".spec-list-line").length - } Players)`; - presenceData.startTimestamp = gameStartTime; - } else if ( - document.querySelector(".login-page") || - document.querySelector(".lobby-page") - ) { - gameStartTime = lobbyStartTime = 0; - presenceData.details = "Main Menu"; - } else if (document.querySelector(".loading-spinner")) { - gameStartTime = lobbyStartTime = 0; - presenceData.details = "Loading..."; - } + presenceData.details = `In Game (${ + document.querySelectorAll('.spec-list-line').length + } Players)` + presenceData.startTimestamp = gameStartTime + } + else if ( + document.querySelector('.login-page') + || document.querySelector('.lobby-page') + ) { + gameStartTime = lobbyStartTime = 0 + presenceData.details = 'Main Menu' + } + else if (document.querySelector('.loading-spinner')) { + gameStartTime = lobbyStartTime = 0 + presenceData.details = 'Loading...' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Domino's Pizza (UK)/metadata.json b/websites/D/Domino's Pizza (UK)/metadata.json index d9c948613427..1d8ff07a9319 100644 --- a/websites/D/Domino's Pizza (UK)/metadata.json +++ b/websites/D/Domino's Pizza (UK)/metadata.json @@ -1,29 +1,29 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "dAn", - "id": "169516316124905473" - }, - "service": "Domino's Pizza (UK)", - "description": { - "en": "Order your favourite pizza custom made to your taste", - "nl": "Bestel uw favoriete pizza op maat naar uw smaak" - }, - "url": [ - "www.dominos.co.uk", - "dominos.co.uk" - ], - "version": "1.3.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Domino's%20Pizza%20(UK)/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Domino's%20Pizza%20(UK)/assets/thumbnail.png", - "color": "#E31837", - "category": "other", - "tags": [ - "pizza", - "dominos", - "dominos-uk", - "pizza-uk", - "region-locked" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "dAn", + "id": "169516316124905473" + }, + "service": "Domino's Pizza (UK)", + "description": { + "en": "Order your favourite pizza custom made to your taste", + "nl": "Bestel uw favoriete pizza op maat naar uw smaak" + }, + "url": [ + "www.dominos.co.uk", + "dominos.co.uk" + ], + "version": "1.3.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Domino's%20Pizza%20(UK)/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Domino's%20Pizza%20(UK)/assets/thumbnail.png", + "color": "#E31837", + "category": "other", + "tags": [ + "pizza", + "dominos", + "dominos-uk", + "pizza-uk", + "region-locked" + ] +} diff --git a/websites/D/Domino's Pizza (UK)/presence.ts b/websites/D/Domino's Pizza (UK)/presence.ts index ce947f03264f..7f7bfd5cf4e4 100644 --- a/websites/D/Domino's Pizza (UK)/presence.ts +++ b/websites/D/Domino's Pizza (UK)/presence.ts @@ -1,159 +1,164 @@ const presence = new Presence({ - clientId: "650464804276011009", -}); - -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Domino's%20Pizza%20(UK)/assets/logo.png", - startTimestamp: Date.now(), - }, - path = document.location.pathname; - - switch (path) { - case "/": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Home Page"; - - break; - } - case "/menu": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Menu"; - - break; - } - case "/deals/storedeals": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Viewing in-store deals"; - - break; - } - default: - if (path.startsWith("/menu/pizza/999")) { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Creating a custom pizza"; - } else if ( - path.startsWith("/deals/deal") && - Number(path.split("/")[path.split("/").length - 1]) - ) { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Customising a deal"; - } else { - switch (path) { - case "/user/login": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Logging in..."; - - break; - } - case "/user/register": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Creating an account"; - - break; - } - case "/welcome": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Home Page"; - - break; - } - case "/store/moreinfo": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Viewing store info"; - - break; - } - default: - if (path.startsWith("/storefinder/bystoreid")) { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Finding stores"; - } else { - switch (path) { - case "/mydominos/addressbook": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Viewing my addresses"; - - break; - } - case "/mydominos": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Viewing my profile"; - - break; - } - case "/mydominos/favourites": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Viewing my favourited orders"; - - break; - } - case "/mydominos/offers": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Entering a promo code"; - - break; - } - case "/mydominos/paymentmethods": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Adding a payment method"; - - break; - } - case "/mydominos/personaldetails": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Editing personal details"; - - break; - } - case "/mydominos/savedpizzas": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Viewing saved pizzas"; - - break; - } - case "/mydominos/security": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Changing password"; - - break; - } - case "/contact": { - presenceData.details = "Browing Domino's Pizza"; - presenceData.state = "Contacting support"; - - break; - } - case "/basketdetails/show": { - const [price] = document.querySelectorAll( - ".new-basket-total-price.basket-price" - ), - [saving] = document.querySelectorAll( - ".new-basket-total-price.basket-alt-price" - ); - - let priceText, savingText; - - if (price) priceText = price.textContent; - - if (saving) savingText = saving.textContent; - - presenceData.details = "Viewing cart"; - presenceData.state = `Total: ${priceText} ${ - saving ? `(${savingText} saved)` : "" - }`; - - break; - } - default: - presenceData.details = "Browing Domino's Pizza"; - } - } - } - } - } - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + clientId: '650464804276011009', +}) + +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Domino\'s%20Pizza%20(UK)/assets/logo.png', + startTimestamp: Date.now(), + } + const path = document.location.pathname + + switch (path) { + case '/': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Home Page' + + break + } + case '/menu': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Menu' + + break + } + case '/deals/storedeals': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Viewing in-store deals' + + break + } + default: + if (path.startsWith('/menu/pizza/999')) { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Creating a custom pizza' + } + else if ( + path.startsWith('/deals/deal') + && Number(path.split('/')[path.split('/').length - 1]) + ) { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Customising a deal' + } + else { + switch (path) { + case '/user/login': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Logging in...' + + break + } + case '/user/register': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Creating an account' + + break + } + case '/welcome': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Home Page' + + break + } + case '/store/moreinfo': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Viewing store info' + + break + } + default: + if (path.startsWith('/storefinder/bystoreid')) { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Finding stores' + } + else { + switch (path) { + case '/mydominos/addressbook': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Viewing my addresses' + + break + } + case '/mydominos': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Viewing my profile' + + break + } + case '/mydominos/favourites': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Viewing my favourited orders' + + break + } + case '/mydominos/offers': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Entering a promo code' + + break + } + case '/mydominos/paymentmethods': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Adding a payment method' + + break + } + case '/mydominos/personaldetails': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Editing personal details' + + break + } + case '/mydominos/savedpizzas': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Viewing saved pizzas' + + break + } + case '/mydominos/security': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Changing password' + + break + } + case '/contact': { + presenceData.details = 'Browing Domino\'s Pizza' + presenceData.state = 'Contacting support' + + break + } + case '/basketdetails/show': { + const [price] = document.querySelectorAll( + '.new-basket-total-price.basket-price', + ) + const [saving] = document.querySelectorAll( + '.new-basket-total-price.basket-alt-price', + ) + + let priceText, savingText + + if (price) + priceText = price.textContent + + if (saving) + savingText = saving.textContent + + presenceData.details = 'Viewing cart' + presenceData.state = `Total: ${priceText} ${ + saving ? `(${savingText} saved)` : '' + }` + + break + } + default: + presenceData.details = 'Browing Domino\'s Pizza' + } + } + } + } + } + + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Doodstreams/metadata.json b/websites/D/Doodstreams/metadata.json index 2509f959abed..78a836377cee 100644 --- a/websites/D/Doodstreams/metadata.json +++ b/websites/D/Doodstreams/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "638080361179512853", - "name": "dark_ville" - }, - "service": "Doodstreams", - "description": { - "en": "Doodstream redefines video sharing with a commitment to unrivaled HLS streaming, unlimited bandwidth and seamless user experience.", - "nl": "Doodstream herdefinieert het delen van video met een toewijding aan ongeëvenaarde HLS streaming, onbeperkte bandbreedte en naadloze gebruikerservaring." - }, - "url": "doods.pro", - "regExp": "((ww(w)?([0-9])?[.])?dood(s)?[.][a-z]*)|((ww(w)?([0-9])?[.])?doodstream[.][a-z]*([.][a-z]*)?)", - "version": "1.0.5", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Doodstreams/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Doodstreams/assets/thumbnail.png", - "color": "#FF9900", - "category": "videos", - "tags": [ - "anime", - "video", - "stream", - "streaming", - "sharing" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "638080361179512853", + "name": "dark_ville" + }, + "service": "Doodstreams", + "description": { + "en": "Doodstream redefines video sharing with a commitment to unrivaled HLS streaming, unlimited bandwidth and seamless user experience.", + "nl": "Doodstream herdefinieert het delen van video met een toewijding aan ongeëvenaarde HLS streaming, onbeperkte bandbreedte en naadloze gebruikerservaring." + }, + "url": "doods.pro", + "regExp": "((ww(w)?([0-9])?[.])?dood(s)?[.][a-z]*)|((ww(w)?([0-9])?[.])?doodstream[.][a-z]*([.][a-z]*)?)", + "version": "1.0.5", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Doodstreams/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Doodstreams/assets/thumbnail.png", + "color": "#FF9900", + "category": "videos", + "tags": [ + "anime", + "video", + "stream", + "streaming", + "sharing" + ] +} diff --git a/websites/D/Doodstreams/presence.ts b/websites/D/Doodstreams/presence.ts index 8bacfee2f8a4..d8b9034b1210 100644 --- a/websites/D/Doodstreams/presence.ts +++ b/websites/D/Doodstreams/presence.ts @@ -1,38 +1,36 @@ const presence = new Presence({ - clientId: "1190374591995060234", - }), - browsingTimestamp = Math.round(Date.now() / 1000), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }); + clientId: '1190374591995060234', +}) +const browsingTimestamp = Math.round(Date.now() / 1000) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - startTimestamp: browsingTimestamp, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Doodstreams/assets/logo.png", - }, - { pathname } = document.location, - video = document.querySelector("video"), - title = document.querySelector("title")?.textContent; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + startTimestamp: browsingTimestamp, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Doodstreams/assets/logo.png', + } + const { pathname } = document.location + const video = document.querySelector('video') + const title = document.querySelector('title')?.textContent - if (pathname.includes("/e/")) { - delete presenceData.startTimestamp; - presenceData.details = title?.split(" S0")?.[0] ?? title; - presenceData.state = title?.match(/S[0-9]*E[0-9]* /gm)?.[0]; + if (pathname.includes('/e/')) { + delete presenceData.startTimestamp + presenceData.details = title?.split(' S0')?.[0] ?? title + presenceData.state = title?.match(/S\d*E\d* /g)?.[0] - if (!isNaN(video?.duration)) { - if (!video.paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - } - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? (await strings).pause - : (await strings).play; - } - } + if (video && !Number.isNaN(video.duration)) { + if (!video.paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + } + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? (await strings).pause + : (await strings).play + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/D/Doordash/metadata.json b/websites/D/Doordash/metadata.json index 5af876007cf6..70a6492af8df 100644 --- a/websites/D/Doordash/metadata.json +++ b/websites/D/Doordash/metadata.json @@ -1,35 +1,35 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "astrid", - "id": "852656702037164053" - }, - "service": "Doordash", - "description": { - "en": "Delivery & takeout from the best local restaurants. Breakfast, lunch, dinner and more, delivered safely to your door." - }, - "url": "www.doordash.com", - "version": "1.0.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Doordash/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Doordash/assets/thumbnail.jpg", - "color": "#ff3008", - "category": "other", - "tags": [ - "food", - "delivery", - "restaurant" - ], - "settings": [ - { - "id": "hideFood", - "title": "Hide Food Selection", - "value": false - }, - { - "id": "hideSearch", - "title": "Hide Search Results", - "value": false - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "astrid", + "id": "852656702037164053" + }, + "service": "Doordash", + "description": { + "en": "Delivery & takeout from the best local restaurants. Breakfast, lunch, dinner and more, delivered safely to your door." + }, + "url": "www.doordash.com", + "version": "1.0.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Doordash/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Doordash/assets/thumbnail.jpg", + "color": "#ff3008", + "category": "other", + "tags": [ + "food", + "delivery", + "restaurant" + ], + "settings": [ + { + "id": "hideFood", + "title": "Hide Food Selection", + "value": false + }, + { + "id": "hideSearch", + "title": "Hide Search Results", + "value": false + } + ] +} diff --git a/websites/D/Doordash/presence.ts b/websites/D/Doordash/presence.ts index f54281fefd4a..ac114e53a78d 100644 --- a/websites/D/Doordash/presence.ts +++ b/websites/D/Doordash/presence.ts @@ -1,93 +1,94 @@ const presence = new Presence({ - clientId: "1001831947611426877", - }), - browsingTimestamp = Date.now(); + clientId: '1001831947611426877', +}) +const browsingTimestamp = Date.now() -presence.on("UpdateData", async () => { - const { pathname } = document.location, - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Doordash/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - [hideSearch, hideFood] = await Promise.all([ - presence.getSetting("hideSearch"), - presence.getSetting("hideFood"), - ]); +presence.on('UpdateData', async () => { + const { pathname } = document.location + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Doordash/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const [hideSearch, hideFood] = await Promise.all([ + presence.getSetting('hideSearch'), + presence.getSetting('hideFood'), + ]) - if (pathname.includes("/store/") && !pathname.includes("/search/")) { - const name = document.querySelector( - "h1.styles__TextElement-sc-1jrzcv7-0" - ).textContent, - image = document - .querySelector( - ".menu-header-styles__LogoInner-sc-1kgi6s8-6 > picture:nth-child(1) > img:nth-child(5)" - ) - .getAttribute("src"); + if (pathname.includes('/store/') && !pathname.includes('/search/')) { + const name = document.querySelector( + 'h1.styles__TextElement-sc-1jrzcv7-0', + )?.textContent + const image = document + .querySelector( + '.menu-header-styles__LogoInner-sc-1kgi6s8-6 > picture:nth-child(1) > img:nth-child(5)', + ) + ?.getAttribute('src') - if ( - !document - .querySelector(".styles__ModalContainer-sc-1r4qbfh-0") - .getAttribute("src") - ) { - presenceData.largeImageKey = image; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Doordash/assets/logo.png"; - presenceData.details = `Viewing the menu of ${name}`; - } else { - if (!hideFood) { - const menuItemImage = document - .querySelector( - ".BaseItemModalStyles__PictureFrame-sc-mpq8va-1 > picture:nth-child(1) > img:nth-child(5)" - ) - .getAttribute("src"); - presenceData.state = `Looking at ${ - document.querySelector(".bbOfWk").textContent - }`; - presenceData.largeImageKey = menuItemImage; - } + if ( + !document + .querySelector('.styles__ModalContainer-sc-1r4qbfh-0') + ?.getAttribute('src') + ) { + presenceData.largeImageKey = image + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Doordash/assets/logo.png' + presenceData.details = `Viewing the menu of ${name}` + } + else { + if (!hideFood) { + const menuItemImage = document + .querySelector( + '.BaseItemModalStyles__PictureFrame-sc-mpq8va-1 > picture:nth-child(1) > img:nth-child(5)', + ) + ?.getAttribute('src') + presenceData.state = `Looking at ${ + document.querySelector('.bbOfWk')?.textContent + }` + presenceData.largeImageKey = menuItemImage + } - presenceData.details = `Viewing the menu of ${name}`; - presenceData.smallImageKey = image; - } - } else if (pathname.includes("/search/store/") && !hideSearch) { - const search = document.querySelector("#FieldWrapper-0"); - presenceData.details = `Searching for ${ - search ? search.value : "something" - }`; - } + presenceData.details = `Viewing the menu of ${name}` + presenceData.smallImageKey = image + } + } + else if (pathname.includes('/search/store/') && !hideSearch) { + const search = document.querySelector('#FieldWrapper-0') + presenceData.details = `Searching for ${ + search ? search.value : 'something' + }` + } - switch (pathname) { - case "/": { - presenceData.details = "Browsing Doordash"; - let activeSpan: HTMLSpanElement; + switch (pathname) { + case '/': { + presenceData.details = 'Browsing Doordash' + let activeSpan: HTMLSpanElement | null = null - const spanArray = Array.from(document.querySelectorAll(".sc-hFLmAl")); + const spanArray = Array.from(document.querySelectorAll('.sc-hFLmAl')) - for (const span of spanArray) { - if (span.attributes[1].value === "#EB1700") - activeSpan = span as HTMLSpanElement; - } + for (const span of spanArray) { + if (span.attributes[1].value === '#EB1700') + activeSpan = span as HTMLSpanElement + } - if (activeSpan) - presenceData.state = `Looking for ${activeSpan.textContent}`; + if (activeSpan) + presenceData.state = `Looking for ${activeSpan.textContent}` - break; - } - case "/orders": { - presenceData.details = "Viewing their orders"; - break; - } - case "/consumer/edit_profile/": { - presenceData.details = "Editing their profile"; - break; - } - case "/saved-stores/": { - presenceData.details = "Viewing their saved stores"; - break; - } - } + break + } + case '/orders': { + presenceData.details = 'Viewing their orders' + break + } + case '/consumer/edit_profile/': { + presenceData.details = 'Editing their profile' + break + } + case '/saved-stores/': { + presenceData.details = 'Viewing their saved stores' + break + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Doronime/metadata.json b/websites/D/Doronime/metadata.json index ae014438d055..ae2315642839 100644 --- a/websites/D/Doronime/metadata.json +++ b/websites/D/Doronime/metadata.json @@ -1,25 +1,25 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "noxzym", - "id": "243728573624614912" - }, - "service": "Doronime", - "description": { - "en": "Download anime, anime music, anime ongoing, or anime batch with Indonesian subtitle", - "id": "Unduh anime, anime musik, anime ongoing, atau anime batch dengan subtitle Indonesia" - }, - "url": "doroni.me", - "version": "1.1.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Doronime/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Doronime/assets/thumbnail.png", - "color": "#b11415", - "category": "anime", - "tags": [ - "anime", - "music", - "ost", - "other" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "noxzym", + "id": "243728573624614912" + }, + "service": "Doronime", + "description": { + "en": "Download anime, anime music, anime ongoing, or anime batch with Indonesian subtitle", + "id": "Unduh anime, anime musik, anime ongoing, atau anime batch dengan subtitle Indonesia" + }, + "url": "doroni.me", + "version": "1.1.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Doronime/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Doronime/assets/thumbnail.png", + "color": "#b11415", + "category": "anime", + "tags": [ + "anime", + "music", + "ost", + "other" + ] +} diff --git a/websites/D/Doronime/presence.ts b/websites/D/Doronime/presence.ts index a539ea7d19d8..3edc58dbd98e 100644 --- a/websites/D/Doronime/presence.ts +++ b/websites/D/Doronime/presence.ts @@ -1,123 +1,144 @@ const presence = new Presence({ - clientId: "967447688687779920", - }), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Doronime/assets/logo.png", - startTimestamp: Math.floor(Date.now() / 1000), - }; + clientId: '967447688687779920', +}) +const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Doronime/assets/logo.png', + startTimestamp: Math.floor(Date.now() / 1000), +} -presence.on("UpdateData", async () => { - const trim = (str?: string) => str?.trim(); +presence.on('UpdateData', async () => { + const trim = (str?: string | null) => str?.trim() - if (document.location.search.startsWith("?s")) - presenceData.details = "Searching Anime"; + if (document.location.search.startsWith('?s')) + presenceData.details = 'Searching Anime' - const { href, pathname } = document.location, - [base, ...data] = pathname.slice(1).split("/"); + const { href, pathname } = document.location + const [base, ...data] = pathname.slice(1).split('/') - switch (base) { - case "batch": - presenceData.details = "Viewing Anime Batch List"; - break; - case "movie": - presenceData.details = "Viewing Anime Movie List"; - break; - case "schedule": - presenceData.details = "Viewing Anime Schedule List"; - break; - case "anime": - if (data.length) { - presenceData.details = trim( - document.querySelector("[aria-current='page']") - ?.previousElementSibling?.textContent ?? - document - .querySelector("h5[class='Content__title']") - ?.textContent?.replace( - /(Episode [0-9]+)|(Subtitle Indonesia)/gm, - "" - ) - ); - presenceData.state = - document.querySelector('[aria-current="page"]')?.textContent ?? - document - .querySelector('h5[class="Content__title"]') - ?.textContent?.match(/Episode [0-9]+/gm)?.[0]; - } else presenceData.details = "Viewing Anime List"; - break; - case "ost": - if (data.length) { - const [title, artist] = [ - ...document.querySelectorAll( - ".Content__description-caption > .form-row > div" - ), - ] - .map((x, i) => (i % 2 === 1 ? x : null)) - .filter(Boolean) - .splice(0, 2) - .map(x => - x.textContent.replace(/ +?/g, "").split("\n").join(" ").trim() - ); - presenceData.details = - title.split(" ").length > 1 ? title.split(" ")[1] : title; - presenceData.state = artist; - } else presenceData.details = "Viewing Anime OST List"; - break; - case "genre": - if (data.length) { - presenceData.details = "Viewing Anime Genre"; - presenceData.state = trim( - document.querySelector('[aria-current="page"]')?.textContent - ); - } else presenceData.details = "Viewing Anime Genre List"; - break; - case "season": - if (data.length) { - presenceData.details = "Viewing Anime Season"; - presenceData.state = trim( - document.querySelector('[aria-current="page"]')?.textContent - ); - } else presenceData.details = "Viewing Anime Season List"; - break; - case "artist": - if (data.length) { - presenceData.details = "Viewing OST Artist"; - presenceData.state = trim( - document.querySelector('[aria-current="page"]')?.textContent - ); - } else presenceData.details = "Viewing Artist List"; - break; - case "producer": - if (data.length) { - presenceData.details = "Viewing Anime Producer"; - presenceData.state = trim( - document.querySelector('[aria-current="page"]')?.textContent - ); - } else presenceData.details = "Viewing Anime Producer List"; - break; - case "studio": - if (data.length) { - presenceData.details = "Viewing Anime Studio"; - presenceData.state = trim( - document.querySelector('[aria-current="page"]')?.textContent - ); - } else presenceData.details = "Viewing Anime Studio List"; - break; - default: - presenceData.details = "Viewing Homepage"; - } + switch (base) { + case 'batch': + presenceData.details = 'Viewing Anime Batch List' + break + case 'movie': + presenceData.details = 'Viewing Anime Movie List' + break + case 'schedule': + presenceData.details = 'Viewing Anime Schedule List' + break + case 'anime': + if (data.length) { + presenceData.details = trim( + document.querySelector('[aria-current=\'page\']') + ?.previousElementSibling + ?.textContent + ?? document + .querySelector('h5[class=\'Content__title\']') + ?.textContent + ?.replace( + /(Episode \d+)|(Subtitle Indonesia)/g, + '', + ), + ) + presenceData.state = document.querySelector('[aria-current="page"]')?.textContent + ?? document + .querySelector('h5[class="Content__title"]') + ?.textContent + ?.match(/Episode \d+/g)?.[0] + } + else { + presenceData.details = 'Viewing Anime List' + } + break + case 'ost': + if (data.length) { + const [title, artist] = [ + ...document.querySelectorAll( + '.Content__description-caption > .form-row > div', + ), + ] + .map((x, i) => (i % 2 === 1 ? x : null)) + .filter(Boolean) + .splice(0, 2) + .map(x => + x?.textContent?.replace(/ /g, '').split('\n').join(' ').trim(), + ) + presenceData.details = title && title.split(' ').length > 1 ? title.split(' ')[1] : title + presenceData.state = artist + } + else { + presenceData.details = 'Viewing Anime OST List' + } + break + case 'genre': + if (data.length) { + presenceData.details = 'Viewing Anime Genre' + presenceData.state = trim( + document.querySelector('[aria-current="page"]')?.textContent, + ) + } + else { + presenceData.details = 'Viewing Anime Genre List' + } + break + case 'season': + if (data.length) { + presenceData.details = 'Viewing Anime Season' + presenceData.state = trim( + document.querySelector('[aria-current="page"]')?.textContent, + ) + } + else { + presenceData.details = 'Viewing Anime Season List' + } + break + case 'artist': + if (data.length) { + presenceData.details = 'Viewing OST Artist' + presenceData.state = trim( + document.querySelector('[aria-current="page"]')?.textContent, + ) + } + else { + presenceData.details = 'Viewing Artist List' + } + break + case 'producer': + if (data.length) { + presenceData.details = 'Viewing Anime Producer' + presenceData.state = trim( + document.querySelector('[aria-current="page"]')?.textContent, + ) + } + else { + presenceData.details = 'Viewing Anime Producer List' + } + break + case 'studio': + if (data.length) { + presenceData.details = 'Viewing Anime Studio' + presenceData.state = trim( + document.querySelector('[aria-current="page"]')?.textContent, + ) + } + else { + presenceData.details = 'Viewing Anime Studio List' + } + break + default: + presenceData.details = 'Viewing Homepage' + } - presenceData.buttons = [ - { - label: data.length - ? base === "anime" - ? "View Anime" - : base === "ost" - ? "View OST" - : "Visit Doronime" - : "Visit Doronime", - url: href, - }, - ]; - presence.setActivity(presenceData); -}); + presenceData.buttons = [ + { + label: data.length + ? base === 'anime' + ? 'View Anime' + : base === 'ost' + ? 'View OST' + : 'Visit Doronime' + : 'Visit Doronime', + url: href, + }, + ] + presence.setActivity(presenceData) +}) diff --git a/websites/D/Downdetector/metadata.json b/websites/D/Downdetector/metadata.json index bf2a0639e0b6..dd48f1b3c0b6 100644 --- a/websites/D/Downdetector/metadata.json +++ b/websites/D/Downdetector/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "NMW03", - "id": "534099893979971584" - }, - "service": "Downdetector", - "description": { - "en": "Real-time problem & outage monitoring", - "nl": "Real-time probleem- en uitvalbewaking" - }, - "url": "downdetector.com", - "version": "1.2.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Downdetector/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Downdetector/assets/thumbnail.png", - "color": "#FF160A", - "category": "other", - "tags": [ - "status", - "monitoring" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "NMW03", + "id": "534099893979971584" + }, + "service": "Downdetector", + "description": { + "en": "Real-time problem & outage monitoring", + "nl": "Real-time probleem- en uitvalbewaking" + }, + "url": "downdetector.com", + "version": "1.2.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Downdetector/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Downdetector/assets/thumbnail.png", + "color": "#FF160A", + "category": "other", + "tags": [ + "status", + "monitoring" + ] +} diff --git a/websites/D/Downdetector/presence.ts b/websites/D/Downdetector/presence.ts index 598b9221e9b9..e38825acbfa9 100644 --- a/websites/D/Downdetector/presence.ts +++ b/websites/D/Downdetector/presence.ts @@ -1,63 +1,71 @@ const presence = new Presence({ - clientId: "656574682916585473", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '656574682916585473', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) function decodeReq(entity: Element): string { - const txt = document.createElement("textarea"); - txt.textContent = entity.textContent; - return txt.textContent; + const txt = document.createElement('textarea') + txt.textContent = entity.textContent + return txt.textContent! } -let title; +let title -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Downdetector/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Downdetector/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (document.location.pathname.startsWith("/search/")) { - presenceData.details = "Searching for:"; - [, presenceData.state] = document.location.href.split("?q="); - presenceData.smallImageKey = Assets.Search; - } else if (document.location.pathname.includes("/archive/")) { - presenceData.details = "Viewing an archive for:"; - title = document.querySelector( - "body > div.container.px-3.px-md-0 > nav > ol > li.breadcrumb-item.active > a" - ); - presenceData.state = decodeReq(title); - } else if (document.location.pathname.includes("/news/")) { - presenceData.details = "Viewing a status overview for:"; - title = document.querySelector( - "body > div.container.px-3.px-md-0 > nav > ol > li:nth-child(2) > a" - ); - presenceData.state = decodeReq(title); - } else if (document.location.pathname.includes("/map/")) { - presenceData.details = "Viewing outage map for:"; - [title] = document.title.split("outage"); - presenceData.state = title; - } else if (document.location.pathname.includes("/status/")) { - presenceData.details = "Viewing a status for:"; - title = document.querySelector( - "body > div.container.px-3.px-md-0 > div.mx-auto > nav > ol > li.breadcrumb-item.active" - ); - presenceData.state = decodeReq(title); - } else if (document.location.pathname.includes("/companies/")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Companies"; - } else if (document.location.pathname.includes("/privacy")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Privacy Policy"; - } else if (document.location.pathname.includes("/terms-of-use")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Terms of Use"; - } else if (document.location.pathname.includes("/accessibility")) { - presenceData.details = "Viewing a page:"; - presenceData.state = "Accessibility Statement"; - } + if (document.location.pathname.startsWith('/search/')) { + presenceData.details = 'Searching for:'; + [, presenceData.state] = document.location.href.split('?q=') + presenceData.smallImageKey = Assets.Search + } + else if (document.location.pathname.includes('/archive/')) { + presenceData.details = 'Viewing an archive for:' + title = document.querySelector( + 'body > div.container.px-3.px-md-0 > nav > ol > li.breadcrumb-item.active > a', + ) + presenceData.state = decodeReq(title!) + } + else if (document.location.pathname.includes('/news/')) { + presenceData.details = 'Viewing a status overview for:' + title = document.querySelector( + 'body > div.container.px-3.px-md-0 > nav > ol > li:nth-child(2) > a', + ) + presenceData.state = decodeReq(title!) + } + else if (document.location.pathname.includes('/map/')) { + presenceData.details = 'Viewing outage map for:'; + [title] = document.title.split('outage') + presenceData.state = title + } + else if (document.location.pathname.includes('/status/')) { + presenceData.details = 'Viewing a status for:' + title = document.querySelector( + 'body > div.container.px-3.px-md-0 > div.mx-auto > nav > ol > li.breadcrumb-item.active', + ) + presenceData.state = decodeReq(title!) + } + else if (document.location.pathname.includes('/companies/')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Companies' + } + else if (document.location.pathname.includes('/privacy')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Privacy Policy' + } + else if (document.location.pathname.includes('/terms-of-use')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Terms of Use' + } + else if (document.location.pathname.includes('/accessibility')) { + presenceData.details = 'Viewing a page:' + presenceData.state = 'Accessibility Statement' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Drama/metadata.json b/websites/D/Drama/metadata.json index e8959eba7427..9f318bac7207 100644 --- a/websites/D/Drama/metadata.json +++ b/websites/D/Drama/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Toki", - "id": "401067750354845727" - }, - "service": "Drama", - "description": { - "en": "Drama.gg is a community for exposing fraudulent companies and businesses." - }, - "url": "drama.gg", - "version": "1.0.18", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Drama/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Drama/assets/thumbnail.png", - "color": "#32f597", - "category": "socials", - "tags": [ - "forum", - "social", - "drama" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Toki", + "id": "401067750354845727" + }, + "service": "Drama", + "description": { + "en": "Drama.gg is a community for exposing fraudulent companies and businesses." + }, + "url": "drama.gg", + "version": "1.0.18", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Drama/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Drama/assets/thumbnail.png", + "color": "#32f597", + "category": "socials", + "tags": [ + "forum", + "social", + "drama" + ] +} diff --git a/websites/D/Drama/presence.ts b/websites/D/Drama/presence.ts index ce6e10245253..e326fbb73473 100644 --- a/websites/D/Drama/presence.ts +++ b/websites/D/Drama/presence.ts @@ -1,93 +1,93 @@ const presence = new Presence({ - clientId: "852245069984825394", -}); + clientId: '852245069984825394', +}) -presence.on("UpdateData", () => { - const presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/D/Drama/assets/logo.png", - smallImageKey: Assets.Search, - smallImageText: "Looking for a thread", - details: "Looking for drama!", - state: "Browsing", - }; +presence.on('UpdateData', () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Drama/assets/logo.png', + smallImageKey: Assets.Search, + smallImageText: 'Looking for a thread', + details: 'Looking for drama!', + state: 'Browsing', + } - switch (true) { - case document.location.pathname.includes("/d/"): - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Drama/assets/logo.png"; - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Reading a thread"; - presenceData.details = `Viewing Thread: ${ - document.querySelector("h2.DiscussionHero-title").textContent - }`; - presenceData.state = `${ - document.querySelector("span.Scrubber-index").textContent - } / ${document.querySelector("span.Scrubber-count").textContent} Posts`; - presenceData.buttons = [ - { - label: "View Post", - url: `${document.URL}`, - }, - ]; - break; - case document.location.pathname.includes("/u/"): - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Viewing a profile"; - presenceData.details = `Viewing Profile: ${document.URL.split("/")[4]}`; - presenceData.state = `Posts: ${ - document.querySelector("span.Button-badge").textContent - } `; - break; - case document.location.pathname.includes("/meta"): - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Looking for a thread"; - presenceData.details = "Looking for drama!"; - presenceData.state = "Looking at meta threads"; - break; - case document.location.pathname.includes("/resolved"): - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Looking for a thread"; - presenceData.details = "Looking for drama!"; - presenceData.state = "Looking at resolved threads"; - break; - case document.location.pathname.includes("/confirmed"): - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Looking for a thread"; - presenceData.details = "Looking for drama!"; - presenceData.state = "Looking at confirmed threads"; - break; - case document.location.pathname.includes("/discussion"): - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Looking for a thread"; - presenceData.details = "Looking for drama!"; - presenceData.state = "Looking at discussions"; - break; - case document.location.pathname.includes("/users"): - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Looking at all users"; - presenceData.details = "Looking for drama!"; - presenceData.state = "Looking at all users"; - break; - case document.location.pathname.includes("/trinkets"): - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Looking at trinkets"; - presenceData.details = "Looking for drama!"; - presenceData.state = "Looking at trinkets"; - break; - case document.querySelector("div.Composer.visible") !== null: - presenceData.smallImageKey = Assets.Reading; - presenceData.smallImageText = "Writing a thread"; - presenceData.details = "Starting some drama!"; - presenceData.state = "Writing a post"; - break; - default: - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Looking for a thread"; - presenceData.details = "Looking for drama!"; - presenceData.state = "Browsing"; - break; - } + switch (true) { + case document.location.pathname.includes('/d/'): + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Drama/assets/logo.png' + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Reading a thread' + presenceData.details = `Viewing Thread: ${ + document.querySelector('h2.DiscussionHero-title')?.textContent + }` + presenceData.state = `${ + document.querySelector('span.Scrubber-index')?.textContent + } / ${document.querySelector('span.Scrubber-count')?.textContent} Posts` + presenceData.buttons = [ + { + label: 'View Post', + url: `${document.URL}`, + }, + ] + break + case document.location.pathname.includes('/u/'): + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Viewing a profile' + presenceData.details = `Viewing Profile: ${document.URL.split('/')[4]}` + presenceData.state = `Posts: ${ + document.querySelector('span.Button-badge')?.textContent + } ` + break + case document.location.pathname.includes('/meta'): + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Looking for a thread' + presenceData.details = 'Looking for drama!' + presenceData.state = 'Looking at meta threads' + break + case document.location.pathname.includes('/resolved'): + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Looking for a thread' + presenceData.details = 'Looking for drama!' + presenceData.state = 'Looking at resolved threads' + break + case document.location.pathname.includes('/confirmed'): + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Looking for a thread' + presenceData.details = 'Looking for drama!' + presenceData.state = 'Looking at confirmed threads' + break + case document.location.pathname.includes('/discussion'): + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Looking for a thread' + presenceData.details = 'Looking for drama!' + presenceData.state = 'Looking at discussions' + break + case document.location.pathname.includes('/users'): + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Looking at all users' + presenceData.details = 'Looking for drama!' + presenceData.state = 'Looking at all users' + break + case document.location.pathname.includes('/trinkets'): + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Looking at trinkets' + presenceData.details = 'Looking for drama!' + presenceData.state = 'Looking at trinkets' + break + case document.querySelector('div.Composer.visible') !== null: + presenceData.smallImageKey = Assets.Reading + presenceData.smallImageText = 'Writing a thread' + presenceData.details = 'Starting some drama!' + presenceData.state = 'Writing a post' + break + default: + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Looking for a thread' + presenceData.details = 'Looking for drama!' + presenceData.state = 'Browsing' + break + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/DramaCool/iframe.ts b/websites/D/DramaCool/iframe.ts index aa5002b4a05b..514bd60a3055 100644 --- a/websites/D/DramaCool/iframe.ts +++ b/websites/D/DramaCool/iframe.ts @@ -1,17 +1,17 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", async () => { - if (document.querySelector("video")) { - const video: HTMLVideoElement = document.querySelector("video"); +iframe.on('UpdateData', async () => { + if (document.querySelector('video')) { + const video = document.querySelector('video') - if (video && !isNaN(video.duration)) { - iframe.send({ - iframeVideo: { - currentTime: video.currentTime, - duration: video.duration, - paused: video.paused, - }, - }); - } - } -}); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + iframeVideo: { + currentTime: video.currentTime, + duration: video.duration, + paused: video.paused, + }, + }) + } + } +}) diff --git a/websites/D/DramaCool/metadata.json b/websites/D/DramaCool/metadata.json index e6c3e345ea12..1c9100729170 100644 --- a/websites/D/DramaCool/metadata.json +++ b/websites/D/DramaCool/metadata.json @@ -1,38 +1,38 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Slowlife", - "id": "374905512661221377" - }, - "service": "DramaCool", - "description": { - "en": "Dramacool - Watch Asian Dramas, Movies and Shows with English Subtitles on Dramacool in Full HD For Free. A cool Site for Great Peoples.", - "nl": "Dramacool - Bekijk Aziatische drama's, films en shows met Engelse ondertiteling op Dramacool in Full HD Gratis. Een coole site voor grote mensen." - }, - "url": "dramacool.vc", - "regExp": "[0-9w]{0,6}.*dramacool.[a-z]+", - "version": "1.3.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DramaCool/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DramaCool/assets/thumbnail.png", - "color": "#26bdc6", - "category": "videos", - "tags": [ - "drama", - "movie" - ], - "iframe": true, - "iFrameRegExp": ".*", - "settings": [ - { - "id": "lang", - "multiLanguage": true - }, - { - "id": "buttons", - "title": "Show buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Slowlife", + "id": "374905512661221377" + }, + "service": "DramaCool", + "description": { + "en": "Dramacool - Watch Asian Dramas, Movies and Shows with English Subtitles on Dramacool in Full HD For Free. A cool Site for Great Peoples.", + "nl": "Dramacool - Bekijk Aziatische drama's, films en shows met Engelse ondertiteling op Dramacool in Full HD Gratis. Een coole site voor grote mensen." + }, + "url": "dramacool.vc", + "regExp": "[0-9w]{0,6}.*dramacool.[a-z]+", + "version": "1.3.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DramaCool/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DramaCool/assets/thumbnail.png", + "color": "#26bdc6", + "category": "videos", + "tags": [ + "drama", + "movie" + ], + "iframe": true, + "iFrameRegExp": ".*", + "settings": [ + { + "id": "lang", + "multiLanguage": true + }, + { + "id": "buttons", + "title": "Show buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/D/DramaCool/presence.ts b/websites/D/DramaCool/presence.ts index cfa52beb23f1..4cdb5ff2e96e 100644 --- a/websites/D/DramaCool/presence.ts +++ b/websites/D/DramaCool/presence.ts @@ -1,167 +1,171 @@ const presence = new Presence({ - clientId: "813038241451343882", - }), - startsTime = Math.floor(Date.now() / 1000), - ShowData = { - title: "", - ep: "", - duration: 0, - currentTime: 0, - paused: true, - }, - getStrings = async () => - presence.getStrings( - { - play: "general.playing", - paused: "general.paused", - browse: "general.browsing", - episode: "general.episode", - searchFor: "general.searchFor", - searching: "general.search", - viewSeriesButton: "general.buttonViewSeries", - viewEpisode: "general.buttonViewEpisode", - viewSeries: "general.viewSeries", - reading: "general.reading", - viewPage: "general.viewPage", - }, - await presence.getSetting("lang").catch(() => "en") - ); -let strings: Awaited>, - oldLang: string = null; - -presence.on("iFrameData", (data: Data) => { - ShowData.duration = data.iframeVideo.duration; - ShowData.paused = data.iframeVideo.paused; - ShowData.currentTime = data.iframeVideo.currentTime; -}); - -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DramaCool/assets/logo.png", - details: "Browsing", - smallImageText: "Browsing", - smallImageKey: Assets.Reading, - startTimestamp: startsTime, - type: ActivityType.Watching, - }, - [buttons, newLang] = await Promise.all([ - presence.getSetting("buttons"), - presence.getSetting("lang").catch(() => "en"), - ]), - { pathname, search, href } = document.location; - - if (oldLang !== newLang || !strings) { - oldLang = newLang; - strings = await getStrings(); - } - - if (pathname.includes("/drama-detail")) { - presenceData.smallImageText = strings.reading; - - presenceData.details = strings.viewSeries; - presenceData.state = document.querySelector("h1").textContent; - - presenceData.buttons = [ - { - label: strings.viewSeriesButton, - url: document.URL, - }, - ]; - } else if (pathname.includes("/search")) { - presenceData.details = strings.searchFor; - presenceData.state = search.includes("movies") ? "Movies" : "Stars"; - - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = strings.searching; - } else if (pathname.match("/([a-z0-9-]+)-episode-([0-9]+)")) { - ShowData.title = - document.querySelector("div.category a")?.textContent ?? - JSON.parse( - document - .querySelector('[class="yoast-schema-graph"]') - .innerHTML.replace(/@/gm, "") - ).graph[3].itemListElement[1].name.replace(/Episode [0-9]*/gm, ""); - if (ShowData.duration) { - ShowData.ep = (document.title.match( - /Episode ?([1-9][0-9]?[0-9]?)?( & )?([1-9][0-9]?[0-9]?)/g - ) || document.URL.match(/episode-?([1-9][0-9]?[0-9]?)/g))[0].replace( - /(episode)(-)?/i, - "" - ); - - presenceData.smallImageKey = ShowData.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = ShowData.paused - ? strings.paused - : strings.play; - - presenceData.details = ShowData.title; - presenceData.state = `${strings.episode} ${ShowData.ep}`; - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(ShowData.currentTime, ShowData.duration); - - presenceData.buttons = [ - { - label: strings.viewEpisode, - url: href, - }, - { - label: strings.viewSeriesButton, - url: document.querySelector(".category a").href, - }, - ]; - - if (ShowData.paused) { - delete presenceData.startTimestamp; - delete presenceData.endTimestamp; - } - } else if (ShowData.title) { - presenceData.smallImageText = strings.reading; - - presenceData.details = strings.viewSeries; - presenceData.state = ShowData.title; - - presenceData.buttons = [ - { - label: strings.viewSeriesButton, - url: document.URL, - }, - ]; - } - } else if (pathname.includes("movie-watch")) { - presenceData.details = - document.querySelector("div.category a")?.textContent; - presenceData.state = "Movie"; - - presenceData.smallImageKey = ShowData.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = ShowData.paused - ? strings.paused - : strings.play; - - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(ShowData.currentTime, ShowData.duration); - } else if (pathname.includes("/calendar")) { - presenceData.details = strings.viewPage; - - presenceData.state = "Calendar"; - presenceData.buttons = [ - { - label: "View Calendar", - url: document.URL, - }, - ]; - } - - if (!buttons && presenceData.buttons) delete presenceData.buttons; - - presence.setActivity(presenceData); -}); + clientId: '813038241451343882', +}) +const startsTime = Math.floor(Date.now() / 1000) +const ShowData = { + title: '', + ep: '', + duration: 0, + currentTime: 0, + paused: true, +} +async function getStrings() { + return presence.getStrings( + { + play: 'general.playing', + paused: 'general.paused', + browse: 'general.browsing', + episode: 'general.episode', + searchFor: 'general.searchFor', + searching: 'general.search', + viewSeriesButton: 'general.buttonViewSeries', + viewEpisode: 'general.buttonViewEpisode', + viewSeries: 'general.viewSeries', + reading: 'general.reading', + viewPage: 'general.viewPage', + }, + await presence.getSetting('lang').catch(() => 'en'), + ) +} +let strings: Awaited> +let oldLang: string | null = null + +presence.on('iFrameData', (inc: unknown) => { + const data = inc as Data + ShowData.duration = data.iframeVideo.duration + ShowData.paused = data.iframeVideo.paused + ShowData.currentTime = data.iframeVideo.currentTime +}) + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DramaCool/assets/logo.png', + details: 'Browsing', + smallImageText: 'Browsing', + smallImageKey: Assets.Reading, + startTimestamp: startsTime, + type: ActivityType.Watching, + } + const [buttons, newLang] = await Promise.all([ + presence.getSetting('buttons'), + presence.getSetting('lang').catch(() => 'en'), + ]) + const { pathname, search, href } = document.location + + if (oldLang !== newLang || !strings) { + oldLang = newLang + strings = await getStrings() + } + + if (pathname.includes('/drama-detail')) { + presenceData.smallImageText = strings.reading + + presenceData.details = strings.viewSeries + presenceData.state = document.querySelector('h1')?.textContent + + presenceData.buttons = [ + { + label: strings.viewSeriesButton, + url: document.URL, + }, + ] + } + else if (pathname.includes('/search')) { + presenceData.details = strings.searchFor + presenceData.state = search.includes('movies') ? 'Movies' : 'Stars' + + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = strings.searching + } + else if (pathname.match('/([a-z0-9-]+)-episode-([0-9]+)')) { + ShowData.title = document.querySelector('div.category a')?.textContent + ?? JSON.parse( + document + .querySelector('[class="yoast-schema-graph"]') + ?.innerHTML + .replace(/@/g, '') ?? '{}', + ).graph[3].itemListElement[1].name.replace(/Episode \d*/g, '') + if (ShowData.duration) { + ShowData.ep = (document.title.match( + /Episode ?([1-9]\d{0,2})?( & )?([1-9]\d{0,2})/g, + ) || document.URL.match(/episode-?([1-9]\d{0,2})/g))![0].replace( + /(episode)(-)?/i, + '', + ) + + presenceData.smallImageKey = ShowData.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = ShowData.paused + ? strings.paused + : strings.play + + presenceData.details = ShowData.title + presenceData.state = `${strings.episode} ${ShowData.ep}`; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(ShowData.currentTime, ShowData.duration) + + presenceData.buttons = [ + { + label: strings.viewEpisode, + url: href, + }, + { + label: strings.viewSeriesButton, + url: document.querySelector('.category a')!.href, + }, + ] + + if (ShowData.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + } + else if (ShowData.title) { + presenceData.smallImageText = strings.reading + + presenceData.details = strings.viewSeries + presenceData.state = ShowData.title + + presenceData.buttons = [ + { + label: strings.viewSeriesButton, + url: document.URL, + }, + ] + } + } + else if (pathname.includes('movie-watch')) { + presenceData.details = document.querySelector('div.category a')?.textContent + presenceData.state = 'Movie' + + presenceData.smallImageKey = ShowData.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = ShowData.paused + ? strings.paused + : strings.play; + + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(ShowData.currentTime, ShowData.duration) + } + else if (pathname.includes('/calendar')) { + presenceData.details = strings.viewPage + + presenceData.state = 'Calendar' + presenceData.buttons = [ + { + label: 'View Calendar', + url: document.URL, + }, + ] + } + + if (!buttons && presenceData.buttons) + delete presenceData.buttons + + presence.setActivity(presenceData) +}) interface Data { - iframeVideo: { - currentTime: number; - paused: boolean; - duration: number; - }; + iframeVideo: { + currentTime: number + paused: boolean + duration: number + } } diff --git a/websites/D/Dribbble/metadata.json b/websites/D/Dribbble/metadata.json index b317b5df3225..5204a9691747 100644 --- a/websites/D/Dribbble/metadata.json +++ b/websites/D/Dribbble/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "B.N", - "id": "259669086160551937" - }, - "service": "Dribbble", - "description": { - "en": "Dribbble is where designers gain inspiration, feedback, community, and jobs and is your best resource to discover and connect with designers worldwide." - }, - "url": "dribbble.com", - "version": "1.0.15", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dribbble/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dribbble/assets/thumbnail.png", - "color": "#ea4c89", - "category": "other", - "tags": [ - "design", - "debdesign", - "branding", - "illustration", - "print", - "typography", - "animation" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "B.N", + "id": "259669086160551937" + }, + "service": "Dribbble", + "description": { + "en": "Dribbble is where designers gain inspiration, feedback, community, and jobs and is your best resource to discover and connect with designers worldwide." + }, + "url": "dribbble.com", + "version": "1.0.15", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dribbble/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dribbble/assets/thumbnail.png", + "color": "#ea4c89", + "category": "other", + "tags": [ + "design", + "debdesign", + "branding", + "illustration", + "print", + "typography", + "animation" + ] +} diff --git a/websites/D/Dribbble/presence.ts b/websites/D/Dribbble/presence.ts index 9794e9aea629..872875c88344 100644 --- a/websites/D/Dribbble/presence.ts +++ b/websites/D/Dribbble/presence.ts @@ -1,76 +1,90 @@ const presence = new Presence({ - clientId: "908758869470216203", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '908758869470216203', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - state: "All shots", - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Dribbble/assets/logo.png", - startTimestamp: browsingTimestamp, - }, - shotsTypes = (type: string) => { - if (document.location.pathname.includes("/animation")) - presenceData.state = `${type} Shots - Animation`; - else if (document.location.pathname.includes("/branding")) - presenceData.state = `${type} Shots - Branding`; - else if (document.location.pathname.includes("/illustration")) - presenceData.state = `${type} Shots - Illustration`; - else if (document.location.pathname.includes("/mobile")) - presenceData.state = `${type} Shots - Mobile`; - else if (document.location.pathname.includes("/print")) - presenceData.state = `${type} Shots - Print`; - else if (document.location.pathname.includes("/product-design")) - presenceData.state = `${type} Shots - Product Design`; - else if (document.location.pathname.includes("/typography")) - presenceData.state = `${type} Shots - Typography`; - else if (document.location.pathname.includes("/web-design")) - presenceData.state = `${type} Shots - Web Design`; - else presenceData.state = `All ${type} Shots`; - }, - search = (type: string) => { - presenceData.details = `Search : "${ - document.querySelector( - "body > div#wrap > div.search-header > div.search-results-details > h1" - )?.textContent - }"`; - shotsTypes(type); - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + state: 'All shots', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Dribbble/assets/logo.png', + startTimestamp: browsingTimestamp, + } + const shotsTypes = (type: string) => { + if (document.location.pathname.includes('/animation')) + presenceData.state = `${type} Shots - Animation` + else if (document.location.pathname.includes('/branding')) + presenceData.state = `${type} Shots - Branding` + else if (document.location.pathname.includes('/illustration')) + presenceData.state = `${type} Shots - Illustration` + else if (document.location.pathname.includes('/mobile')) + presenceData.state = `${type} Shots - Mobile` + else if (document.location.pathname.includes('/print')) + presenceData.state = `${type} Shots - Print` + else if (document.location.pathname.includes('/product-design')) + presenceData.state = `${type} Shots - Product Design` + else if (document.location.pathname.includes('/typography')) + presenceData.state = `${type} Shots - Typography` + else if (document.location.pathname.includes('/web-design')) + presenceData.state = `${type} Shots - Web Design` + else presenceData.state = `All ${type} Shots` + } + const search = (type: string) => { + presenceData.details = `Search : "${ + document.querySelector( + 'body > div#wrap > div.search-header > div.search-results-details > h1', + )?.textContent + }"` + shotsTypes(type) + } - if (document.location.pathname.includes("/following")) { - if (document.location.pathname.includes("/search")) search("following"); - else { - presenceData.details = "Viewing page :"; - shotsTypes("following"); - } - } else if (document.location.pathname.includes("/popular")) { - if (document.location.pathname.includes("/search")) search("popular"); - else { - presenceData.details = "Viewing page :"; - shotsTypes("popular"); - } - } else if (document.location.pathname.includes("/recent")) { - if (document.location.pathname.includes("/search")) search("recent"); - else { - presenceData.details = "Viewing page :"; - shotsTypes("recent"); - } - } else if (document.location.pathname.includes("/search")) search(""); - else if (document.body.id === "profile") { - // view a profile + if (document.location.pathname.includes('/following')) { + if (document.location.pathname.includes('/search')) { + search('following') + } + else { + presenceData.details = 'Viewing page :' + shotsTypes('following') + } + } + else if (document.location.pathname.includes('/popular')) { + if (document.location.pathname.includes('/search')) { + search('popular') + } + else { + presenceData.details = 'Viewing page :' + shotsTypes('popular') + } + } + else if (document.location.pathname.includes('/recent')) { + if (document.location.pathname.includes('/search')) { + search('recent') + } + else { + presenceData.details = 'Viewing page :' + shotsTypes('recent') + } + } + else if (document.location.pathname.includes('/search')) { + search('') + } + else if (document.body.id === 'profile') { + // view a profile - presenceData.details = "Viewing profile :"; - presenceData.state = `- ${document.location.pathname.split("/")[1]} -`; - } else presenceData.details = "Homepage"; + presenceData.details = 'Viewing profile :' + presenceData.state = `- ${document.location.pathname.split('/')[1]} -` + } + else { + presenceData.details = 'Homepage' + } - if (document.body.id === "user-profile") { - // view personal profile + if (document.body.id === 'user-profile') { + // view personal profile - presenceData.details = "Viewing personal profile :"; - presenceData.state = `- ${document.location.pathname.split("/")[1]} -`; - } + presenceData.details = 'Viewing personal profile :' + presenceData.state = `- ${document.location.pathname.split('/')[1]} -` + } - if (!presenceData.details) presence.setActivity(); - else presence.setActivity(presenceData); -}); + if (!presenceData.details) + presence.setActivity() + else presence.setActivity(presenceData) +}) diff --git a/websites/D/Dropbox/metadata.json b/websites/D/Dropbox/metadata.json index 7364120893e2..a6a5ce9e574b 100644 --- a/websites/D/Dropbox/metadata.json +++ b/websites/D/Dropbox/metadata.json @@ -1,35 +1,35 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "MrBartusek", - "id": "212988300137463809" - }, - "service": "Dropbox", - "description": { - "en": "Dropbox is a file hosting service operated by the American company Dropbox, Inc., headquartered in San Francisco, California, that offers cloud storage, file synchronization, personal cloud, and client software.", - "pl": "Dropbox to usługa świadczona przez Dropbox, Inc. polegająca na udostępnieniu przestrzeni dyskowej na serwerach tej firmy. Wysyłanie, przeglądanie i pobieranie danych jest możliwe poprzez zwykłą przeglądarkę lub poprzez dedykowaną aplikację zainstalowaną na komputerze.", - "nl": "Dropbox is een dienst voor het hosten van bestanden die wordt geëxploiteerd door het Amerikaanse bedrijf Dropbox, Inc., met hoofdkantoor in San Francisco, Californië, dat cloudopslag, bestandssynchronisatie, een persoonlijke cloud en clientsoftware biedt." - }, - "url": [ - "www.dropbox.com", - "showcase.dropbox.com" - ], - "version": "1.0.19", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dropbox/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dropbox/assets/thumbnail.png", - "color": "#0062ff", - "category": "other", - "tags": [ - "drive", - "storage" - ], - "settings": [ - { - "id": "showFileNames", - "title": "Show File Names", - "icon": "fas fa-file", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "MrBartusek", + "id": "212988300137463809" + }, + "service": "Dropbox", + "description": { + "en": "Dropbox is a file hosting service operated by the American company Dropbox, Inc., headquartered in San Francisco, California, that offers cloud storage, file synchronization, personal cloud, and client software.", + "pl": "Dropbox to usługa świadczona przez Dropbox, Inc. polegająca na udostępnieniu przestrzeni dyskowej na serwerach tej firmy. Wysyłanie, przeglądanie i pobieranie danych jest możliwe poprzez zwykłą przeglądarkę lub poprzez dedykowaną aplikację zainstalowaną na komputerze.", + "nl": "Dropbox is een dienst voor het hosten van bestanden die wordt geëxploiteerd door het Amerikaanse bedrijf Dropbox, Inc., met hoofdkantoor in San Francisco, Californië, dat cloudopslag, bestandssynchronisatie, een persoonlijke cloud en clientsoftware biedt." + }, + "url": [ + "www.dropbox.com", + "showcase.dropbox.com" + ], + "version": "1.0.19", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dropbox/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dropbox/assets/thumbnail.png", + "color": "#0062ff", + "category": "other", + "tags": [ + "drive", + "storage" + ], + "settings": [ + { + "id": "showFileNames", + "title": "Show File Names", + "icon": "fas fa-file", + "value": true + } + ] +} diff --git a/websites/D/Dropbox/presence.ts b/websites/D/Dropbox/presence.ts index ecb0588089ac..38f130ac72d4 100644 --- a/websites/D/Dropbox/presence.ts +++ b/websites/D/Dropbox/presence.ts @@ -1,62 +1,78 @@ const presence = new Presence({ - clientId: "777578842172162068", -}); + clientId: '777578842172162068', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Dropbox/assets/logo.png", - }, - showFileNames = await presence.getSetting("showFileNames"); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Dropbox/assets/logo.png', + } + const showFileNames = await presence.getSetting('showFileNames') - if (document.location.pathname === "/") - presenceData.details = "Viewing homepage"; - else if (document.location.pathname.startsWith("/login")) - presenceData.details = "Logging-in"; - else if (document.location.pathname.startsWith("/plans")) - presenceData.details = "Choosing new plan"; - else if (document.location.search.startsWith("?preview")) { - presenceData.details = "Previewing a file"; - if (showFileNames) { - presenceData.state = - document.querySelector(".filename--text").textContent; - } - } else if ( - document.location.pathname.startsWith("/h") || - document.location.pathname.startsWith("/home") - ) { - const currentFolder = document.querySelector(".page-header-text > h2"); - if (currentFolder) { - presenceData.details = "Viewing folder"; - if (showFileNames) presenceData.state = currentFolder.textContent; - } else { - presenceData.details = "Browsing files"; - presenceData.state = "All files"; - } - } else if (document.location.pathname.startsWith("/share")) { - presenceData.details = "Browsing files"; - presenceData.state = "Shared files"; - } else if (document.location.pathname.startsWith("/request")) { - presenceData.details = "Browsing files"; - presenceData.state = "File requests"; - } else if (document.location.pathname.startsWith("/deleted_files")) { - presenceData.details = "Browsing files"; - presenceData.state = "Deleted files"; - } else if (document.location.pathname.startsWith("/account")) - presenceData.details = "Changing account settings"; - else if (document.location.pathname.startsWith("/transfer")) - presenceData.details = "Dropbox Transfer"; - else if (document.location.pathname.startsWith("/paper")) - presenceData.details = "Dropbox Paper"; - else if (document.location.pathname.startsWith("/scl")) { - presenceData.details = "Working on paper"; - presenceData.startTimestamp = Math.floor(Date.now() / 1000); - if (showFileNames) presenceData.state = document.title; - } else if (document.location.pathname.startsWith("/landing/hellosign")) - presenceData.details = "Dropbox HelloSign"; - else if (document.location.pathname.startsWith("/apps")) - presenceData.details = "Browsing AppStore"; + if (document.location.pathname === '/') { + presenceData.details = 'Viewing homepage' + } + else if (document.location.pathname.startsWith('/login')) { + presenceData.details = 'Logging-in' + } + else if (document.location.pathname.startsWith('/plans')) { + presenceData.details = 'Choosing new plan' + } + else if (document.location.search.startsWith('?preview')) { + presenceData.details = 'Previewing a file' + if (showFileNames) { + presenceData.state = document.querySelector('.filename--text')?.textContent + } + } + else if ( + document.location.pathname.startsWith('/h') + || document.location.pathname.startsWith('/home') + ) { + const currentFolder = document.querySelector('.page-header-text > h2') + if (currentFolder) { + presenceData.details = 'Viewing folder' + if (showFileNames) + presenceData.state = currentFolder.textContent + } + else { + presenceData.details = 'Browsing files' + presenceData.state = 'All files' + } + } + else if (document.location.pathname.startsWith('/share')) { + presenceData.details = 'Browsing files' + presenceData.state = 'Shared files' + } + else if (document.location.pathname.startsWith('/request')) { + presenceData.details = 'Browsing files' + presenceData.state = 'File requests' + } + else if (document.location.pathname.startsWith('/deleted_files')) { + presenceData.details = 'Browsing files' + presenceData.state = 'Deleted files' + } + else if (document.location.pathname.startsWith('/account')) { + presenceData.details = 'Changing account settings' + } + else if (document.location.pathname.startsWith('/transfer')) { + presenceData.details = 'Dropbox Transfer' + } + else if (document.location.pathname.startsWith('/paper')) { + presenceData.details = 'Dropbox Paper' + } + else if (document.location.pathname.startsWith('/scl')) { + presenceData.details = 'Working on paper' + presenceData.startTimestamp = Math.floor(Date.now() / 1000) + if (showFileNames) + presenceData.state = document.title + } + else if (document.location.pathname.startsWith('/landing/hellosign')) { + presenceData.details = 'Dropbox HelloSign' + } + else if (document.location.pathname.startsWith('/apps')) { + presenceData.details = 'Browsing AppStore' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Dropout/iframe.ts b/websites/D/Dropout/iframe.ts index 6290076c9ba8..773e5e1af554 100644 --- a/websites/D/Dropout/iframe.ts +++ b/websites/D/Dropout/iframe.ts @@ -1,13 +1,13 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -iframe.on("UpdateData", async () => { - const video = document.querySelector("video"); +iframe.on('UpdateData', async () => { + const video = document.querySelector('video') - if (video && !isNaN(video.duration)) { - iframe.send({ - currentTime: video.currentTime, - duration: video.duration, - paused: video.paused, - }); - } -}); + if (video && !Number.isNaN(video.duration)) { + iframe.send({ + currentTime: video.currentTime, + duration: video.duration, + paused: video.paused, + }) + } +}) diff --git a/websites/D/Dropout/interfaces.ts b/websites/D/Dropout/interfaces.ts index b45747cba96c..9aa2d7bb1a70 100644 --- a/websites/D/Dropout/interfaces.ts +++ b/websites/D/Dropout/interfaces.ts @@ -1,9 +1,9 @@ export interface QueryParams { - [key: string]: string; + [key: string]: string } export interface IFrameData { - currentTime: number; - duration: number; - paused: boolean; + currentTime: number + duration: number + paused: boolean } diff --git a/websites/D/Dropout/metadata.json b/websites/D/Dropout/metadata.json index 7e64ff9516c2..16095af3b0d4 100644 --- a/websites/D/Dropout/metadata.json +++ b/websites/D/Dropout/metadata.json @@ -1,35 +1,35 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "189690228292845568", - "name": "angelolz" - }, - "service": "Dropout", - "description": { - "en": "Independent, ad-free, uncensored original comedies that you won't find anywhere else." - }, - "url": "dropout.tv", - "version": "1.0.6", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dropout/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dropout/assets/thumbnail.jpg", - "color": "#ffe93b", - "category": "videos", - "tags": [ - "video", - "streaming", - "media", - "dropout", - "collegehumor" - ], - "iframe": true, - "iFrameRegExp": "embed.vhx.tv", - "settings": [ - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fa-regular fa-rectangle-list", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "189690228292845568", + "name": "angelolz" + }, + "service": "Dropout", + "description": { + "en": "Independent, ad-free, uncensored original comedies that you won't find anywhere else." + }, + "url": "dropout.tv", + "version": "1.0.6", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dropout/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dropout/assets/thumbnail.jpg", + "color": "#ffe93b", + "category": "videos", + "tags": [ + "video", + "streaming", + "media", + "dropout", + "collegehumor" + ], + "iframe": true, + "iFrameRegExp": "embed.vhx.tv", + "settings": [ + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fa-regular fa-rectangle-list", + "value": true + } + ] +} diff --git a/websites/D/Dropout/presence.ts b/websites/D/Dropout/presence.ts index 8e7f94668d82..8297a07afdaa 100644 --- a/websites/D/Dropout/presence.ts +++ b/websites/D/Dropout/presence.ts @@ -1,198 +1,203 @@ -import { QueryParams, IFrameData } from "./interfaces"; +import type { IFrameData, QueryParams } from './interfaces' const presence = new Presence({ - clientId: "1240164154682249227", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1240164154682249227', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum PresenceAssets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Dropout/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Dropout/assets/logo.png', } -let duration: number, currentTime: number, paused: boolean, playback: boolean; - -presence.on("iFrameData", (data: IFrameData) => { - playback = data.duration ? true : false; - if (playback) ({ duration, currentTime, paused } = data); -}); - -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: PresenceAssets.Logo, - startTimestamp: browsingTimestamp, - }, - { pathname, href } = document.location, - showButtons = await presence.getSetting("buttons"); - - getDetails( - presenceData, - pathname.split("/").filter(Boolean), - showButtons, - href - ); - presence.setActivity(presenceData); -}); +let duration: number, currentTime: number, paused: boolean, playback: boolean + +presence.on('iFrameData', (inc: unknown) => { + const data = inc as IFrameData + playback = !!data.duration + if (playback) + ({ duration, currentTime, paused } = data) +}) + +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: PresenceAssets.Logo, + startTimestamp: browsingTimestamp, + } + const { pathname, href } = document.location + const showButtons = await presence.getSetting('buttons') + + getDetails( + presenceData, + pathname.split('/').filter(Boolean), + showButtons, + href, + ) + presence.setActivity(presenceData) +}) function getDetails( - presenceData: PresenceData, - path: string[], - showButtons: boolean, - href: string + presenceData: PresenceData, + path: string[], + showButtons: boolean, + href: string, ): void { - switch (path[0].toLowerCase()) { - case "browse": - presenceData.details = "Browsing home page"; - break; - case "continue-watching": - presenceData.details = "Browsing Continue Watching playlist"; - break; - case "my-list": - presenceData.details = "Browisng my list"; - break; - case "new-releases": - presenceData.details = "Browsing new releases"; - break; - case "recommended-new-shelf": - presenceData.details = "Browsing trending page"; - break; - case "series": - presenceData.details = "Browsing series"; - break; - case "search": - getSearchDetails(presenceData); - break; - default: - getVideoDetails(presenceData, showButtons, href); - } + switch (path[0].toLowerCase()) { + case 'browse': + presenceData.details = 'Browsing home page' + break + case 'continue-watching': + presenceData.details = 'Browsing Continue Watching playlist' + break + case 'my-list': + presenceData.details = 'Browisng my list' + break + case 'new-releases': + presenceData.details = 'Browsing new releases' + break + case 'recommended-new-shelf': + presenceData.details = 'Browsing trending page' + break + case 'series': + presenceData.details = 'Browsing series' + break + case 'search': + getSearchDetails(presenceData) + break + default: + getVideoDetails(presenceData, showButtons, href) + } } function getSearchDetails(presenceData: PresenceData): void { - presenceData.details = "Searching for:"; - presenceData.state = parseQueryParams().q || "..."; - presenceData.smallImageKey = Assets.Search; + presenceData.details = 'Searching for:' + presenceData.state = parseQueryParams().q || '...' + presenceData.smallImageKey = Assets.Search } function getVideoDetails( - presenceData: PresenceData, - showButtons: boolean, - href: string + presenceData: PresenceData, + showButtons: boolean, + href: string, ): void { - const mainSelector = "main > section > section > div > div > div", - seriesNameElement = document.querySelector(`${mainSelector} > h1`); - - if (seriesNameElement !== null) { - // Viewing a series - const selectElement = document.querySelector( - `${mainSelector} > form:nth-child(1) > select` - ); - presenceData.details = "Viewing a series"; - - if (selectElement === null) - presenceData.state = seriesNameElement.textContent.trim(); - else { - presenceData.state = `${seriesNameElement.textContent.trim()}: ${selectElement.options[ - selectElement.selectedIndex - ].textContent.trim()}`; - } - - if (showButtons) { - presenceData.buttons = [ - { - label: "View Series", - url: href, - }, - ]; - } - } else { - const videoNameElement = document.querySelector(".video-title"), - seriesLinkElement = - document.querySelector(".context-link"), - episodeElement = document.querySelector( - "#watch-info > div > div > div > div > div > h5 > a" - ); - - if (!videoNameElement) return; - presenceData.details = videoNameElement.textContent.trim(); - - if (!seriesLinkElement && !episodeElement) { - //no series name or episode indicator - if (showButtons) { - presenceData.buttons = [ - { - label: "Watch Video", - url: href, - }, - ]; - } - } else if (!seriesLinkElement && episodeElement) { - //no series, has episode indicator - presenceData.state = episodeElement.textContent.trim(); - - if (showButtons) { - presenceData.buttons = [ - { - label: "Watch Video", - url: href, - }, - { - label: "View Series", - url: episodeElement.getAttribute("href"), - }, - ]; - } - } else if (seriesLinkElement && episodeElement) { - //has series and episode indicator - const match = episodeElement.textContent.trim().match(/(\d+)[^\d]+(\d+)/); - - presenceData.state = seriesLinkElement.textContent.trim(); - - if (match) { - presenceData.details = `S${match[1]}E${ - match[2] - }: ${videoNameElement.textContent.trim()}`; - } - - if (showButtons) { - presenceData.buttons = [ - { - label: "Watch Episode", - url: href, - }, - { - label: "View Series", - url: seriesLinkElement.href, - }, - ]; - } - } - - setTimestamps(presenceData); - } + const mainSelector = 'main > section > section > div > div > div' + const seriesNameElement = document.querySelector(`${mainSelector} > h1`) + + if (seriesNameElement !== null) { + // Viewing a series + const selectElement = document.querySelector( + `${mainSelector} > form:nth-child(1) > select`, + ) + presenceData.details = 'Viewing a series' + + if (selectElement === null) { + presenceData.state = seriesNameElement.textContent?.trim() + } + else { + presenceData.state = `${seriesNameElement.textContent?.trim()}: ${selectElement.options[ + selectElement.selectedIndex + ].textContent?.trim()}` + } + + if (showButtons) { + presenceData.buttons = [ + { + label: 'View Series', + url: href, + }, + ] + } + } + else { + const videoNameElement = document.querySelector('.video-title') + const seriesLinkElement = document.querySelector('.context-link') + const episodeElement = document.querySelector( + '#watch-info > div > div > div > div > div > h5 > a', + ) + + if (!videoNameElement) + return + presenceData.details = videoNameElement.textContent?.trim() + + if (!seriesLinkElement && !episodeElement) { + // no series name or episode indicator + if (showButtons) { + presenceData.buttons = [ + { + label: 'Watch Video', + url: href, + }, + ] + } + } + else if (!seriesLinkElement && episodeElement) { + // no series, has episode indicator + presenceData.state = episodeElement.textContent?.trim() + + if (showButtons) { + presenceData.buttons = [ + { + label: 'Watch Video', + url: href, + }, + { + label: 'View Series', + url: episodeElement.getAttribute('href'), + }, + ] + } + } + else if (seriesLinkElement && episodeElement) { + // has series and episode indicator + const match = episodeElement.textContent?.trim().match(/(\d+)\D+(\d+)/) + + presenceData.state = seriesLinkElement.textContent?.trim() + + if (match) { + presenceData.details = `S${match[1]}E${ + match[2] + }: ${videoNameElement.textContent?.trim()}` + } + + if (showButtons) { + presenceData.buttons = [ + { + label: 'Watch Episode', + url: href, + }, + { + label: 'View Series', + url: seriesLinkElement.href, + }, + ] + } + } + + setTimestamps(presenceData) + } } function setTimestamps(presenceData: PresenceData): void { - delete presenceData.startTimestamp; - if (!paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps(currentTime, duration); - } - presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play; + delete presenceData.startTimestamp + if (!paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps(currentTime, duration) + } + presenceData.smallImageKey = paused ? Assets.Pause : Assets.Play } function parseQueryParams(): QueryParams { - const queryParams: QueryParams = {}, - queryString = document.location.search.split("?")[1]; + const queryParams: QueryParams = {} + const queryString = document.location.search.split('?')[1] - if (queryString) { - const pairs = queryString.split("&"); + if (queryString) { + const pairs = queryString.split('&') - for (const pair of pairs) { - const keyValue = pair.split("="); - queryParams[decodeURIComponent(keyValue[0])] = decodeURIComponent( - keyValue[1] || "" - ); - } - } + for (const pair of pairs) { + const keyValue = pair.split('=') + queryParams[decodeURIComponent(keyValue[0])] = decodeURIComponent( + keyValue[1] || '', + ) + } + } - return queryParams; + return queryParams } diff --git a/websites/D/Dsc.gg/metadata.json b/websites/D/Dsc.gg/metadata.json index 370a7189d991..20f8fb3976a0 100644 --- a/websites/D/Dsc.gg/metadata.json +++ b/websites/D/Dsc.gg/metadata.json @@ -1,42 +1,42 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Anaxes", - "id": "567885938160697377" - }, - "service": "Dsc.gg", - "description": { - "en": "Free vanity links for you discord servers, bots and templates!", - "nl": "Gratis vanity-links voor je Discord servers, bots en templates!" - }, - "url": [ - "dsc.gg", - "docs.dsc.gg" - ], - "version": "1.1.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dsc.gg/assets/logo.jpeg", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dsc.gg/assets/thumbnail.png", - "color": "#738adb", - "category": "socials", - "tags": [ - "link-shortener", - "discord-link-shortener", - "vanity-urls", - "dscgg" - ], - "settings": [ - { - "id": "timestamp", - "title": "Show Timestamps", - "icon": "fad fa-stopwatch", - "value": true - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Anaxes", + "id": "567885938160697377" + }, + "service": "Dsc.gg", + "description": { + "en": "Free vanity links for you discord servers, bots and templates!", + "nl": "Gratis vanity-links voor je Discord servers, bots en templates!" + }, + "url": [ + "dsc.gg", + "docs.dsc.gg" + ], + "version": "1.1.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dsc.gg/assets/logo.jpeg", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dsc.gg/assets/thumbnail.png", + "color": "#738adb", + "category": "socials", + "tags": [ + "link-shortener", + "discord-link-shortener", + "vanity-urls", + "dscgg" + ], + "settings": [ + { + "id": "timestamp", + "title": "Show Timestamps", + "icon": "fad fa-stopwatch", + "value": true + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true + } + ] +} diff --git a/websites/D/Dsc.gg/presence.ts b/websites/D/Dsc.gg/presence.ts index 0e87e83d0029..7329102f6be5 100644 --- a/websites/D/Dsc.gg/presence.ts +++ b/websites/D/Dsc.gg/presence.ts @@ -1,117 +1,123 @@ const presence = new Presence({ - clientId: "843711390539841577", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '843711390539841577', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Dsc.gg/assets/logo.jpeg", - details: "Viewing 📰 page:", - state: "🛑 Unsupported", - }; - const { pathname, href, host } = document.location, - [showTimestamp, showButtons] = await Promise.all([ - presence.getSetting("timestamp"), - presence.getSetting("buttons"), - ]), - pages: Record = { - "/about": { - details: "📚 About", - buttons: [{ label: "View Page", url: href }], - }, - "/premium": { - details: "💎 Premium", - buttons: [{ label: "View Page", url: href }], - }, - }; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Dsc.gg/assets/logo.jpeg', + details: 'Viewing 📰 page:', + state: '🛑 Unsupported', + } + const { pathname, href, host } = document.location + const [showTimestamp, showButtons] = await Promise.all([ + presence.getSetting('timestamp'), + presence.getSetting('buttons'), + ]) + const pages: Record = { + '/about': { + details: '📚 About', + buttons: [{ label: 'View Page', url: href }], + }, + '/premium': { + details: '💎 Premium', + buttons: [{ label: 'View Page', url: href }], + }, + } - for (const [path, data] of Object.entries(pages)) - if (pathname.includes(path)) presenceData = { ...presenceData, ...data }; + for (const [path, data] of Object.entries(pages)) { + if (pathname.includes(path)) + presenceData = { ...presenceData, ...data } as PresenceData + } - if (host === "dsc.gg") { - if (pathname === "/") { - presenceData.state = "🏡 Home"; - if ( - document.querySelector("h1.text-5xl")?.textContent === "Search Results" - ) { - presenceData.details = `🔎 Searching for: ${document - .querySelector("input.py-4") - ?.getAttribute("searching")}`; - presenceData.state = `${ - document.querySelector("h2.text-lg")?.textContent - }`; - presenceData.smallImageKey = Assets.Search; - } - } else { - switch (pathname) { - case "/dashboard": { - presenceData.details = "Viewing ⚙️ dashboard"; - presenceData.state = "🔗 Links"; - if ( - document.querySelector("h1.text-2xl")?.textContent === - "Create a new link" - ) { - presenceData.details = "New link creation"; - presenceData.state = `${ - document.querySelector("input.p-2")?.getAttribute("value") || - "Loading..." - }`; - } - break; - } - default: - if (pathname.includes("/dashboard/l/")) { - const [, link] = pathname.split("/dashboard/l/"); - presenceData.details = `Editing 🔗 ${link.split("/")[0]} link`; - presenceData.state = `🏓 Tab: ${link.split("/")[1]}`; - presenceData.buttons = [ - { - label: "Visit Link", - url: `https://dsc.gg/${link.split("/")[0]}`, - }, - ]; - } - } - } - } else if (host === "docs.dsc.gg") { - switch (pathname) { - case "/": { - presenceData.details = "Viewing 📑 Documentation"; - presenceData.state = `🌐 Content: ${ - location.href.includes("#") - ? location.href.replace("https://docs.dsc.gg/#", " ") - : "📧 Introduction" - }`; + if (host === 'dsc.gg') { + if (pathname === '/') { + presenceData.state = '🏡 Home' + if ( + document.querySelector('h1.text-5xl')?.textContent === 'Search Results' + ) { + presenceData.details = `🔎 Searching for: ${document + .querySelector('input.py-4') + ?.getAttribute('searching')}` + presenceData.state = `${ + document.querySelector('h2.text-lg')?.textContent + }` + presenceData.smallImageKey = Assets.Search + } + } + else { + switch (pathname) { + case '/dashboard': { + presenceData.details = 'Viewing ⚙️ dashboard' + presenceData.state = '🔗 Links' + if ( + document.querySelector('h1.text-2xl')?.textContent + === 'Create a new link' + ) { + presenceData.details = 'New link creation' + presenceData.state = `${ + document.querySelector('input.p-2')?.getAttribute('value') + || 'Loading...' + }` + } + break + } + default: + if (pathname.includes('/dashboard/l/')) { + const [, link] = pathname.split('/dashboard/l/') + presenceData.details = `Editing 🔗 ${link.split('/')[0]} link` + presenceData.state = `🏓 Tab: ${link.split('/')[1]}` + presenceData.buttons = [ + { + label: 'Visit Link', + url: `https://dsc.gg/${link.split('/')[0]}`, + }, + ] + } + } + } + } + else if (host === 'docs.dsc.gg') { + switch (pathname) { + case '/': { + presenceData.details = 'Viewing 📑 Documentation' + presenceData.state = `🌐 Content: ${ + location.href.includes('#') + ? location.href.replace('https://docs.dsc.gg/#', ' ') + : '📧 Introduction' + }` - break; - } - case "/endpoints": { - presenceData.details = "Viewing 🔗 endpoints"; - presenceData.state = `🌐 Content: ${ - location.href.includes("#") - ? location.href.replace("https://docs.dsc.gg/endpoints#", " ") - : "None" - }`; + break + } + case '/endpoints': { + presenceData.details = 'Viewing 🔗 endpoints' + presenceData.state = `🌐 Content: ${ + location.href.includes('#') + ? location.href.replace('https://docs.dsc.gg/endpoints#', ' ') + : 'None' + }` - break; - } - case "/widgets": { - presenceData.details = "Viewing 🖼️ widgets"; - presenceData.state = `🌐 Content: ${ - location.href.includes("#") - ? location.href.replace("https://docs.dsc.gg/widgets#", " ") - : "None" - }`; + break + } + case '/widgets': { + presenceData.details = 'Viewing 🖼️ widgets' + presenceData.state = `🌐 Content: ${ + location.href.includes('#') + ? location.href.replace('https://docs.dsc.gg/widgets#', ' ') + : 'None' + }` - break; - } - } - } + break + } + } + } - if (!showButtons) delete presenceData.buttons; - if (showTimestamp) presenceData.startTimestamp = browsingTimestamp; + if (!showButtons) + delete presenceData.buttons + if (showTimestamp) + presenceData.startTimestamp = browsingTimestamp - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/DuckDuckGo/metadata.json b/websites/D/DuckDuckGo/metadata.json index b50a25be5105..515f3367a11e 100644 --- a/websites/D/DuckDuckGo/metadata.json +++ b/websites/D/DuckDuckGo/metadata.json @@ -1,111 +1,111 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Cairo", - "id": "208105877838888960" - }, - "service": "DuckDuckGo", - "description": { - "en": "The Internet privacy company that empowers you to seamlessly take control of your personal information online, without any tradeoffs.", - "nl": "Het internetprivacybedrijf dat u in staat stelt naadloos controle te krijgen over uw persoonlijke gegevens online, zonder enige concessies.", - "vi_VN": "Công ty bảo mật Internet giúp bạn nắm kiểm soát về thông tin cá nhân của mình trên mạng, không cần đánh đổi bất cứ thứ gì." - }, - "url": "duckduckgo.com", - "version": "1.2.26", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DuckDuckGo/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DuckDuckGo/assets/thumbnail.png", - "color": "#FF5900", - "category": "other", - "tags": [ - "internet", - "browing", - "search" - ], - "settings": [ - { - "id": "homepageMessage", - "title": "Homepage Message", - "icon": "fas fa-home", - "value": "Viewing the homepage", - "placeholder": "Viewing the homepage" - }, - { - "id": "settingsMessage", - "title": "Settings Message", - "icon": "fas fa-cogs", - "value": "Changing my settings", - "placeholder": "Changing my settings" - }, - { - "id": "standardSearch", - "title": "Standard Search Format", - "icon": "fas fa-search", - "value": "Searching for %search%", - "placeholder": "Searching for %search%" - }, - { - "id": "imageSearch", - "title": "Image Search Format", - "icon": "fas fa-camera", - "value": "Exploring images in search for %search%", - "placeholder": "Exploring images in search for %search%" - }, - { - "id": "videoSearch", - "title": "Video Search Format", - "icon": "fas fa-video", - "value": "Probing videos for %search%", - "placeholder": "Probing videos for %search%" - }, - { - "id": "newsSearch", - "title": "News Search Format", - "icon": "fas fa-newspaper", - "value": "Inquiring the news about %search%", - "placeholder": "Inquiring the news about %search%" - }, - { - "id": "mapSearch", - "title": "Map Search Format", - "icon": "fas fa-map", - "value": "Examining the map for %search%", - "placeholder": "Examining the map for %search%" - }, - { - "id": "shoppingSearch", - "title": "Shopping Search Format", - "icon": "fas fa-shopping-bag", - "value": "Browsing the shops for %search%", - "placeholder": "Browsing the shops for %search%" - }, - { - "id": "recipeSearch", - "title": "Recipe Search Format", - "icon": "fas fa-utensils", - "value": "Finding recipes for %search%", - "placeholder": "Finding recipes for %search%" - }, - { - "id": "definitionSearch", - "title": "Definition Search Format", - "icon": "fas fa-atlas", - "value": "Reading the definition for %search%", - "placeholder": "Reading the definition for %search%" - }, - { - "id": "meaningsSearch", - "title": "Meanings Search Format", - "icon": "fas fa-book", - "value": "Reading the meanings for %search%", - "placeholder": "Reading the meanings for %search%" - }, - { - "id": "stockSearch", - "title": "Stock Search Format", - "icon": "fas fa-money-bill-wave-alt", - "value": "Inspecting %content%'s stock", - "placeholder": "Inspecting %content%'s stock" - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Cairo", + "id": "208105877838888960" + }, + "service": "DuckDuckGo", + "description": { + "en": "The Internet privacy company that empowers you to seamlessly take control of your personal information online, without any tradeoffs.", + "nl": "Het internetprivacybedrijf dat u in staat stelt naadloos controle te krijgen over uw persoonlijke gegevens online, zonder enige concessies.", + "vi_VN": "Công ty bảo mật Internet giúp bạn nắm kiểm soát về thông tin cá nhân của mình trên mạng, không cần đánh đổi bất cứ thứ gì." + }, + "url": "duckduckgo.com", + "version": "1.2.26", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/DuckDuckGo/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/DuckDuckGo/assets/thumbnail.png", + "color": "#FF5900", + "category": "other", + "tags": [ + "internet", + "browing", + "search" + ], + "settings": [ + { + "id": "homepageMessage", + "title": "Homepage Message", + "icon": "fas fa-home", + "value": "Viewing the homepage", + "placeholder": "Viewing the homepage" + }, + { + "id": "settingsMessage", + "title": "Settings Message", + "icon": "fas fa-cogs", + "value": "Changing my settings", + "placeholder": "Changing my settings" + }, + { + "id": "standardSearch", + "title": "Standard Search Format", + "icon": "fas fa-search", + "value": "Searching for %search%", + "placeholder": "Searching for %search%" + }, + { + "id": "imageSearch", + "title": "Image Search Format", + "icon": "fas fa-camera", + "value": "Exploring images in search for %search%", + "placeholder": "Exploring images in search for %search%" + }, + { + "id": "videoSearch", + "title": "Video Search Format", + "icon": "fas fa-video", + "value": "Probing videos for %search%", + "placeholder": "Probing videos for %search%" + }, + { + "id": "newsSearch", + "title": "News Search Format", + "icon": "fas fa-newspaper", + "value": "Inquiring the news about %search%", + "placeholder": "Inquiring the news about %search%" + }, + { + "id": "mapSearch", + "title": "Map Search Format", + "icon": "fas fa-map", + "value": "Examining the map for %search%", + "placeholder": "Examining the map for %search%" + }, + { + "id": "shoppingSearch", + "title": "Shopping Search Format", + "icon": "fas fa-shopping-bag", + "value": "Browsing the shops for %search%", + "placeholder": "Browsing the shops for %search%" + }, + { + "id": "recipeSearch", + "title": "Recipe Search Format", + "icon": "fas fa-utensils", + "value": "Finding recipes for %search%", + "placeholder": "Finding recipes for %search%" + }, + { + "id": "definitionSearch", + "title": "Definition Search Format", + "icon": "fas fa-atlas", + "value": "Reading the definition for %search%", + "placeholder": "Reading the definition for %search%" + }, + { + "id": "meaningsSearch", + "title": "Meanings Search Format", + "icon": "fas fa-book", + "value": "Reading the meanings for %search%", + "placeholder": "Reading the meanings for %search%" + }, + { + "id": "stockSearch", + "title": "Stock Search Format", + "icon": "fas fa-money-bill-wave-alt", + "value": "Inspecting %content%'s stock", + "placeholder": "Inspecting %content%'s stock" + } + ] +} diff --git a/websites/D/DuckDuckGo/presence.ts b/websites/D/DuckDuckGo/presence.ts index 302f6ccf02aa..3070d5a9844c 100644 --- a/websites/D/DuckDuckGo/presence.ts +++ b/websites/D/DuckDuckGo/presence.ts @@ -1,76 +1,90 @@ const presence = new Presence({ - clientId: "691534544301457449", -}); + clientId: '691534544301457449', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/DuckDuckGo/assets/logo.png", - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/DuckDuckGo/assets/logo.png', + } - // Get search query from HTML form input. - function searchQuery(): HTMLInputElement { - return document.querySelector("#search_form_input") as HTMLInputElement; - } + // Get search query from HTML form input. + function searchQuery(): HTMLInputElement { + return document.querySelector('#search_form_input') as HTMLInputElement + } - // Sets the timestamp. - function setTimestamp(): number { - return Math.floor(Date.now() / 1000); - } + // Sets the timestamp. + function setTimestamp(): number { + return Math.floor(Date.now() / 1000) + } - /** - * Get's the setting specified and replaces %search% with the search input or %content% when indicated. - * @param {String} settingName Name of the setting - * @param {String} content Optional - Replaces %content% with this input - */ - async function handleFormatting( - settingName: string, - content?: string - ): Promise { - const setting = await presence.getSetting(settingName); - if (!content) return setting.replace("%search%", searchQuery().value); - return setting.replace("%content%", content); - } + /** + * Get's the setting specified and replaces %search% with the search input or %content% when indicated. + * @param {string} settingName Name of the setting + * @param {string} content Optional - Replaces %content% with this input + */ + async function handleFormatting( + settingName: string, + content?: string, + ): Promise { + const setting = await presence.getSetting(settingName) + if (!content) + return setting.replace('%search%', searchQuery().value) + return setting.replace('%content%', content) + } - if ( - document.URL === "https://duckduckgo.com/" || - document.URL === "https://duckduckgo.com" || - document.location.href.includes("/&t=h_") - ) { - presenceData.details = await presence.getSetting("homepageMessage"); - presenceData.startTimestamp = setTimestamp(); - } else if (document.location.href.includes("/settings")) { - presenceData.details = await presence.getSetting("settingsMessage"); - presenceData.startTimestamp = setTimestamp(); - } else if (document.location.href.includes("?q=")) { - presenceData.startTimestamp = setTimestamp(); - presenceData.smallImageKey = Assets.Search; + if ( + document.URL === 'https://duckduckgo.com/' + || document.URL === 'https://duckduckgo.com' + || document.location.href.includes('/&t=h_') + ) { + presenceData.details = await presence.getSetting('homepageMessage') + presenceData.startTimestamp = setTimestamp() + } + else if (document.location.href.includes('/settings')) { + presenceData.details = await presence.getSetting('settingsMessage') + presenceData.startTimestamp = setTimestamp() + } + else if (document.location.href.includes('?q=')) { + presenceData.startTimestamp = setTimestamp() + presenceData.smallImageKey = Assets.Search - if (document.location.href.includes("iaxm=maps")) - presenceData.details = await handleFormatting("mapSearch"); - else if (document.location.href.includes("iax=images")) - presenceData.details = await handleFormatting("imageSearch"); - else if (document.location.href.includes("iax=videos")) - presenceData.details = await handleFormatting("videoSearch"); - else if (document.location.href.includes("iar=news")) - presenceData.details = await handleFormatting("newsSearch"); - else if (document.location.href.includes("ia=meanings")) - presenceData.details = await handleFormatting("meaningsSearch"); - else if (document.location.href.includes("ia=definition")) - presenceData.details = await handleFormatting("definitonSearch"); - else if (document.location.href.includes("ia=shopping")) - presenceData.details = await handleFormatting("shoppingSearch"); - else if (document.location.href.includes("ia=recipes")) - presenceData.details = await handleFormatting("recipeSearch"); - else if (document.location.href.includes("&ia=stock")) { - presenceData.details = await handleFormatting( - "stockSearch", - document.querySelectorAll(".stocks__header")[0].querySelectorAll("a")[0] - .textContent - ); - } else presenceData.details = await handleFormatting("standardSearch"); - } + if (document.location.href.includes('iaxm=maps')) { + presenceData.details = await handleFormatting('mapSearch') + } + else if (document.location.href.includes('iax=images')) { + presenceData.details = await handleFormatting('imageSearch') + } + else if (document.location.href.includes('iax=videos')) { + presenceData.details = await handleFormatting('videoSearch') + } + else if (document.location.href.includes('iar=news')) { + presenceData.details = await handleFormatting('newsSearch') + } + else if (document.location.href.includes('ia=meanings')) { + presenceData.details = await handleFormatting('meaningsSearch') + } + else if (document.location.href.includes('ia=definition')) { + presenceData.details = await handleFormatting('definitonSearch') + } + else if (document.location.href.includes('ia=shopping')) { + presenceData.details = await handleFormatting('shoppingSearch') + } + else if (document.location.href.includes('ia=recipes')) { + presenceData.details = await handleFormatting('recipeSearch') + } + else if (document.location.href.includes('&ia=stock')) { + presenceData.details = await handleFormatting( + 'stockSearch', + document.querySelectorAll('.stocks__header')[0].querySelectorAll('a')[0] + ?.textContent ?? '', + ) + } + else { + presenceData.details = await handleFormatting('standardSearch') + } + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Dueling Nexus/metadata.json b/websites/D/Dueling Nexus/metadata.json index c420d1c50ddb..07b67355a72a 100644 --- a/websites/D/Dueling Nexus/metadata.json +++ b/websites/D/Dueling Nexus/metadata.json @@ -1,34 +1,34 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Nekolen", - "id": "270125856679002113" - }, - "contributors": [ - { - "name": "Bas950", - "id": "241278257335500811" - } - ], - "service": "Dueling Nexus", - "description": { - "en": "duelingnexus.com is a free online Yu-Gi-Oh simulator for browsers.", - "ro": "duelingnexus.com este un simulator gratuit de Yu-Gi-Oh online pentru browsere.", - "pt_BR": "duelingnexus.com é um simulador de Yu-Gi-Oh online gratuito para navegadores.", - "fr": "duelingnexus.com est un simulateur en ligne gratuit de Yu-Gi-Oh pour les navigateurs.", - "uk_UA": "duelingnexus.com не має симулятора, а також відвідає багато навігацій.", - "nl": "duelingnexus.com is een gratis online Yu-Gi-Oh-simulator voor browsers" - }, - "url": "duelingnexus.com", - "version": "1.5.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dueling%20Nexus/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dueling%20Nexus/assets/thumbnail.jpg", - "color": "#FF4500", - "category": "games", - "tags": [ - "game", - "yu-gi-oh", - "browser" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Nekolen", + "id": "270125856679002113" + }, + "contributors": [ + { + "name": "Bas950", + "id": "241278257335500811" + } + ], + "service": "Dueling Nexus", + "description": { + "en": "duelingnexus.com is a free online Yu-Gi-Oh simulator for browsers.", + "ro": "duelingnexus.com este un simulator gratuit de Yu-Gi-Oh online pentru browsere.", + "pt_BR": "duelingnexus.com é um simulador de Yu-Gi-Oh online gratuito para navegadores.", + "fr": "duelingnexus.com est un simulateur en ligne gratuit de Yu-Gi-Oh pour les navigateurs.", + "uk_UA": "duelingnexus.com не має симулятора, а також відвідає багато навігацій.", + "nl": "duelingnexus.com is een gratis online Yu-Gi-Oh-simulator voor browsers" + }, + "url": "duelingnexus.com", + "version": "1.5.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dueling%20Nexus/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dueling%20Nexus/assets/thumbnail.jpg", + "color": "#FF4500", + "category": "games", + "tags": [ + "game", + "yu-gi-oh", + "browser" + ] +} diff --git a/websites/D/Dueling Nexus/presence.ts b/websites/D/Dueling Nexus/presence.ts index 0c0a16d29e57..56b153cbcc09 100644 --- a/websites/D/Dueling Nexus/presence.ts +++ b/websites/D/Dueling Nexus/presence.ts @@ -1,107 +1,111 @@ const presence = new Presence({ - clientId: "618212337895079996", - }), - elapsed = Math.floor(Date.now() / 1000); -let text; + clientId: '618212337895079996', +}) +const elapsed = Math.floor(Date.now() / 1000) +let text const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Dueling%20Nexus/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Dueling%20Nexus/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: elapsed, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: elapsed, + } - if (document.location.pathname === "/home") { - if (document.querySelectorAll("p")[1].textContent.includes("Welcome back")) - text = document.querySelectorAll("p")[1].textContent; - else text = document.querySelectorAll("p")[3].textContent; + if (document.location.pathname === '/home') { + if (document.querySelectorAll('p')[1].textContent?.includes('Welcome back')) + text = document.querySelectorAll('p')[1].textContent + else text = document.querySelectorAll('p')[3].textContent - if (localStorage.getItem("name")) - localStorage.setItem("name", text.split(",")[1]); + if (localStorage.getItem('name')) + localStorage.setItem('name', text?.split(',')[1] ?? '') - presenceData.details = `Online as ${text.split(",")[1]}`; - presenceData.state = "waiting in lobby"; - presenceData.smallImageKey = Assets.Logo; - presenceData.smallImageText = "in game"; - } else if (document.location.pathname === "/decks") { - (presenceData.details = `Online as ${localStorage.getItem("name")}`), - (presenceData.state = "Looking at decklists"); - presenceData.smallImageKey = Assets.Logo; - presenceData.smallImageText = "in game"; - } else if (document.location.pathname.includes("/editor")) { - presenceData.details = "Building Decks"; - presenceData.state = `Editing: ${ - document.querySelectorAll("strong")[0].textContent - }`; - presenceData.smallImageKey = Assets.Logo; - presenceData.smallImageText = "in game"; - } else if (document.location.pathname.includes("/game")) { - let opponent = document.querySelector("#game-opponent-name").textContent; - const mylife = document.querySelector("#game-life-player").textContent, - opplife = document.querySelector("#game-life-opponent").textContent; - let myname = document.querySelector("#game-player-name").textContent, - state, - status; + presenceData.details = `Online as ${text?.split(',')[1] ?? ''}` + presenceData.state = 'waiting in lobby' + presenceData.smallImageKey = Assets.Logo + presenceData.smallImageText = 'in game' + } + else if (document.location.pathname === '/decks') { + presenceData.details = `Online as ${localStorage.getItem('name')}` + presenceData.state = 'Looking at decklists' + presenceData.smallImageKey = Assets.Logo + presenceData.smallImageText = 'in game' + } + else if (document.location.pathname.includes('/editor')) { + presenceData.details = 'Building Decks' + presenceData.state = `Editing: ${ + document.querySelectorAll('strong')[0].textContent + }` + presenceData.smallImageKey = Assets.Logo + presenceData.smallImageText = 'in game' + } + else if (document.location.pathname.includes('/game')) { + let opponent = document.querySelector('#game-opponent-name')?.textContent + const mylife = document.querySelector('#game-life-player')!.textContent! + const opplife = document.querySelector('#game-life-opponent')!.textContent! + let myname = document.querySelector('#game-player-name')?.textContent + let state + let status - if (myname === "Player" || myname === "Opponent") { - myname = document.querySelector( - "#game-room-player1-username" - ).textContent; - } - if (opponent === "Opponent" || opponent === "Player") { - if ( - document.querySelector("#game-room-player2-username").textContent === - "---" - ) - opponent = "waiting.."; - else { - opponent = document.querySelector( - "#game-room-player2-username" - ).textContent; - } - } - state = `Current lp: ${mylife}, Opponent LP: ${opplife}`; - status = `Game: ${myname}(me) vs ${opponent}`; - if (parseInt(mylife) === 0 && 0 === parseInt(opplife)) { - state = "Game not started"; - status = `Game: ${myname} vs ${opponent}`; - } - /* if(localStorage.getItem("name").replace(" ",'')==myname){ - var status = `Dueling ${opponent}` + if (myname === 'Player' || myname === 'Opponent') { + myname = document.querySelector('#game-room-player1-username')?.textContent + } + if (opponent === 'Opponent' || opponent === 'Player') { + if ( + document.querySelector('#game-room-player2-username')?.textContent === '---' + ) { + opponent = 'waiting..' + } + else { + opponent = document.querySelector('#game-room-player2-username')?.textContent + } + } + state = `Current lp: ${mylife}, Opponent LP: ${opplife}` + status = `Game: ${myname}(me) vs ${opponent}` + if (Number.parseInt(mylife) === 0 && Number.parseInt(opplife) === 0) { + state = 'Game not started' + status = `Game: ${myname} vs ${opponent}` + } + /* if(localStorage.getItem("name").replace(" ",'')==myname){ + var status = `Dueling ${opponent}` } else { var status = `Spectating: ${myname} vs ${opponent}` } */ - presenceData.details = status; - presenceData.state = state; - presenceData.smallImageKey = Assets.Logo; - presenceData.smallImageText = document.location.href; - } else if (document.location.pathname.includes("/hostgame")) { - presenceData.details = "Hosting Game "; - presenceData.state = `as ${localStorage.getItem("name")}`; - presenceData.smallImageKey = Assets.Logo; - presenceData.smallImageText = "in game"; - } else if (document.location.pathname.includes("/gamelist")) { - presenceData.details = "Looking for Game"; - presenceData.state = "at All game list"; - presenceData.smallImageKey = Assets.Logo; - presenceData.smallImageText = "in game"; - } else if (document.location.pathname.includes("/profile")) { - presenceData.details = "Editing Profile"; - presenceData.state = "changing stuffs"; - presenceData.smallImageKey = Assets.Logo; - presenceData.smallImageText = "in game"; - } else if (document.location.pathname.includes("/duel")) { - presenceData.details = "Searching for Duels"; - presenceData.state = "Choosing game mode"; - presenceData.smallImageKey = Assets.Logo; - presenceData.smallImageText = "in game"; - } + presenceData.details = status + presenceData.state = state + presenceData.smallImageKey = Assets.Logo + presenceData.smallImageText = document.location.href + } + else if (document.location.pathname.includes('/hostgame')) { + presenceData.details = 'Hosting Game ' + presenceData.state = `as ${localStorage.getItem('name')}` + presenceData.smallImageKey = Assets.Logo + presenceData.smallImageText = 'in game' + } + else if (document.location.pathname.includes('/gamelist')) { + presenceData.details = 'Looking for Game' + presenceData.state = 'at All game list' + presenceData.smallImageKey = Assets.Logo + presenceData.smallImageText = 'in game' + } + else if (document.location.pathname.includes('/profile')) { + presenceData.details = 'Editing Profile' + presenceData.state = 'changing stuffs' + presenceData.smallImageKey = Assets.Logo + presenceData.smallImageText = 'in game' + } + else if (document.location.pathname.includes('/duel')) { + presenceData.details = 'Searching for Duels' + presenceData.state = 'Choosing game mode' + presenceData.smallImageKey = Assets.Logo + presenceData.smallImageText = 'in game' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Dumpert/metadata.json b/websites/D/Dumpert/metadata.json index 75a297e390f7..b141c88546fe 100644 --- a/websites/D/Dumpert/metadata.json +++ b/websites/D/Dumpert/metadata.json @@ -1,51 +1,51 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dark_Ville", - "id": "638080361179512853" - }, - "service": "Dumpert", - "description": { - "en": "The place for your daily entertainment. With the best videos and photos for when you don't feel like doing work, studying or human contact. Main sponsor of Dutch attic rooms.", - "nl": "De plek voor je dagelijkse entertainment. Met de leukste filmpjes en foto's voor als je even geen zin hebt in werk, studie of menselijk contact. Hoofdsponsor van Nederlandse zolderkamers." - }, - "url": "www.dumpert.nl", - "version": "2.0.5", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dumpert/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dumpert/assets/thumbnail.jpg", - "color": "#00ff2a", - "category": "socials", - "tags": [ - "nl", - "nederlands", - "dutch", - "dumpert" - ], - "settings": [ - { - "id": "privacy", - "title": "Privacy Mode", - "icon": "fas fa-user-secret", - "value": false - }, - { - "id": "buttons", - "title": "Show Buttons", - "icon": "fas fa-compress-arrows-alt", - "value": true, - "if": { - "privacy": false - } - }, - { - "id": "covers", - "title": "Show Cover", - "icon": "fad fa-images", - "value": false, - "if": { - "privacy": false - } - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dark_Ville", + "id": "638080361179512853" + }, + "service": "Dumpert", + "description": { + "en": "The place for your daily entertainment. With the best videos and photos for when you don't feel like doing work, studying or human contact. Main sponsor of Dutch attic rooms.", + "nl": "De plek voor je dagelijkse entertainment. Met de leukste filmpjes en foto's voor als je even geen zin hebt in werk, studie of menselijk contact. Hoofdsponsor van Nederlandse zolderkamers." + }, + "url": "www.dumpert.nl", + "version": "2.0.5", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dumpert/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dumpert/assets/thumbnail.jpg", + "color": "#00ff2a", + "category": "socials", + "tags": [ + "nl", + "nederlands", + "dutch", + "dumpert" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fas fa-user-secret", + "value": false + }, + { + "id": "buttons", + "title": "Show Buttons", + "icon": "fas fa-compress-arrows-alt", + "value": true, + "if": { + "privacy": false + } + }, + { + "id": "covers", + "title": "Show Cover", + "icon": "fad fa-images", + "value": false, + "if": { + "privacy": false + } + } + ] +} diff --git a/websites/D/Dumpert/presence.ts b/websites/D/Dumpert/presence.ts index 60798c3f19fd..951d892051c5 100644 --- a/websites/D/Dumpert/presence.ts +++ b/websites/D/Dumpert/presence.ts @@ -1,137 +1,140 @@ const presence = new Presence({ - clientId: "840126038205923369", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '840126038205923369', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/Dumpert/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Dumpert/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }, - { href, pathname } = window.location, - [privacy, buttons, covers] = await Promise.all([ - presence.getSetting("privacy"), - presence.getSetting("buttons"), - presence.getSetting("covers"), - ]), - search = document.querySelector(".searchfield"), - sortElement = document - .querySelector('[class*="dropdown--"] > div') - ?.textContent?.toLowerCase(); - if (pathname.includes("/zoek/")) { - presenceData.details = privacy - ? "Bekijkt zoekresultaten" - : `Bekijkt zoekresultaten voor: ${ - document - .querySelector('[class*="list_title_holder list_bar_left"] > h1') - ?.textContent?.split("'")[1] - }`; - presenceData.state = sortElement ? `Gesorteerd op: ${sortElement}` : ""; - presence.setActivity(presenceData); - return; - } else if (search?.value) { - presenceData.details = privacy ? "Is aan het zoeken" : "Zoekt naar:"; - presenceData.state = search.value; - presenceData.smallImageKey = Assets.Search; - presenceData.smallImageText = "Aan het zoeken"; - presence.setActivity(presenceData); - return; - } - switch (true) { - case href.includes("selectedId="): - case pathname.includes("/item/"): { - const video = - document.querySelector('[class="vjs-tech"]'); - if (video) { - delete presenceData.startTimestamp; - presenceData.largeImageKey = - document.querySelector('[property="og:image" ]') - ?.content ?? Assets.Logo; - presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Play; - if (!video.paused) { - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestampsfromMedia(video); - } - presenceData.buttons = [ - { - label: "Bekijk Video", - url: href, - }, - ]; - } else { - presenceData.largeImageKey = - document.querySelectorAll("img")[1]?.getAttribute("src") ?? - Assets.Logo; - presenceData.buttons = [ - { - label: "Bekijk Foto", - url: href, - }, - ]; - } +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } + const { href, pathname } = window.location + const [privacy, buttons, covers] = await Promise.all([ + presence.getSetting('privacy'), + presence.getSetting('buttons'), + presence.getSetting('covers'), + ]) + const search = document.querySelector('.searchfield') + const sortElement = document + .querySelector('[class*="dropdown--"] > div') + ?.textContent + ?.toLowerCase() + if (pathname.includes('/zoek/')) { + presenceData.details = privacy + ? 'Bekijkt zoekresultaten' + : `Bekijkt zoekresultaten voor: ${ + document + .querySelector('[class*="list_title_holder list_bar_left"] > h1') + ?.textContent + ?.split('\'')[1] + }` + presenceData.state = sortElement ? `Gesorteerd op: ${sortElement}` : '' + presence.setActivity(presenceData) + return + } + else if (search?.value) { + presenceData.details = privacy ? 'Is aan het zoeken' : 'Zoekt naar:' + presenceData.state = search.value + presenceData.smallImageKey = Assets.Search + presenceData.smallImageText = 'Aan het zoeken' + presence.setActivity(presenceData) + return + } + switch (true) { + case href.includes('selectedId='): + case pathname.includes('/item/'): { + const video = document.querySelector('[class="vjs-tech"]') + if (video) { + delete presenceData.startTimestamp + presenceData.largeImageKey = document.querySelector('[property="og:image" ]') + ?.content ?? Assets.Logo + presenceData.smallImageKey = video?.paused ? Assets.Pause : Assets.Play + if (!video.paused) { + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestampsfromMedia(video) + } + presenceData.buttons = [ + { + label: 'Bekijk Video', + url: href, + }, + ] + } + else { + presenceData.largeImageKey = document.querySelectorAll('img')[1]?.getAttribute('src') + ?? Assets.Logo + presenceData.buttons = [ + { + label: 'Bekijk Foto', + url: href, + }, + ] + } - presenceData.details = - document.querySelector('meta[property~="og:title"]') - ?.content ?? "Onbekende titel"; - break; - } - case pathname.includes("toppers"): { - presenceData.details = privacy ? "Bekijkt content" : "Bekijkt de toppers"; + presenceData.details = document.querySelector('meta[property~="og:title"]') + ?.content ?? 'Onbekende titel' + break + } + case pathname.includes('toppers'): { + presenceData.details = privacy ? 'Bekijkt content' : 'Bekijkt de toppers' - presenceData.buttons = [ - { - label: "Bekijk Content", - url: href, - }, - ]; - break; - } - case pathname.includes("latest"): { - presenceData.details = privacy - ? "Bekijkt content" - : "Bekijkt de nieuwste content"; - presenceData.buttons = [ - { - label: "Bekijk Content", - url: href, - }, - ]; - break; - } - case pathname.includes("/tag/"): { - const active = document - .querySelector('[class*="activeitem--"]') - ?.textContent?.toLowerCase(); - presenceData.details = privacy - ? "Bekijkt resultaten voor een tag" - : active - ? `Bekijkt resultaten voor tag: ${active}` - : `Bekijkt resultaten voor tag: ${ - document - .querySelector('[class*="list_title_holder list_bar_left"] > h1') - ?.textContent?.split("'")[1] - }`; - presenceData.state = sortElement ? `Gesorteerd op: ${sortElement}` : ""; - presenceData.buttons = [ - { - label: "Bekijk Content", - url: href, - }, - ]; - break; - } - } + presenceData.buttons = [ + { + label: 'Bekijk Content', + url: href, + }, + ] + break + } + case pathname.includes('latest'): { + presenceData.details = privacy + ? 'Bekijkt content' + : 'Bekijkt de nieuwste content' + presenceData.buttons = [ + { + label: 'Bekijk Content', + url: href, + }, + ] + break + } + case pathname.includes('/tag/'): { + const active = document + .querySelector('[class*="activeitem--"]') + ?.textContent + ?.toLowerCase() + presenceData.details = privacy + ? 'Bekijkt resultaten voor een tag' + : active + ? `Bekijkt resultaten voor tag: ${active}` + : `Bekijkt resultaten voor tag: ${ + document + .querySelector('[class*="list_title_holder list_bar_left"] > h1') + ?.textContent + ?.split('\'')[1] + }` + presenceData.state = sortElement ? `Gesorteerd op: ${sortElement}` : '' + presenceData.buttons = [ + { + label: 'Bekijk Content', + url: href, + }, + ] + break + } + } - if (privacy && presenceData.state) delete presenceData.state; - if ((!buttons || privacy) && presenceData.buttons) - delete presenceData.buttons; - if (!covers && presenceData.largeImageKey !== Assets.Logo) - presenceData.largeImageKey = Assets.Logo; + if (privacy && presenceData.state) + delete presenceData.state + if ((!buttons || privacy) && presenceData.buttons) + delete presenceData.buttons + if (!covers && presenceData.largeImageKey !== Assets.Logo) + presenceData.largeImageKey = Assets.Logo - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Dungeon Crawl Stone Soup/metadata.json b/websites/D/Dungeon Crawl Stone Soup/metadata.json index 00f69a73d19b..6042562e7f2e 100644 --- a/websites/D/Dungeon Crawl Stone Soup/metadata.json +++ b/websites/D/Dungeon Crawl Stone Soup/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "impsy", - "id": "114894715106623491" - }, - "service": "Dungeon Crawl Stone Soup", - "description": { - "en": "An open source roguelike adventure through dungeons filled with dangerous monsters in a quest to find the mystifyingly fabulous Orb of Zot." - }, - "url": [ - "crawl.akrasiac.org", - "crawl.project357.org", - "cbro.berotato.org", - "crawl.xtahua.com", - "underhound.eu", - "webzook.net", - "lazy-life.ddo.jp", - "crawl.kelbi.org" - ], - "version": "1.0.9", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dungeon%20Crawl%20Stone%20Soup/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dungeon%20Crawl%20Stone%20Soup/assets/thumbnail.png", - "color": "#f00f0f", - "category": "games", - "tags": [ - "crawl" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "impsy", + "id": "114894715106623491" + }, + "service": "Dungeon Crawl Stone Soup", + "description": { + "en": "An open source roguelike adventure through dungeons filled with dangerous monsters in a quest to find the mystifyingly fabulous Orb of Zot." + }, + "url": [ + "crawl.akrasiac.org", + "crawl.project357.org", + "cbro.berotato.org", + "crawl.xtahua.com", + "underhound.eu", + "webzook.net", + "lazy-life.ddo.jp", + "crawl.kelbi.org" + ], + "version": "1.0.9", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dungeon%20Crawl%20Stone%20Soup/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dungeon%20Crawl%20Stone%20Soup/assets/thumbnail.png", + "color": "#f00f0f", + "category": "games", + "tags": [ + "crawl" + ] +} diff --git a/websites/D/Dungeon Crawl Stone Soup/presence.ts b/websites/D/Dungeon Crawl Stone Soup/presence.ts index 21912cab1370..8e2a6a2009dd 100644 --- a/websites/D/Dungeon Crawl Stone Soup/presence.ts +++ b/websites/D/Dungeon Crawl Stone Soup/presence.ts @@ -1,52 +1,55 @@ const presence = new Presence({ - clientId: "994723983415062548", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '994723983415062548', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Dungeon%20Crawl%20Stone%20Soup/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Dungeon%20Crawl%20Stone%20Soup/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (window.location.hash === "#lobby") - presenceData.details = "Browsing lobby"; - else if (window.location.hash.startsWith("#watch")) { - presenceData.details = `Spectating: ${ - document.querySelector("#stats_titleline").textContent - }`; - presenceData.state = `XL: ${ - document.querySelector("#stats_xl").textContent - } | Location: ${ - document.querySelector("#stats_place").textContent - }`; - presenceData.buttons = [ - { - label: "Spectate", - url: document.location.href, - }, - ]; - } else if (window.location.hash.startsWith("#play-")) { - presenceData.details = `Playing as: ${ - document.querySelector("#stats_titleline").textContent - }`; - presenceData.state = `XL: ${ - document.querySelector("#stats_xl").textContent - } | Location: ${ - document.querySelector("#stats_place").textContent - }`; - presenceData.buttons = [ - { - label: "Spectate", - url: `${document.location.origin}/#watch-${document - .querySelector("#stats_titleline") - .textContent.split("the")[0] - .trim()}`, - }, - ]; - } + if (window.location.hash === '#lobby') { + presenceData.details = 'Browsing lobby' + } + else if (window.location.hash.startsWith('#watch')) { + presenceData.details = `Spectating: ${ + document.querySelector('#stats_titleline')?.textContent + }` + presenceData.state = `XL: ${ + document.querySelector('#stats_xl')?.textContent + } | Location: ${ + document.querySelector('#stats_place')?.textContent + }` + presenceData.buttons = [ + { + label: 'Spectate', + url: document.location.href, + }, + ] + } + else if (window.location.hash.startsWith('#play-')) { + presenceData.details = `Playing as: ${ + document.querySelector('#stats_titleline')?.textContent + }` + presenceData.state = `XL: ${ + document.querySelector('#stats_xl')?.textContent + } | Location: ${ + document.querySelector('#stats_place')?.textContent + }` + presenceData.buttons = [ + { + label: 'Spectate', + url: `${document.location.origin}/#watch-${document + .querySelector('#stats_titleline') + ?.textContent + ?.split('the')[0] + ?.trim()}`, + }, + ] + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Duolingo/metadata.json b/websites/D/Duolingo/metadata.json index c38613255385..fff2ed78a232 100644 --- a/websites/D/Duolingo/metadata.json +++ b/websites/D/Duolingo/metadata.json @@ -1,60 +1,60 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "veryCrunchy", - "id": "576097150359044106" - }, - "contributors": [ - { - "name": "TheSlowly", - "id": "505071508851523599" - } - ], - "service": "Duolingo", - "description": { - "ar_SA": "‏الطريقة الممتعة والفعّالة لتعلّم لغة جديدة!", - "cs_CZ": "Bezplatný, zábavný a účinný způsob, jak se naučit jazyk!", - "de": "Effektiv und kostenlos eine Sprache lernen – und dabei Spaß haben!", - "el_GR": "Ο δωρεάν, διασκεδαστικός και αποτελεσματικός τρόπος να μάθεις μια ξένη γλώσσα!", - "en": "The free, fun, and effective way to learn a language!", - "es": "¡La forma divertida, efectiva y gratis de aprender un idioma!", - "fr": "La méthode amusante, gratuite et efficace pour apprendre une langue !", - "hi_IN": "भाषा सीखने का मज़ेदार, मुफ़्त और असरदार तरीका!", - "hu": "Egy ingyenes, szórakoztató és hatékony módja a nyelvtanulásnak!", - "id": "Cara gratis, seru, dan efektif untuk belajar bahasa!", - "it": "Il metodo gratuito, divertente ed efficace per imparare le lingue!", - "ja_JP": "無料で楽しく外国語を学ぼう", - "ko_KR": "재미있고 효과적인 무료 언어 학습 방법!", - "nl": "De gratis, leuke en effectieve manier om een taal te leren!", - "pl": "Darmowy, ciekawy i skuteczny sposób na naukę języka!", - "pt": "O jeito grátis, divertido e eficaz de aprender um idioma!", - "ro": "Modul gratuit, amuzant și eficient de a învăța o limbă!", - "ru": "Учите языки бесплатно, весело и эффективно!", - "th": "วิธีการเรียนภาษาที่ฟรี สนุกและมีประสิทธิภาพ!", - "tr": "Ücretsiz, eğlenceli ve etkili dil öğrenme yolu!", - "uk_UA": "Безкоштовний, веселий та ефективний спосіб вивчення мови!", - "vi_VN": "Cách học ngôn ngữ miễn phí, vui nhộn và hiệu quả!", - "zh_CN": "学习外语,寓教于乐" - }, - "url": "www.duolingo.com", - "regExp": "www\\.duolingo\\.(com|cn)", - "version": "3.1.6", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/thumbnail.png", - "color": "#5dcd32", - "category": "other", - "tags": [ - "education", - "learning", - "language" - ], - "settings": [ - { - "id": "timestamps", - "title": "Show timestamps", - "icon": "fas fa-stopwatch", - "value": true - } - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "veryCrunchy", + "id": "576097150359044106" + }, + "contributors": [ + { + "name": "TheSlowly", + "id": "505071508851523599" + } + ], + "service": "Duolingo", + "description": { + "ar_SA": "‏الطريقة الممتعة والفعّالة لتعلّم لغة جديدة!", + "cs_CZ": "Bezplatný, zábavný a účinný způsob, jak se naučit jazyk!", + "de": "Effektiv und kostenlos eine Sprache lernen – und dabei Spaß haben!", + "el_GR": "Ο δωρεάν, διασκεδαστικός και αποτελεσματικός τρόπος να μάθεις μια ξένη γλώσσα!", + "en": "The free, fun, and effective way to learn a language!", + "es": "¡La forma divertida, efectiva y gratis de aprender un idioma!", + "fr": "La méthode amusante, gratuite et efficace pour apprendre une langue !", + "hi_IN": "भाषा सीखने का मज़ेदार, मुफ़्त और असरदार तरीका!", + "hu": "Egy ingyenes, szórakoztató és hatékony módja a nyelvtanulásnak!", + "id": "Cara gratis, seru, dan efektif untuk belajar bahasa!", + "it": "Il metodo gratuito, divertente ed efficace per imparare le lingue!", + "ja_JP": "無料で楽しく外国語を学ぼう", + "ko_KR": "재미있고 효과적인 무료 언어 학습 방법!", + "nl": "De gratis, leuke en effectieve manier om een taal te leren!", + "pl": "Darmowy, ciekawy i skuteczny sposób na naukę języka!", + "pt": "O jeito grátis, divertido e eficaz de aprender um idioma!", + "ro": "Modul gratuit, amuzant și eficient de a învăța o limbă!", + "ru": "Учите языки бесплатно, весело и эффективно!", + "th": "วิธีการเรียนภาษาที่ฟรี สนุกและมีประสิทธิภาพ!", + "tr": "Ücretsiz, eğlenceli ve etkili dil öğrenme yolu!", + "uk_UA": "Безкоштовний, веселий та ефективний спосіб вивчення мови!", + "vi_VN": "Cách học ngôn ngữ miễn phí, vui nhộn và hiệu quả!", + "zh_CN": "学习外语,寓教于乐" + }, + "url": "www.duolingo.com", + "regExp": "www\\.duolingo\\.(com|cn)", + "version": "3.1.6", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/thumbnail.png", + "color": "#5dcd32", + "category": "other", + "tags": [ + "education", + "learning", + "language" + ], + "settings": [ + { + "id": "timestamps", + "title": "Show timestamps", + "icon": "fas fa-stopwatch", + "value": true + } + ] +} diff --git a/websites/D/Duolingo/presence.ts b/websites/D/Duolingo/presence.ts index 66ecb43f455d..5c84165b1a15 100644 --- a/websites/D/Duolingo/presence.ts +++ b/websites/D/Duolingo/presence.ts @@ -1,378 +1,398 @@ import { - assets, - decompressGzip, - deEsser, - giveArticle, - makeProgressBar, - updateUndefinedKeys, -} from "./util"; + assets, + decompressGzip, + deEsser, + giveArticle, + makeProgressBar, + updateUndefinedKeys, +} from './util' + const presence = new Presence({ - clientId: "1177802176140156998", - }), - timeStamp = newTimeStamp(), - IMAGE = { - duoTool: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/0.png", - profileDuo: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/1.png", - duoGlobe: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/2.png", - }, - LANGUAGE_NAMES: Record = { - ar: "Arabic", - ca: "Catalan", - cs: "Czech", - cy: "Welsh", - da: "Danish", - de: "German", - el: "Greek", - en: "English", - eo: "Esperanto", - es: "Spanish", - fi: "Finnish", - fr: "French", - gd: "Scottish Gaelic", - gn: "Guarani", - he: "Hebrew", - hi: "Hindi", - ht: "Haitian Creole", - hu: "Hungarian", - hv: "High Valyrian", - hw: "Hawaiian", - id: "Indonesian", - it: "Italian", - ja: "Japanese", - ko: "Korean", - la: "Latin", - "nl-nl": "Dutch", - "no-bo": "Norwegian (Bokmål)", - nv: "Navajo", - pl: "Polish", - pt: "Portuguese", - qc: "K'iche'", - ro: "Romanian", - ru: "Russian", - sw: "Swahili", - ga: "Irish", - sv: "Swedish", - tlh: "Klingon", - tr: "Turkish", - uk: "Ukrainian", - vi: "Vietnamese", - yi: "Yiddish", - yu: "Yucatec", - zh: "Chinese", - "zh-hk": "Chinese (Cantonese)", - zu: "Zulu", - }, - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/logo.png", - }, - settings = { - showTime: true, - showTimeOverwrite: false, - lastPath: null as string, - }, - language = { - code: null as string, - name: null as string, - }, - user = { - currentCourseId: null as string, - streak: null as number, - xp: null as number, - freezes: null as number, - lesson: { - timeStamp: null as number, - active: false, - finished: null as string, - }, - }, - storedUsers = localStorage.getItem("PMD-users-cache"), - users: { username: string; displayName: string; img: string }[] = storedUsers - ? JSON.parse(storedUsers) - : []; + clientId: '1177802176140156998', +}) +const timeStamp = newTimeStamp() +const IMAGE = { + duoTool: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/0.png', + profileDuo: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/1.png', + duoGlobe: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/2.png', +} +const LANGUAGE_NAMES: Record = { + 'ar': 'Arabic', + 'ca': 'Catalan', + 'cs': 'Czech', + 'cy': 'Welsh', + 'da': 'Danish', + 'de': 'German', + 'el': 'Greek', + 'en': 'English', + 'eo': 'Esperanto', + 'es': 'Spanish', + 'fi': 'Finnish', + 'fr': 'French', + 'gd': 'Scottish Gaelic', + 'gn': 'Guarani', + 'he': 'Hebrew', + 'hi': 'Hindi', + 'ht': 'Haitian Creole', + 'hu': 'Hungarian', + 'hv': 'High Valyrian', + 'hw': 'Hawaiian', + 'id': 'Indonesian', + 'it': 'Italian', + 'ja': 'Japanese', + 'ko': 'Korean', + 'la': 'Latin', + 'nl-nl': 'Dutch', + 'no-bo': 'Norwegian (Bokmål)', + 'nv': 'Navajo', + 'pl': 'Polish', + 'pt': 'Portuguese', + 'qc': 'K\'iche\'', + 'ro': 'Romanian', + 'ru': 'Russian', + 'sw': 'Swahili', + 'ga': 'Irish', + 'sv': 'Swedish', + 'tlh': 'Klingon', + 'tr': 'Turkish', + 'uk': 'Ukrainian', + 'vi': 'Vietnamese', + 'yi': 'Yiddish', + 'yu': 'Yucatec', + 'zh': 'Chinese', + 'zh-hk': 'Chinese (Cantonese)', + 'zu': 'Zulu', +} +const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/logo.png', +} +const settings = { + showTime: true, + showTimeOverwrite: false, + lastPath: null as unknown as string, +} +const language = { + code: null as unknown as string, + name: null as unknown as string, +} +const user = { + currentCourseId: null as unknown as string, + streak: null as unknown as number, + xp: null as unknown as number, + freezes: null as unknown as number, + lesson: { + timeStamp: null as unknown as number, + active: false, + finished: null as unknown as string, + }, +} +const storedUsers = localStorage.getItem('PMD-users-cache') +const users: { username?: string, displayName?: string, img?: string }[] = storedUsers + ? JSON.parse(storedUsers) + : [] -let timeoutId: number; +let timeoutId: number function newTimeStamp() { - return Math.floor(Date.now() / 1000); + return Math.floor(Date.now() / 1000) } function handleLesson(_path: string | string[]) { - const progressBarElement = document.querySelector('div[role="progressbar"]'), - PBProgression = Number(progressBarElement?.getAttribute("aria-valuenow")); - if ( - !document.querySelector('[data-test="daily-quest-progress-slide"]') && - PBProgression < 10 - ) - user.lesson.finished = null; - if ( - user.lesson.finished || - document.querySelector('[data-test="daily-quest-progress-slide"]') || - document.querySelector('[data-test="session-complete-slide"]') - ) { - const path = user.lesson.finished ? [user.lesson.finished] : _path; + const progressBarElement = document.querySelector('div[role="progressbar"]') + const PBProgression = Number(progressBarElement?.getAttribute('aria-valuenow')) + if ( + !document.querySelector('[data-test="daily-quest-progress-slide"]') + && PBProgression < 10 + ) { + user.lesson.finished = null as unknown as string + } + if ( + user.lesson.finished + || document.querySelector('[data-test="daily-quest-progress-slide"]') + || document.querySelector('[data-test="session-complete-slide"]') + ) { + const path = user.lesson.finished ? [user.lesson.finished] : _path - switch (true) { - case path.includes("legendary"): - user.lesson.finished = "legendary"; - presenceData.details = `Finished ${giveArticle( - language.name - )} legendary challenge`; - break; - case path.includes("placement"): - user.lesson.finished = "placement"; - presenceData.details = `Finished ${language.name} placement test`; - break; - case path.includes("test"): - user.lesson.finished = "test"; - presenceData.details = `Passed ${giveArticle( - language.name - )} jump ahead test`; - break; - case path.includes("mistakes-review"): - user.lesson.finished = "mistakes-review"; - presenceData.details = "Finished reviewing past mistakes"; - break; - case path.includes("unit-rewind"): - user.lesson.finished = "unit-rewind"; - presenceData.details = "Finished reviewing old exercises"; - break; - case path.includes("listen-up"): - case path.includes("listening-practice"): - user.lesson.finished = "listening-practice"; - presenceData.details = `Finished ${language.name} listening exercises`; - break; - case path.includes("finished-default"): - default: - user.lesson.finished = "finished-default"; - presenceData.details = `Finished ${giveArticle(language.name)} lesson`; - } - } + switch (true) { + case path.includes('legendary'): + user.lesson.finished = 'legendary' + presenceData.details = `Finished ${giveArticle( + language.name, + )} legendary challenge` + break + case path.includes('placement'): + user.lesson.finished = 'placement' + presenceData.details = `Finished ${language.name} placement test` + break + case path.includes('test'): + user.lesson.finished = 'test' + presenceData.details = `Passed ${giveArticle( + language.name, + )} jump ahead test` + break + case path.includes('mistakes-review'): + user.lesson.finished = 'mistakes-review' + presenceData.details = 'Finished reviewing past mistakes' + break + case path.includes('unit-rewind'): + user.lesson.finished = 'unit-rewind' + presenceData.details = 'Finished reviewing old exercises' + break + case path.includes('listen-up'): + case path.includes('listening-practice'): + user.lesson.finished = 'listening-practice' + presenceData.details = `Finished ${language.name} listening exercises` + break + case path.includes('finished-default'): + default: + user.lesson.finished = 'finished-default' + presenceData.details = `Finished ${giveArticle(language.name)} lesson` + } + } - if (!user.lesson.finished && progressBarElement) { - user.lesson.active = true; + if (!user.lesson.finished && progressBarElement) { + user.lesson.active = true - presenceData.state = `${makeProgressBar( - PBProgression, - Number(progressBarElement?.getAttribute("aria-valuemax")), - (presenceData.details as string).length / 3.2, - /--web-ui_progress-bar-color: rgb\(var\(--color-(\w+)\)\);/.exec( - progressBarElement?.getAttribute("style") - )?.[1] - )}`; - if (!user.lesson.timeStamp) user.lesson.timeStamp = newTimeStamp(); - settings.showTimeOverwrite = false; - } else if (_path.includes("tips")) presenceData.state = "Viewing tips"; - else if (!user.lesson.active) { - settings.lastPath = "~"; - presenceData.state = "Loading..."; - settings.showTimeOverwrite = true; - user.lesson.finished = null; - } + presenceData.state = `${makeProgressBar( + PBProgression, + Number(progressBarElement?.getAttribute('aria-valuemax')), + (presenceData.details as string).length / 3.2, + /--web-ui_progress-bar-color: rgb\(var\(--color-(\w+)\)\);/.exec( + progressBarElement?.getAttribute('style') ?? '', + )?.[1], + )}` + if (!user.lesson.timeStamp) + user.lesson.timeStamp = newTimeStamp() + settings.showTimeOverwrite = false + } + else if (_path.includes('tips')) { + presenceData.state = 'Viewing tips' + } + else if (!user.lesson.active) { + settings.lastPath = '~' + presenceData.state = 'Loading...' + settings.showTimeOverwrite = true + user.lesson.finished = null as unknown as string + } } async function updateData(_inLesson = false) { - let state = JSON.parse(window.localStorage.getItem("duo.state")); - state = JSON.parse(await decompressGzip(state))?.state?.redux; - if (!state) return; - // resets lesson variables to default on updateData() - // on updateData(true), lesson variables stay untouched - if (!_inLesson) { - user.lesson.active = false; - user.lesson.finished = null; - settings.showTimeOverwrite = true; - } + let state = JSON.parse(window.localStorage.getItem('duo.state') ?? '') + state = JSON.parse(await decompressGzip(state))?.state?.redux + if (!state) + return + // resets lesson variables to default on updateData() + // on updateData(true), lesson variables stay untouched + if (!_inLesson) { + user.lesson.active = false + user.lesson.finished = null as unknown as string + settings.showTimeOverwrite = true + } - user.currentCourseId = state.user.currentCourseId; - if (user.currentCourseId) setLang(/_(.*?)_/.exec(user.currentCourseId)?.[1]); + user.currentCourseId = state.user.currentCourseId + if (user.currentCourseId) + setLang(/_(.*?)_/.exec(user.currentCourseId)?.[1] ?? '') - const showTime = await presence.getSetting("timestamps"); - settings.showTime = showTime; + const showTime = await presence.getSetting('timestamps') + settings.showTime = showTime } function setLang(code: string) { - language.code = code?.toLowerCase(); - language.name = LANGUAGE_NAMES[language.code] || null; - if (!language.name && language.code) { - setLang( - { - dn: "nl-nl", - nb: "no-bo", - zc: "zh-hk", - }[language.code] - ); - } else if (language.name && language.code) { - presenceData.smallImageKey = assets[`lang_${language.code.split("-")[0]}`]; - presenceData.smallImageText = `${language.name}`; - } else presenceData.smallImageKey = IMAGE.duoGlobe; + language.code = code?.toLowerCase() + language.name = LANGUAGE_NAMES[language.code] || null as unknown as string + if (!language.name && language.code) { + setLang( + { + dn: 'nl-nl', + nb: 'no-bo', + zc: 'zh-hk', + }[language.code]!, + ) + } + else if (language.name && language.code) { + presenceData.smallImageKey = assets[`lang_${language.code.split('-')[0]}`] + presenceData.smallImageText = `${language.name}` + } + else { + presenceData.smallImageKey = IMAGE.duoGlobe + } } -updateData(); -presence.on("UpdateData", async () => { - if (settings.lastPath === document.location.pathname) return; +updateData() +presence.on('UpdateData', async () => { + if (settings.lastPath === document.location.pathname) + return - const path = decodeURI(document.location.pathname).split("/"); + const path = decodeURI(document.location.pathname).split('/') - delete presenceData.details; - delete presenceData.smallImageKey; - delete presenceData.smallImageText; - delete presenceData.state; - delete presenceData.startTimestamp; + delete presenceData.details + delete presenceData.smallImageKey + delete presenceData.smallImageText + delete presenceData.state + delete presenceData.startTimestamp - switch (path[1]) { - case "learn": - updateData(); - presenceData.details = `Choosing ${giveArticle(language.name)} lesson`; - break; - case "characters": - updateData(); - presenceData.details = `Viewing ${language.name} characters`; - break; + switch (path[1]) { + case 'learn': + updateData() + presenceData.details = `Choosing ${giveArticle(language.name)} lesson` + break + case 'characters': + updateData() + presenceData.details = `Viewing ${language.name} characters` + break - case "mistakes-review": - updateData(true); - presenceData.details = "Reviewing recent mistakes"; - handleLesson(path); - break; - case "practice-hub": - switch (path[2]) { - case "unit-rewind": - updateData(true); - presenceData.details = "Reviewing old exercises"; - handleLesson(path); - break; - case "listen-up": - case "listening-practice": - updateData(true); - presenceData.details = `Practicing Listening in ${language.name}`; - handleLesson(path); - break; - default: - updateData(); - presenceData.details = "In practice hub"; - switch (true) { - case path.includes("mistakes"): - presenceData.state = "Viewing mistakes"; - break; - case path.includes("stories"): - presenceData.state = "Viewing stories"; - } - } - break; - case "lesson": - case "practice": - case "alphabets": - updateData(true); - switch (true) { - case path.includes("legendary"): - presenceData.details = `In ${giveArticle( - language.name - )} legendary challenge`; - break; + case 'mistakes-review': + updateData(true) + presenceData.details = 'Reviewing recent mistakes' + handleLesson(path) + break + case 'practice-hub': + switch (path[2]) { + case 'unit-rewind': + updateData(true) + presenceData.details = 'Reviewing old exercises' + handleLesson(path) + break + case 'listen-up': + case 'listening-practice': + updateData(true) + presenceData.details = `Practicing Listening in ${language.name}` + handleLesson(path) + break + default: + updateData() + presenceData.details = 'In practice hub' + switch (true) { + case path.includes('mistakes'): + presenceData.state = 'Viewing mistakes' + break + case path.includes('stories'): + presenceData.state = 'Viewing stories' + } + } + break + case 'lesson': + case 'practice': + case 'alphabets': + updateData(true) + switch (true) { + case path.includes('legendary'): + presenceData.details = `In ${giveArticle( + language.name, + )} legendary challenge` + break - case path.includes("test"): - presenceData.details = `Taking ${giveArticle( - language.name - )} jump ahead test`; - break; - case path.includes("alphabets"): - if (path[3] === "tips") { - presenceData.details = "Viewing alphabet tips"; - presenceData.state = `${language.name}`; - } else presenceData.details = `Learning ${path[3]} alphabet`; - break; + case path.includes('test'): + presenceData.details = `Taking ${giveArticle( + language.name, + )} jump ahead test` + break + case path.includes('alphabets'): + if (path[3] === 'tips') { + presenceData.details = 'Viewing alphabet tips' + presenceData.state = `${language.name}` + } + else { + presenceData.details = `Learning ${path[3]} alphabet` + } + break - default: - presenceData.details = `Working on ${giveArticle( - language.name - )} lesson`; - } - if (!path.includes("tips")) handleLesson(path); - break; + default: + presenceData.details = `Working on ${giveArticle( + language.name, + )} lesson` + } + if (!path.includes('tips')) + handleLesson(path) + break - case "placement": - setLang(path[2]); - presenceData.details = `Taking ${language.name} placement test`; - handleLesson(path); - break; + case 'placement': + setLang(path[2]) + presenceData.details = `Taking ${language.name} placement test` + handleLesson(path) + break - case "leaderboard": - presenceData.details = "Viewing leaderboard"; - break; + case 'leaderboard': + presenceData.details = 'Viewing leaderboard' + break - case "quests": - presenceData.state = "Viewing quests"; - break; + case 'quests': + presenceData.state = 'Viewing quests' + break - case "shop": - presenceData.state = "Viewing shop"; - break; + case 'shop': + presenceData.state = 'Viewing shop' + break - case "courses": - presenceData.details = "Viewing available courses"; - presenceData.smallImageKey = IMAGE.duoGlobe; - presenceData.smallImageText = "viewing courses"; - break; - case "enroll": - setLang(path[2]); - presenceData.details = `Viewing ${language.name} course`; - break; + case 'courses': + presenceData.details = 'Viewing available courses' + presenceData.smallImageKey = IMAGE.duoGlobe + presenceData.smallImageText = 'viewing courses' + break + case 'enroll': + setLang(path[2]) + presenceData.details = `Viewing ${language.name} course` + break - case "year-in-review": - presenceData.details = `Viewing ${path[2]} Year in Review`; - break; - case "profile": - case "u": { - const username = path[2], - displayName = document.querySelector( - 'h1[data-test="profile-username"] span' - )?.textContent, - img = document.querySelector( - `img[alt="${displayName}"]` - )?.src, - i = users.findIndex(user => user.username === username); + case 'year-in-review': + presenceData.details = `Viewing ${path[2]} Year in Review` + break + case 'profile': + case 'u': { + const username = path[2] + const displayName = document.querySelector( + 'h1[data-test="profile-username"] span', + )?.textContent ?? undefined + const img = document.querySelector( + `img[alt="${displayName}"]`, + )?.src + const i = users.findIndex(user => user.username === username) - if (i !== -1) { - updateUndefinedKeys(users[i], { - username, - displayName, - img, - }); - } else { - users.push({ username, displayName, img }); - if (users.length > 20) users.shift(); - } + if (i !== -1) { + updateUndefinedKeys(users[i], { + username, + displayName, + img, + }) + } + else { + users.push({ username, displayName, img }) + if (users.length > 20) + users.shift() + } - localStorage.setItem("PMD-users-cache", JSON.stringify(users)); + localStorage.setItem('PMD-users-cache', JSON.stringify(users)) - if (!users[i]?.displayName) { - settings.lastPath = "~"; - return; - } + if (!users[i]?.displayName) { + settings.lastPath = '~' + return + } - presenceData.details = `${path[3] ? "On" : "Viewing"} ${ - users[i]?.displayName ?? displayName - }'s profile`; - if (path[3]) presenceData.state = `Viewing ${path[3]}`; - presenceData.smallImageKey = users[i]?.img ?? img ?? IMAGE.profileDuo; - presenceData.smallImageText = path[1] === "u" ? displayName : username; - break; - } - case "settings": - presenceData.details = `In ${deEsser(path[2])} settings`; - presenceData.smallImageKey = IMAGE.duoTool; - break; - } + presenceData.details = `${path[3] ? 'On' : 'Viewing'} ${ + users[i]?.displayName ?? displayName + }'s profile` + if (path[3]) + presenceData.state = `Viewing ${path[3]}` + presenceData.smallImageKey = users[i]?.img ?? img ?? IMAGE.profileDuo + presenceData.smallImageText = path[1] === 'u' ? displayName : username + break + } + case 'settings': + presenceData.details = `In ${deEsser(path[2])} settings` + presenceData.smallImageKey = IMAGE.duoTool + break + } - if (!user.lesson.active) user.lesson.timeStamp = null; - if (settings.showTime && !settings.showTimeOverwrite) - presenceData.startTimestamp = user.lesson.timeStamp ?? timeStamp; + if (!user.lesson.active) + user.lesson.timeStamp = null as unknown as number + if (settings.showTime && !settings.showTimeOverwrite) + presenceData.startTimestamp = user.lesson.timeStamp ?? timeStamp - presence.setActivity(presenceData); + presence.setActivity(presenceData) - settings.lastPath = document.location.pathname; + settings.lastPath = document.location.pathname - timeoutId = setTimeout(() => { - settings.lastPath = "~"; - clearTimeout(timeoutId); - }, 2000); -}); + timeoutId = setTimeout(() => { + settings.lastPath = '~' + clearTimeout(timeoutId) + }, 2000) +}) diff --git a/websites/D/Duolingo/util.ts b/websites/D/Duolingo/util.ts index 0ec9ef1514c4..291966b971c6 100644 --- a/websites/D/Duolingo/util.ts +++ b/websites/D/Duolingo/util.ts @@ -1,120 +1,118 @@ export function makePossessive(name: string): string { - return name.endsWith("s") ? `${name}'` : `${name}'s`; + return name.endsWith('s') ? `${name}'` : `${name}'s` } export function deEsser(word: string): string { - return word.endsWith("s") ? word.slice(0, -1) : word; + return word.endsWith('s') ? word.slice(0, -1) : word } export function giveArticle(word: string): string { - return `${ - ["a", "e", "i", "o", "u"].some(vowel => - word.toLowerCase().startsWith(vowel) - ) - ? "an" - : "a" - } ${word}`; + return `${ + ['a', 'e', 'i', 'o', 'u'].some(vowel => + word.toLowerCase().startsWith(vowel), + ) + ? 'an' + : 'a' + } ${word}` } export function makeProgressBar( - value: number, - maxValue: number, - size: number, - color?: string + value: number, + maxValue: number, + size: number, + color?: string, ): string { - const progressPercentage = Math.min( - 100, - Math.max(0, Math.floor((value / maxValue) * 100)) - ), - completedSquares = Math.floor((progressPercentage * size) / 100); + const progressPercentage = Math.min( + 100, + Math.max(0, Math.floor((value / maxValue) * 100)), + ) + const completedSquares = Math.floor((progressPercentage * size) / 100) - return `${( - { - owl: "🟩", - bee: "🟨", - fox: "🟨", - cosmos: "🟦", - }[color] ?? "🟩" - ).repeat(completedSquares)}${"⬛".repeat( - size - completedSquares - )} ${progressPercentage}%`; + return `${( + { + owl: '🟩', + bee: '🟨', + fox: '🟨', + cosmos: '🟦', + }[color ?? ''] ?? '🟩' + ).repeat(completedSquares)}${'⬛'.repeat( + size - completedSquares, + )} ${progressPercentage}%` } -//have to define because outdated ts version -type DecompressionStream = GenericTransformStream; -type CompressionFormat = "deflate" | "deflate-raw" | "gzip"; +// have to define because outdated ts version +type TDecompressionStream = GenericTransformStream +type TCompressionFormat = 'deflate' | 'deflate-raw' | 'gzip' declare const DecompressionStream: { - prototype: DecompressionStream; - new (format: CompressionFormat): DecompressionStream; -}; + prototype: TDecompressionStream + new (format: TCompressionFormat): TDecompressionStream +} export async function decompressGzip( - base64GzipString: string + base64GzipString: string, ): Promise { - const bytes = Uint8Array.from(atob(base64GzipString), c => c.charCodeAt(0)), - stream = new DecompressionStream("gzip"), - writer = stream.writable.getWriter(); - writer.write(bytes); - writer.close(); - return new Response(stream.readable) - .arrayBuffer() - .then(function (arrayBuffer) { - return new TextDecoder().decode(arrayBuffer); - }); + const bytes = Uint8Array.from(atob(base64GzipString), c => c.charCodeAt(0)) + const stream = new DecompressionStream('gzip') + const writer = stream.writable.getWriter() + writer.write(bytes) + writer.close() + return new Response(stream.readable) + .arrayBuffer() + .then((arrayBuffer) => { + return new TextDecoder().decode(arrayBuffer) + }) } -type obj = Record; +type obj = Record export function updateUndefinedKeys(obj1: obj, obj2: obj): void { - for (const key of Object.keys(obj2)) { - if (Object.prototype.hasOwnProperty.call(obj2, key) && !obj1[key]) - obj1[key] = obj2[key]; - } + for (const key of Object.keys(obj2)) { + if (Object.prototype.hasOwnProperty.call(obj2, key) && !obj1[key]) + obj1[key] = obj2[key] + } } -/* eslint-disable camelcase */ export const assets: Record = { - lang_tlh: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/3.png", - lang_tr: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/4.png", - lang_uk: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/5.png", - lang_vi: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/6.png", - lang_yi: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/7.png", - lang_zh: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/8.png", - lang_zu: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/9.png", - lang_ar: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/10.png", - lang_ca: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/11.png", - lang_cs: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/12.png", - lang_cy: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/13.png", - lang_da: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/14.png", - lang_de: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/15.png", - lang_el: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/16.png", - lang_eo: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/17.png", - lang_es: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/18.png", - lang_fr: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/19.png", - lang_ga: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/20.png", - lang_gd: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/21.png", - lang_he: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/22.png", - lang_hi: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/23.png", - lang_hu: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/24.png", - lang_hv: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/25.png", - lang_hw: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/26.png", - lang_it: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/27.png", - lang_ja: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/28.png", - lang_la: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/29.png", - lang_nv: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/30.png", - lang_pl: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/31.png", - lang_ro: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/32.png", - lang_ru: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/33.png", - lang_sw: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/34.png", - lang_th: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/35.png", - lang_en: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/36.png", - lang_fi: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/37.png", - lang_gn: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/38.png", - lang_ht: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/39.png", - lang_id: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/40.png", - lang_ko: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/41.png", - lang_pt: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/42.png", - lang_sv: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/43.png", - lang_nl: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/44.png", - lang_no: "https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/45.png", -}; -/* eslint-enable camelcase */ + lang_tlh: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/3.png', + lang_tr: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/4.png', + lang_uk: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/5.png', + lang_vi: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/6.png', + lang_yi: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/7.png', + lang_zh: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/8.png', + lang_zu: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/9.png', + lang_ar: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/10.png', + lang_ca: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/11.png', + lang_cs: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/12.png', + lang_cy: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/13.png', + lang_da: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/14.png', + lang_de: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/15.png', + lang_el: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/16.png', + lang_eo: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/17.png', + lang_es: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/18.png', + lang_fr: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/19.png', + lang_ga: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/20.png', + lang_gd: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/21.png', + lang_he: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/22.png', + lang_hi: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/23.png', + lang_hu: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/24.png', + lang_hv: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/25.png', + lang_hw: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/26.png', + lang_it: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/27.png', + lang_ja: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/28.png', + lang_la: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/29.png', + lang_nv: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/30.png', + lang_pl: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/31.png', + lang_ro: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/32.png', + lang_ru: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/33.png', + lang_sw: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/34.png', + lang_th: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/35.png', + lang_en: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/36.png', + lang_fi: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/37.png', + lang_gn: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/38.png', + lang_ht: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/39.png', + lang_id: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/40.png', + lang_ko: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/41.png', + lang_pt: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/42.png', + lang_sv: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/43.png', + lang_nl: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/44.png', + lang_no: 'https://cdn.rcd.gg/PreMiD/websites/D/Duolingo/assets/45.png', +} diff --git a/websites/D/Durarara/metadata.json b/websites/D/Durarara/metadata.json index 2b863fbfdbce..f1520f6239e7 100644 --- a/websites/D/Durarara/metadata.json +++ b/websites/D/Durarara/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Dawkin Nguyen", - "id": "414274321779916800" - }, - "service": "Durarara", - "description": { - "en": "Durarara!! fan community, DOLLARS Chatroom.", - "nl": "Durarara!! fan gemeenschap, DOLLARS chatroom." - }, - "url": "drrr.com", - "version": "1.0.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Durarara/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Durarara/assets/thumbnail.png", - "color": "#696969", - "category": "socials", - "tags": [ - "anime", - "socials" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Dawkin Nguyen", + "id": "414274321779916800" + }, + "service": "Durarara", + "description": { + "en": "Durarara!! fan community, DOLLARS Chatroom.", + "nl": "Durarara!! fan gemeenschap, DOLLARS chatroom." + }, + "url": "drrr.com", + "version": "1.0.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Durarara/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Durarara/assets/thumbnail.png", + "color": "#696969", + "category": "socials", + "tags": [ + "anime", + "socials" + ] +} diff --git a/websites/D/Durarara/presence.ts b/websites/D/Durarara/presence.ts index 431b5d947523..701fe6fe16b5 100644 --- a/websites/D/Durarara/presence.ts +++ b/websites/D/Durarara/presence.ts @@ -1,34 +1,35 @@ const presence = new Presence({ - clientId: "712269360206708766", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '712269360206708766', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/Durarara/assets/logo.png", - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Durarara/assets/logo.png', + startTimestamp: browsingTimestamp, + } - if (document.location.pathname.includes("/lounge")) { - presenceData.details = "Searching for a room"; - presenceData.state = `Username: ${ - document.querySelector(".name").textContent - }`; - presenceData.smallImageKey = Assets.Search; - } else if (document.location.pathname.includes("/create_room")) - presenceData.details = "Creating a room"; - else if (document.location.pathname.includes("/room/")) { - presenceData.details = `In a room: ${ - document.querySelector(".room-title-name").textContent - }`; - presenceData.state = `Members: ${ - document.querySelector(".room-title-capacity").textContent - }`; - presenceData.smallImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/Durarara/assets/0.png"; - } + if (document.location.pathname.includes('/lounge')) { + presenceData.details = 'Searching for a room' + presenceData.state = `Username: ${ + document.querySelector('.name')?.textContent + }` + presenceData.smallImageKey = Assets.Search + } + else if (document.location.pathname.includes('/create_room')) { + presenceData.details = 'Creating a room' + } + else if (document.location.pathname.includes('/room/')) { + presenceData.details = `In a room: ${ + document.querySelector('.room-title-name')?.textContent + }` + presenceData.state = `Members: ${ + document.querySelector('.room-title-capacity')?.textContent + }` + presenceData.smallImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/Durarara/assets/0.png' + } - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/Dyno/metadata.json b/websites/D/Dyno/metadata.json index ad20a03f22a4..04263179af64 100644 --- a/websites/D/Dyno/metadata.json +++ b/websites/D/Dyno/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Bas950", - "id": "241278257335500811" - }, - "service": "Dyno", - "description": { - "en": "A fully customizable server moderation Discord bot for your Discord server that features a simple and intuitive web dashboard. Server management just got a whole lot easier.", - "nl": "Een volledig aanpasbare servermoderatie Discord-bot voor uw Discord-server met een eenvoudig en intuïtief webdashboard. Serverbeheer is nu een stuk eenvoudiger geworden." - }, - "url": "dyno.gg", - "version": "1.2.21", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dyno/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dyno/assets/thumbnail.png", - "color": "#337fd5", - "category": "other", - "tags": [ - "bot", - "discord" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Bas950", + "id": "241278257335500811" + }, + "service": "Dyno", + "description": { + "en": "A fully customizable server moderation Discord bot for your Discord server that features a simple and intuitive web dashboard. Server management just got a whole lot easier.", + "nl": "Een volledig aanpasbare servermoderatie Discord-bot voor uw Discord-server met een eenvoudig en intuïtief webdashboard. Serverbeheer is nu een stuk eenvoudiger geworden." + }, + "url": "dyno.gg", + "version": "1.2.21", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/Dyno/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Dyno/assets/thumbnail.png", + "color": "#337fd5", + "category": "other", + "tags": [ + "bot", + "discord" + ] +} diff --git a/websites/D/Dyno/presence.ts b/websites/D/Dyno/presence.ts index d8ed2e12b1e6..d03773731612 100644 --- a/websites/D/Dyno/presence.ts +++ b/websites/D/Dyno/presence.ts @@ -1,41 +1,48 @@ const presence = new Presence({ - clientId: "633801594541965334", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '633801594541965334', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) -let title: HTMLElement; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/Dyno/assets/logo.png', + startTimestamp: browsingTimestamp, + } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/D/Dyno/assets/logo.png", - startTimestamp: browsingTimestamp, - }; + if (document.location.pathname.includes('/bot')) { + presenceData.details = 'Reading about the bot' + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/account')) { + presenceData.details = 'Viewing their account' + } + else if (document.location.pathname.includes('/manage/')) { + presenceData.details = 'Managing the settings of' + const title = document.querySelector( + '#dashboard-mount > div > div.column.nav-sidebar > aside > div.guild-header > h3 > div > div', + ) + presenceData.state = `server: ${title?.textContent}` + presenceData.smallImageKey = Assets.Writing + } + else if (document.location.pathname.includes('/servers')) { + presenceData.details = 'Browsing through the' + presenceData.state = 'server listings' + } + else if (document.location.pathname.includes('/commands')) { + presenceData.details = 'Viewing all the commands' + } + else if (document.location.pathname.includes('faq')) { + presenceData.details = 'Reading the FAQ' + presenceData.smallImageKey = Assets.Reading + } + else if (document.location.pathname.includes('/status')) { + presenceData.details = 'Viewing the status' + } + else if (document.location.pathname.includes('/upgrade')) { + presenceData.details = 'Viewing Dyno Premium Plans' + } - if (document.location.pathname.includes("/bot")) { - presenceData.details = "Reading about the bot"; - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/account")) - presenceData.details = "Viewing their account"; - else if (document.location.pathname.includes("/manage/")) { - presenceData.details = "Managing the settings of"; - title = document.querySelector( - "#dashboard-mount > div > div.column.nav-sidebar > aside > div.guild-header > h3 > div > div" - ); - presenceData.state = `server: ${title.textContent}`; - presenceData.smallImageKey = Assets.Writing; - } else if (document.location.pathname.includes("/servers")) { - presenceData.details = "Browsing through the"; - presenceData.state = "server listings"; - } else if (document.location.pathname.includes("/commands")) - presenceData.details = "Viewing all the commands"; - else if (document.location.pathname.includes("faq")) { - presenceData.details = "Reading the FAQ"; - presenceData.smallImageKey = Assets.Reading; - } else if (document.location.pathname.includes("/status")) - presenceData.details = "Viewing the status"; - else if (document.location.pathname.includes("/upgrade")) - presenceData.details = "Viewing Dyno Premium Plans"; - - if (presenceData.details) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (presenceData.details) + presence.setActivity(presenceData) + else presence.setActivity() +}) diff --git a/websites/D/daily.dev/metadata.json b/websites/D/daily.dev/metadata.json index 52cc910284ae..8e1ce9fea44a 100644 --- a/websites/D/daily.dev/metadata.json +++ b/websites/D/daily.dev/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "937757295453044806", - "name": "atsukoro" - }, - "service": "daily.dev", - "description": { - "en": "We know how hard it is to be a developer. It doesn't have to be. Personalized news feed, dev communities and search, much better than what’s out there. Maybe ;)" - }, - "url": "app.daily.dev", - "version": "1.0.3", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/daily.dev/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/daily.dev/assets/thumbnail.png", - "color": "#0E1217", - "category": "socials", - "tags": [ - "developer", - "social", - "news" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "937757295453044806", + "name": "atsukoro" + }, + "service": "daily.dev", + "description": { + "en": "We know how hard it is to be a developer. It doesn't have to be. Personalized news feed, dev communities and search, much better than what’s out there. Maybe ;)" + }, + "url": "app.daily.dev", + "version": "1.0.3", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/daily.dev/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/daily.dev/assets/thumbnail.png", + "color": "#0E1217", + "category": "socials", + "tags": [ + "developer", + "social", + "news" + ] +} diff --git a/websites/D/daily.dev/presence.ts b/websites/D/daily.dev/presence.ts index 01dd792a1b12..189a28e49f4a 100644 --- a/websites/D/daily.dev/presence.ts +++ b/websites/D/daily.dev/presence.ts @@ -1,121 +1,121 @@ const presence = new Presence({ - clientId: "1248697988331864084", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1248697988331864084', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/daily.dev/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/daily.dev/assets/logo.png', } -const processPostSite = (): Partial => { - return { - details: "Reading a post", - state: document.querySelector("h1")?.textContent, - buttons: [ - { - label: "Read Post", - url: document.location.href, - }, - ], - }; - }, - processSourceSite = () => { - return { - details: "Reading a source", - state: `Source: ${document.querySelector("h1")?.textContent}`, - }; - }, - processSearchSite = () => { - return { - details: "Searching", - state: `Searching for ${new URLSearchParams(document.location.search).get( - "search" - )}`, - }; - }, - siteDataMap = [ - { - path: /^\/$/, - process: () => ({ - details: "Homepage", - state: "Discovering new posts", - }), - }, - { - path: /^\/posts\/[a-z0-9-]+$/, - process: processPostSite, - }, - { - path: /^\/squads$/, - process: () => ({ - details: "Squads page", - state: "Discovering new squads", - }), - }, - { - path: /^\/discussed$/, - process: () => ({ - details: "Discussion homepage", - state: "Discovering new discussions", - }), - }, - { - path: /^\/bookmarks$/, - process: () => ({ - details: "Bookmarks", - state: "Discovering saved posts", - }), - }, - { - path: /^\/popular$/, - process: () => ({ - details: "Popular posts", - state: "Discovering popular posts", - }), - }, - { - path: /^\/sources\/.*$/, - process: processSourceSite, - }, - { - path: /^\/upvoted\/.*$/, - process: () => ({ - details: "Upvoted posts", - state: "Discovering upvoted posts", - }), - }, - { - path: /^\/search$/, - process: () => ({ - details: "Searching", - process: processSearchSite, - }), - }, - { - path: /^\/history\/.*$/, - process: () => ({ - details: "History", - state: "Browsing personal history", - }), - }, - ]; +function processPostSite(): Partial { + return { + details: 'Reading a post', + state: document.querySelector('h1')?.textContent, + buttons: [ + { + label: 'Read Post', + url: document.location.href, + }, + ], + } +} +function processSourceSite() { + return { + details: 'Reading a source', + state: `Source: ${document.querySelector('h1')?.textContent}`, + } +} +function processSearchSite() { + return { + details: 'Searching', + state: `Searching for ${new URLSearchParams(document.location.search).get( + 'search', + )}`, + } +} +const siteDataMap = [ + { + path: /^\/$/, + process: () => ({ + details: 'Homepage', + state: 'Discovering new posts', + }), + }, + { + path: /^\/posts\/[a-z0-9-]+$/, + process: processPostSite, + }, + { + path: /^\/squads$/, + process: () => ({ + details: 'Squads page', + state: 'Discovering new squads', + }), + }, + { + path: /^\/discussed$/, + process: () => ({ + details: 'Discussion homepage', + state: 'Discovering new discussions', + }), + }, + { + path: /^\/bookmarks$/, + process: () => ({ + details: 'Bookmarks', + state: 'Discovering saved posts', + }), + }, + { + path: /^\/popular$/, + process: () => ({ + details: 'Popular posts', + state: 'Discovering popular posts', + }), + }, + { + path: /^\/sources\/.*$/, + process: processSourceSite, + }, + { + path: /^\/upvoted\/.*$/, + process: () => ({ + details: 'Upvoted posts', + state: 'Discovering upvoted posts', + }), + }, + { + path: /^\/search$/, + process: () => ({ + details: 'Searching', + process: processSearchSite, + }), + }, + { + path: /^\/history\/.*$/, + process: () => ({ + details: 'History', + state: 'Browsing personal history', + }), + }, +] -presence.on("UpdateData", async () => { - let presenceData: PresenceData = { - largeImageKey: Assets.Logo, - startTimestamp: browsingTimestamp, - }; +presence.on('UpdateData', async () => { + let presenceData: PresenceData = { + largeImageKey: Assets.Logo, + startTimestamp: browsingTimestamp, + } - const siteData = siteDataMap.find(siteData => - siteData.path.test(document.location.pathname) - ); + const siteData = siteDataMap.find(siteData => + siteData.path.test(document.location.pathname), + ) - if (siteData) { - presenceData = { - ...presenceData, - ...siteData.process(), - }; - } + if (siteData) { + presenceData = { + ...presenceData, + ...siteData.process(), + } as PresenceData + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/D/dailymotion/metadata.json b/websites/D/dailymotion/metadata.json index 19e880572b2a..5c932822665f 100644 --- a/websites/D/dailymotion/metadata.json +++ b/websites/D/dailymotion/metadata.json @@ -1,30 +1,30 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Striker", - "id": "215509157837537280" - }, - "contributors": [ - { - "name": "TheSlowly", - "id": "505071508851523599" - } - ], - "service": "dailymotion", - "description": { - "en": "On dailymotion, you can discover and watch new music, news, sports, and trailers from dailymotion's best creators, brands, and channels", - "de": "Auf dailymotion kannst du neue Musik, Nachrichten, Sportsendungen und Trailer von den besten Kreativen, Marken und Kanälen auf dailymotion entdecken und ansehen.", - "nl": "In Explore, kan je nieuwe muziek, nieuws, sport en trailers van de beste Dailymotion makers, merken en kanalen ontdekken en bekijken.", - "pt_BR": "No dailymotion, você pode descobrir e assistir novas músicas, noticías, esportes, e trailers dos melhores criadores do dailymotion, marcas e canais" - }, - "url": "www.dailymotion.com", - "version": "1.2.24", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/dailymotion/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/dailymotion/assets/thumbnail.png", - "color": "#005CCC", - "category": "videos", - "tags": [ - "videos" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Striker", + "id": "215509157837537280" + }, + "contributors": [ + { + "name": "TheSlowly", + "id": "505071508851523599" + } + ], + "service": "dailymotion", + "description": { + "en": "On dailymotion, you can discover and watch new music, news, sports, and trailers from dailymotion's best creators, brands, and channels", + "de": "Auf dailymotion kannst du neue Musik, Nachrichten, Sportsendungen und Trailer von den besten Kreativen, Marken und Kanälen auf dailymotion entdecken und ansehen.", + "nl": "In Explore, kan je nieuwe muziek, nieuws, sport en trailers van de beste Dailymotion makers, merken en kanalen ontdekken en bekijken.", + "pt_BR": "No dailymotion, você pode descobrir e assistir novas músicas, noticías, esportes, e trailers dos melhores criadores do dailymotion, marcas e canais" + }, + "url": "www.dailymotion.com", + "version": "1.2.24", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/dailymotion/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/dailymotion/assets/thumbnail.png", + "color": "#005CCC", + "category": "videos", + "tags": [ + "videos" + ] +} diff --git a/websites/D/dailymotion/presence.ts b/websites/D/dailymotion/presence.ts index 587c218f010d..82ccb4428e33 100644 --- a/websites/D/dailymotion/presence.ts +++ b/websites/D/dailymotion/presence.ts @@ -1,49 +1,47 @@ const presence = new Presence({ - clientId: "611668948131512321", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dailymotion/assets/logo.png", - }; + clientId: '611668948131512321', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) +const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dailymotion/assets/logo.png', +} -presence.on("UpdateData", async () => { - const video: HTMLVideoElement = document.querySelector("#dmp_Video"); - if (video && !isNaN(video.duration)) { - const title = document.querySelector(".VideoInfoTitle__videoTitle___3WLlw"), - uploader = document.querySelector(".ChannelLine__channelName___3JE1B"); - presenceData.details = title - ? (title as HTMLElement).textContent - : "Title not found..."; - presenceData.state = uploader - ? (uploader as HTMLElement).textContent - : "Uploader not found..."; - presenceData.largeImageKey = - "https://cdn.rcd.gg/PreMiD/websites/D/dailymotion/assets/logo.png"; - presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play; - presenceData.smallImageText = video.paused - ? (await strings).pause - : (await strings).play; - [presenceData.startTimestamp, presenceData.endTimestamp] = - presence.getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ); +presence.on('UpdateData', async () => { + const video = document.querySelector('#dmp_Video') + if (video && !Number.isNaN(video.duration)) { + const title = document.querySelector('.VideoInfoTitle__videoTitle___3WLlw') + const uploader = document.querySelector('.ChannelLine__channelName___3JE1B') + presenceData.details = title + ? (title as HTMLElement).textContent + : 'Title not found...' + presenceData.state = uploader + ? (uploader as HTMLElement).textContent + : 'Uploader not found...' + presenceData.largeImageKey = 'https://cdn.rcd.gg/PreMiD/websites/D/dailymotion/assets/logo.png' + presenceData.smallImageKey = video.paused ? Assets.Pause : Assets.Play + presenceData.smallImageText = video.paused + ? (await strings).pause + : (await strings).play; + [presenceData.startTimestamp, presenceData.endTimestamp] = presence.getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) - if (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/D/dailymotion/assets/logo.png", - }); - } -}); + if (title && uploader) + presence.setActivity(presenceData, !video.paused) + } + else { + presence.setActivity({ + details: 'Browsing..', + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dailymotion/assets/logo.png', + }) + } +}) diff --git a/websites/D/dizilab/iframe.ts b/websites/D/dizilab/iframe.ts index ae3a46f63b89..2f1075329a26 100644 --- a/websites/D/dizilab/iframe.ts +++ b/websites/D/dizilab/iframe.ts @@ -1,27 +1,27 @@ -const iframe = new iFrame(); +const iframe = new iFrame() -setInterval(function () { - const video = - (document.querySelector("#vplayer video") as HTMLVideoElement) || - (document.querySelector("video") as HTMLVideoElement); +setInterval(() => { + const video = (document.querySelector('#vplayer video') ?? document.querySelector('video')) - if (video && document.location.hostname === "vidmoly.to") { - iframe.send({ - error: false, - currentTime: video.currentTime, - duration: video.duration, - paused: video.paused, - }); - } else if (video && document.location.hostname !== "vidmoly.to") { - iframe.send({ - error: false, - currentTime: video.currentTime, - duration: video.duration, - paused: video.paused, - }); - } else { - iframe.send({ - error: true, - }); - } -}, 100); + if (video && document.location.hostname === 'vidmoly.to') { + iframe.send({ + error: false, + currentTime: video.currentTime, + duration: video.duration, + paused: video.paused, + }) + } + else if (video && document.location.hostname !== 'vidmoly.to') { + iframe.send({ + error: false, + currentTime: video.currentTime, + duration: video.duration, + paused: video.paused, + }) + } + else { + iframe.send({ + error: true, + }) + } +}, 100) diff --git a/websites/D/dizilab/metadata.json b/websites/D/dizilab/metadata.json index 079da7a83c4f..81fd457fb9f0 100644 --- a/websites/D/dizilab/metadata.json +++ b/websites/D/dizilab/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "EGGSY", - "id": "162969778699501569" - }, - "service": "dizilab", - "description": { - "en": "dizilab is one of the biggest Turkish foreign TV show providers on internet.", - "tr": "dizilab, son çıkan, güncel ve bir çok yabancı diziyi izleyebileceğiniz bir yabancı dizi sitesidir.", - "nl": "dizilab is een van de grootste aanbieders van Turkse buitenlandse TV-programma's op internet." - }, - "url": "dizilab.io", - "version": "1.4.31", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/thumbnail.png", - "color": "#444f53", - "category": "videos", - "tags": [ - "video", - "tvshows", - "turkish" - ], - "iframe": true, - "iFrameRegExp": ".*" -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "EGGSY", + "id": "162969778699501569" + }, + "service": "dizilab", + "description": { + "en": "dizilab is one of the biggest Turkish foreign TV show providers on internet.", + "tr": "dizilab, son çıkan, güncel ve bir çok yabancı diziyi izleyebileceğiniz bir yabancı dizi sitesidir.", + "nl": "dizilab is een van de grootste aanbieders van Turkse buitenlandse TV-programma's op internet." + }, + "url": "dizilab.io", + "version": "1.4.31", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/thumbnail.png", + "color": "#444f53", + "category": "videos", + "tags": [ + "video", + "tvshows", + "turkish" + ], + "iframe": true, + "iFrameRegExp": ".*" +} diff --git a/websites/D/dizilab/presence.ts b/websites/D/dizilab/presence.ts index 25422dda1692..1c469d807261 100644 --- a/websites/D/dizilab/presence.ts +++ b/websites/D/dizilab/presence.ts @@ -1,311 +1,304 @@ const presence = new Presence({ - clientId: "635199664290922512", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }), - pages: { - [name: string]: string; - } = { - "/": "Ana Sayfa", - "/uyeler": "Üyeler", - "/yabanci-dizi-takvimi": "Dizi Takvimi", - "/forum": "Forum", - "/basvuru": "Çevirmenlik", - "/iletisim": "İletişim", - "/sifre_sifirla": "Şifre Sıfırla", - "/mesajlar": "Özel Mesajlar", - "/oyuncular": "Oyuncular", - "/pano": "Pano", - "/pano/sosyal-akis": "Sosyal Akış", - "/pano/takip-ettiklerim": "Takip Ettiklerim", - "/pano/izleme-listesi": "İzleme Listesi", - "/pano/son-izlediklerim": "Son İzlediklerim", - }; + clientId: '635199664290922512', +}) +const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', +}) +const pages: { + [name: string]: string +} = { + '/': 'Ana Sayfa', + '/uyeler': 'Üyeler', + '/yabanci-dizi-takvimi': 'Dizi Takvimi', + '/forum': 'Forum', + '/basvuru': 'Çevirmenlik', + '/iletisim': 'İletişim', + '/sifre_sifirla': 'Şifre Sıfırla', + '/mesajlar': 'Özel Mesajlar', + '/oyuncular': 'Oyuncular', + '/pano': 'Pano', + '/pano/sosyal-akis': 'Sosyal Akış', + '/pano/takip-ettiklerim': 'Takip Ettiklerim', + '/pano/izleme-listesi': 'İzleme Listesi', + '/pano/son-izlediklerim': 'Son İzlediklerim', +} -let video: Video; +let video: Video interface Video extends HTMLVideoElement { - dataAvailable: boolean; + dataAvailable: boolean } -presence.on("iFrameData", (data: Video) => { - if (!data.error) { - video = data; - video.dataAvailable = true; - } -}); +presence.on('iFrameData', (inc: unknown) => { + const data = inc as Video + if (!data.error) { + video = data + video.dataAvailable = true + } +}) -presence.on("UpdateData", async () => { - const page = document.location.pathname, - _video = document.querySelector("video") as HTMLVideoElement, - isVideoData = Object.keys(video).length > 0 ? true : false, - showTitle = document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-profile-head > div.tv-series-right-content > h1" - ), - actorName = document.querySelector( - "#container > div.content > div.right > div.artist-right > div.artist-name > h1" - ); +presence.on('UpdateData', async () => { + const page = document.location.pathname + const _video = document.querySelector('video') as HTMLVideoElement + const isVideoData = Object.keys(video).length > 0 + const showTitle = document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-profile-head > div.tv-series-right-content > h1', + ) + const actorName = document.querySelector( + '#container > div.content > div.right > div.artist-right > div.artist-name > h1', + ) - if (!isVideoData && page.includes("/arsiv")) { - const url = new URL(document.location.href), - genre = url.searchParams.get("tur"), - showName = url.searchParams.get("dizi_adi"); + if (!isVideoData && page.includes('/arsiv')) { + const url = new URL(document.location.href) + const genre = url.searchParams.get('tur') + const showName = url.searchParams.get('dizi_adi') - if ( - !document.location.search || - document.location.search === "" || - (document.location.search !== "" && !genre && !showName) || - (document.location.search !== "" && genre === "" && showName === "") - ) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: "Bir sayfaya göz atıyor:", - state: "Arşiv", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if ((genre && !showName) || (genre && showName === "")) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: "Bir kategoriye göz atıyor:", - state: genre, - smallImageKey: Assets.Search, - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (genre && showName) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: "Bir dizi arıyor:", - state: `${showName} (${genre})`, - smallImageKey: Assets.Search, - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if ( - (!genre && showName) || - (genre === "" && showName && showName !== "") - ) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: "Bir dizi arıyor:", - state: showName, - smallImageKey: Assets.Search, - startTimestamp: Math.floor(Date.now() / 1000), - }); - } - } else if (!isVideoData && page.includes("/uye/")) { - const user = document.querySelector( - "#container > div.content > div.right > div.dashboard-head > h1 > span" - ); + if ( + !document.location.search + || document.location.search === '' + || (document.location.search !== '' && !genre && !showName) + || (document.location.search !== '' && genre === '' && showName === '') + ) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: 'Bir sayfaya göz atıyor:', + state: 'Arşiv', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if ((genre && !showName) || (genre && showName === '')) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: 'Bir kategoriye göz atıyor:', + state: genre, + smallImageKey: Assets.Search, + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (genre && showName) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: 'Bir dizi arıyor:', + state: `${showName} (${genre})`, + smallImageKey: Assets.Search, + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if ( + (!genre && showName) + || (genre === '' && showName && showName !== '') + ) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: 'Bir dizi arıyor:', + state: showName, + smallImageKey: Assets.Search, + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + } + else if (!isVideoData && page.includes('/uye/')) { + const user = document.querySelector( + '#container > div.content > div.right > div.dashboard-head > h1 > span', + ) - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: "Bir üyenin profiline bakıyor:", - state: user && user.textContent ? user.textContent.trim() : "Belirsiz", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (!isVideoData && showTitle && showTitle.textContent !== "") { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: "Bir diziyi inceliyor:", - state: showTitle.textContent, - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (!isVideoData && actorName && actorName.textContent !== "") { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: "Bir aktörü inceliyor:", - state: actorName.textContent, - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else if (!isVideoData && page.includes("/forum")) { - const postTitle = document.querySelector( - "#container > div.content > div.right > div.right-inner > h2 > span" - ), - forumTitle = document.querySelector( - "#container > div.content > div.right > div.forum-head > h1" - ); + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: 'Bir üyenin profiline bakıyor:', + state: user && user.textContent ? user.textContent.trim() : 'Belirsiz', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (!isVideoData && showTitle && showTitle.textContent !== '') { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: 'Bir diziyi inceliyor:', + state: showTitle.textContent, + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (!isVideoData && actorName && actorName.textContent !== '') { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: 'Bir aktörü inceliyor:', + state: actorName.textContent, + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else if (!isVideoData && page.includes('/forum')) { + const postTitle = document.querySelector( + '#container > div.content > div.right > div.right-inner > h2 > span', + ) + const forumTitle = document.querySelector( + '#container > div.content > div.right > div.forum-head > h1', + ) - if (page.slice(page.indexOf("/forum") + 6).length <= 0) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: `${ - forumTitle && forumTitle.textContent !== "" - ? forumTitle.textContent.replace(" tartışma forumu", "") - : "Bilinmeyen" - } dizisinin forumlarına bakıyor:`, - state: "Ana Sayfa", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } else { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: `${ - forumTitle && forumTitle.textContent !== "" - ? forumTitle.textContent.replace(" tartışma forumu", "") - : "Bilinmeyen" - } dizisinin forumlarına bakıyor:`, - state: - postTitle && postTitle.textContent !== "" - ? postTitle.textContent - : "Bilinmeyen", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } - } else if (pages[page] || pages[page.slice(0, -1)]) { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/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 if (_video && _video.currentTime) { - const title = - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > a > span > span" - ) || - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > a > span > span" - ), - episodeX = - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div" - ) && - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div" - ).textContent - ? document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div" - ).textContent - : null || - (document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(2) > span" - ) && - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(3)" - )) - ? `${document - .querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(2) > span" - ) - .textContent.trim()}. Sezon ${ - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(3)" - ).textContent - }. Bölüm` - : "none found", - timestamps = presence.getTimestamps( - Math.floor(_video.currentTime), - Math.floor(_video.duration) - ), - data: { [k: string]: boolean | string | number } = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: title.textContent, - state: episodeX - .replace(/\n/g, "") - .replaceAll("-", "") - .replace(title.textContent, "") - .replace(" ", "") - .trim(), - smallImageKey: video.paused ? Assets.Pause : Assets.Play, - smallImageText: video.paused - ? (await strings).pause - : (await strings).play, - }; + if (page.slice(page.indexOf('/forum') + 6).length <= 0) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: `${ + forumTitle && forumTitle.textContent !== '' + ? forumTitle.textContent?.replace(' tartışma forumu', '') + : 'Bilinmeyen' + } dizisinin forumlarına bakıyor:`, + state: 'Ana Sayfa', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + else { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: `${ + forumTitle && forumTitle.textContent !== '' + ? forumTitle.textContent?.replace(' tartışma forumu', '') + : 'Bilinmeyen' + } dizisinin forumlarına bakıyor:`, + state: postTitle && postTitle.textContent !== '' ? postTitle.textContent : 'Bilinmeyen', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + } + else if (pages[page] || pages[page.slice(0, -1)]) { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/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 if (_video && _video.currentTime) { + const title = document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > a > span > span', + ) + || document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > a > span > span', + ) + const episodeX = document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div', + ) + && document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div', + )?.textContent + ? document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div', + )?.textContent + : (document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(2) > span', + ) + && document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(3)', + )) + ? `${document + .querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(2) > span', + ) + ?.textContent + ?.trim()}. Sezon ${ + document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(3)', + )?.textContent + }. Bölüm` + : 'none found' + const timestamps = presence.getTimestamps( + Math.floor(_video.currentTime), + Math.floor(_video.duration), + ) + const data: { [k: string]: boolean | string | number } = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: title?.textContent ?? '', + state: episodeX + ?.replace(/\n/g, '') + ?.replaceAll('-', '') + ?.replace(title?.textContent ?? '', '') + ?.replace(' ', '') + ?.trim() ?? '', + smallImageKey: video.paused ? Assets.Pause : Assets.Play, + smallImageText: video.paused + ? (await strings).pause + : (await strings).play, + } - if (!isNaN(timestamps[0]) && !isNaN(timestamps[1])) - [data.startTimestamp, data.endTimestamp] = timestamps; + if (!Number.isNaN(timestamps[0]) && !Number.isNaN(timestamps[1])) + [data.startTimestamp, data.endTimestamp] = timestamps - if (video.paused) { - delete data.startTimestamp; - delete data.endTimestamp; - } + if (video.paused) { + delete data.startTimestamp + delete data.endTimestamp + } - presence.setActivity(data); - } else if (isVideoData) { - const title = - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > a > span > span" - ) || - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > a > span > span" - ), - episodeX = - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div" - ) && - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div" - ).textContent - ? document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div" - ).textContent - : null || - (document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(2) > span" - ) && - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(3)" - )) - ? `${document - .querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(2) > span" - ) - .textContent.trim()}. Sezon ${ - document.querySelector( - "#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(3)" - ).textContent - }. Bölüm` - : null; + presence.setActivity(data) + } + else if (isVideoData) { + const title = document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > a > span > span', + ) + || document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > a > span > span', + ) + const episodeX = document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div', + ) + && document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div', + )?.textContent + ? document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div', + )?.textContent + : (document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(2) > span', + ) + && document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(3)', + )) + ? `${document + .querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(2) > span', + ) + ?.textContent + ?.trim()}. Sezon ${ + document.querySelector( + '#container > div.content > div.right > div.right-inner > div.tv-series-head > div.mini-info > h1 > div > span:nth-child(3)', + )?.textContent + }. Bölüm` + : null - if (title && title.textContent !== "" && episodeX) { - const timestamps = presence.getTimestamps( - Math.floor(video.currentTime), - Math.floor(video.duration) - ), - presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: title.textContent, - state: episodeX - .replace(/\n/g, "") - .replaceAll("-", "") - .replace(title.textContent, "") - .replace(" ", "") - .trim(), - smallImageKey: video.paused ? Assets.Pause : Assets.Play, - smallImageText: video.paused - ? (await strings).pause - : (await strings).play, - }; + if (title && title.textContent !== '' && episodeX) { + const timestamps = presence.getTimestamps( + Math.floor(video.currentTime), + Math.floor(video.duration), + ) + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: title.textContent, + state: episodeX + .replace(/\n/g, '') + .replaceAll('-', '') + .replace(title?.textContent ?? '', '') + .replace(' ', '') + .trim(), + 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; - } - presence.setActivity(presenceData); - } else { - presence.setActivity({ - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png", - details: "Bir sayfaya göz atıyor:", - state: "Bilinmeyen Sayfa", - startTimestamp: Math.floor(Date.now() / 1000), - }); - } - } -}); + if (video.paused) { + delete presenceData.startTimestamp + delete presenceData.endTimestamp + } + presence.setActivity(presenceData) + } + else { + presence.setActivity({ + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dizilab/assets/logo.png', + details: 'Bir sayfaya göz atıyor:', + state: 'Bilinmeyen Sayfa', + startTimestamp: Math.floor(Date.now() / 1000), + }) + } + } +}) diff --git a/websites/D/diziwatch/metadata.json b/websites/D/diziwatch/metadata.json index 34517e4f0cea..0d2d0c576b8f 100644 --- a/websites/D/diziwatch/metadata.json +++ b/websites/D/diziwatch/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "510174958270545920", - "name": "emrovsky" - }, - "service": "diziwatch", - "description": { - "en": "diziwatch is a platform you can watch animes,movies" - }, - "url": "diziwatch.net", - "version": "1.0.7", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/diziwatch/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/diziwatch/assets/thumbnail.png", - "color": "#0BA7BC", - "category": "videos", - "tags": [ - "diziwatch", - "anime", - "movie" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "id": "510174958270545920", + "name": "emrovsky" + }, + "service": "diziwatch", + "description": { + "en": "diziwatch is a platform you can watch animes,movies" + }, + "url": "diziwatch.net", + "version": "1.0.7", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/diziwatch/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/diziwatch/assets/thumbnail.png", + "color": "#0BA7BC", + "category": "videos", + "tags": [ + "diziwatch", + "anime", + "movie" + ] +} diff --git a/websites/D/diziwatch/presence.ts b/websites/D/diziwatch/presence.ts index 699267c26a9d..8ff82132966c 100644 --- a/websites/D/diziwatch/presence.ts +++ b/websites/D/diziwatch/presence.ts @@ -1,84 +1,85 @@ const presence = new Presence({ - clientId: "1214974615202299994", - }), - browsingTimestamp = Math.floor(Date.now() / 1000); + clientId: '1214974615202299994', +}) +const browsingTimestamp = Math.floor(Date.now() / 1000) const enum Assets { - Logo = "https://cdn.rcd.gg/PreMiD/websites/D/diziwatch/assets/logo.png", + Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/diziwatch/assets/logo.png', } -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: Assets.Logo, - }; - presenceData.startTimestamp = browsingTimestamp; - switch (document.location.pathname) { - case "/": { - presenceData.details = "Ana sayfa görüntüleniyor"; - break; - } - case "/calendar/": { - presenceData.details = "Takvim sayfası görüntüleniyor"; - break; - } - case "/anime-arsivi/": { - presenceData.details = "Anime arşivi görüntüleniyor"; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: Assets.Logo, + } + presenceData.startTimestamp = browsingTimestamp + switch (document.location.pathname) { + case '/': { + presenceData.details = 'Ana sayfa görüntüleniyor' + break + } + case '/calendar/': { + presenceData.details = 'Takvim sayfası görüntüleniyor' + break + } + case '/anime-arsivi/': { + presenceData.details = 'Anime arşivi görüntüleniyor' - break; - } - case "/dizi-arsivi/": { - presenceData.details = "Dizi arşivi görüntüleniyor"; - break; - } - case "/episodes/": { - presenceData.details = "Bölümler inceleniyor"; - break; - } - case "/contact-us/": { - presenceData.details = "İletişim bilgileri inceleniyor 💀"; - break; - } - default: - if (document.location.pathname.startsWith("/dizi/")) { - presenceData.details = `${ - document.querySelector("#content > div.incontentx > div.title > h1") - .textContent - } inceleniyor`; - } else { - presenceData.startTimestamp = null; - const animeImg = document - .querySelector("#player .jw-preview") - .getAttribute("style") - .split('"')[1], - playStatus = document - .querySelector(".jw-icon.jw-icon-display.jw-button-color.jw-reset") - .getAttribute("aria-label"); + break + } + case '/dizi-arsivi/': { + presenceData.details = 'Dizi arşivi görüntüleniyor' + break + } + case '/episodes/': { + presenceData.details = 'Bölümler inceleniyor' + break + } + case '/contact-us/': { + presenceData.details = 'İletişim bilgileri inceleniyor 💀' + break + } + default: + if (document.location.pathname.startsWith('/dizi/')) { + presenceData.details = `${ + document.querySelector('#content > div.incontentx > div.title > h1') + ?.textContent + } inceleniyor` + } + else { + presenceData.startTimestamp = null + const animeImg = document + .querySelector('#player .jw-preview') + ?.getAttribute('style') + ?.split('"')[1] + const playStatus = document + .querySelector('.jw-icon.jw-icon-display.jw-button-color.jw-reset') + ?.getAttribute('aria-label') - presenceData.details = document.querySelector( - "#player .jw-title-primary" - ).textContent; - presenceData.state = `${ - document.querySelector("#player .jw-icon.jw-text-elapsed").textContent - } / ${ - document.querySelector("#player .jw-icon.jw-text-duration") - .textContent - }`; - if (playStatus === "Oynat") { - presenceData.smallImageKey = Assets.Play; - presenceData.smallImageText = "Duraklatıldı"; - } + presenceData.details = document.querySelector( + '#player .jw-title-primary', + )?.textContent + presenceData.state = `${ + document.querySelector('#player .jw-icon.jw-text-elapsed')?.textContent + } / ${ + document.querySelector('#player .jw-icon.jw-text-duration') + ?.textContent + }` + if (playStatus === 'Oynat') { + presenceData.smallImageKey = Assets.Play + presenceData.smallImageText = 'Duraklatıldı' + } - if (playStatus === "Duraklat") { - presenceData.smallImageKey = Assets.Pause; - presenceData.smallImageText = "Oynatılıyor"; - } + if (playStatus === 'Duraklat') { + presenceData.smallImageKey = Assets.Pause + presenceData.smallImageText = 'Oynatılıyor' + } - presenceData.largeImageKey = animeImg; - presenceData.largeImageText = document.querySelector( - "#benzerli > div > span" - ).textContent; - } - } + presenceData.largeImageKey = animeImg + presenceData.largeImageText = document.querySelector( + '#benzerli > div > span', + )?.textContent as undefined + } + } - presence.setActivity(presenceData); -}); + presence.setActivity(presenceData) +}) diff --git a/websites/D/dlive/metadata.json b/websites/D/dlive/metadata.json index 5b69c338dfa4..d42b03db2180 100644 --- a/websites/D/dlive/metadata.json +++ b/websites/D/dlive/metadata.json @@ -1,27 +1,27 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "TheDrop.", - "id": "293828021134295040" - }, - "service": "dlive", - "description": { - "en": "DLive.tv is the largest live streaming community on blockchain that powered by Lino blockchain.", - "de": "DLive.tv ist die größte Livestreaming-Community auf Blockchain, die von Lino Blockchain unterstützt wird.", - "ro": "DLive.tv este cea mai mare comunitate de live streaming pe blockchain cu spirjinul blockchain-ului Lino.", - "pt_BR": "DLive.tv é a maior comunidade de transmissão ao vivo em blockchain que é alimentada pela Lino blockchain.", - "uk_UA": "DLive.tv — найбільша спільнота потокової трансляції у блокчейні, що працює на базі блокчейна Lino.", - "nl": "DLive.tv is de grootste live streaming community op blockchain die wordt aangedreven door Lino blockchain." - }, - "url": "dlive.tv", - "version": "2.2.22", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/dlive/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/dlive/assets/thumbnail.png", - "color": "#ffd300", - "category": "videos", - "tags": [ - "video", - "livestream" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "TheDrop.", + "id": "293828021134295040" + }, + "service": "dlive", + "description": { + "en": "DLive.tv is the largest live streaming community on blockchain that powered by Lino blockchain.", + "de": "DLive.tv ist die größte Livestreaming-Community auf Blockchain, die von Lino Blockchain unterstützt wird.", + "ro": "DLive.tv este cea mai mare comunitate de live streaming pe blockchain cu spirjinul blockchain-ului Lino.", + "pt_BR": "DLive.tv é a maior comunidade de transmissão ao vivo em blockchain que é alimentada pela Lino blockchain.", + "uk_UA": "DLive.tv — найбільша спільнота потокової трансляції у блокчейні, що працює на базі блокчейна Lino.", + "nl": "DLive.tv is de grootste live streaming community op blockchain die wordt aangedreven door Lino blockchain." + }, + "url": "dlive.tv", + "version": "2.2.22", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/dlive/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/dlive/assets/thumbnail.png", + "color": "#ffd300", + "category": "videos", + "tags": [ + "video", + "livestream" + ] +} diff --git a/websites/D/dlive/presence.ts b/websites/D/dlive/presence.ts index d84b03e31741..859edcd04914 100644 --- a/websites/D/dlive/presence.ts +++ b/websites/D/dlive/presence.ts @@ -1,49 +1,44 @@ const presence = new Presence({ - clientId: "609531561389588480", -}); + clientId: '609531561389588480', +}) -let lastPlaybackState = null, - playback: boolean, - browsingTimestamp = Math.floor(Date.now() / 1000); +let lastPlaybackState = null +let playback: boolean | null = null +let browsingTimestamp = Math.floor(Date.now() / 1000) if (lastPlaybackState !== playback) { - lastPlaybackState = playback; - browsingTimestamp = Math.floor(Date.now() / 1000); + lastPlaybackState = playback + browsingTimestamp = Math.floor(Date.now() / 1000) } -presence.on("UpdateData", async () => { - playback = - document.querySelector("video.dplayer-video.dplayer-video-current") !== null - ? true - : false; - - if (!playback) { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dlive/assets/logo.png", - }; - - presenceData.details = "Browsing..."; - presenceData.startTimestamp = browsingTimestamp; - - presence.setActivity(presenceData, true); - } - - if (document.querySelector("video.dplayer-video.dplayer-video-current")) { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dlive/assets/logo.png", - smallImageKey: Assets.Live, - }; - - presenceData.details = document.querySelector( - ".info-line-left.flex-box .flex-column.flex-justify-center div" - ).textContent; - presenceData.state = document.querySelector( - "div.channel-header span.dlive-name span.overflow-ellipsis" - ).textContent; - presenceData.startTimestamp = browsingTimestamp; - - presence.setActivity(presenceData, true); - } -}); +presence.on('UpdateData', async () => { + playback = document.querySelector('video.dplayer-video.dplayer-video-current') !== null + + if (!playback) { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dlive/assets/logo.png', + } + + presenceData.details = 'Browsing...' + presenceData.startTimestamp = browsingTimestamp + + presence.setActivity(presenceData, true) + } + + if (document.querySelector('video.dplayer-video.dplayer-video-current')) { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dlive/assets/logo.png', + smallImageKey: Assets.Live, + } + + presenceData.details = document.querySelector( + '.info-line-left.flex-box .flex-column.flex-justify-center div', + )?.textContent + presenceData.state = document.querySelector( + 'div.channel-header span.dlive-name span.overflow-ellipsis', + )?.textContent + presenceData.startTimestamp = browsingTimestamp + + presence.setActivity(presenceData, true) + } +}) diff --git a/websites/D/dod Games/metadata.json b/websites/D/dod Games/metadata.json index cb430066447d..2f09f0b8428d 100644 --- a/websites/D/dod Games/metadata.json +++ b/websites/D/dod Games/metadata.json @@ -1,23 +1,23 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "nFin1ty", - "id": "131877010157862912" - }, - "service": "dod Games", - "description": { - "en": "dod Games is one of the most famous multiplayer game and chatting community in Greece", - "el_GR": "Το dod Games είναι ένα από τα πιο γνωστά site online παιχνιδιών και chatting στην Ελλάδα" - }, - "url": "www.dod.gr", - "version": "1.1.10", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/dod%20Games/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/dod%20Games/assets/thumbnail.png", - "color": "#008fec", - "category": "games", - "tags": [ - "dod", - "dod-games" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "nFin1ty", + "id": "131877010157862912" + }, + "service": "dod Games", + "description": { + "en": "dod Games is one of the most famous multiplayer game and chatting community in Greece", + "el_GR": "Το dod Games είναι ένα από τα πιο γνωστά site online παιχνιδιών και chatting στην Ελλάδα" + }, + "url": "www.dod.gr", + "version": "1.1.10", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/dod%20Games/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/dod%20Games/assets/thumbnail.png", + "color": "#008fec", + "category": "games", + "tags": [ + "dod", + "dod-games" + ] +} diff --git a/websites/D/dod Games/presence.ts b/websites/D/dod Games/presence.ts index 29a3be53dba3..48984b17755f 100644 --- a/websites/D/dod Games/presence.ts +++ b/websites/D/dod Games/presence.ts @@ -1,260 +1,273 @@ const presence = new Presence({ - clientId: "937393073539911730", -}); + clientId: '937393073539911730', +}) -let isInGame = false, - timeStarted = Date.now(); +let isInGame = false +let timeStarted = Date.now() -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/dod%20Games/assets/logo.png", - }, - playerName = document.querySelector( - "#component_top_right_loginasname_text" - ).textContent, - urls = document.querySelectorAll("#topBarDownLink"), - supportedGames: string[] = ["drawit", "quiz", "agonia", "tichu"]; - let openRooms = 0; +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/dod%20Games/assets/logo.png', + } + const playerName = document.querySelector( + '#component_top_right_loginasname_text', + )?.textContent + const urls = document.querySelectorAll('#topBarDownLink') + const supportedGames: string[] = ['drawit', 'quiz', 'agonia', 'tichu'] + let openRooms = 0 - function addJoinRoomButton(roomURL: string) { - presenceData.buttons = [ - { - label: "Είσοδος", - url: roomURL, - }, - ]; - } + function addJoinRoomButton(roomURL: string) { + presenceData.buttons = [ + { + label: 'Είσοδος', + url: roomURL, + }, + ] + } - function parseGameData(game: string, roomURL?: string) { - if (!isInGame) { - timeStarted = Date.now(); - isInGame = true; - } + function parseGameData(game: string, roomURL?: string) { + if (!isInGame) { + timeStarted = Date.now() + isInGame = true + } - switch (game) { - case "drawit": { - const scores = document.querySelectorAll("#playersContainer .player"); - for (let i = 0; i < scores.length; i++) { - if (scores[i].querySelector(".name").textContent === playerName) { - if ( - document.querySelector("#drawtools").style - .display !== "none" - ) { - presenceData.smallImageKey = Assets.Writing; - presenceData.smallImageText = "Ζωγραφίζει"; - } + switch (game) { + case 'drawit': { + const scores = document.querySelectorAll('#playersContainer .player') + for (let i = 0; i < scores.length; i++) { + if (scores[i].querySelector('.name')?.textContent === playerName) { + if ( + document.querySelector('#drawtools')?.style.display !== 'none' + ) { + presenceData.smallImageKey = Assets.Writing + presenceData.smallImageText = 'Ζωγραφίζει' + } - presenceData.state = `Σκορ: ${ - scores[i].querySelector(".score").textContent - } | Γύρος: ${document - .querySelector("#round b") - .textContent.replaceAll(" ", "")} | Θέση #${ - parseInt(scores[i].getAttribute("index")) + 1 - }/${scores.length}`; - } - } - if (scores.length < 10 && roomURL) addJoinRoomButton(roomURL); + presenceData.state = `Σκορ: ${ + scores[i].querySelector('.score')?.textContent + } | Γύρος: ${document + .querySelector('#round b') + ?.textContent + ?.replaceAll(' ', '')} | Θέση #${ + Number.parseInt(scores[i].getAttribute('index') ?? '0') + 1 + }/${scores.length}` + } + } + if (scores.length < 10 && roomURL) + addJoinRoomButton(roomURL) - presenceData.details = "Παίζει Ζωγράφισέ Το"; - presenceData.startTimestamp = timeStarted; - break; - } + presenceData.details = 'Παίζει Ζωγράφισέ Το' + presenceData.startTimestamp = timeStarted + break + } - case "quiz": { - const scores = document.querySelectorAll( - "#playersContainer .numberAndPlayerContainer" - ); - for (let i = 0; i < scores.length; i++) { - if ( - scores[i].querySelector(".quiz_playerName").textContent === - playerName - ) { - presenceData.state = `Σκορ: ${ - scores[i].querySelector(".quiz_playerPoints").textContent - } | Γύρος: ${ - parseInt(document.querySelector("#countRound").textContent) || "–" - } | Θέση #${parseInt( - scores[i].querySelector(".quiz_playerNumber").textContent - )}/${scores.length}`; - } - } - if (roomURL) addJoinRoomButton(roomURL); + case 'quiz': { + const scores = document.querySelectorAll( + '#playersContainer .numberAndPlayerContainer', + ) + for (let i = 0; i < scores.length; i++) { + if ( + scores[i].querySelector('.quiz_playerName')?.textContent + === playerName + ) { + presenceData.state = `Σκορ: ${ + scores[i].querySelector('.quiz_playerPoints')?.textContent + } | Γύρος: ${ + Number.parseInt(document.querySelector('#countRound')?.textContent ?? '0') || '–' + } | Θέση #${Number.parseInt( + scores[i].querySelector('.quiz_playerNumber')?.textContent ?? '0', + )}/${scores.length}` + } + } + if (roomURL) + addJoinRoomButton(roomURL) - presenceData.details = "Παίζει Κουίζ"; - presenceData.startTimestamp = timeStarted; - break; - } + presenceData.details = 'Παίζει Κουίζ' + presenceData.startTimestamp = timeStarted + break + } - case "agonia": { - const nPlayers = parseInt( - document.querySelector("#agonia_content").className.match(/\d+/g)[0] - ), - playerClassNames = [ - "agonia_player1", - "agonia_player2", - "agonia_player3", - "agonia_player4", - ], - state: { [key: string]: AgoniaPlayerState } = {}; - for (const playerClassName of playerClassNames) { - const player = document.querySelector(`#${playerClassName}`); - if (player) { - const playerName = player.querySelector(".gnh_name").textContent; - if (playerName) { - state[playerName] = { - score: player.querySelector(".gnh_score_text").textContent, - winner: false, - }; - } - } - } + case 'agonia': { + const nPlayers = Number.parseInt( + document.querySelector('#agonia_content')?.className.match(/\d+/g)?.[0] ?? '0', + ) + const playerClassNames = [ + 'agonia_player1', + 'agonia_player2', + 'agonia_player3', + 'agonia_player4', + ] + const state: { [key: string]: AgoniaPlayerState } = {} + for (const playerClassName of playerClassNames) { + const player = document.querySelector(`#${playerClassName}`) + if (player) { + const playerName = player.querySelector('.gnh_name')?.textContent + if (playerName) { + state[playerName] = { + score: player.querySelector('.gnh_score_text')?.textContent ?? '0', + winner: false, + } + } + } + } - const gameOverVisible = - document.querySelector("#gameover_content").parentElement.style - .display !== "none"; - if (gameOverVisible) { - const gameOverClassNames = [ - "gameover_user1", - "gameover_user2", - "gameover_user3", - "gameover_user4", - ]; - for (const gameOverClassName of gameOverClassNames) { - const player = document.querySelector(`#${gameOverClassName}`); - if ( - player && - player.querySelector(".gameover_userphotowin") - .style.display !== "none" - ) { - const winnerName = player.getAttribute("shownname"); - if (winnerName in state) state[winnerName].winner = true; - } - } - } - let stateString = ""; - for (const key in state) { - const value = state[key]; - stateString += `${value.winner ? " 🏆 " : ""}${key}: ${ - value.score - } – `; - } - if (Object.keys(state).length === nPlayers || gameOverVisible) - presenceData.state = stateString.substring(0, stateString.length - 3); - else { - presenceData.state = `${ - Object.keys(state).length - }/${nPlayers} παίκτες...`; - if (roomURL) addJoinRoomButton(roomURL); - } - presenceData.details = `Παίζει Αγωνία | 💪🏻 ${document - .querySelector(".mytr") - .getAttribute("elo")}`; - presenceData.startTimestamp = timeStarted; - break; - } + const gameOverVisible = document.querySelector('#gameover_content')?.parentElement?.style.display !== 'none' + if (gameOverVisible) { + const gameOverClassNames = [ + 'gameover_user1', + 'gameover_user2', + 'gameover_user3', + 'gameover_user4', + ] + for (const gameOverClassName of gameOverClassNames) { + const player = document.querySelector(`#${gameOverClassName}`) + if ( + player + && player.querySelector('.gameover_userphotowin') + ?.style + ?.display !== 'none' + ) { + const winnerName = player.getAttribute('shownname')! + if (winnerName in state) + state[winnerName].winner = true + } + } + } + let stateString = '' + for (const key in state) { + const value = state[key] + stateString += `${value.winner ? ' 🏆 ' : ''}${key}: ${ + value.score + } – ` + } + if (Object.keys(state).length === nPlayers || gameOverVisible) { + presenceData.state = stateString.substring(0, stateString.length - 3) + } + else { + presenceData.state = `${ + Object.keys(state).length + }/${nPlayers} παίκτες...` + if (roomURL) + addJoinRoomButton(roomURL) + } + presenceData.details = `Παίζει Αγωνία | 💪🏻 ${document + .querySelector('.mytr') + ?.getAttribute('elo') ?? '0'}` + presenceData.startTimestamp = timeStarted + break + } - case "tichu": { - const playerPositions = ["bottom", "up", "right", "left"], - teamPlayers: string[] = [], - opPlayers: string[] = [], - playerState: { [key: string]: TichuPlayerState } = {}; - for (const playerPos of playerPositions) { - const playerName = document.querySelector( - `#nickholder_${playerPos} .playerName` - ).textContent; - if (playerName) - playerState[playerPos] = { name: playerName, bet: null }; - } + case 'tichu': { + const playerPositions = ['bottom', 'up', 'right', 'left'] + const teamPlayers: string[] = [] + const opPlayers: string[] = [] + const playerState: { [key: string]: TichuPlayerState } = {} + for (const playerPos of playerPositions) { + const playerName = document.querySelector( + `#nickholder_${playerPos} .playerName`, + )?.textContent + if (playerName) + playerState[playerPos] = { name: playerName, bet: '' } + } - for (const pos of ["up", "left", "right"]) { - if (!(pos in playerState)) continue; - const betElement = document.querySelector( - `#nickholder_${pos} #tichugrand` - ); - if (betElement.style.display !== "none") - playerState[pos].bet = betElement.className; - } + for (const pos of ['up', 'left', 'right']) { + if (!(pos in playerState)) + continue + const betElement = document.querySelector( + `#nickholder_${pos} #tichugrand`, + ) + if (betElement?.style.display !== 'none') + playerState[pos].bet = betElement!.className + } - let betElement = - document.querySelector("#btnTichuToggle"); - if (betElement.style.display !== "none") playerState.bot.bet = "tichu"; + let betElement = document.querySelector('#btnTichuToggle') + if (betElement?.style.display !== 'none') + playerState.bot.bet = 'tichu' - betElement = document.querySelector("#btnGrandToggle"); - if (betElement.style.display !== "none") playerState.bot.bet = "grand"; + betElement = document.querySelector('#btnGrandToggle') + if (betElement?.style.display !== 'none') + playerState.bot.bet = 'grand' - for (const pos in playerState) { - const player = playerState[pos]; - (["bottom", "up"].includes(pos) ? teamPlayers : opPlayers).push( - `${ - player.bet === "tichu" ? "🟠" : player.bet === "grand" ? "🔴" : "" - }${player.name}` - ); - } + for (const pos in playerState) { + const player = playerState[pos]; + (['bottom', 'up'].includes(pos) ? teamPlayers : opPlayers).push( + `${ + player.bet === 'tichu' ? '🟠' : player.bet === 'grand' ? '🔴' : '' + }${player.name}`, + ) + } - if (teamPlayers.length === 2 && opPlayers.length === 2) { - presenceData.state = `(${teamPlayers[0]}, ${teamPlayers[1]}) ${ - document.querySelector("#txtMyTeamScore").textContent - } – ${document.querySelector("#txtOpTeamScore").textContent} (${ - opPlayers[0] - }, ${opPlayers[1]})`; - } else { - presenceData.state = `${ - teamPlayers.length + opPlayers.length - }/4 παίκτες...`; - if (roomURL) addJoinRoomButton(roomURL); - } - presenceData.details = `Παίζει Tichu | 💪🏻 ${document - .querySelector(".mytr") - .getAttribute("elo")}`; - presenceData.startTimestamp = timeStarted; - break; - } - } - } + if (teamPlayers.length === 2 && opPlayers.length === 2) { + presenceData.state = `(${teamPlayers[0]}, ${teamPlayers[1]}) ${ + document.querySelector('#txtMyTeamScore')?.textContent + } – ${document.querySelector('#txtOpTeamScore')?.textContent} (${ + opPlayers[0] + }, ${opPlayers[1]})` + } + else { + presenceData.state = `${ + teamPlayers.length + opPlayers.length + }/4 παίκτες...` + if (roomURL) + addJoinRoomButton(roomURL) + } + presenceData.details = `Παίζει Tichu | 💪🏻 ${document + .querySelector('.mytr') + ?.getAttribute('elo')}` + presenceData.startTimestamp = timeStarted + break + } + } + } - for (const url of urls) { - if (url.textContent.includes("&room=")) openRooms++; + for (const url of urls) { + if (url.textContent?.includes('&room=')) + openRooms++ - for (const game of supportedGames) { - if (url.textContent.includes(`game=${game}&room=`)) - parseGameData(game, url.textContent); - } - } + for (const game of supportedGames) { + if (url.textContent?.includes(`game=${game}&room=`)) + parseGameData(game, url.textContent) + } + } - if (!openRooms) { - const lobbyTabs = document.querySelectorAll( - "#windowLobbyTab2.windowLobbyTabSelected > .windowTabText > .dodlangspan" - ); + if (!openRooms) { + const lobbyTabs = document.querySelectorAll( + '#windowLobbyTab2.windowLobbyTabSelected > .windowTabText > .dodlangspan', + ) - for (const tab of lobbyTabs) { - if (tab.textContent.includes("Ζωγράφισε")) { - openRooms++; - parseGameData("drawit"); - } else if (tab.textContent.includes("Κουίζ")) { - openRooms++; - parseGameData("quiz"); - } else if (tab.textContent.includes("Αγωνία")) { - openRooms++; - parseGameData("agonia"); - } else if (tab.textContent.includes("Tichu")) { - openRooms++; - parseGameData("tichu"); - } - } - } + for (const tab of lobbyTabs) { + if (tab.textContent?.includes('Ζωγράφισε')) { + openRooms++ + parseGameData('drawit') + } + else if (tab.textContent?.includes('Κουίζ')) { + openRooms++ + parseGameData('quiz') + } + else if (tab.textContent?.includes('Αγωνία')) { + openRooms++ + parseGameData('agonia') + } + else if (tab.textContent?.includes('Tichu')) { + openRooms++ + parseGameData('tichu') + } + } + } - if (!openRooms) isInGame = false; - if (isInGame) presence.setActivity(presenceData); - else presence.setActivity(); -}); + if (!openRooms) + isInGame = false + if (isInGame) + presence.setActivity(presenceData) + else presence.setActivity() +}) interface AgoniaPlayerState { - score: string; - winner: boolean; + score: string + winner: boolean } interface TichuPlayerState { - name: string; - bet: string; + name: string + bet: string } diff --git a/websites/D/draw.io/metadata.json b/websites/D/draw.io/metadata.json index ed1cbb9bb687..8f644e3f26f7 100644 --- a/websites/D/draw.io/metadata.json +++ b/websites/D/draw.io/metadata.json @@ -1,44 +1,44 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "id": "348083986989449216", - "name": "hopperelec" - }, - "service": "draw.io", - "description": { - "en": "draw.io or diagrams.net is a configurable diagramming/whiteboarding visualization application" - }, - "url": "app.diagrams.net", - "version": "1.0.4", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/draw.io/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/draw.io/assets/thumbnail.png", - "color": "#d89000", - "category": "other", - "tags": [ - "drawio", - "diagramsnet", - "draw-io", - "diagrams-net", - "draw", - "chart", - "diagrams", - "diagramming", - "whiteboard", - "whiteboarding", - "white-board", - "white-boarding", - "flowchart", - "flowcharts", - "flow-chart", - "flow-charts" - ], - "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": "348083986989449216", + "name": "hopperelec" + }, + "service": "draw.io", + "description": { + "en": "draw.io or diagrams.net is a configurable diagramming/whiteboarding visualization application" + }, + "url": "app.diagrams.net", + "version": "1.0.4", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/draw.io/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/draw.io/assets/thumbnail.png", + "color": "#d89000", + "category": "other", + "tags": [ + "drawio", + "diagramsnet", + "draw-io", + "diagrams-net", + "draw", + "chart", + "diagrams", + "diagramming", + "whiteboard", + "whiteboarding", + "white-board", + "white-boarding", + "flowchart", + "flowcharts", + "flow-chart", + "flow-charts" + ], + "settings": [ + { + "id": "privacy", + "title": "Privacy Mode", + "icon": "fad fa-user-secret", + "value": false + } + ] +} diff --git a/websites/D/draw.io/presence.ts b/websites/D/draw.io/presence.ts index 2b3c8ec77bda..61ad5b59138f 100644 --- a/websites/D/draw.io/presence.ts +++ b/websites/D/draw.io/presence.ts @@ -1,19 +1,19 @@ const presence = new Presence({ - clientId: "1175537518746279956", -}); + clientId: '1175537518746279956', +}) -presence.on("UpdateData", async () => { - const presenceData: PresenceData = { - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/draw.io/assets/logo.png", - startTimestamp: Date.now(), - }; - if (document.title === "draw.io") - presenceData.details = "Creating a new diagram"; - else { - presenceData.details = "Editing a diagram"; - if (!(await presence.getSetting("privacy"))) - presenceData.state = document.title.replace(/ - draw.io$/, ""); - } - presence.setActivity(presenceData); -}); +presence.on('UpdateData', async () => { + const presenceData: PresenceData = { + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/draw.io/assets/logo.png', + startTimestamp: Date.now(), + } + if (document.title === 'draw.io') { + presenceData.details = 'Creating a new diagram' + } + else { + presenceData.details = 'Editing a diagram' + if (!(await presence.getSetting('privacy'))) + presenceData.state = document.title.replace(/ - draw.io$/, '') + } + presence.setActivity(presenceData) +}) diff --git "a/websites/D/d\343\202\242\343\203\213\343\203\241\343\202\271\343\203\210\343\202\242/metadata.json" "b/websites/D/d\343\202\242\343\203\213\343\203\241\343\202\271\343\203\210\343\202\242/metadata.json" index 5163478a394c..f3bd183d702f 100644 --- "a/websites/D/d\343\202\242\343\203\213\343\203\241\343\202\271\343\203\210\343\202\242/metadata.json" +++ "b/websites/D/d\343\202\242\343\203\213\343\203\241\343\202\271\343\203\210\343\202\242/metadata.json" @@ -1,26 +1,26 @@ { - "$schema": "https://schemas.premid.app/metadata/1.12", - "apiVersion": 1, - "author": { - "name": "Eai", - "id": "132779412771962880" - }, - "service": "dアニメストア", - "description": { - "en": "No.1 anime streaming website in Japan! Free for the first month! Unlimited viewing of over 2,900 anime works for 400 yen per month (excluding taxes)! You can use other than DoCoMo mobile devices. Even better quality on tablets, PCs, Chromecasts, and Fire TV!", - "de": "No.1 anime streaming website in Japan! Free for the first month! Unlimited viewing of over 2,900 anime works for 400 yen per month (excluding taxes)! You can use other than DoCoMo mobile devices. Even better quality on tablets, PCs, Chromecasts, and Fire TV!", - "ja_JP": "アニメ作品数No.1見放題サイトdアニメストア!初回31日間無料!月額400円(税抜)で2,900作品以上のアニメが見放題!ドコモのケータイ以外も利用可能。タブレットやPC,Chromecast,Fire TVではさらに高画質!", - "pt_BR": "Site número 1 em streaming de animes no Japão! Grátis no primeiro mês! Assista mais de 2,900 animes por 400 ienes por mês (excluindo taxas)! Você pode usar outros dispositivos móveis além de DoCoMo. Melhor qualidade em tablets, PCs, Chromecasts, e Fire TV!", - "nl": "De beste anime streaming website in Japan! Eerste maand gratis! Onbeperkt bekijken van meer dan 2900 animes voor 400 yen per maand (exclusief belasting)! U kunt andere dan DoCoMo mobiele apparaten ook gebruiken. Nog betere kwaliteit op tablets, pc's, Chromecasts en Fire TV!" - }, - "url": "animestore.docomo.ne.jp", - "version": "2.0.12", - "logo": "https://cdn.rcd.gg/PreMiD/websites/D/d%E3%82%A2%E3%83%8B%E3%83%A1%E3%82%B9%E3%83%88%E3%82%A2/assets/logo.png", - "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/d%E3%82%A2%E3%83%8B%E3%83%A1%E3%82%B9%E3%83%88%E3%82%A2/assets/thumbnail.jpg", - "color": "#ea552a", - "category": "anime", - "tags": [ - "video", - "anime" - ] -} \ No newline at end of file + "$schema": "https://schemas.premid.app/metadata/1.12", + "apiVersion": 1, + "author": { + "name": "Eai", + "id": "132779412771962880" + }, + "service": "dアニメストア", + "description": { + "en": "No.1 anime streaming website in Japan! Free for the first month! Unlimited viewing of over 2,900 anime works for 400 yen per month (excluding taxes)! You can use other than DoCoMo mobile devices. Even better quality on tablets, PCs, Chromecasts, and Fire TV!", + "de": "No.1 anime streaming website in Japan! Free for the first month! Unlimited viewing of over 2,900 anime works for 400 yen per month (excluding taxes)! You can use other than DoCoMo mobile devices. Even better quality on tablets, PCs, Chromecasts, and Fire TV!", + "ja_JP": "アニメ作品数No.1見放題サイトdアニメストア!初回31日間無料!月額400円(税抜)で2,900作品以上のアニメが見放題!ドコモのケータイ以外も利用可能。タブレットやPC,Chromecast,Fire TVではさらに高画質!", + "pt_BR": "Site número 1 em streaming de animes no Japão! Grátis no primeiro mês! Assista mais de 2,900 animes por 400 ienes por mês (excluindo taxas)! Você pode usar outros dispositivos móveis além de DoCoMo. Melhor qualidade em tablets, PCs, Chromecasts, e Fire TV!", + "nl": "De beste anime streaming website in Japan! Eerste maand gratis! Onbeperkt bekijken van meer dan 2900 animes voor 400 yen per maand (exclusief belasting)! U kunt andere dan DoCoMo mobiele apparaten ook gebruiken. Nog betere kwaliteit op tablets, pc's, Chromecasts en Fire TV!" + }, + "url": "animestore.docomo.ne.jp", + "version": "2.0.12", + "logo": "https://cdn.rcd.gg/PreMiD/websites/D/d%E3%82%A2%E3%83%8B%E3%83%A1%E3%82%B9%E3%83%88%E3%82%A2/assets/logo.png", + "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/d%E3%82%A2%E3%83%8B%E3%83%A1%E3%82%B9%E3%83%88%E3%82%A2/assets/thumbnail.jpg", + "color": "#ea552a", + "category": "anime", + "tags": [ + "video", + "anime" + ] +} diff --git "a/websites/D/d\343\202\242\343\203\213\343\203\241\343\202\271\343\203\210\343\202\242/presence.ts" "b/websites/D/d\343\202\242\343\203\213\343\203\241\343\202\271\343\203\210\343\202\242/presence.ts" index d93d389aaeb8..dbbe050232b5 100644 --- "a/websites/D/d\343\202\242\343\203\213\343\203\241\343\202\271\343\203\210\343\202\242/presence.ts" +++ "b/websites/D/d\343\202\242\343\203\213\343\203\241\343\202\271\343\203\210\343\202\242/presence.ts" @@ -1,37 +1,36 @@ { - const presence = new Presence({ - clientId: "611012705306017792", - }), - strings = presence.getStrings({ - play: "general.playing", - pause: "general.paused", - }); + const presence = new Presence({ + clientId: '611012705306017792', + }) + const strings = presence.getStrings({ + play: 'general.playing', + pause: 'general.paused', + }) - presence.on("UpdateData", async () => { - if ( - location.pathname.startsWith("/animestore/sc_d_pc") && - document.querySelector("#video") - ) { - const video: HTMLVideoElement = document.querySelector("#video"), - isPlaying = !video.paused, - presenceData: PresenceData = { - details: `${document.querySelector(".backInfoTxt1").textContent} - ${ - document.querySelector(".backInfoTxt2").textContent - }`, - state: document.querySelector(".backInfoTxt3").textContent, - largeImageKey: - "https://cdn.rcd.gg/PreMiD/websites/D/d%E3%82%A2%E3%83%8B%E3%83%A1%E3%82%B9%E3%83%88%E3%82%A2/assets/logo.png", - smallImageKey: isPlaying ? Assets.Play : Assets.Pause, - smallImageText: isPlaying - ? (await strings).play - : (await strings).pause, - startTimestamp: - Math.floor(Date.now() / 1000) - Math.floor(video.currentTime), - }; + presence.on('UpdateData', async () => { + if ( + location.pathname.startsWith('/animestore/sc_d_pc') + && document.querySelector('#video') + ) { + const video = document.querySelector('#video') + const isPlaying = video && !video.paused + const presenceData: PresenceData = { + details: `${document.querySelector('.backInfoTxt1')?.textContent} - ${ + document.querySelector('.backInfoTxt2')?.textContent + }`, + state: document.querySelector('.backInfoTxt3')?.textContent, + largeImageKey: 'https://cdn.rcd.gg/PreMiD/websites/D/d%E3%82%A2%E3%83%8B%E3%83%A1%E3%82%B9%E3%83%88%E3%82%A2/assets/logo.png', + smallImageKey: isPlaying ? Assets.Play : Assets.Pause, + smallImageText: isPlaying + ? (await strings).play + : (await strings).pause, + startTimestamp: Math.floor(Date.now() / 1000) - Math.floor(video?.currentTime ?? 0), + } - if (!isPlaying) delete presenceData.startTimestamp; + if (!isPlaying) + delete presenceData.startTimestamp - presence.setActivity(presenceData); - } - }); + presence.setActivity(presenceData) + } + }) }