From e0b35003ac74e5715072aef388ed3204d79b02d8 Mon Sep 17 00:00:00 2001 From: murdle Date: Sun, 21 Dec 2025 00:10:41 +0200 Subject: [PATCH] even more fixes for firefox 52 --- assets/public/custom/serviceWorker.js | 15 ++++++++------- assets/public/custom/web/main.js | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/assets/public/custom/serviceWorker.js b/assets/public/custom/serviceWorker.js index 4aa3c175..7fe61552 100644 --- a/assets/public/custom/serviceWorker.js +++ b/assets/public/custom/serviceWorker.js @@ -4,15 +4,15 @@ self.addEventListener("push", (event) => { const payload = event.data.json(); if (payload.type !== "message") return; - const channel = payload.data?.channel || {}; - + const channel = payload.data && payload.data.channel ? payload.data.channel : {}; const isInGuild = channel.type === "GUILD_TEXT" || channel.type === "GUILD_VOICE"; - const channelType = isInGuild ? channel.type === "GUILD_TEXT" ? "Text" : "Voice" : ""; - const title = `${payload.data?.author ?? "Unknown"}${isInGuild ? ` (#${channel.name}, ${channelType} Channels)` : ""}`; + + const channelType = isInGuild ? (channel.type === "GUILD_TEXT" ? "Text" : "Voice") : ""; + const title = `${payload.data && payload.data.author ? payload.data.author : "Unknown"}${isInGuild ? ` (#${channel.name}, ${channelType} Channels)` : ""}`; const options = { - body: payload.data?.content || "", - icon: payload.data?.avatar || null, + body: payload.data && payload.data.content ? payload.data.content : "", + icon: payload.data && payload.data.avatar ? payload.data.avatar : null, tag: `channel-${channel.id}`, data: { channelId: channel.id, isInGuild }, }; @@ -28,7 +28,8 @@ self.addEventListener("notificationclick", (event) => { event.waitUntil( clients.matchAll({ type: "window", includeUncontrolled: true }).then((clientList) => { - for (const client of clientList) { + for (let i = 0; i < clientList.length; i++) { + const client = clientList[i]; if (client.url === targetUrl && "focus" in client) { return client.focus(); } diff --git a/assets/public/custom/web/main.js b/assets/public/custom/web/main.js index 68a1a4e7..950cff0e 100644 --- a/assets/public/custom/web/main.js +++ b/assets/public/custom/web/main.js @@ -125,7 +125,8 @@ const maskRef = rect.getAttribute("mask"); if (!maskRef) continue; - const maskId = maskRef.match(/#([^)]+)/)?.[1]; + const maskMatch = maskRef.match(/#([^)]+)/); + const maskId = maskMatch ? maskMatch[1] : null; if (!maskId) continue; const mask = document.getElementById(maskId);