Plugin
ReactErrorDecoder
Replaces "Minified React Error" with the actual error.
1
/*2
* FiveCord — a Discord client mod3
* Copyright (c) 2025 FiveCord4
* SPDX-License-Identifier: GPL-3.0-or-later5
*/6
7
import { Devs } from "@utils/constants";8
import definePlugin from "@utils/types";9
import { React } from "@webpack/common";10
11
let ERROR_CODES: Record<string, string> | undefined;12
13
export default definePlugin({14
name: "ReactErrorDecoder",15
description: 039;Replaces "Minified React Error" with the actual error.039;,16
tags: ["Developers"],17
authors: [Devs.Cyn, Devs.maisymoe],18
patches: [19
{20
find: "React has blocked a javascript: URL as a security precaution.",21
replacement: {22
match: /"https:\/\/react.dev\/errors\/"\+\i;/,23
replace: "$&const vcDecodedError=$self.decodeError(...arguments);if(vcDecodedError)return vcDecodedError;"24
}25
}26
],27
28
async start() {29
const CODES_URL = `https:class="ts-cmt">//raw.githubusercontent.com/facebook/react/v${React.version}/scripts/error-codes/codes.json`;30
31
ERROR_CODES = await fetch(CODES_URL)32
.then(res => res.json())33
.catch(e => console.error("[ReactErrorDecoder] Failed to fetch React error codes\n", e));34
},35
36
stop() {37
ERROR_CODES = undefined;38
},39
40
decodeError(code: number, ...args: any) {41
let index = 0;42
return ERROR_CODES?.[code]?.replace(/%s/g, () => {43
const arg = args[index];44
index++;45
return arg;46
});47
}48
});49