mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Feat: build index.html
This commit is contained in:
@@ -21,8 +21,8 @@ function makeCidrList(cidr) {
|
||||
|
||||
return `############################
|
||||
# Mainland China IPv4 CIDR
|
||||
# Data from vx.link (tmplink @ GitHub)
|
||||
# Last Updated: ${date.getFullYear()}-${date.getUTCMonth() + 1}-${date.getUTCDate()} ${date.getUTCHours()}:${date.getUTCMinutes()}:${date.getUTCSeconds()}
|
||||
# Data from misaka.io (misakaio @ GitHub)
|
||||
# Last Updated: ${date.toISOString()}
|
||||
# Routes: ${cidr.length}
|
||||
############################\n` + cidr.map(i => `IP-CIDR,${i}`).join('\n') + '\n########### END ############\n';
|
||||
};
|
||||
|
||||
64
Build/build-index.html.js
Normal file
64
Build/build-index.html.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const listDir = require('@sukka/listdir');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const rootPath = path.resolve(__dirname, '../');
|
||||
|
||||
(async () => {
|
||||
const list = await listDir(rootPath, {
|
||||
ignoreHidden: true,
|
||||
ignorePattern: /node_modules|Build|.DS_Store|\.(json|html|md|js)|LICENSE/
|
||||
});
|
||||
|
||||
const html = template(list);
|
||||
|
||||
await fs.promises.writeFile(path.join(rootPath, 'index.html'), html, 'utf-8');
|
||||
})();
|
||||
|
||||
/**
|
||||
* @param {string[]} urlList
|
||||
* @returns {string}
|
||||
*/
|
||||
function template(urlList) {
|
||||
const date = new Date();
|
||||
|
||||
return `
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Surge Ruleset Server | Sukka (@SukkaW)</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<link href="https://cdn.skk.moe/favicon.ico" rel="icon" type="image/ico">
|
||||
<link href="https://cdn.skk.moe/favicon/apple-touch-icon.png" rel="apple-touch-icon" sizes="180x180">
|
||||
<link href="https://cdn.skk.moe/favicon/android-chrome-192x192.png" rel="icon" type="image/png" sizes="192x192">
|
||||
<link href="https://cdn.skk.moe/favicon/favicon-32x32.png" rel="icon" type="image/png" sizes="32x32">
|
||||
<link href="https://cdn.skk.moe/favicon/favicon-16x16.png" rel="icon" type="image/png" sizes="16x16">
|
||||
<link href="https://cdn.skk.moe/favicon/safari-pinned-tab.svg" rel="mask-icon" color="#fcfcfc">
|
||||
<meta name="description" content="Sukka 自用的 Surge 规则组">
|
||||
<meta property="og:title" content="Surge Ruleset | Sukka (@SukkaW)">
|
||||
<meta property="og:type" content="Website">
|
||||
<meta property="og:url" content="https://ruleset.skk.moe/">
|
||||
<meta property="og:image" content="https://cdn.skk.moe/favicon/android-chrome-192x192.png">
|
||||
<meta property="og:description" content="Sukka 自用的 Surge 规则组">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<link rel="canonical" href="https://ruleset.skk.moe/">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@1.5.0/css/pico.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<main class="container">
|
||||
<h1>Sukka Surge Ruleset Server</h1>
|
||||
<p>Made by <a href="https://skk.moe">Sukka</a> | <a href="https://github.com/SukkaW/Surge/">Source @ GitHub</a> | Licensed under <a href="https://github.com/SukkaW/Surge/blob/master/LICENSE" target="_blank">AGPL-3.0</a></p>
|
||||
<p>Last Updated: ${date.toISOString()}</p>
|
||||
<hr>
|
||||
<br>
|
||||
<ul>
|
||||
${urlList.sort().map(url => `
|
||||
<li><a href="${url}" target="_blank">${url}</a></li>
|
||||
`).join('')}
|
||||
</ul>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
}
|
||||
@@ -14,7 +14,7 @@ async function processDomainLists(domainListsUrl) {
|
||||
/** @type Set<string> */
|
||||
const domainSets = new Set();
|
||||
/** @type string[] */
|
||||
const domains = (await got(domainListsUrl).text()).split('\n');
|
||||
const domains = (await (await fetch(domainListsUrl)).text()).split('\n');
|
||||
domains.forEach(line => {
|
||||
if (
|
||||
line.startsWith('#')
|
||||
@@ -44,7 +44,7 @@ async function processHosts(hostsUrl, includeAllSubDomain = false) {
|
||||
const domainSets = new Set();
|
||||
|
||||
/** @type string[] */
|
||||
const hosts = (await got(hostsUrl).text()).split('\n');
|
||||
const hosts = (await(await fetch(hostsUrl)).text()).split('\n');
|
||||
hosts.forEach(line => {
|
||||
if (line.includes('#')) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user