Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

chore: update contributors and formatting [skip ci]

github-actions[bot]c73f3f979544
diff --git a/filters/README.md b/filters/README.md
index 2a6eb3fa..9726c666 100644
--- a/filters/README.md
+++ b/filters/README.md
@@ -2,13 +2,13 @@
Runtime templates built with the `content-blocking` feature (which `runtime-template` turns on) embed these lists, unmodified and gzipped, for the `content_blocking` groups in `pake.json`. The npm package does not ship this folder, and the CLI never enables the feature.
-| Group | List | Authors | License |
-| --- | --- | --- | --- |
-| `ads` | EasyList | The EasyList authors (https://easylist.to/) | GPL-3.0-or-later or CC BY-SA 3.0 (https://easylist.to/pages/licence.html) |
-| `trackers` | EasyPrivacy | The EasyList authors (https://easylist.to/) | GPL-3.0-or-later or CC BY-SA 3.0 (https://easylist.to/pages/licence.html) |
-| `cookies` | AdGuard Cookie Notices filter | AdGuard (https://github.com/AdguardTeam/AdguardFilters) | GPL-3.0 |
-| `china` | EasyList China | The EasyList China authors (https://github.com/easylist/easylistchina) | GPL-3.0-or-later or CC BY-SA 3.0 (https://easylist.to/pages/licence.html) |
-| always | uBlock filters – Unbreak | uBlock Origin contributors (https://github.com/uBlockOrigin/uAssets) | GPL-3.0 |
+| Group | List | Authors | License |
+| ---------- | ----------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------- |
+| `ads` | EasyList | The EasyList authors (https://easylist.to/) | GPL-3.0-or-later or CC BY-SA 3.0 (https://easylist.to/pages/licence.html) |
+| `trackers` | EasyPrivacy | The EasyList authors (https://easylist.to/) | GPL-3.0-or-later or CC BY-SA 3.0 (https://easylist.to/pages/licence.html) |
+| `cookies` | AdGuard Cookie Notices filter | AdGuard (https://github.com/AdguardTeam/AdguardFilters) | GPL-3.0 |
+| `china` | EasyList China | The EasyList China authors (https://github.com/easylist/easylistchina) | GPL-3.0-or-later or CC BY-SA 3.0 (https://easylist.to/pages/licence.html) |
+| always | uBlock filters – Unbreak | uBlock Origin contributors (https://github.com/uBlockOrigin/uAssets) | GPL-3.0 |
`sources.json` records each list's download URL, version and date. Refresh them with `node scripts/update-filter-lists.mjs` before a runtime release; `cargo test --features content-blocking content_blocking` then checks that every list unpacks and that all groups together still fit WebKit's 150,000-rule limit.
diff --git a/scripts/update-filter-lists.mjs b/scripts/update-filter-lists.mjs
index db6c6fd5..d30e64ad 100644
--- a/scripts/update-filter-lists.mjs
+++ b/scripts/update-filter-lists.mjs
@@ -2,38 +2,38 @@
// Downloads the filter lists that runtime templates built with the
// `content-blocking` feature embed, and stores them gzipped under filters/.
// Run it before a runtime release; the lists age within days of a download.
-import { gzipSync } from 'node:zlib';
-import { writeFileSync, mkdirSync } from 'node:fs';
-import { dirname, join } from 'node:path';
-import { fileURLToPath } from 'node:url';
+import { gzipSync } from "node:zlib";
+import { writeFileSync, mkdirSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
-const root = join(dirname(fileURLToPath(import.meta.url)), '..');
-const out = join(root, 'filters');
+const root = join(dirname(fileURLToPath(import.meta.url)), "..");
+const out = join(root, "filters");
// Group names are the values of `content_blocking` in pake.json.
export const LISTS = [
- { file: 'ads', url: 'https://easylist.to/easylist/easylist.txt' },
- { file: 'trackers', url: 'https://easylist.to/easylist/easyprivacy.txt' },
+ { file: "ads", url: "https://easylist.to/easylist/easylist.txt" },
+ { file: "trackers", url: "https://easylist.to/easylist/easyprivacy.txt" },
{
- file: 'cookies',
- url: 'https://filters.adtidy.org/extension/ublock/filters/18.txt',
+ file: "cookies",
+ url: "https://filters.adtidy.org/extension/ublock/filters/18.txt",
},
{
- file: 'china',
- url: 'https://easylist-downloads.adblockplus.org/easylistchina.txt',
+ file: "china",
+ url: "https://easylist-downloads.adblockplus.org/easylistchina.txt",
},
// Always added to any selection: fixes for sites the other lists break.
{
- file: 'unbreak',
- url: 'https://ublockorigin.github.io/uAssets/filters/unbreak.txt',
+ file: "unbreak",
+ url: "https://ublockorigin.github.io/uAssets/filters/unbreak.txt",
},
];
function header(text, key) {
const line = text
- .split('\n', 40)
+ .split("\n", 40)
.find((l) => l.toLowerCase().startsWith(`! ${key.toLowerCase()}:`));
- return line ? line.slice(line.indexOf(':') + 1).trim() : '';
+ return line ? line.slice(line.indexOf(":") + 1).trim() : "";
}
mkdirSync(out, { recursive: true });
@@ -42,22 +42,26 @@ for (const { file, url } of LISTS) {
const response = await fetch(url);
if (!response.ok) throw new Error(`${url}: HTTP ${response.status}`);
const text = await response.text();
- if (!text.includes('##') && !text.includes('||')) {
+ if (!text.includes("##") && !text.includes("||")) {
throw new Error(`${url} does not look like a filter list`);
}
// mtime 0 keeps the gzip bytes stable for the same text.
writeFileSync(join(out, `${file}.txt.gz`), gzipSync(text, { level: 9 }));
sources.push({
group: file,
- title: header(text, 'Title'),
- version: header(text, 'Version') || header(text, 'Last modified'),
+ title: header(text, "Title"),
+ version: header(text, "Version") || header(text, "Last modified"),
url,
- license: header(text, 'Licence') || header(text, 'License'),
- lines: text.split('\n').length,
+ license: header(text, "Licence") || header(text, "License"),
+ lines: text.split("\n").length,
});
console.log(`${file}: ${text.length} bytes`);
}
writeFileSync(
- join(out, 'sources.json'),
- JSON.stringify({ fetched: new Date().toISOString().slice(0, 10), lists: sources }, null, 2) + '\n',
+ join(out, "sources.json"),
+ JSON.stringify(
+ { fetched: new Date().toISOString().slice(0, 10), lists: sources },
+ null,
+ 2,
+ ) + "\n",
);