From 70a2a01ec3bbc6f3341c8a093a0b7e9671db58b0 Mon Sep 17 00:00:00 2001 From: chylex Date: Sun, 20 Mar 2022 13:36:12 +0100 Subject: [PATCH] Fix switching to next channel in DMs after a recent Discord update --- app/Resources/Tracker/scripts/discord.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Resources/Tracker/scripts/discord.js b/app/Resources/Tracker/scripts/discord.js index 791f3ac..7968d74 100644 --- a/app/Resources/Tracker/scripts/discord.js +++ b/app/Resources/Tracker/scripts/discord.js @@ -232,16 +232,21 @@ class DISCORD { if (dms) { const currentChannel = DOM.queryReactClass("selected", dms); - const nextChannel = currentChannel && currentChannel.nextElementSibling; + const currentChannelContainer = currentChannel && currentChannel.closest("[class*='channel-']"); + const nextChannel = currentChannelContainer && currentChannelContainer.nextElementSibling; - if (!nextChannel || !nextChannel.getAttribute("class").includes("channel-") || !("href" in nextChannel) || !nextChannel.href.includes("/@me/")) { + if (!nextChannel || !nextChannel.getAttribute("class").includes("channel-")) { return false; } - else { - nextChannel.click(); - nextChannel.scrollIntoView(true); - return true; + + const nextChannelLink = nextChannel.querySelector("a[href*='/@me/']"); + if (!nextChannelLink) { + return false; } + + nextChannelLink.click(); + nextChannelLink.scrollIntoView(true); + return true; } else { const channelListEle = document.getElementById("channels");