From d52753846fb1154c35bac0c982c467e0bf6c7131 Mon Sep 17 00:00:00 2001 From: Lance Fetters Date: Thu, 28 Sep 2023 15:38:28 +0100 Subject: [PATCH] Translator: Fix issue with threads due to Discord misusing id props --- Plugins/Translator/Translator.plugin.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Translator/Translator.plugin.js b/Plugins/Translator/Translator.plugin.js index 1afe4192d6..6f8062d963 100644 --- a/Plugins/Translator/Translator.plugin.js +++ b/Plugins/Translator/Translator.plugin.js @@ -794,8 +794,10 @@ module.exports = (_ => { } showTooltipForMessageContent (message, translation) { - let node = document.getElementById(`message-content-${message.id}`); - if (!node || node.parentElement.querySelector(":hover") !== node) return; + // NOTE: Although id props should be unique, Discord reuses them when, for example, displaying threads in floating views. + let nodes = document.querySelectorAll(`#message-content-${message.id}`); + let node = Array.from(nodes).find((n) => n === n.parentElement.querySelector(":hover")); + if (!node) return; let tooltip = node.__translatorMessageContentTooltip; if (!tooltip) {