revenge-bundle-next/src/plugins/no-track/index.ts
PalmDevs a43cd5d564
feat!: plugins page, tons of API changes, and bug fixes
Plugins
- Settings: Plugins page is now semi-functional
- No Track: Added new plugin
- Developer Settings: Clean up properly
- Logging: Log in preInit stage
- Staff Settings: Add ReloadRequired flags when late-running

@revenge-mod/init
- Moved to the top-level src/index.ts instead

@revenge-mod/modules
- Switch `exports` and `id` parameters in finders APIs
- Lookups now return an array of exports and ID instead of just exports
  - Lookup ID APIs have been removed
- Add `finders.get` helper, a new alternative for `finders.find`
- Corrected documentation for subscription APIs

@revenge-mod/plugins
- Added new APIs for plugins to allow running during pre-init stages
- Added `unscoped.modules.finders.get*`
- Added `unscoped.react.native`

@revenge-mod/react
- native: Added `onRunApplication` and `onRunApplicationFinished`

@revenge-mod/utils
- callbacks: Add `noopFalse`
- promises: Fix `allSettled`
- promises: Add `sleep`
2025-05-18 22:24:48 +07:00

69 lines
2.6 KiB
TypeScript

import { byProps } from '@revenge-mod/modules/finders/filters'
import { waitForModules } from '@revenge-mod/modules/finders/wait'
import { instead } from '@revenge-mod/patcher'
import { PluginFlags } from '@revenge-mod/plugins/constants'
import { InternalPluginFlags, registerPlugin } from '@revenge-mod/plugins/_'
// TODO(plugins/no-track): Block Sentry native-side
registerPlugin(
{
id: 'revenge.no-track',
name: 'No Track',
description: "Disables Discord's analytics/tracking, and Sentry.",
author: 'Revenge',
icon: 'AnalyticsIcon',
},
{
preInit({ cleanup }) {
// modules/errors/native/SentryInitUtils.tsx
const unsubSIU = waitForModules(byProps('initSentry'), SentryInitUtils => {
unsubSIU()
console.log('Patching SentryInitUtils...')
cleanup(instead(SentryInitUtils, 'initSentry', () => {}))
cleanup(() => SentryInitUtils.initSentry())
})
},
init({ cleanup, logger }) {
// utils/AnalyticsUtils.tsx
const unsubAU = waitForModules(
byProps<{
trackNetworkAction: () => void
default: {
track: () => void
AnalyticsActionHandlers: Record<string, () => void>
}
}>('trackNetworkAction'),
AnalyticsUtils => {
unsubAU()
logger.info('Patching AnalyticsUtils...')
cleanup(instead(AnalyticsUtils.default, 'track', () => {}))
cleanup(instead(AnalyticsUtils, 'trackNetworkAction', () => {}))
for (const key in AnalyticsUtils.default.AnalyticsActionHandlers)
cleanup(instead(AnalyticsUtils.default.AnalyticsActionHandlers, key, () => {}))
},
)
// modules/app_analytics/useTrackImpression.tsx
const unsubTI = waitForModules(
byProps<{
default: () => void
trackImpression: () => void
}>('trackImpression'),
useTrackImpression => {
unsubTI()
logger.info('Patching useTrackImpression...')
cleanup(instead(useTrackImpression, 'trackImpression', () => {}))
cleanup(instead(useTrackImpression, 'default', () => {}))
},
)
},
},
PluginFlags.Enabled,
// TODO(plugins/no-track): is it essential?
InternalPluginFlags.Internal | InternalPluginFlags.Essential,
)