From 5bc20ba1620edd7075d3664d3d5c1da3ca13df05 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 2 May 2024 00:36:37 -0300 Subject: [PATCH] NoTrack: Option to keep analytics, improve patches --- src/plugins/_core/noTrack.ts | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/plugins/_core/noTrack.ts b/src/plugins/_core/noTrack.ts index 424e62c04..67f6c6448 100644 --- a/src/plugins/_core/noTrack.ts +++ b/src/plugins/_core/noTrack.ts @@ -16,17 +16,31 @@ * along with this program. If not, see . */ +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; +import definePlugin, { OptionType } from "@utils/types"; + +const settings = definePluginSettings({ + disableAnalytics: { + type: OptionType.BOOLEAN, + description: "Disable Discord's tracking (analytics/'science')", + default: true, + restartNeeded: true + } +}); export default definePlugin({ name: "NoTrack", - description: "Disable Discord's tracking ('science'), metrics and Sentry crash reporting", + description: "Disable Discord's tracking (analytics/'science'), metrics and Sentry crash reporting", authors: [Devs.Cyn, Devs.Ven, Devs.Nuckyz, Devs.Arrow], required: true, + + settings, + patches: [ { find: "AnalyticsActionHandlers.handle", + predicate: () => settings.store.disableAnalytics, replacement: { match: /^.+$/, replace: "()=>{}", @@ -44,11 +58,11 @@ export default definePlugin({ replacement: [ { match: /this\._intervalId=/, - replace: "this._intervalId=undefined&&" + replace: "this._intervalId=void 0&&" }, { - match: /(increment\(\i\){)/, - replace: "$1return;" + match: /(?:increment|distribution)\(\i(?:,\i)?\){/g, + replace: "$&return;" } ] },