From 18f5823f2a5502f365d54d01135e0b0e18e59d84 Mon Sep 17 00:00:00 2001 From: chylex Date: Sun, 29 Oct 2023 06:09:40 +0100 Subject: [PATCH] Fix not seeing messages after a Discord update Closes #226 --- app/Resources/Tracker/scripts/discord.js | 12 ++++++------ app/Resources/Tracker/scripts/dom.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Resources/Tracker/scripts/discord.js b/app/Resources/Tracker/scripts/discord.js index b7045a6..ca49ec7 100644 --- a/app/Resources/Tracker/scripts/discord.js +++ b/app/Resources/Tracker/scripts/discord.js @@ -9,7 +9,7 @@ class DISCORD { } static getMessageElements() { - return this.getMessageOuterElement().querySelectorAll("[class*='message-']"); + return this.getMessageOuterElement().querySelectorAll("[class*='message_']"); } static hasMoreMessages() { @@ -168,7 +168,7 @@ class DISCORD { if (dms) { let name; - for (const ele of dms.querySelectorAll("[class*='channel-'] [class*='selected-'] [class^='name-'] *, [class*='channel-'][class*='selected-'] [class^='name-'] *")) { + for (const ele of dms.querySelectorAll("[class*='channel_'] [class*='selected_'] [class^='name_'] *")) { const node = Array.prototype.find.call(ele.childNodes, node => node.nodeType === Node.TEXT_NODE); if (node) { @@ -199,7 +199,7 @@ class DISCORD { else if (obj.guild_id) { let guild; - for (const child of DOM.getReactProps(document.querySelector("nav header [class*='headerContent-']")).children) { + for (const child of DOM.getReactProps(document.querySelector("nav header [class*='headerContent_']")).children) { if (child && child.props && child.props.guild) { guild = child.props.guild; break; @@ -251,10 +251,10 @@ class DISCORD { if (dms) { const currentChannel = DOM.queryReactClass("selected", dms); - const currentChannelContainer = currentChannel && currentChannel.closest("[class*='channel-']"); + const currentChannelContainer = currentChannel && currentChannel.closest("[class*='channel_']"); const nextChannel = currentChannelContainer && currentChannelContainer.nextElementSibling; - if (!nextChannel || !nextChannel.getAttribute("class").includes("channel-")) { + if (!nextChannel || !nextChannel.getAttribute("class").includes("channel_")) { return false; } @@ -281,7 +281,7 @@ class DISCORD { let nextChannel = null; for (let index = 0; index < allTextChannels.length - 1; index++) { - if (allTextChannels[index].className.includes("selected-")) { + if (allTextChannels[index].className.includes("selected_")) { nextChannel = allTextChannels[index + 1]; break; } diff --git a/app/Resources/Tracker/scripts/dom.js b/app/Resources/Tracker/scripts/dom.js index dc32f57..7b7bf51 100644 --- a/app/Resources/Tracker/scripts/dom.js +++ b/app/Resources/Tracker/scripts/dom.js @@ -11,7 +11,7 @@ class DOM { * Returns the first child element containing the specified obfuscated class. Parent defaults to the entire document. */ static queryReactClass(cls, parent) { - return (parent || document).querySelector(`[class*="${cls}-"]`); + return (parent || document).querySelector(`[class*="${cls}_"]`); } /**