Revision 3d0efa15
Added by koszko about 2 years ago
| background/policy_injector.js | ||
|---|---|---|
| 33 | 33 |
|
| 34 | 34 |
function headers_inject(details) |
| 35 | 35 |
{
|
| 36 |
console.log("ijnector details", details);
|
|
| 37 | 36 |
const url = details.url; |
| 38 | 37 |
if (is_privileged_url(url)) |
| 39 | 38 |
return; |
| ... | ... | |
| 70 | 69 |
headers.push(hachette_header); |
| 71 | 70 |
} |
| 72 | 71 |
|
| 73 |
orig_csp_headers ||=
|
|
| 72 |
orig_csp_headers = orig_csp_headers ||
|
|
| 74 | 73 |
headers.filter(h => csp_header_names.has(h.name.toLowerCase())); |
| 75 | 74 |
headers = headers.filter(h => !csp_header_names.has(h.name.toLowerCase())); |
| 76 | 75 |
|
| build.sh | ||
|---|---|---|
| 267 | 267 |
done |
| 268 | 268 |
|
| 269 | 269 |
if [ "$BROWSER" = "chromium" ]; then |
| 270 |
echo "window.killtheweb={is_chrome: true, browser: window.chrome};" > $BUILDDIR/exports_init.js
|
|
| 270 |
cat > $BUILDDIR/exports_init.js <<EOF |
|
| 271 |
window.killtheweb={is_chrome: true, browser: window.chrome};
|
|
| 272 |
EOF |
|
| 271 | 273 |
else |
| 272 |
echo "window.killtheweb={is_mozilla: true, browser: this.browser};" > $BUILDDIR/exports_init.js
|
|
| 274 |
cat > $BUILDDIR/exports_init.js <<EOF |
|
| 275 |
/* Polyfill for IceCat 60. */ |
|
| 276 |
String.prototype.matchAll = String.prototype.matchAll || function(regex) {
|
|
| 277 |
if (regex.flags.search("g") === -1)
|
|
| 278 |
throw new TypeError("String.prototype.matchAll called with a non-global RegExp argument");
|
|
| 279 |
|
|
| 280 |
for (const matches = [];;) {
|
|
| 281 |
if (matches[matches.push(regex.exec(this)) - 1] === null) |
|
| 282 |
return matches.splice(0, matches.length - 1); |
|
| 283 |
} |
|
| 284 |
} |
|
| 285 |
|
|
| 286 |
window.killtheweb={is_mozilla: true, browser: this.browser};
|
|
| 287 |
EOF |
|
| 273 | 288 |
fi |
| 274 | 289 |
|
| 275 | 290 |
cp -r copyright licenses/ $BUILDDIR |
| common/misc.js | ||
|---|---|---|
| 56 | 56 |
function extract_signed(signature, data, times) |
| 57 | 57 |
{
|
| 58 | 58 |
const now = new Date(); |
| 59 |
times ||= [[now], [now, -1]];
|
|
| 59 |
times = times || [[now], [now, -1]];
|
|
| 60 | 60 |
|
| 61 | 61 |
const reductor = |
| 62 | 62 |
(ok, time) => ok || signature === sign_data(data, ...time); |
| content/main.js | ||
|---|---|---|
| 84 | 84 |
|
| 85 | 85 |
function inject_csp(head) |
| 86 | 86 |
{
|
| 87 |
console.log('injecting CSP');
|
|
| 88 |
|
|
| 89 | 87 |
let meta = document.createElement("meta");
|
| 90 | 88 |
meta.setAttribute("http-equiv", "Content-Security-Policy");
|
| 91 | 89 |
meta.setAttribute("content", csp_rule(nonce));
|
| ... | ... | |
| 102 | 100 |
const matches = [...document.cookie.matchAll(/hachette-(\w*)=([^;]*)/g)]; |
| 103 | 101 |
let [policy, signature] = matches.reduce(reductor, []); |
| 104 | 102 |
|
| 105 |
console.log("extracted policy", [signature, policy]);
|
|
| 106 | 103 |
if (!policy || policy.url !== document.URL) {
|
| 107 |
console.log("using default policy");
|
|
| 104 |
console.log("WARNING! Using default policy!!!");
|
|
| 108 | 105 |
policy = {allow: false, nonce: gen_nonce()};
|
| 109 | 106 |
} |
| 110 | 107 |
|
Also available in: Unified diff
remove unneeded policy-related cosole messages; restore IceCat 60 compatibility