aboutsummaryrefslogtreecommitdiff
path: root/background
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2021-09-13 16:56:44 +0200
committerWojtek Kosior <koszko@koszko.org>2021-09-13 16:56:44 +0200
commit2bd35bc4b0d32b70320b06d932db90e75e89373e (patch)
treed38333de0b9cf54d31d35812784aeca367bea42e /background
parent947fbdefffe0f6010e32abbfdce2f4b388d3f7f7 (diff)
downloadbrowser-extension-2bd35bc4b0d32b70320b06d932db90e75e89373e.tar.gz
browser-extension-2bd35bc4b0d32b70320b06d932db90e75e89373e.zip
rename the extension to "Haketilo"
Diffstat (limited to 'background')
-rw-r--r--background/cookie_filter.js17
-rw-r--r--background/main.js4
-rw-r--r--background/page_actions_server.js4
-rw-r--r--background/policy_injector.js26
-rw-r--r--background/storage.js4
-rw-r--r--background/storage_server.js4
-rw-r--r--background/stream_filter.js6
7 files changed, 39 insertions, 26 deletions
diff --git a/background/cookie_filter.js b/background/cookie_filter.js
index fea2d23..64d18b2 100644
--- a/background/cookie_filter.js
+++ b/background/cookie_filter.js
@@ -1,7 +1,8 @@
/**
- * part of Hachette
- * Filtering request headers to remove hachette cookies that might have slipped
- * through.
+ * This file is part of Haketilo.
+ *
+ * Function: Filtering request headers to remove haketilo cookies that might
+ * have slipped through.
*
* Copyright (C) 2021 Wojtek Kosior
* Redistribution terms are gathered in the `copyright' file.
@@ -13,29 +14,29 @@
* IMPORTS_END
*/
-function is_valid_hachette_cookie(cookie)
+function is_valid_haketilo_cookie(cookie)
{
- const match = /^hachette-(\w*)=(.*)$/.exec(cookie);
+ const match = /^haketilo-(\w*)=(.*)$/.exec(cookie);
if (!match)
return false;
return !extract_signed(match.slice(1, 3)).fail;
}
-function remove_hachette_cookies(header)
+function remove_haketilo_cookies(header)
{
if (header.name !== "Cookie")
return header;
const cookies = header.value.split("; ");
- const value = cookies.filter(c => !is_valid_hachette_cookie(c)).join("; ");
+ const value = cookies.filter(c => !is_valid_haketilo_cookie(c)).join("; ");
return value ? {name: "Cookie", value} : null;
}
function filter_cookie_headers(headers)
{
- return headers.map(remove_hachette_cookies).filter(h => h);
+ return headers.map(remove_haketilo_cookies).filter(h => h);
}
/*
diff --git a/background/main.js b/background/main.js
index 03cd5d7..40b3a9e 100644
--- a/background/main.js
+++ b/background/main.js
@@ -1,5 +1,7 @@
/**
- * Hachette main background script
+ * This file is part of Haketilo.
+ *
+ * Function: Main background script.
*
* Copyright (C) 2021 Wojtek Kosior
* Redistribution terms are gathered in the `copyright' file.
diff --git a/background/page_actions_server.js b/background/page_actions_server.js
index e21ca6e..156a79f 100644
--- a/background/page_actions_server.js
+++ b/background/page_actions_server.js
@@ -1,5 +1,7 @@
/**
- * Hachette serving of page actions to content scripts
+ * This file is part of Haketilo.
+ *
+ * Function: Serving page actions to content scripts.
*
* Copyright (C) 2021 Wojtek Kosior
* Redistribution terms are gathered in the `copyright' file.
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: <signature>_0_<data> */
+ for (const header of headers.filter(h => h.name === "x-haketilo")) {
+ /* x-haketilo header has format: <signature>_0_<data> */
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({
diff --git a/background/storage.js b/background/storage.js
index 12c0c61..a4e626a 100644
--- a/background/storage.js
+++ b/background/storage.js
@@ -1,5 +1,7 @@
/**
- * Hachette storage manager
+ * This file is part of Haketilo.
+ *
+ * Function: Storage manager.
*
* Copyright (C) 2021 Wojtek Kosior
* Redistribution terms are gathered in the `copyright' file.
diff --git a/background/storage_server.js b/background/storage_server.js
index 2252eb5..73126d4 100644
--- a/background/storage_server.js
+++ b/background/storage_server.js
@@ -1,5 +1,7 @@
/**
- * Hachette storage through connection (server side)
+ * This file is part of Haketilo.
+ *
+ * Function: Storage through messages (server side).
*
* Copyright (C) 2021 Wojtek Kosior
* Redistribution terms are gathered in the `copyright' file.
diff --git a/background/stream_filter.js b/background/stream_filter.js
index 3e30a4b..e5e0827 100644
--- a/background/stream_filter.js
+++ b/background/stream_filter.js
@@ -1,5 +1,7 @@
/**
- * Hachette modifying a web page using the StreamFilter API
+ * This file is part of Haketilo.
+ *
+ * Function: Modifying a web page using the StreamFilter API.
*
* Copyright (C) 2018 Giorgio Maone <giorgio@maone.net>
* Copyright (C) 2021 Wojtek Kosior
@@ -173,7 +175,7 @@ function filter_data(properties, event)
*/
const dummy_script =
- `<script data-hachette-deleteme="${properties.policy.nonce}" nonce="${properties.policy.nonce}">null</script>`;
+ `<script data-haketilo-deleteme="${properties.policy.nonce}" nonce="${properties.policy.nonce}">null</script>`;
const doctype_decl = /^(\s*<!doctype[^<>"']*>)?/i.exec(decoded)[0];
decoded = doctype_decl + dummy_script +
decoded.substring(doctype_decl.length);