Fix not seeing messages after a Discord update

Closes #226
This commit is contained in:
chylex 2023-10-29 06:09:40 +01:00
parent 37640c97b0
commit 18f5823f2a
No known key found for this signature in database
GPG Key ID: 4DE42C8F19A80548
2 changed files with 7 additions and 7 deletions

View File

@ -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;
}

View File

@ -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}_"]`);
}
/**