From 9052a5cb78d07bed3491cd567d942f697394cb04 Mon Sep 17 00:00:00 2001 From: CanadaHonk Date: Mon, 3 Apr 2023 10:46:52 +0100 Subject: [PATCH] domopt: rewrite and apply to append too --- src/mainWindow.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mainWindow.js b/src/mainWindow.js index 95db72a..10feeec 100644 --- a/src/mainWindow.js +++ b/src/mainWindow.js @@ -59,20 +59,24 @@ const injCSS = x => { injCSS(``); -openasar = {}; // Define global for any mods which want to know / etc +// Define global for any mods which want to know / etc +openasar = {}; -setInterval(() => { // Try init themesync +// Try init themesync +setInterval(() => { try { themesync(); } catch (e) { } }, 10000); themesync(); -// DOM Optimizer - see docs (todo) -const removeOrig = Element.prototype.removeChild; -Element.prototype.removeChild = function(...args) { +// DOM Optimizer - https://github.com/GooseMod/OpenAsar/wiki/DOM-Optimizer +const optimize = orig => function(...args) { if (typeof args[0].className === 'string' && (args[0].className.indexOf('activity') !== -1)) - return setTimeout(() => removeOrig.apply(this, args), 100); + return setTimeout(() => orig.apply(this, args), 100); - return removeOrig.apply(this, args); -}; \ No newline at end of file + return orig.apply(this, args); +}; + +Element.prototype.removeChild = optimize(Element.prototype.removeChild); +Element.prototype.appendChild = optimize(Element.prototype.appendChild); \ No newline at end of file