diff --git a/app/Resources/Tracker/scripts/discord.js b/app/Resources/Tracker/scripts/discord.js index 028bbfa..cb2c8d6 100644 --- a/app/Resources/Tracker/scripts/discord.js +++ b/app/Resources/Tracker/scripts/discord.js @@ -110,16 +110,20 @@ class DISCORD { const messages = []; for (const ele of this.getMessageElements()) { - const props = this.getMessageElementProps(ele); - - if (props != null) { - messages.push(props.message); + try { + const props = this.getMessageElementProps(ele); + + if (props != null) { + messages.push(props.message); + } + } catch (e) { + console.error("[DHT] Error extracing message data, skipping it.", e, ele, DOM.tryGetReactProps(ele)); } } return messages; } catch (e) { - console.error(e); + console.error("[DHT] Error retrieving messages.", e); return []; } } diff --git a/app/Resources/Tracker/scripts/dom.js b/app/Resources/Tracker/scripts/dom.js index ea6fb34..dc32f57 100644 --- a/app/Resources/Tracker/scripts/dom.js +++ b/app/Resources/Tracker/scripts/dom.js @@ -71,4 +71,15 @@ class DOM { key = keys.find(key => key.startsWith("__reactProps$")); return key ? ele[key] : null; } + + /** + * Returns internal React state object of an element, or null if the retrieval throws. + */ + static tryGetReactProps(ele) { + try { + return this.getReactProps(ele); + } catch (e) { + return null; + } + } }