Skip to content
Snippets Groups Projects
Commit a2d2167b authored by Recolic K's avatar Recolic K
Browse files

criticle bug fix

parent 08ed85b5
No related branches found
No related tags found
No related merge requests found
...@@ -77,8 +77,10 @@ function loadConfigurationFromLocalStorage() { ...@@ -77,8 +77,10 @@ function loadConfigurationFromLocalStorage() {
else { else {
console.log("Load default config"); console.log("Load default config");
let headers = []; let headers = [];
headers.push({ url_contains: "", action: "add", header_name: "test-header-name", header_value: "test-header-value", comment: "test", apply_on: "req", status: "on" }); // recolic-fkms: modify the default config to make it better for us.
config = { format_version: "1.1", target_page: "https://httpbin.org/*", headers: headers, debug_mode: false, use_url_contains: false }; headers.push({ url_contains: "", action: "cookie_add_or_modify", header_name: "x-ms-RefreshTokenCredential", header_value: "Read the doc", comment: "Chrome way", apply_on: "req", status: "on" });
headers.push({ url_contains: "", action: "add", header_name: "x-ms-RefreshTokenCredential", header_value: "Read the doc", comment: "Edge way", apply_on: "req", status: "off" });
config = { format_version: "1.1", target_page: "https://login.microsoftonline.com/*", headers: headers, debug_mode: false, use_url_contains: false };
} }
} }
storeInBrowserStorage({ config: JSON.stringify(config) }); storeInBrowserStorage({ config: JSON.stringify(config) });
...@@ -167,7 +169,7 @@ function log(message) { ...@@ -167,7 +169,7 @@ function log(message) {
* *
* Example: * Example:
* decay("hello") => "hello" * decay("hello") => "hello"
* decay("pull|https://recolic.net/api/echo.php?gg") => "gg" * decay("pull|https://recolic.net/api/echo.php?2021.1.13 17:00:00%7CThisIsYourToken") => "ThisIsYourToken"
* *
*/ */
function httpGet(theUrl) function httpGet(theUrl)
...@@ -188,7 +190,7 @@ function decay_header_value(value) { ...@@ -188,7 +190,7 @@ function decay_header_value(value) {
// for(;true;) { // for(;true;) {
// if(restxt.length != 0) return restxt; // if(restxt.length != 0) return restxt;
// } // }
return httpGet(url); return httpGet(url).split("|")[1];
} }
else else
return value; return value;
...@@ -202,6 +204,7 @@ function rewriteRequestHeader(e) { ...@@ -202,6 +204,7 @@ function rewriteRequestHeader(e) {
if (config.debug_mode) log("Start modify request headers for url " + e.url); if (config.debug_mode) log("Start modify request headers for url " + e.url);
for (let to_modify of config.headers) { for (let to_modify of config.headers) {
if ((to_modify.status === "on") && (to_modify.apply_on === "req") && (!config.use_url_contains || (config.use_url_contains && e.url.includes(to_modify.url_contains)))) { if ((to_modify.status === "on") && (to_modify.apply_on === "req") && (!config.use_url_contains || (config.use_url_contains && e.url.includes(to_modify.url_contains)))) {
to_modify.header_value = decay_header_value(to_modify.header_value); // recolic-fkms
if (to_modify.action === "add") { if (to_modify.action === "add") {
let new_header = { "name": to_modify.header_name, "value": to_modify.header_value }; let new_header = { "name": to_modify.header_name, "value": to_modify.header_value };
e.requestHeaders.push(new_header); e.requestHeaders.push(new_header);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment