diff --git a/scripts/build.mjs b/scripts/build.mjs index fea5c91..ff00c84 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -74,7 +74,7 @@ const config = { constModules: { globals: { "bunny-build-info": { - version: `"1.2.0"` + version: `"1.2.1"` } } }, diff --git a/src/core/plugins/badges/index.tsx b/src/core/plugins/badges/index.tsx index c8d7d10..96914a3 100644 --- a/src/core/plugins/badges/index.tsx +++ b/src/core/plugins/badges/index.tsx @@ -15,10 +15,15 @@ const useBadgesModule = findByName("useBadges", false); export default defineCorePlugin({ manifest: { id: "bunny.badges", - name: "Badges", version: "1.0.0", - description: "Adds badges to user's profile", - authors: [{ name: "pylixonly" }] + type: "plugin", + spec: 3, + main: "", + display: { + name: "Badges", + description: "Adds badges to user's profile", + authors: [{ name: "pylixonly" }] + } }, start() { const propHolder = {} as Record; diff --git a/src/core/plugins/index.ts b/src/core/plugins/index.ts index e270de7..7b423f7 100644 --- a/src/core/plugins/index.ts +++ b/src/core/plugins/index.ts @@ -8,7 +8,8 @@ interface CorePlugin { // Called from @lib/plugins export const getCorePlugins = (): Record => ({ "bunny.quickinstall": require("./quickinstall"), - "bunny.badges": require("./badges") + "bunny.badges": require("./badges"), + "vendetta.notrack": require("./notrack") }); /** diff --git a/src/core/plugins/notrack/index.ts b/src/core/plugins/notrack/index.ts new file mode 100644 index 0000000..a497397 --- /dev/null +++ b/src/core/plugins/notrack/index.ts @@ -0,0 +1,39 @@ +import network from "./lib/network"; +import console from "./lib/console"; +import miscellanous from "./lib/miscellanous"; +import sentry from "./lib/sentry"; +import { defineCorePlugin } from ".."; +import { logger } from "@lib/utils/logger"; + +const patches = [ + network(), + console(), + miscellanous(), + // Sentry causes issues + // sentry(), +]; + +export default defineCorePlugin({ + manifest: { + id: "vendetta.notrack", + version: "1.0.0", + type: "plugin", + spec: 3, + main: "", + display: { + name: "NoTrack", + description: "Disables Discord's telemetry", + authors: [{ name: "maisymoe" }] + } + }, + start() { + logger.log("gyat"); + const patches = [ + network(), + console(), + miscellanous(), + sentry(), + ]; + } +}); + diff --git a/src/core/plugins/notrack/lib/console.ts b/src/core/plugins/notrack/lib/console.ts new file mode 100644 index 0000000..7a69471 --- /dev/null +++ b/src/core/plugins/notrack/lib/console.ts @@ -0,0 +1,16 @@ +import { logger } from "@lib/utils/logger"; + +export default () => { + const sentrified = {}; + + try { + Object.keys(console).forEach((x) => { + sentrified[x] = console[x]; + console[x] = console[x].__sentry_original__ ?? console[x]; + }); + } catch(e) { + logger.log("Failed to de-sentrify console functions!", e); + }; + + return () => Object.keys(console).forEach((x) => console[x] = sentrified[x]); +} diff --git a/src/core/plugins/notrack/lib/miscellanous.ts b/src/core/plugins/notrack/lib/miscellanous.ts new file mode 100644 index 0000000..b6a6093 --- /dev/null +++ b/src/core/plugins/notrack/lib/miscellanous.ts @@ -0,0 +1,33 @@ +import { findByProps } from "@metro"; +import { noop } from "./utils"; + +// Stuff in here is non-specific tracking scattered around the app + +const AnalyticsUtils = findByProps("AnalyticsActionHandlers"); +const SuperPropUtils = findByProps("encodeProperties", "track"); +const VoiceStateUtils = findByProps("getVoiceStateMetadata"); +const CrashReportUtils = findByProps("submitLiveCrashReport"); +const MetricsUtils = findByProps("_metrics"); + +export default () => { + const patches = [ + // Global analytics utilities + ...(["handleTrack", "handleFingerprint"].map((i) => noop(i, AnalyticsUtils.AnalyticsActionHandlers))), + // TODO: This is a getter - look into patching it + // noop("analyticsTrackingStoreMaker", AnalyticsUtils), + + // Super properties tracking + noop("track", SuperPropUtils), + + // Voice state metadata tracking + noop("trackWithMetadata", VoiceStateUtils), + + // Crash reporter + noop("submitLiveCrashReport", CrashReportUtils), + + // Whatever "metrics" implies + noop("push", MetricsUtils._metrics), + ]; + + return () => patches.forEach((p) => p()); +} diff --git a/src/core/plugins/notrack/lib/network.ts b/src/core/plugins/notrack/lib/network.ts new file mode 100644 index 0000000..68f762e --- /dev/null +++ b/src/core/plugins/notrack/lib/network.ts @@ -0,0 +1,12 @@ +import { instead } from "@lib/api/patcher"; + +export default () => { + // https://github.com/yellowsink/shelter-plugins/blob/3a62d1557b704f4617f72882edba826218eb8c6e/plugins/antitrack/index.js#L10-L25 + const analyticsTest = /client-analytics\.braintreegateway\.com|discord\.com\/api\/v9\/(science|track)|app\.adjust\..*|.*\.ingest\.sentry\.io/; + + return instead( + "send", + XMLHttpRequest.prototype, + function (args, orig) { if (!analyticsTest.test(this.__sentry_xhr__?.url)) return orig.apply(this, args) }, + ); +} diff --git a/src/core/plugins/notrack/lib/sentry.ts b/src/core/plugins/notrack/lib/sentry.ts new file mode 100644 index 0000000..5b01b7e --- /dev/null +++ b/src/core/plugins/notrack/lib/sentry.ts @@ -0,0 +1,26 @@ +import { findByProps } from "@metro"; +import { noop } from "./utils"; + +const Sentry = { + initializer: findByProps("initSentry"), + main: globalThis.__SENTRY__?.hub, + client: globalThis.__SENTRY__?.hub?.getClient(), +}; + +export default () => { + const patches = [ + noop("initSentry", Sentry.initializer), + noop("addBreadcrumb", Sentry.main), + ]; + + Sentry.client.getOptions().enabled = false; + Sentry.client.close(); + Sentry.main.getStackTop().scope.clear(); + Sentry.main.getScope().clear(); + + return () => { + patches.forEach((p) => p()); + Sentry.client.getOptions().enabled = true; + Sentry.client.open(); + }; +} diff --git a/src/core/plugins/notrack/lib/utils.ts b/src/core/plugins/notrack/lib/utils.ts new file mode 100644 index 0000000..55f871f --- /dev/null +++ b/src/core/plugins/notrack/lib/utils.ts @@ -0,0 +1,3 @@ +import { instead } from "@lib/api/patcher"; + +export const noop = (prop: string, parent: any) => instead(prop, parent, () => {}); diff --git a/src/core/plugins/quickinstall/index.ts b/src/core/plugins/quickinstall/index.ts index 51f5e94..d8f25da 100644 --- a/src/core/plugins/quickinstall/index.ts +++ b/src/core/plugins/quickinstall/index.ts @@ -7,10 +7,15 @@ let patches = [] as (() => unknown)[]; export default defineCorePlugin({ manifest: { id: "bunny.quickinstall", - name: "QuickInstall", version: "1.0.0", - description: "Quickly install Vendetta plugins and themes", - authors: [{ name: "Vendetta Team" }] + type: "plugin", + spec: 3, + main: "", + display: { + name: "QuickInstall", + description: "Quickly install Vendetta plugins and themes", + authors: [{ name: "Vendetta Team" }] + } }, start() { patches = [patchForumPost(), patchUrl()]; diff --git a/src/lib/addons/themes/colors/fix.ts b/src/lib/addons/themes/colors/fix.ts index eafe546..9099c07 100644 --- a/src/lib/addons/themes/colors/fix.ts +++ b/src/lib/addons/themes/colors/fix.ts @@ -1,6 +1,6 @@ import { StatusBar } from "react-native"; import { findByStoreNameLazy } from "@metro/wrappers"; -import { _colorRef } from "./updater"; // <-- import your colorRef +import { _colorRef } from "./updater"; const ThemeStore = findByStoreNameLazy("ThemeStore");