even more fixes for firefox 52
This commit is contained in:
parent
6e64e505f9
commit
e0b35003ac
@ -4,15 +4,15 @@ self.addEventListener("push", (event) => {
|
|||||||
const payload = event.data.json();
|
const payload = event.data.json();
|
||||||
if (payload.type !== "message") return;
|
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 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 = {
|
const options = {
|
||||||
body: payload.data?.content || "",
|
body: payload.data && payload.data.content ? payload.data.content : "",
|
||||||
icon: payload.data?.avatar || null,
|
icon: payload.data && payload.data.avatar ? payload.data.avatar : null,
|
||||||
tag: `channel-${channel.id}`,
|
tag: `channel-${channel.id}`,
|
||||||
data: { channelId: channel.id, isInGuild },
|
data: { channelId: channel.id, isInGuild },
|
||||||
};
|
};
|
||||||
@ -28,7 +28,8 @@ self.addEventListener("notificationclick", (event) => {
|
|||||||
|
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
clients.matchAll({ type: "window", includeUncontrolled: true }).then((clientList) => {
|
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) {
|
if (client.url === targetUrl && "focus" in client) {
|
||||||
return client.focus();
|
return client.focus();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,7 +125,8 @@
|
|||||||
const maskRef = rect.getAttribute("mask");
|
const maskRef = rect.getAttribute("mask");
|
||||||
if (!maskRef) continue;
|
if (!maskRef) continue;
|
||||||
|
|
||||||
const maskId = maskRef.match(/#([^)]+)/)?.[1];
|
const maskMatch = maskRef.match(/#([^)]+)/);
|
||||||
|
const maskId = maskMatch ? maskMatch[1] : null;
|
||||||
if (!maskId) continue;
|
if (!maskId) continue;
|
||||||
|
|
||||||
const mask = document.getElementById(maskId);
|
const mask = document.getElementById(maskId);
|
||||||
|
|||||||
Reference in New Issue
Block a user