From b2dbfb6c0f6e184a45ed57815491988ce92dec66 Mon Sep 17 00:00:00 2001 From: itsmeeudrino <142719764+itsmeeudrino@users.noreply.github.com> Date: Fri, 24 May 2024 19:14:17 +0300 Subject: [PATCH] fix(The Mahjong): add support for language routes (#8396) --- websites/T/The Mahjong/metadata.json | 2 +- websites/T/The Mahjong/presence.ts | 30 ++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/websites/T/The Mahjong/metadata.json b/websites/T/The Mahjong/metadata.json index 2b5292e741dc..440158be60fb 100644 --- a/websites/T/The Mahjong/metadata.json +++ b/websites/T/The Mahjong/metadata.json @@ -9,7 +9,7 @@ "en": "Amazing free Mahjong that’ll knock your socks off. Play classic and modern Mahjong games in full screen, with lots of layouts and beautiful tiles." }, "url": "themahjong.com", - "version": "1.0.1", + "version": "1.0.2", "logo": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Mahjong/assets/logo.png", "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/T/The%20Mahjong/assets/thumbnail.jpg", "color": "#577e54", diff --git a/websites/T/The Mahjong/presence.ts b/websites/T/The Mahjong/presence.ts index 2e8109908170..16c8ef5e293a 100644 --- a/websites/T/The Mahjong/presence.ts +++ b/websites/T/The Mahjong/presence.ts @@ -7,13 +7,39 @@ const enum Assets { Logo = "https://cdn.rcd.gg/PreMiD/websites/T/The%20Mahjong/assets/logo.png", } +const SITE_LANGS = [ + "ar", + "de", + "es", + "pt", + "da", + "fr", + "ru", + "id", + "it", + "nl", + "pl", + "sv", + "tr", + "vi", + "zh", + "hi", + "ko", + "ja", +]; + presence.on("UpdateData", async () => { const presenceData: PresenceData = { largeImageKey: Assets.Logo, startTimestamp: browsingTimestamp, }, - { pathname, href } = document.location, - pathArr = pathname.split("/"); + { pathname, href } = document.location; + let pathArr = pathname.split("/"); + + if (SITE_LANGS.find(lang => lang === pathname.split("/")[1])) { + pathArr = ["", ...pathArr.slice(2)]; + if (pathArr.length === 1) pathArr = ["", ""]; + } if (pathArr[1] === "" || pathArr[1] === "mahjong") { if (pathArr[1] === "mahjong" && pathArr[2] === "")