Fix server name detection after a Discord update

Closes #204
This commit is contained in:
chylex 2022-10-07 14:35:30 +02:00
parent 8c68438fbb
commit 7e7d140957
No known key found for this signature in database
GPG Key ID: 4DE42C8F19A80548

View File

@ -197,9 +197,22 @@ class DISCORD {
return { server, channel };
}
else if (obj.guild_id) {
let guild;
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;
}
}
if (!guild || typeof guild.name !== "string" || obj.guild_id !== guild.id) {
return null;
}
const server = {
"id": obj.guild_id,
"name": document.querySelector("nav header h1[class*='name-']").innerText,
"id": guild.id,
"name": guild.name,
"type": "SERVER"
};