even more fixes for firefox 52

This commit is contained in:
murdle 2025-12-21 00:10:41 +02:00
parent 6e64e505f9
commit e0b35003ac
2 changed files with 10 additions and 8 deletions

View File

@ -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();
}

View File

@ -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);