From faa729cd62fd2c1ea01a404ea2ff43373784ca00 Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sat, 10 Aug 2024 08:00:49 +0100 Subject: [PATCH] Remove incompatible Wikimedia webpHandler --- www/js/app.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index fa0a21b5..3703a2c7 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -6094,9 +6094,12 @@ function displayArticleContentInContainer (dirEntry, htmlArticle) { if (!/]*data-mw-section-id=["'][1-9]/i.test(htmlArticle)) break; } } - } else if (appstate.wikimediaZimLoaded && params.manipulateImages) { - // Remove incompatible webP handler that breaks on some Edge Legacy - htmlArticle = htmlArticle.replace(//gi, ''); + } else if (appstate.wikimediaZimLoaded && params.openAllSections) { + // Remove incompatible webP handler that breaks on some Edge Legacy and conflicts with own webP handler + // @TODO It appears webpHandler is loaded by script.js, so this line and equivalent in block above may be redundant. Check for latest ZIMs. + // Maybe older ZIMs loaded them direct? + htmlArticle = htmlArticle.replace(/]+src=["'][^"']*(webp(?:Handler|Hero))[^"']*\.js\b[^<]+<\/script>/gi, ''); + htmlArticle = htmlArticle.replace(/]+-\/(j\/js_modules\/)?script\.js"[^<]*<\/script>/i, ''); } // Gutenberg ZIMs try to initialize before all assets are fully loaded. Affect UWP app.