mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-22 14:23:35 -07:00
Move patch to its own file
This commit is contained in:
parent
af5dc4160f
commit
a229f9b2d1
4 changed files with 65 additions and 12 deletions
|
@ -26,6 +26,7 @@
|
||||||
<script defer src="scripts/lib/MooTools-Core-1.6.0-compat-compressed.js"></script>
|
<script defer src="scripts/lib/MooTools-Core-1.6.0-compat-compressed.js"></script>
|
||||||
<script defer src="scripts/lib/MooTools-More-1.6.0-compat-compressed.js"></script>
|
<script defer src="scripts/lib/MooTools-More-1.6.0-compat-compressed.js"></script>
|
||||||
<script defer src="scripts/lib/mocha.min.js"></script>
|
<script defer src="scripts/lib/mocha.min.js"></script>
|
||||||
|
<script defer src="scripts/monkeypatch.js?v=${CACHEID}"></script>
|
||||||
<script defer src="scripts/cache.js?v=${CACHEID}"></script>
|
<script defer src="scripts/cache.js?v=${CACHEID}"></script>
|
||||||
<script defer src="scripts/localpreferences.js?v=${CACHEID}"></script>
|
<script defer src="scripts/localpreferences.js?v=${CACHEID}"></script>
|
||||||
<script defer src="scripts/color-scheme.js?v=${CACHEID}"></script>
|
<script defer src="scripts/color-scheme.js?v=${CACHEID}"></script>
|
||||||
|
|
|
@ -175,18 +175,6 @@ let setStatusFilter = () => {};
|
||||||
let toggleFilterDisplay = () => {};
|
let toggleFilterDisplay = () => {};
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", (event) => {
|
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();
|
window.qBittorrent.LocalPreferences.upgrade();
|
||||||
|
|
||||||
let isSearchPanelLoaded = false;
|
let isSearchPanelLoaded = false;
|
||||||
|
|
63
src/webui/www/private/scripts/monkeypatch.js
Normal file
63
src/webui/www/private/scripts/monkeypatch.js
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2025 bolshoytoster <toasterbig@gmail.com>
|
||||||
|
* 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();
|
|
@ -408,6 +408,7 @@
|
||||||
<file>private/scripts/localpreferences.js</file>
|
<file>private/scripts/localpreferences.js</file>
|
||||||
<file>private/scripts/misc.js</file>
|
<file>private/scripts/misc.js</file>
|
||||||
<file>private/scripts/mocha-init.js</file>
|
<file>private/scripts/mocha-init.js</file>
|
||||||
|
<file>private/scripts/monkeypatch.js</file>
|
||||||
<file>private/scripts/pathAutofill.js</file>
|
<file>private/scripts/pathAutofill.js</file>
|
||||||
<file>private/scripts/piecesbar.js</file>
|
<file>private/scripts/piecesbar.js</file>
|
||||||
<file>private/scripts/progressbar.js</file>
|
<file>private/scripts/progressbar.js</file>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue