diff --git a/downloader/background.js b/downloader/background.js index eaf65e72c86d290ac013f75e7c57f08f7de11f8b..7e57301ea58578d1c48d7988731a616d503b8f4f 100644 --- a/downloader/background.js +++ b/downloader/background.js @@ -77,8 +77,10 @@ function loadConfigurationFromLocalStorage() { else { console.log("Load default config"); 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" }); - config = { format_version: "1.1", target_page: "https://httpbin.org/*", headers: headers, debug_mode: false, use_url_contains: false }; + // recolic-fkms: modify the default config to make it better for us. + 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) }); @@ -167,7 +169,7 @@ function log(message) { * * Example: * 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) @@ -188,7 +190,7 @@ function decay_header_value(value) { // for(;true;) { // if(restxt.length != 0) return restxt; // } - return httpGet(url); + return httpGet(url).split("|")[1]; } else return value; @@ -202,6 +204,7 @@ function rewriteRequestHeader(e) { if (config.debug_mode) log("Start modify request headers for url " + e.url); 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)))) { + to_modify.header_value = decay_header_value(to_modify.header_value); // recolic-fkms if (to_modify.action === "add") { let new_header = { "name": to_modify.header_name, "value": to_modify.header_value }; e.requestHeaders.push(new_header);