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 1/2] 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 424e62c046..67f6c6448e 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;" } ] }, From 9be3af33692f9add643e1de27c3bace79a9b012f Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 2 May 2024 14:58:31 +0200 Subject: [PATCH 2/2] improve contributor badge --- src/api/Badges.ts | 6 ++---- src/plugins/_api/badges.tsx | 15 +++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/api/Badges.ts b/src/api/Badges.ts index b50016c5bc..061bdeb8a2 100644 --- a/src/api/Badges.ts +++ b/src/api/Badges.ts @@ -36,7 +36,7 @@ export interface ProfileBadge { image?: string; link?: string; /** Action to perform when you click the badge */ - onClick?(): void; + onClick?(event: React.MouseEvent, props: BadgeUserArgs): void; /** Should the user display this badge? */ shouldShow?(userInfo: BadgeUserArgs): boolean; /** Optional props (e.g. style) for the badge, ignored for component badges */ @@ -87,9 +87,7 @@ export function _getBadges(args: BadgeUserArgs) { export interface BadgeUserArgs { user: User; - profile: Profile; - premiumSince: Date; - premiumGuildSince?: Date; + guildId: string; } interface ConnectedAccount { diff --git a/src/plugins/_api/badges.tsx b/src/plugins/_api/badges.tsx index 6b1a79cd55..6cbe1feb06 100644 --- a/src/plugins/_api/badges.tsx +++ b/src/plugins/_api/badges.tsx @@ -34,14 +34,13 @@ const ContributorBadge: ProfileBadge = { description: "Vencord Contributor", image: CONTRIBUTOR_BADGE, position: BadgePosition.START, - props: { - style: { - borderRadius: "50%", - transform: "scale(0.9)" // The image is a bit too big compared to default badges - } - }, shouldShow: ({ user }) => isPluginDev(user.id), - link: "https://github.com/Vendicated/Vencord" + onClick(_, { user }) { + // circular import shenanigans + const { openContributorModal } = require("@components/PluginSettings/ContributorModal") as typeof import("@components/PluginSettings/ContributorModal"); + // setImmediate is needed to run on later tick to workaround limitation in proxyLazy + setImmediate(() => openContributorModal(user)); + } }; let DonorBadges = {} as Record>>; @@ -85,7 +84,7 @@ export default definePlugin({ // conditionally override their onClick with badge.onClick if it exists { match: /href:(\i)\.link/, - replace: "...($1.onClick && { onClick: $1.onClick }),$&" + replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, arguments[0]) }),$&" } ] }