From 796df9cd5681ecbbe6c95cdea69e3fa81969cea0 Mon Sep 17 00:00:00 2001 From: "wont.stream" Date: Tue, 24 Sep 2024 18:48:28 -0400 Subject: [PATCH] update --- plugins/eurotilities/helpers/modules.ts | 25 --- plugins/eurotilities/helpers/webpack.ts | 160 ------------------ plugins/eurotilities/index.ts | 22 --- plugins/eurotilities/modules/alwaysTrust.ts | 8 - plugins/eurotilities/modules/antiTrack.ts | 24 --- plugins/eurotilities/modules/muteNewGuild.ts | 26 --- plugins/eurotilities/modules/noCallIdle.ts | 18 -- plugins/eurotilities/modules/noConsoleSpam.ts | 19 --- .../modules/noDevtoolsDetection.ts | 17 -- .../eurotilities/modules/noReplyMention.ts | 10 -- plugins/eurotilities/modules/noTyping.ts | 7 - .../eurotilities/modules/steamStatusSync.ts | 24 --- .../eurotilities/modules/timestampedFiles.ts | 23 --- plugins/eurotilities/plugin.json | 5 - .../index.ts} | 27 +-- plugins/noNitroUpsell/plugin.json | 5 + 16 files changed, 22 insertions(+), 398 deletions(-) delete mode 100644 plugins/eurotilities/helpers/modules.ts delete mode 100644 plugins/eurotilities/helpers/webpack.ts delete mode 100644 plugins/eurotilities/index.ts delete mode 100644 plugins/eurotilities/modules/alwaysTrust.ts delete mode 100644 plugins/eurotilities/modules/antiTrack.ts delete mode 100644 plugins/eurotilities/modules/muteNewGuild.ts delete mode 100644 plugins/eurotilities/modules/noCallIdle.ts delete mode 100644 plugins/eurotilities/modules/noConsoleSpam.ts delete mode 100644 plugins/eurotilities/modules/noDevtoolsDetection.ts delete mode 100644 plugins/eurotilities/modules/noReplyMention.ts delete mode 100644 plugins/eurotilities/modules/noTyping.ts delete mode 100644 plugins/eurotilities/modules/steamStatusSync.ts delete mode 100644 plugins/eurotilities/modules/timestampedFiles.ts delete mode 100644 plugins/eurotilities/plugin.json rename plugins/{eurotilities/modules/noNitroUpsell.ts => noNitroUpsell/index.ts} (53%) create mode 100644 plugins/noNitroUpsell/plugin.json diff --git a/plugins/eurotilities/helpers/modules.ts b/plugins/eurotilities/helpers/modules.ts deleted file mode 100644 index 52f73bb..0000000 --- a/plugins/eurotilities/helpers/modules.ts +++ /dev/null @@ -1,25 +0,0 @@ -import alwaysTrust from "../modules/alwaysTrust.ts"; -import antiTrack from "../modules/antiTrack.ts"; -import muteNewGuild from "../modules/muteNewGuild.ts"; -import noCallIdle from "../modules/noCallIdle.ts"; -import noConsoleSpam from "../modules/noConsoleSpam.ts"; -import noDevtoolsDetection from "../modules/noDevtoolsDetection.ts"; -import noNitroUpsell from "../modules/noNitroUpsell.ts"; -import noReplyMention from "../modules/noReplyMention.ts"; -import noTyping from "../modules/noTyping.ts"; -import steamStatusSync from "../modules/steamStatusSync.ts"; -import timestampedFiles from "../modules/timestampedFiles.ts"; - -export default { - alwaysTrust, - antiTrack, - muteNewGuild, - noCallIdle, - noConsoleSpam, - noDevtoolsDetection, - noNitroUpsell, - noReplyMention, - noTyping, - steamStatusSync, - timestampedFiles, -}; diff --git a/plugins/eurotilities/helpers/webpack.ts b/plugins/eurotilities/helpers/webpack.ts deleted file mode 100644 index 92bed8a..0000000 --- a/plugins/eurotilities/helpers/webpack.ts +++ /dev/null @@ -1,160 +0,0 @@ -// Original code taken from https://github.com/Vendicated/Vencord under GPLv3 license - -// biome-ignore lint/suspicious/noImplicitAnyLet: N/A -let wreq; -// biome-ignore lint/suspicious/noImplicitAnyLet: N/A -// biome-ignore lint/style/useConst: N/A -let cache; - -declare global { - interface Window { - // biome-ignore lint/suspicious/noExplicitAny: N/A - webpackChunkdiscord_app: any[]; - } -} - -window.webpackChunkdiscord_app.push([ - [Symbol()], - {}, - (x) => { - wreq = x; - }, -]); -window.webpackChunkdiscord_app.pop(); -cache = wreq.c; - -export const filters = { - byProps: - (...props) => - (m) => - props.every((p) => m[p] !== void 0), -}; - -export function handleModuleNotFound(method, ...filter) { - const errMsg = `webpack.${method} found no module. Filter: ${filter}`; - console.error(new Error(errMsg)); - return { error: errMsg }; -} - -export function find(filter, { isIndirect = false, isWaitFor = false } = {}) { - if (typeof filter !== "function") { - return handleModuleNotFound("find", "Invalid filter function"); - } - - for (const key in cache) { - const mod = cache[key]; - if (!mod.loaded || !mod?.exports) continue; - - const exports = mod.exports; - - if (filter(exports)) return isWaitFor ? [exports, key] : exports; - - if (exports.default && filter(exports.default)) { - const found = exports.default; - return isWaitFor ? [found, key] : found; - } - - if (typeof exports === "object") { - for (const nestedKey in exports) { - if (nestedKey.length > 3) continue; - - const nested = exports[nestedKey]; - if (nested && filter(nested)) { - return isWaitFor ? [nested, key] : nested; - } - } - } - } - - if (!isIndirect) { - return handleModuleNotFound("find", filter); - } - - return isWaitFor ? [null, null] : null; -} - -export function findByProps(...props) { - const result = find(filters.byProps(...props), { isIndirect: true }); - if (!result || result.error) { - return handleModuleNotFound("findByProps", ...props); - } - return result; -} - -{ - // Original code taken from https://github.com/Vendicated/Vencord under GPLv3 license - - // biome-ignore lint/suspicious/noImplicitAnyLet: N/A - let wreq; - // biome-ignore lint/suspicious/noImplicitAnyLet: N/A - // biome-ignore lint/style/useConst: N/A - let cache; - - window.webpackChunkdiscord_app.push([ - [Symbol()], - {}, - (x) => { - wreq = x; - }, - ]); - window.webpackChunkdiscord_app.pop(); - cache = wreq.c; - - const filters = { - byProps: - (...props) => - (m) => - props.every((p) => m[p] !== void 0), - }; - - function handleModuleNotFound(method, ...filter) { - const errMsg = `webpack.${method} found no module. Filter: ${filter}`; - console.error(new Error(errMsg)); - return { error: errMsg }; - } - - function find(filter, { isIndirect = false, isWaitFor = false } = {}) { - if (typeof filter !== "function") { - return handleModuleNotFound("find", "Invalid filter function"); - } - - for (const key in cache) { - const mod = cache[key]; - if (!mod.loaded || !mod?.exports) continue; - - const exports = mod.exports; - - if (filter(exports)) return isWaitFor ? [exports, key] : exports; - - if (exports.default && filter(exports.default)) { - const found = exports.default; - return isWaitFor ? [found, key] : found; - } - - if (typeof exports === "object") { - for (const nestedKey in exports) { - if (nestedKey.length > 3) continue; - - const nested = exports[nestedKey]; - if (nested && filter(nested)) { - return isWaitFor ? [nested, key] : nested; - } - } - } - } - - if (!isIndirect) { - return handleModuleNotFound("find", filter); - } - - return isWaitFor ? [null, null] : null; - } - - function findByProps(...props) { - const result = find(filters.byProps(...props), { isIndirect: true }); - if (!result || result.error) { - return handleModuleNotFound("findByProps", ...props); - } - return result; - } -} diff --git a/plugins/eurotilities/index.ts b/plugins/eurotilities/index.ts deleted file mode 100644 index 001cb61..0000000 --- a/plugins/eurotilities/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import modules from "./helpers/modules.ts"; - -const { - ui: { showToast }, -} = shelter; - -export function onLoad() { - for (const module of Object.keys(modules)) { - modules[module](); - } -} - -export function onUnload() { - showToast({ - title: "Restart Required", - content: "€tilities requires a restart to disable.", - onClick() { - location.reload(); - }, - duration: Number.POSITIVE_INFINITY, - }); -} diff --git a/plugins/eurotilities/modules/alwaysTrust.ts b/plugins/eurotilities/modules/alwaysTrust.ts deleted file mode 100644 index 51bd1d1..0000000 --- a/plugins/eurotilities/modules/alwaysTrust.ts +++ /dev/null @@ -1,8 +0,0 @@ -const { flux, patcher } = shelter; -const { stores } = flux; -const { instead } = patcher; -const { MaskedLinkStore } = stores; - -export default () => { - instead("isTrustedDomain", MaskedLinkStore, () => true, false); -}; diff --git a/plugins/eurotilities/modules/antiTrack.ts b/plugins/eurotilities/modules/antiTrack.ts deleted file mode 100644 index 3bf7460..0000000 --- a/plugins/eurotilities/modules/antiTrack.ts +++ /dev/null @@ -1,24 +0,0 @@ -const { http } = shelter; -const { intercept } = http; - -export default () => { - try { - ( - window as unknown as { - __SENTRY__: { - hub: { - getClient: () => { getOptions: () => { enabled: boolean } }; - }; - }; - } - ).__SENTRY__.hub - .getClient() - .getOptions().enabled = false; - for (const x of Object.keys(console)) { - console[x] = console[x].__sentry_original__ ?? console[x]; - } - } catch {} - - // @ts-ignore - intercept("post", /^\/science|^\/error-reporting-proxy/, () => {}); -}; diff --git a/plugins/eurotilities/modules/muteNewGuild.ts b/plugins/eurotilities/modules/muteNewGuild.ts deleted file mode 100644 index 448076d..0000000 --- a/plugins/eurotilities/modules/muteNewGuild.ts +++ /dev/null @@ -1,26 +0,0 @@ -const { flux, http } = shelter; -const { dispatcher } = flux; -const { patch } = http; - -export default () => { - dispatcher.subscribe( - "INVITE_ACCEPT_SUCCESS", - ({ - invite: { - guild: { id }, - }, - }) => { - if (patch) { - patch({ - body: { - muted: true, - suppress_everyone: true, - suppress_roles: true, - }, - url: `/users/@me/guilds/${id}/settings`, - oldFormErrors: false, - }); - } - }, - ); -}; diff --git a/plugins/eurotilities/modules/noCallIdle.ts b/plugins/eurotilities/modules/noCallIdle.ts deleted file mode 100644 index cd0a96c..0000000 --- a/plugins/eurotilities/modules/noCallIdle.ts +++ /dev/null @@ -1,18 +0,0 @@ -const { flux } = shelter; -const { intercept, dispatcher } = flux; - -const dispatchTypes = ["EMBEDDED_ACTIVITY_DISCONNECT", "VOICE_STATE_UPDATES"]; - -export default () => { - intercept(({ type }) => { - if (dispatchTypes.includes(type)) { - const actionHandlers = dispatcher._subscriptions[type] ?? []; - - for (const handler of actionHandlers) { - if (handler.toString().includes("idleTimeout.start")) { - actionHandlers.delete(handler); - } - } - } - }); -}; diff --git a/plugins/eurotilities/modules/noConsoleSpam.ts b/plugins/eurotilities/modules/noConsoleSpam.ts deleted file mode 100644 index 7ade582..0000000 --- a/plugins/eurotilities/modules/noConsoleSpam.ts +++ /dev/null @@ -1,19 +0,0 @@ -const originalConsoleMethods: { [key: string]: (...args: unknown[]) => void } = - {}; - -export default () => { - for (const method of Object.keys(console)) { - originalConsoleMethods[method] = console[method]; - - console[method] = (...args: unknown[]) => { - const message = args[0]; - if ( - typeof message === "string" && - (message.includes("%c[") || message.toLowerCase().includes("sentry")) - ) { - return; - } - originalConsoleMethods[method].apply(console, args); - }; - } -}; diff --git a/plugins/eurotilities/modules/noDevtoolsDetection.ts b/plugins/eurotilities/modules/noDevtoolsDetection.ts deleted file mode 100644 index 96ef8db..0000000 --- a/plugins/eurotilities/modules/noDevtoolsDetection.ts +++ /dev/null @@ -1,17 +0,0 @@ -const nativeWindow = window as unknown as { - DiscordNative: { - window: { - setDevtoolsCallbacks: (a, b) => VoidFunction; - }; - }; -}; - -export default () => { - if (nativeWindow.DiscordNative) { - // desktop, cannot be unloaded easily - nativeWindow.DiscordNative.window.setDevtoolsCallbacks( - () => {}, - () => {}, - ); - } -}; diff --git a/plugins/eurotilities/modules/noReplyMention.ts b/plugins/eurotilities/modules/noReplyMention.ts deleted file mode 100644 index 6469a99..0000000 --- a/plugins/eurotilities/modules/noReplyMention.ts +++ /dev/null @@ -1,10 +0,0 @@ -const { flux } = shelter; -const { intercept } = flux; - -export default () => { - intercept((dispatch) => { - if (dispatch.type !== "CREATE_PENDING_REPLY") return; - - dispatch.shouldMention = false; - }); -}; diff --git a/plugins/eurotilities/modules/noTyping.ts b/plugins/eurotilities/modules/noTyping.ts deleted file mode 100644 index 47bb688..0000000 --- a/plugins/eurotilities/modules/noTyping.ts +++ /dev/null @@ -1,7 +0,0 @@ -const { http } = shelter; -const { intercept } = http; - -export default () => { - // @ts-ignore - intercept("post", /.*typing$/, () => {}); -}; diff --git a/plugins/eurotilities/modules/steamStatusSync.ts b/plugins/eurotilities/modules/steamStatusSync.ts deleted file mode 100644 index 4e3660c..0000000 --- a/plugins/eurotilities/modules/steamStatusSync.ts +++ /dev/null @@ -1,24 +0,0 @@ -const { flux } = shelter; -const { dispatcher } = flux; - -const statusMap = { - online: "online", - idle: "away", - dnd: "away", - invisible: "invisible", -}; - -export default () => { - dispatcher.subscribe("USER_SETTINGS_PROTO_UPDATE", ({ settings }) => { - const protoStatus = settings.proto.status; - const discordStatus = protoStatus.status.value; - const showCurrentGame = protoStatus.showCurrentGame.value; - const steamStatus = statusMap[discordStatus]; - - if (!showCurrentGame) { - return open("steam://friends/status/invisible"); - } - - return open(`steam://friends/status/${steamStatus}`); - }); -}; diff --git a/plugins/eurotilities/modules/timestampedFiles.ts b/plugins/eurotilities/modules/timestampedFiles.ts deleted file mode 100644 index a615633..0000000 --- a/plugins/eurotilities/modules/timestampedFiles.ts +++ /dev/null @@ -1,23 +0,0 @@ -const { flux } = shelter; -const { intercept } = flux; - -export default () => { - intercept((dispatch) => { - if (dispatch?.type === "UPLOAD_ATTACHMENT_ADD_FILES") { - for (const { file } of dispatch?.files ?? []) { - if (!file?.name) continue; - - let newFilename = Date.now().toString(); - - if (file.name.includes(".")) { - newFilename += file.name.slice(file.name.lastIndexOf(".")); - } - - Object.defineProperty(file, "name", { - value: newFilename, - }); - } - return dispatch; - } - }); -}; diff --git a/plugins/eurotilities/plugin.json b/plugins/eurotilities/plugin.json deleted file mode 100644 index 393b2a2..0000000 --- a/plugins/eurotilities/plugin.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "€tilities", - "author": "S€th", - "description": "A shelter plugin providing an opinionated collection of tweaks. " -} diff --git a/plugins/eurotilities/modules/noNitroUpsell.ts b/plugins/noNitroUpsell/index.ts similarity index 53% rename from plugins/eurotilities/modules/noNitroUpsell.ts rename to plugins/noNitroUpsell/index.ts index 094f125..721dd21 100644 --- a/plugins/eurotilities/modules/noNitroUpsell.ts +++ b/plugins/noNitroUpsell/index.ts @@ -1,16 +1,16 @@ -import type * as types from "@uwu/shelter-defs"; +const { flux, util } = shelter; +const { awaitDispatch } = util; +const { awaitStore } = flux; -interface UserStore extends types.FluxStore { +import type { FluxStore } from "@uwu/shelter-defs"; + +interface UserStore extends FluxStore { getCurrentUser: () => { - premiumType: number; - _eurotilities__premiumType: number; + premiumType: undefined | number; + _real_premiumType: undefined | number; }; } -const { flux, util } = shelter; -const { awaitDispatch } = util; -const { awaitStore } = flux; - const getUser = async () => { const UserStore = await awaitStore("UserStore", true); @@ -26,9 +26,16 @@ const getUser = async () => { return user; }; -export default async () => { +export const onLoad = async () => { const user = await getUser(); - user._eurotilities__premiumType = user.premiumType; + user._real_premiumType = user.premiumType; user.premiumType = 2; }; + +export const onUnload = async () => { + const user = await getUser(); + + user.premiumType = user._real_premiumType; + user._real_premiumType = undefined; +}; diff --git a/plugins/noNitroUpsell/plugin.json b/plugins/noNitroUpsell/plugin.json new file mode 100644 index 0000000..aab32a8 --- /dev/null +++ b/plugins/noNitroUpsell/plugin.json @@ -0,0 +1,5 @@ +{ + "name": "No Nitro Upsel", + "author": "S€th", + "description": "Trick the client into thinking you have Nitro." +}