blob: a4c129f9aebe3a7196af850ca8ee352f1552d4eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/**
* SPDX-License-Identifier: CC0-1.0
*
* Copyright (C) 2026 Woj. Kosior <koszko@koszko.org>
*/
/*
#+begin_src manifest-jq
.matches = ["<all_urls>"]
#+end_src
*/
if (false) { /* #+begin_src background-js */
blockJsOnCookie(/^pow_challenge=[0-9]{12}[.]/);
} /* #+end_src */
/*
* Solve "Varnish PoW" challenges. These are used in some places under
* *.debian.org and are derived from haphash PoW challenges. We utilize
* `pow-solver.js' for computing the hashes and
* `appended-number-counting-schemes.js' for the counting scheme.
*/
(() => {
const target = new URLSearchParams(window.location.search).get('original');
const match = /(?:^|;)\s*pow_challenge=(\S*)/.exec(document.cookie);
if (target && match && !window.location.href.startsWith("file://")) {
document.documentElement.innerHTML = `\
<p style="margin: 1em auto; max-width: 600px; text-align: center;">
Simple extension is trying to solve a Varnish PoW challenge on this page…
</p>
`;
const challenge = match[1];
/* A fixed length of 8 zero bits is required by this challenge. */
genericSolvePow(challenge + ';', 8, appendedNumberCountingSchemes)
.then(({suffixArray}) => {
const nonce = new TextDecoder().decode(suffixArray);
document.cookie = `pow_nonce=${nonce}; Path=/`;
window.location.href = target;
});
}
})();
|