diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html
index 1f11f3aa5..23001f92c 100644
--- a/src/webui/www/private/index.html
+++ b/src/webui/www/private/index.html
@@ -26,6 +26,7 @@
+
diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js
index 287429ecc..7f95a74f5 100644
--- a/src/webui/www/private/scripts/client.js
+++ b/src/webui/www/private/scripts/client.js
@@ -175,18 +175,6 @@ let setStatusFilter = () => {};
let toggleFilterDisplay = () => {};
window.addEventListener("DOMContentLoaded", (event) => {
- // Override MooTools' `document.id` (used for `$(id)`), which prevents it
- // from allocating a `uniqueNumber` for elements that don't need it.
- // This is also more efficient than the original.
- document.id = el => {
- switch (typeOf(el)) {
- case "string":
- return document.getElementById(el);
- case "element":
- return el;
- }
- };
-
window.qBittorrent.LocalPreferences.upgrade();
let isSearchPanelLoaded = false;
diff --git a/src/webui/www/private/scripts/monkeypatch.js b/src/webui/www/private/scripts/monkeypatch.js
new file mode 100644
index 000000000..58ecd2db1
--- /dev/null
+++ b/src/webui/www/private/scripts/monkeypatch.js
@@ -0,0 +1,63 @@
+/*
+ * Bittorrent Client using Qt and libtorrent.
+ * Copyright (C) 2025 bolshoytoster
+ * Copyright (C) 2025 Mike Tzou (Chocobo1)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * In addition, as a special exception, the copyright holders give permission to
+ * link this program with the OpenSSL project's "OpenSSL" library (or with
+ * modified versions of it that use the same license as the "OpenSSL" library),
+ * and distribute the linked executables. You must obey the GNU General Public
+ * License in all respects for all of the code used other than "OpenSSL". If you
+ * modify file(s), you may extend this exception to your version of the file(s),
+ * but you are not obligated to do so. If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
+
+"use strict";
+
+window.qBittorrent ??= {};
+window.qBittorrent.MonkeyPatch ??= (() => {
+ const exports = () => {
+ return {
+ patch: patch
+ };
+ };
+
+ const patch = () => {
+ patchMootoolsDocumentId();
+ };
+
+ const patchMootoolsDocumentId = () => {
+ // Override MooTools' `document.id` (used for `$(id)`), which prevents it
+ // from allocating a `uniqueNumber` for elements that don't need it.
+ // This is also more efficient than the original.
+ document.id = el => {
+ switch (typeOf(el)) {
+ case "string":
+ return document.getElementById(el);
+ case "element":
+ return el;
+ }
+ };
+ };
+
+ return exports();
+})();
+Object.freeze(window.qBittorrent.MonkeyPatch);
+
+// execute now
+window.qBittorrent.MonkeyPatch.patch();
diff --git a/src/webui/www/webui.qrc b/src/webui/www/webui.qrc
index bc637f56c..4a833b85a 100644
--- a/src/webui/www/webui.qrc
+++ b/src/webui/www/webui.qrc
@@ -408,6 +408,7 @@
private/scripts/localpreferences.js
private/scripts/misc.js
private/scripts/mocha-init.js
+ private/scripts/monkeypatch.js
private/scripts/pathAutofill.js
private/scripts/piecesbar.js
private/scripts/progressbar.js