From e6490bc8ddc32f37a5b61c262e5dc83263315c9e Mon Sep 17 00:00:00 2001 From: John Fries Date: Thu, 9 May 2024 07:31:10 +0100 Subject: [PATCH 1/6] feat(OG-Network): add presence --- websites/O/OG Network/metadata.json | 24 +++++++++ websites/O/OG Network/presence.ts | 81 +++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 websites/O/OG Network/metadata.json create mode 100644 websites/O/OG Network/presence.ts diff --git a/websites/O/OG Network/metadata.json b/websites/O/OG Network/metadata.json new file mode 100644 index 000000000000..fe2daaab9ec7 --- /dev/null +++ b/websites/O/OG Network/metadata.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://schemas.premid.app/metadata/1.9", + "author": { + "id": "630070645874622494", + "name": "johnfries" + }, + "service": "OG Network", + "description": { + "en": "OG Network website presence" + }, + "url": [ + "og-network.net", + "shop-og-network.net" + ], + "version": "1.0.0", + "logo": "https://www.og-network.net/assets/logo.png", + "thumbnail": "https://www.og-network.net/assets/logo.png", + "color": "#9eeb34", + "category": "games", + "tags": [ + "minecraft", + "server" + ] +} \ No newline at end of file diff --git a/websites/O/OG Network/presence.ts b/websites/O/OG Network/presence.ts new file mode 100644 index 000000000000..75640b972e78 --- /dev/null +++ b/websites/O/OG Network/presence.ts @@ -0,0 +1,81 @@ +const presence = new Presence({ clientId: "1237999667023708231" }); + +const assets = { + logo: "https://www.og-network.net/assets/logo.png", +}; + +let startTime: number; + +presence.on("UpdateData", async () => { + const url = window.location.href; + const elapsedTime = startTime ? Math.round((Date.now() - startTime) / 1000) : 0; + + let presenceData: PresenceData = { + largeImageKey: assets.logo, + startTimestamp: Math.floor(Date.now() / 1000 - elapsedTime), + }; + + if (url.includes("/forums")) { + presenceData.details = "Browsing the OG Network Forums"; + if (url.includes("rules.5/")) + presenceData.details = "Viewing the Rule Category."; + if (url.includes("news-and-announcements.2/")) + presenceData.details = "Viewing the Servers News."; + } else if (url.includes("/rules")) { + presenceData.details = "Viewing the Servers Rules."; + } else if (url.includes("/apply")) { + presenceData.details = "Applying for something."; + } else if (url.includes("/vote")) { + presenceData.details = "Voting for the server!"; + } else if (url.includes("/cosmetics")) { + presenceData.details = "Learning about the cosmetics!"; + } else if (url.includes("/account")) { + presenceData.details = "Editing their account details."; + } else if (url.includes("/modifications")) { + presenceData.details = "Viewing the Modifications Rules"; + } else if (url.includes("/threads")) { + const matches = /threads\/(.*?)(\.\d+)?\/?$/.exec(url); + if (matches && matches[1]) { + const threadName = matches[1].replace(/-/g, " ").trim(); + presenceData.details = `Viewing Thread: ${threadName}`; + } else { + presenceData.details = "Viewing Thread: Unknown"; + } + } else if (url.includes("/members")) { + const matches = /members\/(.*?)\.\d+\/?$/.exec(url); + if (matches && matches[1]) { + const memberName = matches[1].replace(/_/g, " "); + presenceData.details = `Viewing ${memberName}'s profile`; + } else { + presenceData.details = "Viewing Member's profile: Unknown"; + } + } else if (url.includes("og-network.net") || url.includes("shop-og-network.net")) { + // Check for OG Network and Shop URLs + if (url.includes("/category")) { + const matches = /\/category\/(.*?)(\.\d+)?\/?$/.exec(url); + if (matches && matches[1]) { + const categoryName = matches[1].replace(/-/g, " ").trim(); + presenceData.details = `Browsing the ${categoryName} category`; + } else { + presenceData.details = "Browsing OG Network Store"; + } + } else { + presenceData.details = "Browsing OG Network website"; + } + } else { + presenceData.details = "Browsing OG Network website"; + } + + presenceData.buttons = [ + { + label: "View", + url: url, + }, + ]; + + presence.setActivity(presenceData); + + if (!startTime) { + startTime = Date.now(); + } +}); From ea8dd36a5d2123f2b1389dcef50741cd2a5844b9 Mon Sep 17 00:00:00 2001 From: John Fries Date: Thu, 9 May 2024 07:39:33 +0100 Subject: [PATCH 2/6] fix(OG-Network): yarn format --- websites/O/OG Network/metadata.json | 2 +- websites/O/OG Network/presence.ts | 140 ++++++++++++++-------------- 2 files changed, 69 insertions(+), 73 deletions(-) diff --git a/websites/O/OG Network/metadata.json b/websites/O/OG Network/metadata.json index fe2daaab9ec7..ff6e082bf951 100644 --- a/websites/O/OG Network/metadata.json +++ b/websites/O/OG Network/metadata.json @@ -1,5 +1,5 @@ { - "$schema": "https://schemas.premid.app/metadata/1.9", + "$schema": "https://schemas.premid.app/metadata/1.10", "author": { "id": "630070645874622494", "name": "johnfries" diff --git a/websites/O/OG Network/presence.ts b/websites/O/OG Network/presence.ts index 75640b972e78..8f02e1b4681e 100644 --- a/websites/O/OG Network/presence.ts +++ b/websites/O/OG Network/presence.ts @@ -1,81 +1,77 @@ -const presence = new Presence({ clientId: "1237999667023708231" }); - -const assets = { - logo: "https://www.og-network.net/assets/logo.png", -}; +const presence = new Presence({ clientId: "1237999667023708231" }), + assets = { + logo: "https://www.og-network.net/assets/logo.png", + }; let startTime: number; presence.on("UpdateData", async () => { - const url = window.location.href; - const elapsedTime = startTime ? Math.round((Date.now() - startTime) / 1000) : 0; - - let presenceData: PresenceData = { - largeImageKey: assets.logo, - startTimestamp: Math.floor(Date.now() / 1000 - elapsedTime), - }; + const url = window.location.href, + presenceData: PresenceData = { + largeImageKey: assets.logo, + startTimestamp: Math.floor( + Date.now() / 1000 - startTime + ? Math.round((Date.now() - startTime) / 1000) + : 0 + ), + }; - if (url.includes("/forums")) { - presenceData.details = "Browsing the OG Network Forums"; - if (url.includes("rules.5/")) - presenceData.details = "Viewing the Rule Category."; - if (url.includes("news-and-announcements.2/")) - presenceData.details = "Viewing the Servers News."; - } else if (url.includes("/rules")) { - presenceData.details = "Viewing the Servers Rules."; - } else if (url.includes("/apply")) { - presenceData.details = "Applying for something."; - } else if (url.includes("/vote")) { - presenceData.details = "Voting for the server!"; - } else if (url.includes("/cosmetics")) { - presenceData.details = "Learning about the cosmetics!"; - } else if (url.includes("/account")) { - presenceData.details = "Editing their account details."; - } else if (url.includes("/modifications")) { - presenceData.details = "Viewing the Modifications Rules"; - } else if (url.includes("/threads")) { - const matches = /threads\/(.*?)(\.\d+)?\/?$/.exec(url); - if (matches && matches[1]) { - const threadName = matches[1].replace(/-/g, " ").trim(); - presenceData.details = `Viewing Thread: ${threadName}`; - } else { - presenceData.details = "Viewing Thread: Unknown"; - } - } else if (url.includes("/members")) { - const matches = /members\/(.*?)\.\d+\/?$/.exec(url); - if (matches && matches[1]) { - const memberName = matches[1].replace(/_/g, " "); - presenceData.details = `Viewing ${memberName}'s profile`; - } else { - presenceData.details = "Viewing Member's profile: Unknown"; - } - } else if (url.includes("og-network.net") || url.includes("shop-og-network.net")) { - // Check for OG Network and Shop URLs - if (url.includes("/category")) { - const matches = /\/category\/(.*?)(\.\d+)?\/?$/.exec(url); - if (matches && matches[1]) { - const categoryName = matches[1].replace(/-/g, " ").trim(); - presenceData.details = `Browsing the ${categoryName} category`; - } else { - presenceData.details = "Browsing OG Network Store"; - } - } else { - presenceData.details = "Browsing OG Network website"; - } - } else { - presenceData.details = "Browsing OG Network website"; - } + if (url.includes("/forums")) { + presenceData.details = "Browsing the OG Network Forums"; + if (url.includes("rules.5/")) + presenceData.details = "Viewing the Rule Category."; + if (url.includes("news-and-announcements.2/")) + presenceData.details = "Viewing the Servers News."; + } else if (url.includes("/rules")) + presenceData.details = "Viewing the Servers Rules."; + else if (url.includes("/apply")) + presenceData.details = "Applying for something."; + else if (url.includes("/vote")) + presenceData.details = "Voting for the server!"; + else if (url.includes("/cosmetics")) + presenceData.details = "Learning about the cosmetics!"; + else if (url.includes("/account")) + presenceData.details = "Editing their account details."; + else if (url.includes("/modifications")) + presenceData.details = "Viewing the Modifications Rules"; + else if (url.includes("/threads")) { + const matches = /threads\/(.*?)(\.\d+)?\/?$/.exec(url); + if (matches && matches[1]) + presenceData.details = `Viewing Thread: ${matches[1] + .replace(/-/g, " ") + .trim()}`; + else presenceData.details = "Viewing Thread: Unknown"; + } else if (url.includes("/members")) { + const matches = /members\/(.*?)\.\d+\/?$/.exec(url); + if (matches && matches[1]) + presenceData.details = `Viewing ${matches[1].replace( + /_/g, + " " + )}'s profile`; + else presenceData.details = "Viewing Member's profile: Unknown"; + } else if ( + url.includes("og-network.net") || + url.includes("shop-og-network.net") + ) { + // Check for OG Network and Shop URLs + if (url.includes("/category")) { + const matches = /\/category\/(.*?)(\.\d+)?\/?$/.exec(url); + if (matches && matches[1]) + presenceData.details = `Browsing the ${matches[1] + .replace(/-/g, " ") + .trim()} category`; + else presenceData.details = "Browsing OG Network Store"; + } else presenceData.details = "Browsing OG Network website"; + } else presenceData.details = "Browsing OG Network website"; - presenceData.buttons = [ - { - label: "View", - url: url, - }, - ]; + presenceData.buttons = [ + { + label: "View", + url, + }, + ]; - presence.setActivity(presenceData); + presence.setActivity(presenceData); - if (!startTime) { - startTime = Date.now(); - } + if (!startTime) startTime = Date.now(); }); From 6e912b03941dd3d81db2bd9a78c636e7206204d5 Mon Sep 17 00:00:00 2001 From: John Fries Date: Thu, 9 May 2024 18:51:01 +0100 Subject: [PATCH 3/6] feat(OG-Network): add presence Co-authored-by: Dark_Ville <42322979+DarkVillager@users.noreply.github.com> Signed-off-by: John Fries --- websites/O/OG Network/presence.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/websites/O/OG Network/presence.ts b/websites/O/OG Network/presence.ts index 8f02e1b4681e..0d639a0e32ce 100644 --- a/websites/O/OG Network/presence.ts +++ b/websites/O/OG Network/presence.ts @@ -9,11 +9,7 @@ presence.on("UpdateData", async () => { const url = window.location.href, presenceData: PresenceData = { largeImageKey: assets.logo, - startTimestamp: Math.floor( - Date.now() / 1000 - startTime - ? Math.round((Date.now() - startTime) / 1000) - : 0 - ), + startTimestamp: browsingTimestamp; }; if (url.includes("/forums")) { From 947422e5426a6be36fe90ace9cf38496bed9f96f Mon Sep 17 00:00:00 2001 From: John Fries Date: Thu, 9 May 2024 18:51:25 +0100 Subject: [PATCH 4/6] fix(OG-Network): update logo Co-authored-by: Dark_Ville <42322979+DarkVillager@users.noreply.github.com> Signed-off-by: John Fries --- websites/O/OG Network/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/O/OG Network/metadata.json b/websites/O/OG Network/metadata.json index ff6e082bf951..16bdb499c089 100644 --- a/websites/O/OG Network/metadata.json +++ b/websites/O/OG Network/metadata.json @@ -13,7 +13,7 @@ "shop-og-network.net" ], "version": "1.0.0", - "logo": "https://www.og-network.net/assets/logo.png", + "logo": "https://i.imgur.com/6jC2EYO.png", "thumbnail": "https://www.og-network.net/assets/logo.png", "color": "#9eeb34", "category": "games", From b21fa12c87ca802fb6193f5beea48429879453f3 Mon Sep 17 00:00:00 2001 From: John Fries Date: Thu, 9 May 2024 18:51:35 +0100 Subject: [PATCH 5/6] fix(OG-Network): update logo Co-authored-by: Dark_Ville <42322979+DarkVillager@users.noreply.github.com> Signed-off-by: John Fries --- websites/O/OG Network/presence.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/websites/O/OG Network/presence.ts b/websites/O/OG Network/presence.ts index 0d639a0e32ce..f54dd29f1401 100644 --- a/websites/O/OG Network/presence.ts +++ b/websites/O/OG Network/presence.ts @@ -1,6 +1,7 @@ const presence = new Presence({ clientId: "1237999667023708231" }), - assets = { - logo: "https://www.og-network.net/assets/logo.png", +browsingTimestamp = Math.floor(Date.now() / 1000); + const enum Assets = { + logo: "https://i.imgur.com/6jC2EYO.png", }; let startTime: number; From 932ba2bd28533a3df3cf902476df50ee9a35f327 Mon Sep 17 00:00:00 2001 From: John Fries Date: Mon, 13 May 2024 04:49:27 +0100 Subject: [PATCH 6/6] fix(OG-Network): remove not needed = Co-authored-by: Dark_Ville <42322979+DarkVillager@users.noreply.github.com> Signed-off-by: John Fries --- websites/O/OG Network/presence.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/O/OG Network/presence.ts b/websites/O/OG Network/presence.ts index f54dd29f1401..b83df63ea323 100644 --- a/websites/O/OG Network/presence.ts +++ b/websites/O/OG Network/presence.ts @@ -1,6 +1,6 @@ const presence = new Presence({ clientId: "1237999667023708231" }), browsingTimestamp = Math.floor(Date.now() / 1000); - const enum Assets = { + const enum Assets { logo: "https://i.imgur.com/6jC2EYO.png", };