From 8abc513ff390c2da1e344e5e991f119649db2cb0 Mon Sep 17 00:00:00 2001 From: lukakoning <102363211+lukakoning@users.noreply.github.com> Date: Sat, 6 Apr 2024 11:41:16 +0200 Subject: [PATCH 1/2] Update background.js to support Replace String In Response Value Adds option to replace a string in the response header value --- background.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/background.js b/background.js index c5e42f7..06b73af 100644 --- a/background.js +++ b/background.js @@ -288,6 +288,31 @@ function rewriteResponseHeader(e) { if (config.debug_mode) log("cookie_delete.resp delete_header : name=" + to_modify.header_name + " for url " + e.url); } } + else if (to_modify.action === "replace_value") { + for (let header of e.responseHeaders) { + if (header.name.toLowerCase() === to_modify.header_name.toLowerCase()) { + let replacePattern = to_modify.header_value; + let originalValue = header.value; + + let match = replacePattern.match(/\((.*?)\)\((.*?)\)/); + let searchString = match[1]; // What to search for in the original value + let replaceString = match[2]; // What to replace with in the original value, to create the new value + + let regex = new RegExp(searchString, "g"); + let newValue = originalValue.replace(regex, replaceString); + + if (config.debug_mode) log( + "Replace value in response header : name= " + to_modify.header_name + + ",old value=" + originalValue + + ",replace pattern=" + replacePattern + + ",new value=" + newValue + + " for url " + e.url + ); + + header.value = newValue; + } + } + } } } if (config.debug_mode) log("End modify response headers for url " + e.url); From 6a60ce7dc14dd6f4674502b6a85782d054a69e78 Mon Sep 17 00:00:00 2001 From: lukakoning <102363211+lukakoning@users.noreply.github.com> Date: Sat, 6 Apr 2024 11:46:09 +0200 Subject: [PATCH 2/2] Update config.js to support Replace String In Response Value Adds option to replace a string in the response header value --- popup/config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/popup/config.js b/popup/config.js index 29ae8ea..f3a4d98 100644 --- a/popup/config.js +++ b/popup/config.js @@ -126,6 +126,7 @@ function appendLine(url_contains,action,header_name,header_value,comment,apply_o +