-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerateRules.js
More file actions
33 lines (32 loc) · 875 Bytes
/
generateRules.js
File metadata and controls
33 lines (32 loc) · 875 Bytes
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
// eslint-disable-next-line import/no-extraneous-dependencies
const fetch = require("node-fetch");
const {
promises: { writeFile }
} = require("fs");
fetch("https://api.bytez.com/papers")
.then(res => res.json())
.then(list => console.log(list.length.toLocaleString()) || list)
.then(list =>
writeFile(
`${__dirname}/public/rules.json`,
JSON.stringify(
list.map((paperID, index) => ({
id: index + 1,
priority: 2147483646,
action: {
type: "redirect",
redirect: {
url: `https://bytez.com/read/arxiv/${paperID}`
}
},
condition: {
isUrlFilterCaseSensitive: false,
urlFilter: `*://arxiv.org/pdf/${paperID}`,
resourceTypes: ["main_frame"]
}
})),
undefined,
2
)
)
);