From ad98eb60e1e9ca3a22805d208a0c6a413454a98f Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Tue, 5 Dec 2023 06:38:35 +0700 Subject: [PATCH] Only call eval() once per patch group --- better-xcloud.user.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/better-xcloud.user.js b/better-xcloud.user.js index fb9a7be..8165e80 100644 --- a/better-xcloud.user.js +++ b/better-xcloud.user.js @@ -4449,6 +4449,7 @@ class Patcher { for (let groupIndex = 0; groupIndex < Patcher.#PATCH_ORDERS.length; groupIndex++) { const group = Patcher.#PATCH_ORDERS[groupIndex]; + let modified = false; for (let patchIndex = 0; patchIndex < group.length; patchIndex++) { const patchName = group[patchIndex]; @@ -4466,11 +4467,10 @@ class Patcher { } } + modified = true; funcStr = patchedFuncStr; console.log(`[Better xCloud] Applied "${patchName}" patch`); - // Apply patched function - item[1][id] = eval(patchedFuncStr); appliedPatches.push(patchName); // Remove patch from group @@ -4478,6 +4478,11 @@ class Patcher { patchIndex--; } + // Apply patched functions + if (modified) { + item[1][id] = eval(funcStr); + } + // Remove empty group if (!group.length) { Patcher.#PATCH_ORDERS.splice(groupIndex, 1);