From 15494eddbd1a9ef17a8b0385bc2663c12568c3cb Mon Sep 17 00:00:00 2001 From: Artemy Date: Wed, 22 May 2024 17:44:40 +0300 Subject: [PATCH] new look --- README.md | 14 +++++------- index.js | 65 +++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 54 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ca7efd5..148ca55 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ -# instances +# Instances of TXTDot proxies -Instances of TXTDot proxies - -| Name | Base URL | Search | Connection | -| ------------ | -------------------------- | ------- | ---------- | -| Official 1 | | enabled | https | -| Official 2 | | enabled | https | -| Bloatcat | | enabled | https | -| Clovius club | | enabled | https | +- ![search](https://img.shields.io/badge/search-enabled-blue) ![protocol](https://img.shields.io/badge/protocol-https-blue) +- ![search](https://img.shields.io/badge/search-enabled-blue) ![protocol](https://img.shields.io/badge/protocol-https-blue) +- ![search](https://img.shields.io/badge/search-enabled-blue) ![protocol](https://img.shields.io/badge/protocol-https-blue) +- ![search](https://img.shields.io/badge/search-enabled-blue) ![protocol](https://img.shields.io/badge/protocol-https-blue) diff --git a/index.js b/index.js index 7924990..9e16c43 100644 --- a/index.js +++ b/index.js @@ -2,21 +2,54 @@ const fs = require("fs"); const instances = JSON.parse(fs.readFileSync("instances.json", "utf8")); -fs.writeFileSync( - "README.md", - `# instances +function badge(url, label, path) { + return `![${label}](https://img.shields.io/badge/dynamic/json?url=${encodeURIComponent( + url + )}&query=${encodeURIComponent(path)}&label=${encodeURIComponent(label)})`; +} -Instances of TXTDot proxies +function static(label, text) { + return `![${label}](https://img.shields.io/badge/${label}-${text}-blue)`; +} -| Name | Base URL | Search | Connection | -| ---- | -------- | ------ | ---------- | -${instances - .map( - (instance) => - `| ${instance.name} | <${instance.baseUrl}> | ${ - instance.search ? "enabled" : "" - } | ${instance.HTTPS ? "https" : "http"} |` - ) - .join("\n")} -` -); +async function run() { + fs.writeFileSync( + "README.md", + `# Instances of TXTDot proxies + \r${( + await Promise.all( + instances.map(async (instance) => { + if (typeof instance === "string") { + const config_url = instance + "/configuration/json"; + let config = await fetch(config_url).then((res) => res.json()); + + return `- <${instance}> ${badge( + config_url, + "version", + "version" + )} ${badge(config_url, "protocol", "protocol")} ${badge( + config_url, + "searx", + "third_party.searx_url" + )} ${badge(config_url, "webder", "third_party.webder_url")} ${badge( + config_url, + "image compression", + "proxy.img_compress" + )}`; + } else { + return `- <${instance.baseUrl}> ${ + instance.search ? static("search", "enabled") : "" + } ${ + instance.HTTPS + ? static("protocol", "https") + : static("protocol", "http") + }`; + } + }) + ) + ).join("\n")} + ` + ); +} + +run();