Compare commits
78 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1547421074 | ||
|
|
f3b7935ab0 | ||
|
|
2fca83c60a | ||
|
|
c663a3724c | ||
|
|
94e651a50e | ||
|
|
40726d5b9a | ||
|
|
d8b35b5501 | ||
|
|
32d32d3f02 | ||
|
|
3914eb8e11 | ||
|
|
ad9963ade2 | ||
|
|
363f9984f6 | ||
|
|
f5c9edd1fd | ||
|
|
c1b2498009 | ||
|
|
1e381e4940 | ||
|
|
e87aff3801 | ||
|
|
0ed3508d7c | ||
|
|
c1b8f5969e | ||
|
|
24ebe343bd | ||
|
|
d0b633fa17 | ||
|
|
9dfe5ca671 | ||
|
|
bdb448eb94 | ||
|
|
2c91da18ea | ||
|
|
1d630e1e3a | ||
|
|
2c0c24cb86 | ||
|
|
a42fb7ce36 | ||
|
|
f48aea843f | ||
|
|
8430031566 | ||
|
|
fa8ebe30bd | ||
|
|
e6e5728d25 | ||
|
|
5f41539026 | ||
|
|
1b99480b82 | ||
|
|
151b07434e | ||
|
|
11a6e4d1c4 | ||
|
|
cbcbd53cc0 | ||
|
|
d26de6be8e | ||
|
|
b51ae0677d | ||
|
|
5cdb7d9969 | ||
|
|
687f47318b | ||
|
|
1071349bbc | ||
|
|
72ce900cd8 | ||
|
|
ecef05061b | ||
|
|
15915a08b9 | ||
|
|
ad46e065c9 | ||
|
|
f5bbcecade | ||
|
|
3f5643931c | ||
|
|
28fe79ade4 | ||
|
|
5858340d04 | ||
|
|
36e4bccc6a | ||
|
|
1d73ac91e5 | ||
|
|
1f3ad73135 | ||
|
|
4bb190b81a | ||
|
|
723815e4c5 | ||
|
|
4b64d99ac4 | ||
|
|
cb877a2a99 | ||
|
|
a60f527f3c | ||
|
|
fc6e5bccfd | ||
|
|
185f4ab6f3 | ||
|
|
0dc4e8cdf7 | ||
|
|
a628abc128 | ||
|
|
01a00fc98d | ||
|
|
4c2c6a3058 | ||
|
|
4f4a84ebce | ||
|
|
791956daac | ||
|
|
3c009cc46e | ||
|
|
e345bb14d3 | ||
|
|
3637ba9963 | ||
|
|
2155a2a055 | ||
|
|
dd91831481 | ||
|
|
61751664c5 | ||
|
|
06c8853399 | ||
|
|
727603ff46 | ||
|
|
de84964ff1 | ||
|
|
03ccabfb5c | ||
|
|
752d1c9b11 | ||
|
|
d31739d8d8 | ||
|
|
ec97bbb3be | ||
|
|
d9ba90e6ef | ||
|
|
3bae44e833 |
35 changed files with 1410 additions and 1916 deletions
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
|
|
@ -98,7 +98,7 @@ jobs:
|
|||
tag_name: ${{ steps.prepare.outputs.tag }}
|
||||
name: Release ${{ steps.prepare.outputs.tag }}
|
||||
files: |
|
||||
dist/shiggycord.js
|
||||
dist/shiggycord.min.js
|
||||
dist/gooncord.js
|
||||
dist/gooncord.min.js
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
|
|||
24
README.md
24
README.md
|
|
@ -1,39 +1,41 @@
|
|||
# ShiggyCord [](https://discord.shiggycord.dev)
|
||||
# GoonCord [](https://discord.shiggycord.dev)
|
||||
|
||||
Bundle based on Kettu, made just for fun
|
||||
Bundle based on ShiggyCord, made just for fun
|
||||
|
||||
## Installing
|
||||
|
||||
### Android
|
||||
|
||||
- Rooted: [Shiggy Xposed](https://github.com/kmmiio99o/ShiggyXposed)
|
||||
- Rooted: [Goon Xposed](https://github.com/OTKUSteyler/GoonXposed)
|
||||
|
||||
- Non-Rooted: [Shiggy Manager](https://github.com/kmmiio99o/ShiggyManager)
|
||||
- Non-Rooted: [Goon Manager](https://github.com/OTKUSteyler/GoonManager)
|
||||
|
||||
### Android/iOS
|
||||
- **Injecting bundle:**
|
||||
```url
|
||||
https://github.com/kmmiio99o/ShiggyCord/releases/latest/download/shiggycord.js
|
||||
https://github.com/OTKUSteyler/GoonCord/releases/latest/download/gooncord.js
|
||||
```
|
||||
|
||||
## Building
|
||||
1. Install a ShiggyCord loader with loader config support (any mentioned in the [Installing](#installing) section).
|
||||
1. Install a GoonCord loader with loader config support (any mentioned in the [Installing](#installing) section).
|
||||
1. Go to Settings > General and enable Developer Settings.
|
||||
1. Clone the repo:
|
||||
```
|
||||
git clone https://github.com/kmmiio99o/Shiggycord.git
|
||||
git clone https://github.com/OTKUSteyler/gooncord.git
|
||||
```
|
||||
1. Install dependencies:
|
||||
```
|
||||
bun i
|
||||
```
|
||||
1. Build ShiggyCord's code:
|
||||
1. Build GoonCord's code:
|
||||
```
|
||||
bun run build
|
||||
```
|
||||
1. In the newly created `dist` directory, run a HTTP server. I recommend [http-server](https://www.npmjs.com/package/http-server).
|
||||
1. Go to Settings > Developer enabled earlier. Enable `Load from custom url` and input the IP address and port of the server (e.g. `http://192.168.1.236:4040/shiggycord.js`) in the new input box labelled `ShiggyCord URL`.
|
||||
1. Restart Discord. Upon reload, you should notice that your device will download ShiggyCord's bundled code from your server, rather than GitHub.
|
||||
1. Go to Settings > Developer enabled earlier. Enable `Load from custom url` and input the IP address and port of the server (e.g. `http://192.168.1.236:4040/gooncord.js`) in the new input box labelled `GoonCord URL`.
|
||||
1. Restart Discord. Upon reload, you should notice that your device will download GoonCord's bundled code from your server, rather than GitHub.
|
||||
1. Make your changes, rebuild, reload, go wild!
|
||||
|
||||
Alternatively, you can directly *serve* the bundled code by running `bun run serve`. `shiggycord.js` will be served on your local address under the port 4040. You will then insert `http://<local ip address>:4040/shiggycord.js` as a custom url and reload. Whenever you restart your mobile client, the script will rebuild the bundle as your client fetches it.
|
||||
Alternatively, you can directly *serve* the bundled code by running `bun run serve`. `gooncord.js` will be served on your local address under the port 4040. You will then insert `http://<local ip address>:4040/gooncord.js` as a custom url and reload. Whenever you restart your mobile client, the script will rebuild the bundle as your client fetches it.
|
||||
|
||||

|
||||
|
|
|
|||
51
package.json
51
package.json
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name": "ShiggyCord",
|
||||
"name": "GoonCord",
|
||||
"private": true,
|
||||
"author": {
|
||||
"name": "kmmiio99o",
|
||||
"url": "https://github.com/kmmiio99o"
|
||||
"name": "OTKUSteyler",
|
||||
"url": "https://github.com/OTKUSteyler"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node scripts/build.mjs",
|
||||
|
|
@ -13,45 +13,40 @@
|
|||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"devDependencies": {
|
||||
"@saithodev/semantic-release-backmerge": "^4.0.1",
|
||||
"@semantic-release/changelog": "^6.0.3",
|
||||
"@semantic-release/exec": "^7.1.0",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"semantic-release": "^25.0.3",
|
||||
"@swc/core": "^1.15.24",
|
||||
"@swc/helpers": "^0.5.21",
|
||||
"@types/node": "^25.5.2",
|
||||
"@swc/core": "^1.15.47",
|
||||
"@swc/helpers": "^0.5.23",
|
||||
"@types/node": "^26.1.2",
|
||||
"@types/yargs-parser": "^21.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^8.58.0",
|
||||
"@typescript-eslint/parser": "^8.58.0",
|
||||
"@typescript-eslint/typescript-estree": "^8.58.0",
|
||||
"chalk": "^5.6.2",
|
||||
"esbuild": "^0.28.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.65.0",
|
||||
"@typescript-eslint/parser": "^8.65.0",
|
||||
"@typescript-eslint/typescript-estree": "^8.65.0",
|
||||
"chalk": "^6.0.0",
|
||||
"esbuild": "^0.28.1",
|
||||
"esbuild-plugin-globals": "^0.2.0",
|
||||
"eslint": "^10.2.0",
|
||||
"eslint": "^10.8.0",
|
||||
"eslint-plugin-import-alias": "^1.2.0",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"eslint-plugin-simple-import-sort": "^14.0.0",
|
||||
"eslint-plugin-unused-imports": "^4.4.1",
|
||||
"typescript": "^6.0.2",
|
||||
"typescript": "^7.0.2",
|
||||
"yargs-parser": "^22.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gullerya/object-observer": "^6.1.4",
|
||||
"@tanstack/react-query": "^5.96.2",
|
||||
"@gullerya/object-observer": "^7.0.0",
|
||||
"@tanstack/react-query": "^5.101.4",
|
||||
"@types/chroma-js": "~3.1.2",
|
||||
"@types/lodash": "~4.17.24",
|
||||
"@types/react": "19.2.14",
|
||||
"es-toolkit": "^1.45.1",
|
||||
"@types/react": "19.2.17",
|
||||
"es-toolkit": "^1.50.0",
|
||||
"fuzzysort": "^3.1.0",
|
||||
"intl-messageformat": "^11.2.0",
|
||||
"intl-messageformat": "^11.2.12",
|
||||
"moment": "2.30.1",
|
||||
"react-devtools": "^7.0.1",
|
||||
"react-native": "0.84.1",
|
||||
"react-native-reanimated": "^4.3.0",
|
||||
"react-native-webview": "^13.16.1",
|
||||
"react-native": "0.86.2",
|
||||
"react-native-reanimated": "^4.5.3",
|
||||
"react-native-webview": "^14.0.1",
|
||||
"spitroast": "^2.1.6",
|
||||
"type-fest": "^5.5.0"
|
||||
"type-fest": "^5.8.0"
|
||||
},
|
||||
"trustedDependencies": [
|
||||
"@swc/core",
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ let context = null;
|
|||
const config = {
|
||||
entryPoints: ["src/entry.ts"],
|
||||
bundle: true,
|
||||
outfile: "dist/shiggycord.js",
|
||||
outfile: "dist/gooncord.js",
|
||||
format: "iife",
|
||||
splitting: false,
|
||||
// Enable minification by default for release builds (when a release-branch is provided).
|
||||
|
|
@ -56,6 +56,8 @@ const config = {
|
|||
"!ShiggyCord-deps-shim!": "./shims/depsModule.ts",
|
||||
spitroast: "./node_modules/spitroast",
|
||||
"react/jsx-runtime": "./shims/jsxRuntime",
|
||||
"@gullerya/object-observer":
|
||||
path.resolve("./node_modules/@gullerya/object-observer/dist/object-observer.min.js"),
|
||||
},
|
||||
plugins: [
|
||||
globalPlugin({
|
||||
|
|
@ -75,7 +77,7 @@ const config = {
|
|||
constModules: {
|
||||
globals: {
|
||||
"bunny-build-info": {
|
||||
version: `"1.4.1.3"`,
|
||||
version: `"1.4.1.8"`,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.7 KiB |
|
|
@ -8,7 +8,7 @@ import { messageUtil } from "@metro/common";
|
|||
|
||||
export default () =>
|
||||
<ApplicationCommand>{
|
||||
name: "debug",
|
||||
name: "Goon",
|
||||
description: Strings.COMMAND_DEBUG_DESC,
|
||||
options: [
|
||||
{
|
||||
|
|
@ -18,16 +18,20 @@ export default () =>
|
|||
},
|
||||
],
|
||||
execute([ephemeral], ctx) {
|
||||
const info = getDebugInfo();
|
||||
const content = [
|
||||
"**ShiggyCord Debug Info**",
|
||||
`> ShiggyCord: ${info.bunny.version} (${info.bunny.loader.name} ${info.bunny.loader.version})`,
|
||||
`> Discord: ${info.discord.version} (${info.discord.build})`,
|
||||
`> React: ${info.react.version} (RN ${info.react.nativeVersion})`,
|
||||
`> Hermes: ${info.hermes.version} (bcv${info.hermes.bytecodeVersion})`,
|
||||
`> System: ${info.os.name} ${info.os.version} ${info.os.sdk ? `(SDK ${info.os.sdk})` : ""}`.trimEnd(),
|
||||
`> Device: ${info.device.model}`,
|
||||
].join("\n");
|
||||
const info = getDebugInfo();
|
||||
|
||||
if(info.device.codename === undefined) { info.device.codename = ""}
|
||||
else{ info.device.codename = "(" + info.device.codename + ")" }
|
||||
|
||||
const content = [
|
||||
"**💦GoonCord💦 Debug Info**",
|
||||
`> GoonCord: ${info.bunny.version} (${info.bunny.loader.name} ${info.bunny.loader.version})`,
|
||||
`> Discord: ${info.discord.version} (${info.discord.build})`,
|
||||
`> React: ${info.react.version} (RN ${info.react.nativeVersion})`,
|
||||
`> Hermes: ${info.hermes.version} (bcv${info.hermes.bytecodeVersion})`,
|
||||
`> System: ${info.os.name} ${info.os.version} ${info.os.sdk ? `(SDK ${info.os.sdk})` : ""}`.trimEnd(),
|
||||
`> Device: ${info.device.model} ${info.device.codename}`,
|
||||
].join("\n");
|
||||
|
||||
if (ephemeral?.value) {
|
||||
messageUtil.sendBotMessage(ctx.channel.id, content);
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ import { BundleUpdaterManager } from "@lib/api/native/modules";
|
|||
|
||||
export default () =>
|
||||
<ApplicationCommand>{
|
||||
name: "reload",
|
||||
name: "ReGoon",
|
||||
description: Strings.COMMAND_RELOAD_DESC,
|
||||
options: [],
|
||||
execute() {
|
||||
BundleUpdaterManager.reload();
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
"IMAGE_FILES": "Image Files",
|
||||
"TEXT_FILES": "Text Files",
|
||||
"BRAND": "Brand",
|
||||
"SHIGGYCORD": "ShiggyCord",
|
||||
"SHIGGYCORD_URL": "ShiggyCord URL",
|
||||
"SHIGGYCORD": "GoonCord",
|
||||
"SHIGGYCORD_URL": "GoonCord URL",
|
||||
"BROWSER": "Browser",
|
||||
"BYTECODE": "Bytecode",
|
||||
"CANCEL": "Cancel",
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
"CLEAR_DATA_SUCCESSFUL": "Cleared data for {name}",
|
||||
"CODEBERG": "Codeberg",
|
||||
"CODENAME": "Codename",
|
||||
"COMMAND_DEBUG_DESC": "Send ShiggyCord debug info.",
|
||||
"COMMAND_DEBUG_DESC": "Send 💦GoonCord💦 debug info.",
|
||||
"COMMAND_DEBUG_OPT_EPHEMERALLY": "Send debug info ephemerally.",
|
||||
"COMMAND_EVAL_DESC": "Evaluate JavaScript code.",
|
||||
"COMMAND_EVAL_OPT_ASYNC": "Whether to support 'await' in code. Must explicitly return for result (default: false)",
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
"LABEL_EXTRACT_FONTS_FROM_THEME": "Extract font from theme",
|
||||
"LINKS": "Links",
|
||||
"LOAD_FROM_CUSTOM_URL": "Load from custom URL",
|
||||
"LOAD_FROM_CUSTOM_URL_DEC": "Load ShiggyCord from a custom endpoint.",
|
||||
"LOAD_FROM_CUSTOM_URL_DEC": "Load GoonCord from a custom endpoint.",
|
||||
"LOAD_REACT_DEVTOOLS": "Load React DevTools",
|
||||
"SHIGGY_URL": "ShiggyCord URL",
|
||||
"LOADER": "Loader",
|
||||
|
|
@ -94,7 +94,7 @@
|
|||
"PLUGINS": "Plugins",
|
||||
"REFETCH": "Refetch",
|
||||
"RELOAD": "Reload",
|
||||
"RELOAD_DISCORD": "Reshiggy your Discord",
|
||||
"RELOAD_DISCORD": "ReGoon your Discord",
|
||||
"RELOAD_IN_NORMAL_MODE": "Reload in Normal Mode",
|
||||
"RELOAD_IN_NORMAL_MODE_DESC": "Safe mode currently enabled, tap to reload in normal mode",
|
||||
"RELOAD_IN_SAFE_MODE": "Reload in Safe Mode",
|
||||
|
|
@ -123,7 +123,7 @@
|
|||
"UH_OH": "Uh Oh",
|
||||
"UNINSTALL": "Uninstall",
|
||||
"UNINSTALL_TITLE": "Uninstall {title}",
|
||||
"URL_PLACEHOLDER": "https://github.com/kmmiio99o/ShiggyCord",
|
||||
"URL_PLACEHOLDER": "https://github.com/OTKUSteyler/GoonCord",
|
||||
"VERSION": "Version",
|
||||
"VERSIONS": "Versions"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,6 +156,16 @@ export function formatString<T = void>(
|
|||
val: Record<string, T>,
|
||||
): FormatStringRet<T> {
|
||||
const str = Strings[key];
|
||||
// @ts-ignore
|
||||
return new IntlMessageFormat(str).format(val);
|
||||
if (!str) return str as FormatStringRet<T>;
|
||||
try {
|
||||
// @ts-ignore
|
||||
return new IntlMessageFormat(str).format(val);
|
||||
} catch (e: any) {
|
||||
if (e?.name === "SyntaxError") {
|
||||
logger.warn(`[i18n] Failed to parse message for key "${String(key)}":`, e.message);
|
||||
return str as FormatStringRet<T>;
|
||||
}
|
||||
logger.warn(`[i18n] Failed to format message for key "${String(key)}":`, e?.message ?? e);
|
||||
return str as FormatStringRet<T>;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { after } from "@lib/api/patcher";
|
||||
import { onJsxCreate } from "@lib/api/react/jsx";
|
||||
import { findByName, findByNameLazy } from "@metro";
|
||||
import { useEffect, useState } from "react";
|
||||
import { findByNameLazy } from "@metro";
|
||||
import { defineCorePlugin } from "..";
|
||||
import { FluxDispatcher } from "@metro/common";
|
||||
|
||||
|
|
@ -10,14 +9,9 @@ interface Badge {
|
|||
url: string;
|
||||
}
|
||||
|
||||
interface CustomBadge {
|
||||
label: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface UserBadgeData {
|
||||
roles?: string[];
|
||||
custom?: CustomBadge[];
|
||||
custom?: Badge[];
|
||||
}
|
||||
|
||||
interface BadgeData {
|
||||
|
|
@ -33,6 +27,11 @@ interface RolesData {
|
|||
[roleName: string]: RoleData;
|
||||
}
|
||||
|
||||
interface EquicordBadge {
|
||||
tooltip: string;
|
||||
badge: string;
|
||||
}
|
||||
|
||||
const useBadgesModule = findByNameLazy("useBadges", false);
|
||||
|
||||
const badgesCache = new Map<string, Badge[]>();
|
||||
|
|
@ -40,20 +39,20 @@ const badgeProps = new Map<string, Record<string, any>>();
|
|||
const pendingRequests = new Set<string>();
|
||||
|
||||
export default defineCorePlugin({
|
||||
manifest: {
|
||||
id: "bunny.badges",
|
||||
version: "1.1.0",
|
||||
type: "plugin",
|
||||
spec: 3,
|
||||
main: "",
|
||||
display: {
|
||||
name: "Badges",
|
||||
description: "Adds badges to user's profile",
|
||||
authors: [{ name: "cocobo1" }, { name: "pylixonly" }],
|
||||
manifest: {
|
||||
id: "bunny.badges",
|
||||
version: "1.2.0",
|
||||
type: "plugin",
|
||||
spec: 3,
|
||||
main: "",
|
||||
display: {
|
||||
name: "Badges",
|
||||
description: "Adds badges to user's profile",
|
||||
authors: [{ name: "cocobo1" }, { name: "pylixonly" }],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
start() {
|
||||
start() {
|
||||
onJsxCreate("ProfileBadge", (component, ret) => {
|
||||
if (ret.props.id?.startsWith("rain-")) {
|
||||
const cachedProps = badgeProps.get(ret.props.id);
|
||||
|
|
@ -74,27 +73,67 @@ export default defineCorePlugin({
|
|||
}
|
||||
});
|
||||
|
||||
// Small helper so one failing/optional source can't take down the others.
|
||||
const safeFetchJson = async <T,>(url: string, fallback: T): Promise<T> => {
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
if (!res.ok) return fallback;
|
||||
return (await res.json()) as T;
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
};
|
||||
|
||||
const fetchAndProcessBadges = async (userId: string) => {
|
||||
if (pendingRequests.has(userId)) return;
|
||||
pendingRequests.add(userId);
|
||||
|
||||
try {
|
||||
const [badgesRes, rolesRes] = await Promise.all([
|
||||
fetch("https://codeberg.org/raincord/badges/raw/branch/main/badges.json"),
|
||||
fetch("https://codeberg.org/raincord/badges/raw/branch/main/assets/roles/roles.json"),
|
||||
const [
|
||||
goonBadgesData,
|
||||
goonRolesData,
|
||||
rainBadgesData,
|
||||
rainRolesData,
|
||||
equicordData,
|
||||
] = await Promise.all([
|
||||
safeFetchJson<BadgeData>(
|
||||
"https://codeberg.org/chocomint-chan/GoonCord_Badges/raw/branch/main/badges.json",
|
||||
{}
|
||||
),
|
||||
safeFetchJson<RolesData>(
|
||||
"https://codeberg.org/chocomint-chan/GoonCord_Badges/raw/branch/main/assets/roles/roles.json",
|
||||
{}
|
||||
),
|
||||
safeFetchJson<BadgeData>(
|
||||
"https://codeberg.org/raincord/badges/raw/branch/main/badges.json",
|
||||
{}
|
||||
),
|
||||
safeFetchJson<RolesData>(
|
||||
"https://codeberg.org/raincord/badges/raw/branch/main/assets/roles/roles.json",
|
||||
{}
|
||||
),
|
||||
safeFetchJson<Record<string, EquicordBadge[]>>(
|
||||
"https://badge.equicord.org/badges.json",
|
||||
{}
|
||||
),
|
||||
]);
|
||||
|
||||
const badgesData: BadgeData = await badgesRes.json();
|
||||
const rolesData: RolesData = await rolesRes.json();
|
||||
|
||||
const userBadgeData = badgesData[userId] || { roles: [], custom: [] };
|
||||
|
||||
const allBadges: Badge[] = [];
|
||||
|
||||
// process role badges
|
||||
if (userBadgeData.roles) {
|
||||
userBadgeData.roles.forEach(roleName => {
|
||||
const roleData = rolesData[roleName];
|
||||
// GoonCord and raincord badge/role sets are keyed independently,
|
||||
// so each source is resolved against its own roles file.
|
||||
const badgeSources: Array<{ badges: BadgeData; roles: RolesData }> = [
|
||||
{ badges: goonBadgesData, roles: goonRolesData },
|
||||
{ badges: rainBadgesData, roles: rainRolesData },
|
||||
];
|
||||
|
||||
badgeSources.forEach(({ badges, roles }) => {
|
||||
const userBadgeData = badges[userId];
|
||||
if (!userBadgeData) return;
|
||||
|
||||
// process role badges
|
||||
userBadgeData.roles?.forEach(roleName => {
|
||||
const roleData = roles[roleName];
|
||||
if (roleData) {
|
||||
allBadges.push({
|
||||
label: roleData.label,
|
||||
|
|
@ -102,12 +141,18 @@ export default defineCorePlugin({
|
|||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// process custom badges
|
||||
if (userBadgeData.custom) {
|
||||
allBadges.push(...userBadgeData.custom);
|
||||
}
|
||||
// process custom badges
|
||||
if (userBadgeData.custom) {
|
||||
allBadges.push(...userBadgeData.custom);
|
||||
}
|
||||
});
|
||||
|
||||
// process equicord badges
|
||||
const equicordUserBadges = equicordData[userId] ?? [];
|
||||
equicordUserBadges.forEach(b => {
|
||||
allBadges.push({ label: b.tooltip, url: b.badge });
|
||||
});
|
||||
|
||||
badgesCache.set(userId, allBadges);
|
||||
|
||||
|
|
@ -122,12 +167,14 @@ export default defineCorePlugin({
|
|||
});
|
||||
|
||||
FluxDispatcher.dispatch({ type: "USER_UPDATE", user: { id: userId } });
|
||||
} catch (err) {
|
||||
console.error("[bunny.badges] Failed to fetch/process badges:", err);
|
||||
} finally {
|
||||
pendingRequests.delete(userId);
|
||||
}
|
||||
};
|
||||
|
||||
after("default", useBadgesModule, ([user], result) => {
|
||||
return after("default", useBadgesModule, ([user], result) => {
|
||||
if (!user) return;
|
||||
|
||||
const userId = user.userId;
|
||||
|
|
|
|||
13
src/core/plugins/favouriteanything/Settings.tsx
Normal file
13
src/core/plugins/favouriteanything/Settings.tsx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { Forms } from "@vendetta/ui/components";
|
||||
const { FormSection, FormText } = Forms;
|
||||
|
||||
export default () => (
|
||||
<FormSection title="FavouriteAnything">
|
||||
<FormText>
|
||||
Adds the favourite button to ALL media in the image viewer, not just GIFs!
|
||||
</FormText>
|
||||
<FormText style={{ marginTop: 8, color: "#b9bbbe" }}>
|
||||
Images and videos can now be saved to your GIF favourites picker. Works by patching Discord's GIFFavButton to accept all media types.
|
||||
</FormText>
|
||||
</FormSection>
|
||||
)
|
||||
169
src/core/plugins/favouriteanything/index.ts
Normal file
169
src/core/plugins/favouriteanything/index.ts
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
// src/core/plugins/favouriteanything/index.ts
|
||||
import { defineCorePlugin } from "..";
|
||||
import { findByProps } from "@metro";
|
||||
import { before } from "@lib/api/patcher";
|
||||
import { logger } from "@lib/utils/logger";
|
||||
|
||||
type PatchCleanupFn = () => void;
|
||||
|
||||
let origType: Function | null = null;
|
||||
let memoWrapper: any = null;
|
||||
let retryTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
let unpatchAddFavorite: PatchCleanupFn | null = null;
|
||||
let origUseFavoriteGIFsMobile: Function | null = null;
|
||||
let favMobileModule: any = null;
|
||||
|
||||
const VIDEO_EXT = [".mp4", ".webm", ".mov", ".avi", ".mkv", ".flv", ".wmv", ".m4v", ".gifv"];
|
||||
const processed = new WeakSet<object>();
|
||||
|
||||
function isVideo(url: string): boolean {
|
||||
if (!url) return false;
|
||||
const path = url.split("?")[0].toLowerCase();
|
||||
return VIDEO_EXT.some(e => path.endsWith(e));
|
||||
}
|
||||
|
||||
function makeVideoThumbnail(url: string): string {
|
||||
if (!url) return url;
|
||||
let out = url.replace("cdn.discordapp.com", "media.discordapp.net");
|
||||
if (out.includes("media.discordapp.net") || out.includes("images-ext")) {
|
||||
return out + (out.includes("?") ? "&" : "?") + "format=jpeg";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
function findGIFFavButton(): any {
|
||||
const modules = (globalThis as any).__bunny?.metro?.modules ?? (globalThis as any).modules;
|
||||
if (!modules) return null;
|
||||
|
||||
for (const id in modules) {
|
||||
try {
|
||||
const mod = modules[id]?.publicModule?.exports;
|
||||
if (!mod) continue;
|
||||
const def = mod.default;
|
||||
if (def?.$$typeof?.toString().includes("memo") && def.type) {
|
||||
if (def.type.displayName === "GIFFavButton" || def.type.name === "GIFFavButton") return def;
|
||||
}
|
||||
if (typeof mod === "function" && (mod.displayName === "GIFFavButton" || mod.name === "GIFFavButton")) return mod;
|
||||
} catch {}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function patchSource(source: any): any {
|
||||
if (source.isGIFV) return source;
|
||||
return {
|
||||
...source,
|
||||
isGIFV: true,
|
||||
embedURI: source.embedURI || source.sourceURI || source.uri,
|
||||
videoURI: source.videoURI || source.uri,
|
||||
embedProviderName: source.embedProviderName || "",
|
||||
};
|
||||
}
|
||||
|
||||
function applyPatch(): boolean {
|
||||
memoWrapper = findGIFFavButton();
|
||||
if (!memoWrapper) return false;
|
||||
|
||||
origType = memoWrapper.type;
|
||||
memoWrapper.type = function PatchedGIFFavButton(props: any) {
|
||||
const p = { ...props };
|
||||
if (p.source && !p.source.isGIFV) p.source = patchSource(p.source);
|
||||
return (origType as Function)(p);
|
||||
};
|
||||
(memoWrapper.type as any).displayName = "GIFFavButton";
|
||||
return true;
|
||||
}
|
||||
|
||||
function patchAddFavorite(): void {
|
||||
const favModule = findByProps("addFavoriteGIF");
|
||||
if (!favModule) return;
|
||||
|
||||
unpatchAddFavorite = before("addFavoriteGIF", favModule, (args: any[]) => {
|
||||
const data = args[0];
|
||||
if (!data || typeof data !== "object") return;
|
||||
const url = data.url || "";
|
||||
const src = data.src || "";
|
||||
|
||||
if (isVideo(url) || isVideo(src)) {
|
||||
data.format = 2;
|
||||
} else if (data.format === 2) {
|
||||
data.format = 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function patchMobileFavorites(): void {
|
||||
const mod = findByProps("useFavoriteGIFsMobile");
|
||||
if (!mod) return;
|
||||
|
||||
favMobileModule = mod;
|
||||
origUseFavoriteGIFsMobile = mod.useFavoriteGIFsMobile;
|
||||
|
||||
let lastFavs: any = null;
|
||||
mod.useFavoriteGIFsMobile = function (...args: any[]) {
|
||||
const result = (origUseFavoriteGIFsMobile as Function).apply(this, args);
|
||||
if (result?.favorites && Array.isArray(result.favorites) && result.favorites !== lastFavs) {
|
||||
lastFavs = result.favorites;
|
||||
for (const item of result.favorites) {
|
||||
if (!item || processed.has(item)) continue;
|
||||
processed.add(item);
|
||||
if (isVideo(item.url) || isVideo(item.src)) {
|
||||
item.src = makeVideoThumbnail(item.src || item.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
export default defineCorePlugin({
|
||||
manifest: {
|
||||
id: "bunny.favouriteanything",
|
||||
version: "1.0.0",
|
||||
type: "plugin",
|
||||
spec: 3,
|
||||
main: "",
|
||||
display: {
|
||||
name: "FavouriteAnything",
|
||||
description: "Adds the favourite button to ALL media, not just GIFs",
|
||||
authors: [{ name: "TheUnrealZaka" }],
|
||||
},
|
||||
},
|
||||
|
||||
start() {
|
||||
if (applyPatch()) {
|
||||
logger.log("[FavouriteAnything] Patched GIFFavButton.");
|
||||
} else {
|
||||
let retries = 0;
|
||||
const tryPatch = () => {
|
||||
if (applyPatch()) {
|
||||
logger.log("[FavouriteAnything] Patched GIFFavButton (after retry).");
|
||||
retryTimeout = null;
|
||||
} else if (retries++ < 50) {
|
||||
retryTimeout = setTimeout(tryPatch, 300);
|
||||
} else {
|
||||
logger.error("[FavouriteAnything] GIFFavButton not found after retries.");
|
||||
}
|
||||
};
|
||||
retryTimeout = setTimeout(tryPatch, 300);
|
||||
}
|
||||
|
||||
patchAddFavorite();
|
||||
patchMobileFavorites();
|
||||
},
|
||||
|
||||
stop() {
|
||||
if (retryTimeout) { clearTimeout(retryTimeout); retryTimeout = null; }
|
||||
if (memoWrapper && origType) {
|
||||
memoWrapper.type = origType;
|
||||
origType = null;
|
||||
memoWrapper = null;
|
||||
}
|
||||
if (unpatchAddFavorite) { unpatchAddFavorite(); unpatchAddFavorite = null; }
|
||||
if (favMobileModule && origUseFavoriteGIFsMobile) {
|
||||
favMobileModule.useFavoriteGIFsMobile = origUseFavoriteGIFsMobile;
|
||||
origUseFavoriteGIFsMobile = null;
|
||||
favMobileModule = null;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -42,19 +42,19 @@ function transformLinks(content: string, config: FixEmbedSettings): string {
|
|||
if (config.instagram) {
|
||||
result = result.replace(
|
||||
/https?:\/\/(?:www\.)?instagram\.com(\/[^\s]+)/gi,
|
||||
"https://uuinstagram.com$1",
|
||||
"https://kkinstagram.com$1",
|
||||
);
|
||||
}
|
||||
// TikTok: Replace domain, keep path
|
||||
if (config.tiktok) {
|
||||
result = result.replace(
|
||||
/https?:\/\/(?:www\.)?tiktok\.com(\/[^\s]+)/gi,
|
||||
"https://tnktok.com$1",
|
||||
"https://tiktokez.com$1",
|
||||
);
|
||||
// TikTok short links (vm.tiktok.com)
|
||||
result = result.replace(
|
||||
/https?:\/\/vm\.tiktok\.com\/([A-Za-z0-9]+)\/?/gi,
|
||||
"https://vm.tnktok.com/$1",
|
||||
"https://vm.tiktokez.com/$1",
|
||||
);
|
||||
}
|
||||
// Reddit: Replace domain, keep path
|
||||
|
|
|
|||
|
|
@ -34,8 +34,12 @@ export const getCorePlugins = (): CorePluginRecord => ({
|
|||
"bunny.quickinstall": makeLazyPlugin(() => require("./quickinstall"), true),
|
||||
"bunny.badges": makeLazyPlugin(() => require("./badges")),
|
||||
"bunny.notrack": makeLazyPlugin(() => require("./notrack")),
|
||||
"bunny.messagefix": makeLazyPlugin(() => require("./messagefix")),
|
||||
"bunny.fixembed": makeLazyPlugin(() => require("./fixembed")),
|
||||
"bunny.favouriteanything": makeLazyPlugin(() => require("./favouriteanything")),
|
||||
"bunny.nodelete": makeLazyPlugin(() => require("./nodelete")),
|
||||
"bunny.maxverstappen": makeLazyPlugin(() => require("./maxverstappen")),
|
||||
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
|||
BIN
src/core/plugins/maxverstappen/Max Verstappen.mp3
Normal file
BIN
src/core/plugins/maxverstappen/Max Verstappen.mp3
Normal file
Binary file not shown.
145
src/core/plugins/maxverstappen/index.ts
Normal file
145
src/core/plugins/maxverstappen/index.ts
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
import { defineCorePlugin } from "..";
|
||||
import { findByProps } from "@metro";
|
||||
import { logger } from "@lib/utils/logger";
|
||||
|
||||
const { ReactNative } = window as any;
|
||||
const { DCDSoundManager } = ReactNative?.NativeModules || {};
|
||||
|
||||
const AUDIO_URL = "https://github.com/OTKUSteyler/GoonCord/raw/refs/heads/main/src/core/plugins/maxverstappen/Max%20Verstappen.mp3";
|
||||
const SOUND_ID = 6972;
|
||||
const TRIGGER_CHANCE = 0.33;
|
||||
const MAX_PATTERN = /\bmax\s*verst[ae]pp?en\b/i;
|
||||
|
||||
let isPlaying = false;
|
||||
let isPrepared = false;
|
||||
let isPreparing = false;
|
||||
let soundDuration = 30000;
|
||||
let timeoutId: NodeJS.Timeout | null = null;
|
||||
let onMessageCreate: ((e: any) => void) | null = null;
|
||||
let onMessageSend: ((e: any) => void) | null = null;
|
||||
|
||||
function shouldTrigger(): boolean {
|
||||
return Math.random() < TRIGGER_CHANCE;
|
||||
}
|
||||
|
||||
function checkText(text: string): boolean {
|
||||
if (!text) return false;
|
||||
return MAX_PATTERN.test(text) && shouldTrigger();
|
||||
}
|
||||
|
||||
function ensurePrepared(): Promise<number> {
|
||||
return new Promise((resolve) => {
|
||||
if (isPrepared) return resolve(soundDuration);
|
||||
if (isPreparing) return resolve(-1);
|
||||
|
||||
isPreparing = true;
|
||||
DCDSoundManager.prepare(AUDIO_URL, "music", SOUND_ID, (error: any, sound: any) => {
|
||||
isPreparing = false;
|
||||
if (error) {
|
||||
logger.error("[MaxVerstappen] Failed to prepare:", error);
|
||||
return resolve(-1);
|
||||
}
|
||||
isPrepared = true;
|
||||
soundDuration = sound?.duration || 30000;
|
||||
resolve(soundDuration);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function playAudio() {
|
||||
if (!DCDSoundManager) return;
|
||||
if (isPlaying) return;
|
||||
|
||||
const duration = await ensurePrepared();
|
||||
if (duration === -1) return;
|
||||
|
||||
isPlaying = true;
|
||||
try {
|
||||
await DCDSoundManager.play(SOUND_ID);
|
||||
timeoutId = setTimeout(() => {
|
||||
DCDSoundManager.stop(SOUND_ID);
|
||||
isPlaying = false;
|
||||
timeoutId = null;
|
||||
}, soundDuration);
|
||||
} catch (e) {
|
||||
logger.error("[MaxVerstappen] Playback error:", e);
|
||||
isPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
export default defineCorePlugin({
|
||||
manifest: {
|
||||
id: "bunny.maxverstappen",
|
||||
version: "1.0.0",
|
||||
type: "plugin",
|
||||
spec: 3,
|
||||
main: "",
|
||||
display: {
|
||||
name: "Max Verstappen",
|
||||
description: "Plays audio when Max Verstappen is mentioned (33% chance)",
|
||||
authors: [{ name: "GoonCord Team" }],
|
||||
},
|
||||
},
|
||||
|
||||
start() {
|
||||
if (!DCDSoundManager) {
|
||||
logger.error("[MaxVerstappen] DCDSoundManager not found");
|
||||
return;
|
||||
}
|
||||
|
||||
const FluxDispatcher = findByProps("dispatch", "subscribe");
|
||||
if (!FluxDispatcher) {
|
||||
logger.error("[MaxVerstappen] FluxDispatcher not found");
|
||||
return;
|
||||
}
|
||||
|
||||
onMessageCreate = ({ message }: any) => {
|
||||
try {
|
||||
if (!message?.content) return;
|
||||
if (checkText(message.content)) playAudio();
|
||||
} catch (e) {
|
||||
logger.error("[MaxVerstappen] MESSAGE_CREATE error:", e);
|
||||
}
|
||||
};
|
||||
|
||||
onMessageSend = ({ message }: any) => {
|
||||
try {
|
||||
if (!message?.content) return;
|
||||
if (checkText(message.content)) playAudio();
|
||||
} catch (e) {
|
||||
logger.error("[MaxVerstappen] MESSAGE_SEND error:", e);
|
||||
}
|
||||
};
|
||||
|
||||
FluxDispatcher.subscribe("MESSAGE_CREATE", onMessageCreate);
|
||||
FluxDispatcher.subscribe("MESSAGE_SEND", onMessageSend);
|
||||
|
||||
logger.log("[MaxVerstappen] Enabled");
|
||||
},
|
||||
|
||||
stop() {
|
||||
if (DCDSoundManager && isPlaying) {
|
||||
DCDSoundManager.stop(SOUND_ID);
|
||||
isPlaying = false;
|
||||
}
|
||||
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
|
||||
const FluxDispatcher = findByProps("dispatch", "subscribe");
|
||||
if (FluxDispatcher) {
|
||||
if (onMessageCreate) FluxDispatcher.unsubscribe("MESSAGE_CREATE", onMessageCreate);
|
||||
if (onMessageSend) FluxDispatcher.unsubscribe("MESSAGE_SEND", onMessageSend);
|
||||
}
|
||||
|
||||
onMessageCreate = null;
|
||||
onMessageSend = null;
|
||||
isPrepared = false;
|
||||
isPreparing = false;
|
||||
soundDuration = 30000;
|
||||
|
||||
logger.log("[MaxVerstappen] Disabled");
|
||||
},
|
||||
});
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
import { defineCorePlugin } from "..";
|
||||
import { findByProps } from "@metro";
|
||||
import { logger } from "@lib/utils/logger";
|
||||
|
||||
// Find the MessageActions module
|
||||
const MessageActions = findByProps("sendMessage");
|
||||
let originalSendMessage: Function;
|
||||
|
||||
export default defineCorePlugin({
|
||||
manifest: {
|
||||
id: "bunny.messagefix",
|
||||
version: "1.0.0",
|
||||
type: "plugin",
|
||||
spec: 3,
|
||||
main: "",
|
||||
display: {
|
||||
name: "MessageFix",
|
||||
description: "Ensures messages include the required nonce parameter",
|
||||
authors: [{ name: "Win8.1VMUser (plugin by ShiggyCord Team)" }],
|
||||
},
|
||||
},
|
||||
|
||||
start() {
|
||||
// Save original function
|
||||
originalSendMessage = MessageActions.sendMessage;
|
||||
|
||||
// Replace with our implementation
|
||||
MessageActions.sendMessage = function (
|
||||
channelId: unknown,
|
||||
message: unknown,
|
||||
replyRef: unknown,
|
||||
options: Record<string, unknown>,
|
||||
) {
|
||||
// Ensure options exists and has a nonce
|
||||
options = options || {};
|
||||
if (!options.nonce) {
|
||||
options.nonce = (BigInt(Date.now() - 1420070400000) << 22n).toString();
|
||||
}
|
||||
|
||||
// Call original with fixed parameters
|
||||
return (originalSendMessage as Function).call(
|
||||
this,
|
||||
channelId,
|
||||
message,
|
||||
replyRef,
|
||||
options,
|
||||
);
|
||||
};
|
||||
|
||||
logger.log("MessageFix: Enabled - adding nonce to all messages");
|
||||
},
|
||||
|
||||
stop() {
|
||||
// Restore original function
|
||||
if (originalSendMessage) MessageActions.sendMessage = originalSendMessage;
|
||||
logger.log("MessageFix: Disabled");
|
||||
},
|
||||
});
|
||||
76
src/core/plugins/nodelete/index.ts
Normal file
76
src/core/plugins/nodelete/index.ts
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
// src/core/plugins/NoDelete/index.ts
|
||||
import { defineCorePlugin } from "..";
|
||||
import { findByStoreName } from "@metro";
|
||||
import { before } from "@lib/api/patcher";
|
||||
import { logger } from "@lib/utils/logger";
|
||||
import { FluxDispatcher } from "@metro/common";
|
||||
|
||||
type PatchCleanupFn = () => void;
|
||||
|
||||
let patches: PatchCleanupFn[] = [];
|
||||
let MessageStore: any = null;
|
||||
let deleteable: string[] = [];
|
||||
|
||||
function patchDispatcher(): PatchCleanupFn {
|
||||
return before("dispatch", FluxDispatcher, (args: any[]) => {
|
||||
try {
|
||||
if (!MessageStore) MessageStore = findByStoreName("MessageStore");
|
||||
|
||||
const event = args[0];
|
||||
if (!event || event?.type !== "MESSAGE_DELETE") return;
|
||||
if (!event?.id || !event?.channelId) return;
|
||||
|
||||
if (deleteable.includes(event.id)) {
|
||||
deleteable.splice(deleteable.indexOf(event.id), 1);
|
||||
return;
|
||||
}
|
||||
|
||||
deleteable.push(event.id);
|
||||
|
||||
args[0] = {
|
||||
type: "MESSAGE_EDIT_FAILED_AUTOMOD",
|
||||
messageData: {
|
||||
type: 1,
|
||||
message: {
|
||||
channelId: event.channelId,
|
||||
messageId: event.id,
|
||||
},
|
||||
},
|
||||
errorResponseBody: {
|
||||
code: 200000,
|
||||
message: "[deleted]",
|
||||
},
|
||||
};
|
||||
} catch (e) {
|
||||
logger.error("NoDelete: dispatcher patch failed", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default defineCorePlugin({
|
||||
manifest: {
|
||||
id: "bunny.nodelete",
|
||||
version: "1.0.0",
|
||||
type: "plugin",
|
||||
spec: 3,
|
||||
main: "",
|
||||
display: {
|
||||
name: "NoDelete",
|
||||
description: "Prevents messages from being deleted from your view",
|
||||
authors: [{ name: "meqativ" }],
|
||||
},
|
||||
},
|
||||
|
||||
start() {
|
||||
patches = [patchDispatcher()].filter(Boolean);
|
||||
logger.log("NoDelete: Enabled");
|
||||
},
|
||||
|
||||
stop() {
|
||||
patches.forEach((p) => p?.());
|
||||
patches = [];
|
||||
deleteable = [];
|
||||
MessageStore = null;
|
||||
logger.log("NoDelete: Disabled");
|
||||
},
|
||||
});
|
||||
90
src/core/plugins/nodelete/settings.jsx
Normal file
90
src/core/plugins/nodelete/settings.jsx
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import { React, ReactNative } from "@vendetta/metro/common";
|
||||
import { storage } from "@vendetta/plugin";
|
||||
import { useProxy } from "@vendetta/storage";
|
||||
import { showConfirmationAlert } from "@vendetta/ui/alerts";
|
||||
import { Forms } from "@vendetta/ui/components";
|
||||
import { getAssetIDByName } from "@vendetta/ui/assets";
|
||||
import { getTranslation } from "./translations.js";
|
||||
import ItemWithRemove from "../../common/ui/ItemWithRemove.jsx";
|
||||
import { findByStoreName, findByProps } from "@vendetta/metro";
|
||||
let UserStore, UncachedUserManager, Profiles;
|
||||
export default (props) => {
|
||||
UserStore ??= findByStoreName("UserStore");
|
||||
UncachedUserManager ??= findByProps("fetchProfile", "getUser", "setFlag");
|
||||
Profiles ??= findByProps("showUserProfile");
|
||||
async function openProfile(userId) {
|
||||
const show = Profiles.showUserProfile;
|
||||
|
||||
UserStore.getUser(userId) ? show({ userId }) : UncachedUserManager.getUser(userId).then(({ id }) => show({ userId: id }));
|
||||
}
|
||||
|
||||
useProxy(storage);
|
||||
const [users, setUsers] = React.useState(storage["ignore"]["users"]);
|
||||
|
||||
const handleRemoveUser = (userId) => {
|
||||
const newArr = users.filter((id) => id !== userId);
|
||||
storage["ignore"].users = newArr;
|
||||
setUsers(newArr);
|
||||
};
|
||||
const handleClearUsers = () => {
|
||||
storage["ignore"].users = [];
|
||||
setUsers([]);
|
||||
};
|
||||
let uncached = 0;
|
||||
|
||||
return (
|
||||
<ReactNative.ScrollView style={{ flex: 1 }}>
|
||||
<Forms.FormSection title={getTranslation("settings.titles.settings")} titleStyleType="no_border">
|
||||
<Forms.FormRow label={getTranslation("settings.showTimestamps")} trailing={<Forms.FormSwitch value={storage.timestamps} onValueChange={(v) => (storage.timestamps = v)} />} />
|
||||
<Forms.FormRow label={getTranslation("settings.ewTimestampFormat")} trailing={<Forms.FormSwitch value={storage["ew"]} onValueChange={(v) => (storage.ew = v)} />} />
|
||||
<Forms.FormDivider />
|
||||
<Forms.FormRow label={getTranslation("settings.youDeletedItWarning")} />
|
||||
</Forms.FormSection>
|
||||
<Forms.FormSection title={getTranslation("settings.titles.filters")}>
|
||||
<Forms.FormRow label={getTranslation("settings.ignoreBots")} trailing={<Forms.FormSwitch value={storage["ignore"].bots} onValueChange={(value) => (storage["ignore"].bots = value)} />} />
|
||||
<Forms.FormRow
|
||||
label={getTranslation("settings.clearUsersLabel", true)?.make?.(users.length)}
|
||||
trailing={<Forms.FormRow.Icon source={getAssetIDByName("ic_trash_24px")} />}
|
||||
onPress={() => {
|
||||
if (users.length !== 0)
|
||||
showConfirmationAlert({
|
||||
title: getTranslation("settings.confirmClear.title"),
|
||||
content: getTranslation("settings.confirmClear.description", true)?.make?.(users.length),
|
||||
confirmText: getTranslation("settings.confirmClear.yes"),
|
||||
cancelText: getTranslation("settings.confirmClear.no"),
|
||||
confirmColor: "brand",
|
||||
onConfirm: handleClearUsers,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<ReactNative.ScrollView style={{ flex: 1, gap: 3, marginLeft: 15 }}>
|
||||
{users.map((id) => {
|
||||
const User = UserStore.getUser(id) ?? {};
|
||||
let pfp = User?.getAvatarURL?.(null,26)?.replace?.(/\.(gif|webp)/, ".png");
|
||||
if (!pfp) {
|
||||
pfp = "https://cdn.discordapp.com/embed/avatars/1.png?size=48";
|
||||
User.username = `${id} Uncached`;
|
||||
User.discriminator = "0";
|
||||
if (uncached === 0) User.username += ", press the avatar";
|
||||
uncached++;
|
||||
}
|
||||
|
||||
return (
|
||||
<ItemWithRemove
|
||||
imageSource={{ uri: pfp }}
|
||||
onImagePress={() => {
|
||||
openProfile(id);
|
||||
}}
|
||||
onRemove={() => handleRemoveUser(id)}
|
||||
label={User.username + (User.discriminator == 0 ? "" : `#${User.discriminator}`)}
|
||||
labelRemove={getTranslation("settings.removeUserButton")}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</ReactNative.ScrollView>
|
||||
<Forms.FormDivider />
|
||||
<Forms.FormRow label={getTranslation("settings.addUsersInfo")} />
|
||||
</Forms.FormSection>
|
||||
</ReactNative.ScrollView>
|
||||
);
|
||||
};
|
||||
158
src/core/plugins/nodelete/translations.js
Normal file
158
src/core/plugins/nodelete/translations.js
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
function slavicNoun(number, $1, $2, $5) {
|
||||
let n = Math.abs(number);
|
||||
n %= 100;
|
||||
if (n >= 5 && n <= 20) return $5;
|
||||
|
||||
n %= 10;
|
||||
if (n === 1) return $1;
|
||||
if (n >= 2 && n <= 4) return $2;
|
||||
return $5;
|
||||
}
|
||||
function latinNoun(number, $1, $x) {
|
||||
return number === 1 ? $1 : $x;
|
||||
}
|
||||
export let massive = {};
|
||||
massive = {
|
||||
settings: {
|
||||
titles: {
|
||||
settings: {
|
||||
"en-GB": "Settings",
|
||||
uk: "Налаштування",
|
||||
ru: "Настройки",
|
||||
},
|
||||
filters: {
|
||||
"en-GB": "Filters",
|
||||
uk: "Фільтри",
|
||||
ru: "Фильтры",
|
||||
},
|
||||
},
|
||||
showTimestamps: {
|
||||
"en-GB": "Show the time of deletion",
|
||||
uk: "Показувати час видалення",
|
||||
ru: "Показывать время удаления",
|
||||
},
|
||||
ewTimestampFormat: {
|
||||
"en-GB": "Use 12-hour format",
|
||||
uk: "Використовувати 12-годинний формат",
|
||||
ru: "Использовать 12-часовой формат",
|
||||
},
|
||||
youDeletedItWarning: {
|
||||
"en-GB": "The messages YOU deleted - are not saved",
|
||||
uk: "Повідомлення які видалили ВИ - не зберігаются",
|
||||
ru: "Сообщения удаленные ВАМИ - не сохраняются",
|
||||
},
|
||||
addUsersInfo: {
|
||||
"en-GB": () =>
|
||||
`To add or remove users from the ignore list, follow these steps:\n` +
|
||||
`1. open their profile\n` +
|
||||
`2. press the •••\n` +
|
||||
`3. press "${massive.optionLabels[0]["en-GB"]}"\n` +
|
||||
`4. 🎉`,
|
||||
uk: () =>
|
||||
`Щоб добавити когось до списку ігнорованих користувачів, виконайте ці дії:\n` +
|
||||
`1. відкрите їх профіль\n` +
|
||||
`2. натисніть •••\n` +
|
||||
`3. натисніть "${massive.optionLabels[0]["uk"]}"\n` +
|
||||
`4. 🎉`,
|
||||
ru: () =>
|
||||
`Чтобы добавить кого-то в список игнорированных пользователей - следуйте этим шагам\n` +
|
||||
`1. откройте их профиль\n` +
|
||||
`2. нажмите •••\n` +
|
||||
`3. нажмите "${massive.optionLabels[0]["ru"]}"\n` +
|
||||
`4. 🎉`,
|
||||
},
|
||||
ignoreBots: {
|
||||
"en-GB": "Ignore bots",
|
||||
uk: "Ігнорувати ботів",
|
||||
ru: "Игнорировать ботов",
|
||||
},
|
||||
clearUsersLabel: {
|
||||
"en-GB": (amount) =>
|
||||
`You have ${amount} user${latinNoun(amount, "", "s")} in the ignored users list`,
|
||||
uk: (amount) =>
|
||||
`Ви маєте ${amount} користувач${slavicNoun(amount, "а", "а", "ів")} у списку ігнорованих користувачів`,
|
||||
ru: (amount) =>
|
||||
`Вы имеете ${amount} пользовател${slavicNoun(amount, "я", "я", "ей")} в списке игнорированных пользователей`,
|
||||
},
|
||||
|
||||
confirmClear: {
|
||||
title: {
|
||||
"en-GB": "Hold on!",
|
||||
uk: "Почекай-но!",
|
||||
ru: "Положди-ка!",
|
||||
},
|
||||
description: {
|
||||
"en-GB": (amount) =>
|
||||
`This will remove ${amount} user${latinNoun(amount, "", "s")} from the ignored users list.\nDo you you really want to do that?`,
|
||||
uk: (amount) =>
|
||||
`Це прибере ${amount} користувач${slavicNoun(amount, "а", "а", "ів")} зі списку ігнорованих користувачів.\nВи дійсно хочете продовжити?`,
|
||||
ru: (amount) =>
|
||||
`Это уберет ${amount} пользовател${slavicNoun(amount, "я", "я", "ей")} из списка игнорированных пользователей.\nВы действительно хотите продолжить?`,
|
||||
},
|
||||
yes: {
|
||||
"en-GB": "Yes",
|
||||
uk: "Так",
|
||||
ru: "Да",
|
||||
},
|
||||
no: {
|
||||
"en-GB": "Cancel",
|
||||
uk: "Відминити",
|
||||
ru: "Отменить",
|
||||
},
|
||||
},
|
||||
removeUserButton: {
|
||||
"en-GB": "REMOVE",
|
||||
uk: "ПРИБРАТИ",
|
||||
ru: "УБРАТЬ",
|
||||
},
|
||||
},
|
||||
optionLabels: [
|
||||
{
|
||||
"en-GB": "Add to NoDelete ignored users list",
|
||||
uk: "Добавити до списку ігнорованих користувачів у NoDelete",
|
||||
ru: "Добавить в список игнорированных пользователей в NoDelete",
|
||||
},
|
||||
{
|
||||
"en-GB": "Remove from the NoDelete ignore list",
|
||||
uk: "Прибрати з списку ігнорованих користувачів у NoDelete",
|
||||
ru: "Убрать из списка игнорированных пользователей в NoDelete",
|
||||
},
|
||||
],
|
||||
toastLabels: [
|
||||
{
|
||||
"en-GB": "Added {user} to the ignored users list",
|
||||
uk: "{user} добавлено до списку ігнорованих користувачів",
|
||||
ru: "{user} добавлены в список игнорированных пользователей",
|
||||
},
|
||||
{
|
||||
"en-GB": "Removed {user} from the ignored users list",
|
||||
uk: "{user} прибрано зі списку ігнорованих користувачів",
|
||||
ru: "{user} убраны из списка игнорированных пользователей",
|
||||
},
|
||||
],
|
||||
thisMessageWasDeleted: {
|
||||
"en-GB": "This message was deleted",
|
||||
uk: "Це повідомлення було видалено",
|
||||
ru: "Это сообщение было удалено",
|
||||
},
|
||||
};
|
||||
|
||||
export const locale = () =>
|
||||
vendetta.metro.findByStoreName("LocaleStore").locale;
|
||||
const defaultLocale = "en-GB";
|
||||
export function getTranslation(find, fn) {
|
||||
let value = massive;
|
||||
|
||||
for (const key of find.split(".")) {
|
||||
// biome-ignore lint/suspicious/noPrototypeBuiltins: meow
|
||||
if (value?.hasOwnProperty(key)) {
|
||||
value = value[key];
|
||||
} else {
|
||||
value = massive;
|
||||
}
|
||||
}
|
||||
if (value === massive) return find;
|
||||
let localized = value[locale()] ?? value[defaultLocale] ?? find;
|
||||
if (typeof localized === "function" && !fn) localized = localized();
|
||||
return fn ? { make: localized } : localized;
|
||||
}
|
||||
|
|
@ -23,51 +23,54 @@ const { showSimpleActionSheet } = lazyDestructure(() =>
|
|||
|
||||
// TODO: These styles work weirdly. Low DPI Has cramped text. Fix?
|
||||
const useStyles = createStyles({
|
||||
card: {
|
||||
backgroundColor: semanticColors?.CARD_SECONDARY_BG,
|
||||
borderRadius: 12,
|
||||
overflow: "hidden",
|
||||
},
|
||||
header: {
|
||||
padding: 0,
|
||||
},
|
||||
headerLeading: {
|
||||
flexDirection: "column",
|
||||
justifyContent: "center",
|
||||
scale: 1.2,
|
||||
},
|
||||
headerTrailing: {
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
gap: 15,
|
||||
alignItems: "center",
|
||||
},
|
||||
headerLabel: {
|
||||
...TextStyleSheet["heading-md/semibold"],
|
||||
color: semanticColors.MOBILE_TEXT_HEADING_PRIMARY,
|
||||
},
|
||||
headerSubtitle: {
|
||||
...TextStyleSheet["text-md/semibold"],
|
||||
color: semanticColors.TEXT_MUTED,
|
||||
},
|
||||
descriptionLabel: {
|
||||
...TextStyleSheet["text-md/semibold"],
|
||||
color: semanticColors.TEXT_NORMAL,
|
||||
},
|
||||
actions: {
|
||||
flexDirection: "row-reverse",
|
||||
alignItems: "center",
|
||||
gap: 5,
|
||||
},
|
||||
iconStyle: {
|
||||
tintColor: semanticColors.INTERACTIVE_ICON_DEFAULT,
|
||||
opacity: 0.2,
|
||||
height: 64,
|
||||
width: 64,
|
||||
left: void 0,
|
||||
right: "30%",
|
||||
top: "-10%",
|
||||
},
|
||||
card: {
|
||||
backgroundColor: semanticColors?.CARD_SECONDARY_BG,
|
||||
borderRadius: 12,
|
||||
overflow: "hidden"
|
||||
},
|
||||
header: {
|
||||
padding: 0,
|
||||
},
|
||||
headerLeading: {
|
||||
flex: 1,
|
||||
flexDirection: "column",
|
||||
justifyContent: "center",
|
||||
scale: 1.2
|
||||
},
|
||||
headerTrailing: {
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
gap: 15,
|
||||
alignItems: "center"
|
||||
},
|
||||
headerLabel: {
|
||||
...TextStyleSheet["heading-lg/semibold"],
|
||||
},
|
||||
headerLabelCompact: {
|
||||
...TextStyleSheet["text-md/semibold"],
|
||||
},
|
||||
headerSubtitle: {
|
||||
...TextStyleSheet["text-sm/semibold"],
|
||||
color: semanticColors.TEXT_MUTED,
|
||||
},
|
||||
descriptionLabel: {
|
||||
...TextStyleSheet["text-md/semibold"],
|
||||
color: "text-strong",
|
||||
},
|
||||
actions: {
|
||||
flexDirection: "row-reverse",
|
||||
alignItems: "center",
|
||||
gap: 5
|
||||
},
|
||||
iconStyle: {
|
||||
tintColor: semanticColors.LOGO_PRIMARY,
|
||||
opacity: 0.2,
|
||||
height: 64,
|
||||
width: 64,
|
||||
left: void 0,
|
||||
right: "30%",
|
||||
top: "-10%"
|
||||
}
|
||||
});
|
||||
|
||||
interface Action {
|
||||
|
|
@ -108,9 +111,9 @@ export default function AddonCard(props: CardProps) {
|
|||
<Stack spacing={16}>
|
||||
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
||||
<View style={styles.headerLeading}>
|
||||
<Text style={styles.headerLabel}>{props.headerLabel}</Text>
|
||||
<Text numberOfLines={1} ellipsizeMode="tail" style={styles.headerLabel}>{props.headerLabel}</Text>
|
||||
{props.headerSublabel && (
|
||||
<Text style={styles.headerSubtitle}>{props.headerSublabel}</Text>
|
||||
<Text numberOfLines={1} ellipsizeMode="tail" style={styles.headerSubtitle}>{props.headerSublabel}</Text>
|
||||
)}
|
||||
</View>
|
||||
<View style={[styles.headerTrailing, { marginLeft: "auto" }]}>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import {
|
|||
TableSwitchRow,
|
||||
Stack,
|
||||
} from "@metro/common/components";
|
||||
import { semanticColors } from "@ui/color";
|
||||
import { ScrollView, View } from "react-native";
|
||||
|
||||
import ErrorComponentStackCard from "./ErrorComponentStackCard";
|
||||
|
|
@ -74,8 +73,8 @@ export default function ErrorBoundaryScreen(props: {
|
|||
<ScrollView fadingEdgeLength={64} contentContainerStyle={{ gap: 12 }}>
|
||||
<Text
|
||||
variant="heading-md/extrabold"
|
||||
color="text-default"
|
||||
style={{
|
||||
color: semanticColors.HEADER_PRIMARY,
|
||||
marginBottom: 8,
|
||||
textAlign: "center",
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export { shiggycordIcon };
|
|||
|
||||
export default function initSettings() {
|
||||
registerSection({
|
||||
name: "ShiggyCord",
|
||||
name: "GoonCord",
|
||||
items: [
|
||||
{
|
||||
key: "SHIGGYCORD",
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ export default function About() {
|
|||
variant="text-md/medium"
|
||||
style={{ textAlign: "center", marginTop: 4 }}
|
||||
>
|
||||
Shiggy your discord client!
|
||||
💦Goon💦 your discord client!
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ export default function General() {
|
|||
>
|
||||
<TableRowGroup title="App Information">
|
||||
<TableRow
|
||||
label="ShiggyCord"
|
||||
label="GoonCord"
|
||||
icon={<TableRow.Icon source={{ uri: shiggycordIcon ?? "" }} />}
|
||||
trailing={<TableRow.TrailingText text={debugInfo.bunny.version} />}
|
||||
/>
|
||||
|
|
@ -144,7 +144,7 @@ export default function General() {
|
|||
subLabel={`${debugInfo.bunny.loader.name} loader`}
|
||||
icon={<TableRow.Icon source={findAssetId("DownloadIcon")} />}
|
||||
trailing={
|
||||
<TableRow.TrailingText text={debugInfo.bunny.loader.version} />
|
||||
<TableRow.TrailingText text={debugInfo.bunny.loader.version ?? ""} />
|
||||
}
|
||||
/>
|
||||
</TableRowGroup>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ async function initializeShiggyCord() {
|
|||
Object.freeze = Object.seal = Object;
|
||||
|
||||
await require("@metro/internals/caches").initMetroCache();
|
||||
await require(".").default();
|
||||
require(".").default();
|
||||
} catch (e) {
|
||||
const { ClientInfoManager } = require("@lib/api/native/modules");
|
||||
const stack = e instanceof Error ? e.stack : undefined;
|
||||
|
|
|
|||
56
src/index.ts
56
src/index.ts
|
|
@ -11,13 +11,8 @@ import { injectFluxInterceptor } from "@lib/api/flux";
|
|||
import { patchJsx } from "@lib/api/react/jsx";
|
||||
import { logger } from "@lib/utils/logger";
|
||||
import { patchSettings } from "@ui/settings";
|
||||
import { updaterSettings } from "@lib/api/settings";
|
||||
import { InteractionManager } from "react-native";
|
||||
import { getDebugInfo, initDebugger } from "@lib/api/debug";
|
||||
|
||||
// Debug toggle helper (temporary runtime fallback). The helper is dynamically
|
||||
// imported when needed (to avoid bundling it permanently) and removed after use.
|
||||
|
||||
import * as lib from "./lib";
|
||||
import { timings } from "@lib/utils/timings";
|
||||
|
||||
|
|
@ -66,52 +61,19 @@ export default async () => {
|
|||
const { VdPluginManager } = await import("@core/vendetta/plugins");
|
||||
const { initPlugins, updatePlugins } = await import("@lib/addons/plugins");
|
||||
|
||||
// Initialize Vendetta plugins (may start many plugins) — do not block UI.
|
||||
VdPluginManager.initPlugins()
|
||||
.then((u) => lib.unload.push(u))
|
||||
.catch((e) => logger.log("Vendetta init failed:", e));
|
||||
await Promise.all([
|
||||
VdPluginManager.initPlugins()
|
||||
.then((u) => u && lib.unload.push(u))
|
||||
.catch((e) => logger.log("Vendetta init failed:", e)),
|
||||
initPlugins()
|
||||
.catch((e) => logger.log("initPlugins failed:", e)),
|
||||
]);
|
||||
|
||||
// Start ShiggyCord (Bunny) plugins now without forcing repository updates.
|
||||
// Plugin repository fetching is deferred so the app can finish launching first.
|
||||
// Stagger plugin startup to reduce CPU/memory spikes: use smaller batches and a small interval.
|
||||
// This keeps the UI responsive while plugins initialize in the background.
|
||||
initPlugins({ staggerInterval: 500, batchSize: 2 });
|
||||
|
||||
// Attempt a lightweight recovery toggle if some core plugins failed to start.
|
||||
try {
|
||||
// Dynamically import the helper (if present) but suppress verbose errors.
|
||||
const mod = await import("@core/debug/toggleCorePlugins").catch(
|
||||
() => null,
|
||||
);
|
||||
if (mod?.default) {
|
||||
// Run helper with minimal noise; ignore failures.
|
||||
mod.default({ offDuration: 1500 }).catch(() => {});
|
||||
}
|
||||
|
||||
// Try to remove the helper source file (best-effort, ignore failures).
|
||||
await import("@lib/api/native/fs")
|
||||
.then((fs) => fs.removeFile("src/core/debug/toggleCorePlugins.ts"))
|
||||
.catch(() => {});
|
||||
} catch {
|
||||
// suppressed
|
||||
}
|
||||
updatePlugins()
|
||||
.catch((e) => logger.log("updatePlugins failed:", e));
|
||||
|
||||
// Update fonts in background
|
||||
updateFonts().catch((e) => logger.log("updateFonts failed:", e));
|
||||
|
||||
// Schedule plugin repository update after a delay (5 minutes) so update work
|
||||
// does not impact initial launch performance.
|
||||
setTimeout(
|
||||
() => {
|
||||
updatePlugins().catch((e) =>
|
||||
logger.log("updatePlugins failed (deferred 5min):", e),
|
||||
);
|
||||
},
|
||||
5 * 60 * 1000,
|
||||
);
|
||||
|
||||
// Note: we intentionally moved the call to `updatePlugins()` above so core
|
||||
// plugins are registered prior to calling `initPlugins()`.
|
||||
};
|
||||
|
||||
// Preferred: wait until interactions finish (animations / navigation).
|
||||
|
|
|
|||
|
|
@ -752,27 +752,54 @@ export async function updatePlugins() {
|
|||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const enabledIds = [...registeredPlugins.keys()].filter(
|
||||
(id) => isPluginEnabled(id) && !pluginInstances.has(id),
|
||||
);
|
||||
await Promise.allSettled(
|
||||
enabledIds.map(async (id) => {
|
||||
try {
|
||||
await startPlugin(id).catch((e) => {
|
||||
console.error(`Failed to start plugin ${id}:`, e);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Unexpected error while starting plugin ${id}:`, error);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize plugins but stagger startup to avoid CPU spikes during app start.
|
||||
* Register all installed plugins from local storage manifests without any
|
||||
* network fetch. This lets initPlugins() start plugins immediately using
|
||||
* previously-cached scripts, keeping startup snappy.
|
||||
*
|
||||
* This replaces the original "start all enabled plugins in parallel" approach
|
||||
* with a configurable staggered startup: plugins are started in small batches and
|
||||
* we await a small interval between batches. This reduces short-lived CPU and I/O contention
|
||||
* that causes jank on low-end devices.
|
||||
*
|
||||
* Backwards-compatible: callers can still call initPlugins() with no arguments.
|
||||
*
|
||||
* Options:
|
||||
* - staggerInterval (ms) - wait time between batches (default: 100)
|
||||
* - batchSize - how many plugins to start concurrently in a single batch (default: 3)
|
||||
* Safe to call multiple times — skips already-registered plugins.
|
||||
*/
|
||||
export async function initPlugins(
|
||||
options: { staggerInterval?: number; batchSize?: number } = {},
|
||||
) {
|
||||
const { staggerInterval = 100, batchSize = 3 } = options;
|
||||
export async function registerInstalledPlugins() {
|
||||
await awaitStorage(pluginRepositories, pluginSettings);
|
||||
|
||||
const ids = Object.keys(pluginSettings ?? {});
|
||||
if (ids.length === 0) return;
|
||||
|
||||
// Load all manifest files from local storage in parallel.
|
||||
const results = await Promise.allSettled(
|
||||
ids.map(async (id) => {
|
||||
if (registeredPlugins.has(id) || isCorePlugin(id)) return;
|
||||
const loaded = await preloadStorageIfExists(`plugins/manifests/${id}.json`);
|
||||
if (loaded) {
|
||||
const manifest = getPreloadedStorage<t.BunnyPluginManifest>(
|
||||
`plugins/manifests/${id}.json`,
|
||||
);
|
||||
if (manifest) {
|
||||
registeredPlugins.set(id, manifest);
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export async function initPlugins() {
|
||||
// Ensure core plugins are registered prior to any plugin startup logic so
|
||||
// settings pages and UI that read registered/core plugins show them.
|
||||
// registerCorePlugins is synchronous and idempotent, but call it here as a
|
||||
|
|
@ -784,6 +811,7 @@ export async function initPlugins(
|
|||
}
|
||||
|
||||
await awaitStorage(pluginRepositories, pluginSettings);
|
||||
await registerInstalledPlugins();
|
||||
|
||||
// Collect enabled plugin ids
|
||||
const enabledIds = [...registeredPlugins.keys()].filter((id) =>
|
||||
|
|
@ -792,32 +820,18 @@ export async function initPlugins(
|
|||
|
||||
if (enabledIds.length === 0) return;
|
||||
|
||||
// Helper sleep
|
||||
const sleep = (ms: number) => new Promise<void>((res) => setTimeout(res, ms));
|
||||
|
||||
// Start plugins in batches to avoid starting all at once.
|
||||
for (let i = 0; i < enabledIds.length; i += batchSize) {
|
||||
const batch = enabledIds.slice(i, i + batchSize);
|
||||
|
||||
// Start the batch in parallel but don't let exceptions bubble to halt everything.
|
||||
await Promise.allSettled(
|
||||
batch.map(async (id) => {
|
||||
try {
|
||||
// Only attempt to start if still enabled and not already started
|
||||
if (!isPluginEnabled(id) || pluginInstances.has(id)) return;
|
||||
await startPlugin(id).catch((e) => {
|
||||
// startPlugin may throw; ensure it doesn't crash the whole batch
|
||||
console.error(`Failed to start plugin ${id}:`, e);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Unexpected error while starting plugin ${id}:`, error);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
// If there are more plugins to start, wait before starting the next batch.
|
||||
if (i + batchSize < enabledIds.length) {
|
||||
await sleep(staggerInterval);
|
||||
}
|
||||
}
|
||||
// Start all enabled plugins in parallel
|
||||
await Promise.allSettled(
|
||||
enabledIds.map(async (id) => {
|
||||
try {
|
||||
// Only attempt to start if still enabled and not already started
|
||||
if (!isPluginEnabled(id) || pluginInstances.has(id)) return;
|
||||
await startPlugin(id).catch((e) => {
|
||||
console.error(`Failed to start plugin ${id}:`, e);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Unexpected error while starting plugin ${id}:`, error);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,19 +40,55 @@ export function updateBunnyColor(colorManifest: ColorManifest | null, { update =
|
|||
});
|
||||
|
||||
if (internalDef != null) {
|
||||
tokenRef.Theme[ref.key.toUpperCase()] = ref.key;
|
||||
FormDivider.DIVIDER_COLORS[ref.key] = FormDivider.DIVIDER_COLORS[ref.current!.reference];
|
||||
// Register the synthetic key BEFORE calling native, and verify it actually
|
||||
// landed in every table native reads from. If any registration step fails,
|
||||
// bail out to a known-good theme instead of handing native an unknown key.
|
||||
try {
|
||||
tokenRef.Theme[ref.key.toUpperCase()] = ref.key;
|
||||
|
||||
Object.keys(tokenRef.Shadow).forEach(k => tokenRef.Shadow[k][ref.key] = tokenRef.Shadow[k][ref.current!.reference]);
|
||||
Object.keys(tokenRef.SemanticColor).forEach(k => {
|
||||
tokenRef.SemanticColor[k][ref.key] = {
|
||||
...tokenRef.SemanticColor[k][ref.current!.reference]
|
||||
};
|
||||
});
|
||||
if (!FormDivider.DIVIDER_COLORS[ref.current!.reference]) {
|
||||
throw new Error(`Missing divider color reference: ${ref.current!.reference}`);
|
||||
}
|
||||
FormDivider.DIVIDER_COLORS[ref.key] = FormDivider.DIVIDER_COLORS[ref.current!.reference];
|
||||
|
||||
Object.keys(tokenRef.Shadow).forEach(k => {
|
||||
if (!(ref.current!.reference in tokenRef.Shadow[k])) {
|
||||
throw new Error(`Missing shadow reference: ${ref.current!.reference}`);
|
||||
}
|
||||
tokenRef.Shadow[k][ref.key] = tokenRef.Shadow[k][ref.current!.reference];
|
||||
});
|
||||
|
||||
Object.keys(tokenRef.SemanticColor).forEach(k => {
|
||||
if (!(ref.current!.reference in tokenRef.SemanticColor[k])) {
|
||||
throw new Error(`Missing semantic color reference: ${ref.current!.reference}`);
|
||||
}
|
||||
tokenRef.SemanticColor[k][ref.key] = {
|
||||
...tokenRef.SemanticColor[k][ref.current!.reference]
|
||||
};
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("Failed to register custom theme key, falling back", e);
|
||||
ref.current = null; // force fallback path below
|
||||
}
|
||||
}
|
||||
|
||||
if (update) {
|
||||
AppearanceManager.setShouldSyncAppearanceSettings(false);
|
||||
AppearanceManager.updateTheme(internalDef != null ? ref.key : ref.lastSetDiscordTheme);
|
||||
|
||||
const targetTheme = ref.current != null ? ref.key : ref.lastSetDiscordTheme;
|
||||
|
||||
// This is the actual crash site: a raw call into native code with no
|
||||
// guard. Wrap it so a native-side rejection can't take the whole
|
||||
// bridge/thread down — fall back to the last known-good Discord theme.
|
||||
try {
|
||||
AppearanceManager.updateTheme(targetTheme);
|
||||
} catch (e) {
|
||||
console.error(`Native rejected theme "${targetTheme}", reverting to "${ref.lastSetDiscordTheme}"`, e);
|
||||
try {
|
||||
AppearanceManager.updateTheme(ref.lastSetDiscordTheme);
|
||||
} catch (e2) {
|
||||
console.error("Fallback theme also failed to apply", e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ export function getCurrentTheme() {
|
|||
* @internal
|
||||
*/
|
||||
export function getThemeFromLoader(): VdThemeInfo | null {
|
||||
return getStoredTheme();
|
||||
return getStoredTheme() ?? getCurrentTheme();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -157,6 +157,7 @@ export async function initThemes() {
|
|||
}
|
||||
|
||||
await newAwaitStorage(colorsPref);
|
||||
await awaitStorage(themes);
|
||||
|
||||
const currentTheme = getThemeFromLoader();
|
||||
initColors(currentTheme?.data ?? null);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ const rainLoaderIdentity = globalThis.__RAIN_LOADER__;
|
|||
// @ts-ignore
|
||||
const vendettaLoaderIdentity = globalThis.__vendetta_loader;
|
||||
|
||||
// @ts-ignore
|
||||
const shiggyLoaderIdentity = globalThis.__SHIGGY_LOADER__;
|
||||
|
||||
export interface VendettaLoaderIdentity {
|
||||
name: string;
|
||||
features: {
|
||||
|
|
@ -36,6 +39,10 @@ export function isRa1nLoader() {
|
|||
return rainLoaderIdentity != null;
|
||||
}
|
||||
|
||||
export function isShiggyLoader() {
|
||||
return shiggyLoaderIdentity != null;
|
||||
}
|
||||
|
||||
function polyfillVendettaLoaderIdentity() {
|
||||
if (!isPyonLoader() || isVendettaLoader() || !isRa1nLoader()) return null;
|
||||
|
||||
|
|
@ -98,6 +105,8 @@ export function getLoaderIdentity() {
|
|||
return getVendettaLoaderIdentity();
|
||||
} else if (isRa1nLoader()) {
|
||||
return rainLoaderIdentity();
|
||||
} else if (isShiggyLoader()) {
|
||||
return shiggyLoaderIdentity;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
@ -116,6 +125,7 @@ export function getLoaderName() {
|
|||
if (isPyonLoader()) return pyonLoaderIdentity.loaderName;
|
||||
else if (isRa1nLoader()) return rainLoaderIdentity.loadername;
|
||||
else if (isVendettaLoader()) return vendettaLoaderIdentity.name;
|
||||
else if (isShiggyLoader()) return shiggyLoaderIdentity.loaderName;
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
|
@ -123,6 +133,7 @@ export function getLoaderName() {
|
|||
export function getLoaderVersion(): string | null {
|
||||
if (isPyonLoader()) return pyonLoaderIdentity.loaderVersion;
|
||||
else if (isRa1nLoader()) return rainLoaderIdentity.loaderVersion;
|
||||
else if (isShiggyLoader()) return shiggyLoaderIdentity.loaderVersion;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +155,9 @@ export function isThemeSupported() {
|
|||
} else if (isVendettaLoader()) {
|
||||
return vendettaLoaderIdentity!!.features.themes != null;
|
||||
} else if (isRa1nLoader()) {
|
||||
return false; // Ra1n has theme support disabled, this is here just to make sure it doesnt think it does
|
||||
return false; // Rain has theme support disabled, this is here just to make sure it doesnt think it does
|
||||
} else if (isShiggyLoader()) {
|
||||
return shiggyLoaderIdentity.hasThemeSupport;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -158,6 +171,8 @@ export function getStoredTheme(): VdThemeInfo | null {
|
|||
if (!themeProp) return null;
|
||||
// @ts-ignore
|
||||
return globalThis[themeProp] || null;
|
||||
} else if (isShiggyLoader()) {
|
||||
return shiggyLoaderIdentity.storedTheme || null;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
@ -168,6 +183,8 @@ export function getThemeFilePath() {
|
|||
return "pyoncord/current-theme.json";
|
||||
} else if (isVendettaLoader()) {
|
||||
return "vendetta_theme.json";
|
||||
} else if (isShiggyLoader()) {
|
||||
return "ShiggyCord/current-theme.json";
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
@ -241,6 +258,7 @@ export function getLoaderConfigPath() {
|
|||
|
||||
export function isFontSupported() {
|
||||
if (isPyonLoader()) return pyonLoaderIdentity.fontPatch === 2;
|
||||
else if (isShiggyLoader()) return shiggyLoaderIdentity.fontPatch === 2;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -248,4 +266,4 @@ export function isFontSupported() {
|
|||
export async function clearBundle() {
|
||||
// TODO: This should be not be hardcoded, maybe put in loader.json?
|
||||
return void await removeCacheFile("bundle.js");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,15 +5,14 @@ import type { ImageURISource } from "react-native";
|
|||
import { patchTabsUI } from "./patches/tabs";
|
||||
|
||||
export interface RowConfig {
|
||||
key: string;
|
||||
title: () => string;
|
||||
onPress?: () => any;
|
||||
render?: Parameters<typeof lazy>[0];
|
||||
icon?: ImageURISource | number;
|
||||
IconComponent?: React.ReactNode;
|
||||
usePredicate?: () => boolean;
|
||||
useTrailing?: () => string | JSX.Element;
|
||||
rawTabsConfig?: Record<string, any>;
|
||||
key: string;
|
||||
title: () => string;
|
||||
onPress?: () => any;
|
||||
render?: Parameters<typeof lazy>[0];
|
||||
icon?: ImageURISource | number;
|
||||
IconComponent?: React.ReactNode,
|
||||
usePredicate?: () => boolean,
|
||||
useTrailing?: () => string | JSX.Element
|
||||
}
|
||||
|
||||
export const registeredSections = {} as {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { after } from "@lib/api/patcher";
|
|||
import { TableRow } from "@metro/common/components";
|
||||
import { findByNameLazy, findByPropsLazy } from "@metro/wrappers";
|
||||
import { registeredSections } from "@ui/settings";
|
||||
import { Strings } from "@core/i18n";
|
||||
|
||||
import { CustomPageRenderer, wrapOnPress } from "./shared";
|
||||
import { findInReactTree } from "@lib/utils";
|
||||
|
|
@ -29,9 +28,9 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) {
|
|||
IconComponent: () => <TableRow.Icon source={row.icon} />,
|
||||
usePredicate: row.usePredicate,
|
||||
useTrailing: row.useTrailing,
|
||||
useTitle: row.title,
|
||||
onPress: wrapOnPress(row.onPress, null, row.render, row.title()),
|
||||
withArrow: true,
|
||||
...row.rawTabsConfig,
|
||||
},
|
||||
})),
|
||||
)
|
||||
|
|
@ -48,6 +47,7 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) {
|
|||
VendettaCustomPage: {
|
||||
type: "route",
|
||||
title: () => "ShiggyCord",
|
||||
useTitle: () => "ShiggyCord",
|
||||
screen: {
|
||||
route: "VendettaCustomPage",
|
||||
getComponent: () => CustomPageRenderer,
|
||||
|
|
@ -56,6 +56,7 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) {
|
|||
SHIGGYCORD_CUSTOM_PAGE: {
|
||||
type: "route",
|
||||
title: () => "ShiggyCord",
|
||||
useTitle: () => "ShiggyCord",
|
||||
screen: {
|
||||
route: "SHIGGYCORD_CUSTOM_PAGE",
|
||||
getComponent: () => CustomPageRenderer,
|
||||
|
|
@ -64,6 +65,7 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) {
|
|||
BUNNY_CUSTOM_PAGE: {
|
||||
type: "route",
|
||||
title: () => "ShiggyCord",
|
||||
useTitle: () => "ShiggyCord",
|
||||
screen: {
|
||||
route: "BUNNY_CUSTOM_PAGE",
|
||||
getComponent: () => CustomPageRenderer,
|
||||
|
|
|
|||
|
|
@ -117,17 +117,13 @@ for (const [id, moduleExports] of cacher.getModules()) {
|
|||
}
|
||||
|
||||
const exportsKeysLength = Reflect.ownKeys(actualExports).length;
|
||||
if (_source[prop] && exportsKeysLength >= _source[prop]) {
|
||||
if (_source[prop] && exportsKeysLength <= _source[prop]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
_module[prop] = actualExports[prop];
|
||||
_source[prop] = Reflect.ownKeys(actualExports).length;
|
||||
cacher.cacheId(id);
|
||||
|
||||
if (exportsKeysLength === 1) {
|
||||
redesignProps.delete(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue