Skip to content

Commit 58fb5dc

Browse files
committed
use js for update lists
1 parent 0060001 commit 58fb5dc

File tree

3 files changed

+54
-15
lines changed

3 files changed

+54
-15
lines changed

data/update-lists.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const { execSync } = require("child_process");
2+
const readline = require("readline");
3+
const fs = require("fs");
4+
5+
const rl = readline.createInterface({
6+
input: process.stdin,
7+
output: process.stdout,
8+
});
9+
10+
execSync(
11+
"curl -o data/easylist.to/easylist/easylist.txt https://easylist.to/easylist/easylist.txt"
12+
);
13+
execSync(
14+
"curl -o data/easylist.to/easylist/easyprivacy.txt https://easylist.to/easylist/easyprivacy.txt"
15+
);
16+
execSync(
17+
"curl -o data/easylist.to/easylistgermany/easylistgermany.txt https://easylist.to/easylistgermany/easylistgermany.txt"
18+
);
19+
20+
(async () => {
21+
console.log(
22+
"You need to provide Brave Services Key and target version to update brave-main-list.txt"
23+
);
24+
const apiKey = await new Promise((resolve) => {
25+
rl.question("Enter Brave Services Key: ", resolve);
26+
});
27+
28+
const version = await new Promise((resolve) => {
29+
rl.question("Enter target version (i.e 1.0.10268): ", resolve);
30+
});
31+
32+
const versionNumber = version.replace(/\./g, "_");
33+
const extensionId = "iodkpdagapdfkphljnddpjlldadblomo";
34+
35+
execSync(
36+
`curl -o extension.zip -H "BraveServiceKey: ${apiKey}" ` +
37+
`https://brave-core-ext.s3.brave.com/release/${extensionId}/extension_${versionNumber}.crx`
38+
);
39+
40+
try {
41+
execSync("unzip extension.zip list.txt");
42+
} catch (e) {
43+
if (!fs.existsSync("list.txt")) {
44+
console.error("Failed to find list.txt in extension.zip");
45+
process.exit(1);
46+
}
47+
}
48+
49+
execSync("mv -f list.txt data/brave/brave-main-list.txt");
50+
51+
fs.unlinkSync("extension.zip");
52+
rl.close();
53+
})();

data/update-lists.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"build": "cd js && cargo-cp-artifact -nc index.node -- cargo build --message-format=json-render-diagnostics",
3535
"build-debug": "npm run build --",
3636
"build-release": "npm run build -- --release",
37+
"update-lists": "node data/update-lists.js",
3738
"install": "npm run build-release",
3839
"test": "cargo test"
3940
}

0 commit comments

Comments
 (0)