mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
26 lines
922 B
JavaScript
26 lines
922 B
JavaScript
// @ts-check
|
|
const { fetchRemoteTextAndCreateReadlineInterface } = require('./lib/fetch-remote-text-by-line');
|
|
const { processLine } = require('./lib/process-line');
|
|
const path = require('path');
|
|
const fse = require('fs-extra');
|
|
const fs = require('fs');
|
|
|
|
(async () => {
|
|
/** @type {Set<string>} */
|
|
const result = new Set();
|
|
for await (const line of await fetchRemoteTextAndCreateReadlineInterface('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf')) {
|
|
const l = processLine(line);
|
|
if (l) {
|
|
result.add(
|
|
l.replace('server=/', '').replace('/114.114.114.114', '')
|
|
);
|
|
}
|
|
}
|
|
|
|
await fse.ensureDir(path.resolve(__dirname, '../List/internal'));
|
|
await fs.promises.writeFile(
|
|
path.resolve(__dirname, '../List/internal/accelerated-china-domains.txt'),
|
|
`${Array.from(result).map(line => `SUFFIX,${line}`).join('\n')}\n`
|
|
);
|
|
})();
|