aboutsummaryrefslogtreecommitdiff
path: root/content/go-away-bot-blocker.js
blob: 95af89edbbb670fd89f1c53de6a563a8a794e5b6 (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
/**
 * SPDX-License-Identifier: CC0-1.0
 *
 * Copyright (C) 2025 Woj. Kosior <koszko@koszko.org>
 */

/*
  #+begin_src manifest-jq
  .matches = ["<all_urls>"]
  #+end_src
*/

if (false) { /* #+begin_src background-js */
    blockJsOnHeader(
        /^via$/,
        /\sgit[.]gammaspectra[.]live[/]git[/]go-away/
    );
} /* #+end_src */

const goAwayJsRegex =
      /^\s*window[.]location\s*=\s*("[^"]+[/]go-away[/][^"]+")\s*;\s*$/;

for (const script of document.scripts) {
    const match = goAwayJsRegex.exec(script.textContent);
    if (match) {
        window.location = JSON.parse(match[1]);
        break;
    }
}