domopt: rewrite and apply to append too

This commit is contained in:
Ducko 2023-04-03 10:46:52 +01:00
parent 28e8ed4a60
commit 9052a5cb78
1 changed files with 12 additions and 8 deletions

View File

@ -59,20 +59,24 @@ const injCSS = x => {
injCSS(`<css>`); injCSS(`<css>`);
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 { try {
themesync(); themesync();
} catch (e) { } } catch (e) { }
}, 10000); }, 10000);
themesync(); themesync();
// DOM Optimizer - see docs (todo) // DOM Optimizer - https://github.com/GooseMod/OpenAsar/wiki/DOM-Optimizer
const removeOrig = Element.prototype.removeChild; const optimize = orig => function(...args) {
Element.prototype.removeChild = function(...args) {
if (typeof args[0].className === 'string' && (args[0].className.indexOf('activity') !== -1)) 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); return orig.apply(this, args);
}; };
Element.prototype.removeChild = optimize(Element.prototype.removeChild);
Element.prototype.appendChild = optimize(Element.prototype.appendChild);