/** * 抽查 custom-brand-icons 与 game-icon-pack no-padding 的 SVG 内容 */ 'use strict'; const https = require('https'); function fetchRaw(url) { return new Promise((resolve, reject) => { const req = https.get(url, { timeout: 25000 }, (res) => { if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { res.resume(); return resolve(fetchRaw(res.headers.location)); } if (res.statusCode !== 200) { reject(new Error('HTTP ' + res.statusCode + ' ' + url)); res.resume(); return; } const chunks = []; res.on('data', (c) => chunks.push(c)); res.on('end', () => resolve(Buffer.concat(chunks).toString('utf8'))); }); req.on('error', reject); }); } (async () => { // 1. custom-brand-icons 抽查:单色还是彩色?viewBox? for (const f of ['cloudflare.svg', 'apple.svg', '2N.svg', 'Hydro-Québec.svg']) { try { const svg = await fetchRaw(`https://cdn.jsdelivr.net/gh/elax46/custom-brand-icons@main/icon-svg/${encodeURIComponent(f)}`); const tag = svg.match(/]*>/); const vm = tag && tag[0].match(/viewBox=["']([^"']+)["']/); const fillCount = (svg.match(/fill="#[0-9a-fA-F]{3,6}"/g) || []).length; const pathCount = (svg.match(/ setTimeout(r, 300)); } // 2. game-icon-pack no-padding 文件名是否唯一 try { const j = JSON.parse(await fetchRaw('https://data.jsdelivr.com/v1/packages/gh/Nieobie/game-icon-pack@main')); const names = []; const walk = (files, prefix) => { for (const f of files || []) { if (f.type === 'file') names.push(f.name.toLowerCase()); else walk(f.files || [], prefix + f.name + '/'); } }; const noPad = j.files.find(f => f.name === 'svg').files.find(d => d.name === 'no-padding'); walk(noPad.files || [], ''); const dup = names.filter((n, i) => names.indexOf(n) !== i); console.log(`\ngame-icon-pack no-padding 文件数: ${names.length} | 重名数: ${dup.length}`, dup.length ? dup.slice(0, 10).join(',') : ''); } catch (e) { console.log('game no-padding: ❌', e.message); } })().catch((e) => { console.error('❌', e.message); process.exit(1); });