Fix switching to next channel in DMs after a recent Discord update

This commit is contained in:
chylex 2022-03-20 13:36:12 +01:00
parent c31155738e
commit 70a2a01ec3
No known key found for this signature in database
GPG Key ID: 4DE42C8F19A80548

View File

@ -232,16 +232,21 @@ class DISCORD {
if (dms) { if (dms) {
const currentChannel = DOM.queryReactClass("selected", 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; return false;
} }
else {
nextChannel.click(); const nextChannelLink = nextChannel.querySelector("a[href*='/@me/']");
nextChannel.scrollIntoView(true); if (!nextChannelLink) {
return true; return false;
} }
nextChannelLink.click();
nextChannelLink.scrollIntoView(true);
return true;
} }
else { else {
const channelListEle = document.getElementById("channels"); const channelListEle = document.getElementById("channels");