From 2bd35bc4b0d32b70320b06d932db90e75e89373e Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Mon, 13 Sep 2021 16:56:44 +0200 Subject: rename the extension to "Haketilo" --- background/policy_injector.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'background/policy_injector.js') diff --git a/background/policy_injector.js b/background/policy_injector.js index e5af055..881595b 100644 --- a/background/policy_injector.js +++ b/background/policy_injector.js @@ -1,5 +1,7 @@ /** - * Hachette injecting policy to page using webRequest + * This file is part of Haketilo. + * + * Function: Injecting policy to page by modifying HTTP headers. * * Copyright (C) 2021 Wojtek Kosior * Copyright (C) 2021 jahoti @@ -19,10 +21,10 @@ function inject_csp_headers(headers, policy) { let csp_headers; let old_signature; - let hachette_header; + let haketilo_header; - for (const header of headers.filter(h => h.name === "x-hachette")) { - /* x-hachette header has format: _0_ */ + for (const header of headers.filter(h => h.name === "x-haketilo")) { + /* x-haketilo header has format: _0_ */ const match = /^([^_]+)_(0_.*)$/.exec(header.value); if (!match) continue; @@ -38,7 +40,7 @@ function inject_csp_headers(headers, policy) csp_headers = old_data.csp_headers; old_signature = old_data.policy_sig; - hachette_header = header; + haketilo_header = header; break; } @@ -53,9 +55,9 @@ function inject_csp_headers(headers, policy) headers.push(...csp_headers || []); } - if (!hachette_header) { - hachette_header = {name: "x-hachette"}; - headers.push(hachette_header); + if (!haketilo_header) { + haketilo_header = {name: "x-haketilo"}; + headers.push(haketilo_header); } if (old_signature) @@ -66,7 +68,7 @@ function inject_csp_headers(headers, policy) const later_30sec = new Date(new Date().getTime() + 30000).toGMTString(); headers.push({ name: "Set-Cookie", - value: `hachette-${signed_policy.join("=")}; Expires=${later_30sec};` + value: `haketilo-${signed_policy.join("=")}; Expires=${later_30sec};` }); /* @@ -74,9 +76,9 @@ function inject_csp_headers(headers, policy) * These are signed with a time of 0, as it's not clear there is a limit on * how long Firefox might retain headers in the cache. */ - let hachette_data = {csp_headers, policy_sig: signed_policy[0]}; - hachette_data = encodeURIComponent(JSON.stringify(hachette_data)); - hachette_header.value = sign_data(hachette_data, 0).join("_"); + let haketilo_data = {csp_headers, policy_sig: signed_policy[0]}; + haketilo_data = encodeURIComponent(JSON.stringify(haketilo_data)); + haketilo_header.value = sign_data(haketilo_data, 0).join("_"); if (!policy.allow) { headers.push({ -- cgit v1.2.3