From ad1a6ea51386feccfb1da0bc0fc4f5ace101b71b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 27 Sep 2022 11:58:12 +1000 Subject: A better fix for bugs #58131 --- bg/ResponseProcessor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bg') diff --git a/bg/ResponseProcessor.js b/bg/ResponseProcessor.js index 922ff19..3c90d9c 100644 --- a/bg/ResponseProcessor.js +++ b/bg/ResponseProcessor.js @@ -83,6 +83,8 @@ class ResponseTextFilter { if (res) return res; const { requestId } = request; + // create a filter to modify response data, see + // Mozilla/Add-ons/WebExtensions/API/webRequest/filterResponseData const filter = browser.webRequest.filterResponseData(requestId); let buffer = []; @@ -118,7 +120,7 @@ class ResponseTextFilter { } catch (e) { console.error(e); } - if (editedText !== null && editedText.indexOf('/* LibreJS: script accepted') !== 0) { + if (editedText !== null && editedText !== response.text) { // we changed the content, let's re-encode const encoded = new TextEncoder().encode(editedText); // pre-pending the UTF-8 BOM will force the charset per HTML 5 specs -- cgit v1.2.3