diff options
author | Nuckyz <61953774+Nuckyz@users.noreply.github.com> | 2023-03-06 18:54:01 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-06 22:54:01 +0100 |
commit | 7322c3af047489e122b59b01825ba5473dc96a62 (patch) | |
tree | 6770f6166e793e48cdab55fd65ab9c88da331555 | |
parent | 36c27f1111d3a56536d21d2bbeade3f44da7eee0 (diff) | |
download | Vencord-7322c3af047489e122b59b01825ba5473dc96a62.tar.gz Vencord-7322c3af047489e122b59b01825ba5473dc96a62.tar.bz2 Vencord-7322c3af047489e122b59b01825ba5473dc96a62.zip |
Fix Crash Loops and prevent metrics (#580)
-rw-r--r-- | src/plugins/crashHandler.ts | 19 | ||||
-rw-r--r-- | src/plugins/noTrack.ts | 13 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/plugins/crashHandler.ts b/src/plugins/crashHandler.ts index 6f030b1..79db782 100644 --- a/src/plugins/crashHandler.ts +++ b/src/plugins/crashHandler.ts @@ -41,6 +41,8 @@ const settings = definePluginSettings({ } }); +let crashCount: number = 0; + export default definePlugin({ name: "CrashHandler", description: "Utility plugin for handling and possibly recovering from Crashes without a restart", @@ -69,8 +71,22 @@ export default definePlugin({ ], handleCrash(_this: ReactElement & { forceUpdate: () => void; }) { + if (++crashCount > 5) { + try { + showNotification({ + color: "#eed202", + title: "Discord has crashed!", + body: "Awn :( Discord has crashed more than five times, not attempting to recover.", + }); + } catch { } + + return false; + } + + setTimeout(() => crashCount--, 60_000); + try { - maybePromptToUpdate("Uh oh, Discord has just crashed... but good news, there is a Vencord update available that might fix this issue! Would you like to update now?", true); + if (crashCount === 1) maybePromptToUpdate("Uh oh, Discord has just crashed... but good news, there is a Vencord update available that might fix this issue! Would you like to update now?", true); if (settings.store.attemptToPreventCrashes) { this.handlePreventCrash(_this); @@ -80,6 +96,7 @@ export default definePlugin({ return false; } catch (err) { CrashHandlerLogger.error("Failed to handle crash", err); + return false; } }, diff --git a/src/plugins/noTrack.ts b/src/plugins/noTrack.ts index 27ff430..617ab8b 100644 --- a/src/plugins/noTrack.ts +++ b/src/plugins/noTrack.ts @@ -38,6 +38,19 @@ export default definePlugin({ match: /window\.DiscordSentry=function.+\}\(\)/, replace: "", } + }, + { + find: ".METRICS,", + replacement: [ + { + match: /this\._intervalId.+?12e4\)/, + replace: "" + }, + { + match: /(?<=increment=function\(\i\){)/, + replace: "return;" + } + ] } ] }); |