diff --git a/assets/public/custom/pushMessages.js b/assets/public/custom/pushMessages.js index 5afc54e1..4a76100f 100644 --- a/assets/public/custom/pushMessages.js +++ b/assets/public/custom/pushMessages.js @@ -7,12 +7,15 @@ async function isPushRegistered() { checkServiceWorkerSupport(); try { const registrations = await navigator.serviceWorker.getRegistrations(); - if (!registrations?.length) return false; + if (!registrations || registrations.length === 0) return false; - return await Promise.any( - registrations.map(async (reg) => !!(await reg.pushManager.getSubscription())) - ).catch(() => false); - } catch { + for (let reg of registrations) { + const subscription = await reg.pushManager.getSubscription(); + if (subscription) return true; + } + + return false; + } catch (error) { return false; } } diff --git a/assets/public/custom/rtcPatcher.js b/assets/public/custom/rtcPatcher.js index 276c7498..4fd2fa34 100644 --- a/assets/public/custom/rtcPatcher.js +++ b/assets/public/custom/rtcPatcher.js @@ -14,7 +14,10 @@ window.RTCPeerConnection = function (...args) { const lines = offer.sdp.split("\n"); for (const line of lines) { if (line.includes("a=fingerprint")) { - fingerprint = line.split("a=fingerprint:")[1]?.trim() ?? null; + const fingerprintMatch = line.split("a=fingerprint:")[1]; + if (fingerprintMatch) { + fingerprint = fingerprintMatch.trim(); + } } } } diff --git a/assets/public/custom/utils.js b/assets/public/custom/utils.js index 92f5dc61..aa74e69a 100644 --- a/assets/public/custom/utils.js +++ b/assets/public/custom/utils.js @@ -23,7 +23,7 @@ function loadConfig() { ...DEFAULT_CONFIG, ...JSON.parse(localStorage_.getItem(CONFIG_KEY) || "{}") }; - } catch { + } catch(error) { return { ...DEFAULT_CONFIG }; } } diff --git a/assets/public/custom/web/main.js b/assets/public/custom/web/main.js index 8f864b8e..c182d085 100644 --- a/assets/public/custom/web/main.js +++ b/assets/public/custom/web/main.js @@ -32,14 +32,26 @@ if (document.querySelector("[data-join-date]")) return; const nitroBadge = document.querySelector(CSS_CLASSES.nitroBadge); - const date = nitroBadge?.getAttribute("aria-label")?.replace("Subscriber since ", ""); - if (!date) return; + if (!nitroBadge) return; + + const date = nitroBadge.getAttribute("aria-label"); + if (date) { + const formattedDate = date.replace("Subscriber since ", ""); + if (!formattedDate) return; + } const isCompact = !!document.querySelector("h3.bodyTitle-2Az3VQ"); - const anchor = [...document.querySelectorAll("h3")].find(h => - (h.className.includes("bodyTitle") && h.textContent.includes("Role")) || - h.textContent.trim() === "Note" - ); + const h3Elements = document.querySelectorAll("h3"); + + let anchor = null; + for (let i = 0; i < h3Elements.length; i++) { + const h = h3Elements[i]; + if ((h.className.indexOf("bodyTitle") > -1 && h.textContent.indexOf("Role") > -1) || + h.textContent.trim() === "Note") { + anchor = h; + break; + } + } if (!anchor) return; const infoText = document.createElement("div"); @@ -50,7 +62,7 @@ const dateText = document.createElement("div"); dateText.className = isCompact ? CSS_CLASSES.userInfoBody : CSS_CLASSES.userInfoText; - dateText.textContent = date; + dateText.textContent = formattedDate; dateText.dataset.joinDate = "value"; if (isCompact) { @@ -64,7 +76,8 @@ } infoText.style.marginTop = isNewSection ? "0px" : "10px"; - infoSection.append(infoText, dateText); + infoSection.appendChild(infoText); + infoSection.appendChild(dateText); } else { anchor.parentNode.insertBefore(infoText, anchor); anchor.parentNode.insertBefore(dateText, anchor);