Files
gitea eb872abb89 把 deertools 缺的补齐到 498 个工具 + 首页分类磁贴
- 新增 cat-file / cat-check2 / cat-zip / cat-misc2 / cat-net / cat-final 六个目录文件
- 内置 vendor:qrcode-generator、bcryptjs、marked(均 MIT),server.mjs 放行 /js/vendor/
- 首页加分类磁贴(带数量与说明,点一下筛到该分类),hero 文案区分本地/联网工具
- zip/tar 自写解析与打包,xlsx↔csv/json/html/md,docx/pptx/epub 抽文本,ttf→woff
- 屏幕/色觉/散光/视力/摄像头/GPS/传感器/键盘/双击/轮询率等硬件自测
- 二维码 & WiFi 码 & vCard & bcrypt & Markdown 编辑器
- 我的 IP / IP 归属 / DNS(DoH) / 网速 / 响应测试(标注需联网)
- README/INSTALL 更新:工具数、依赖说明、第六批清单
2026-11-20 15:27:22 +08:00

548 lines
48 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function () {
const { el, panelTitle, copy, toast, bytes, download, downloadText } = DB
const pane = (t, ...k) => { const p = el('div', { class: 'panel' }); if (t) p.append(panelTitle(t)); p.append(...k.filter(Boolean)); return p }
const btn = (l, f, c = '') => el('button', { class: 'btn ' + c, text: l, onclick: f })
const row = (...k) => el('div', { class: 'row' }, ...k)
const kv = (t) => el('div', { class: 'kv-out', text: t || '' })
/* ---------- 二维码(vendor: qrcode-generator, MIT) ---------- */
function qrCanvas(text, size = 260, correct = 'M') {
const qr = window.qrcode(0, correct); qr.addData(text, 'Byte'); qr.make()
const n = qr.getModuleCount(), cell = Math.max(2, Math.floor(size / n)), pad = 4 * cell
const c = el('canvas'); c.width = n * cell + pad * 2; c.height = c.width
const g = c.getContext('2d'); if (!g) return c
g.fillStyle = '#fff'; g.fillRect(0, 0, c.width, c.height); g.fillStyle = '#000'
for (let r = 0; r < n; r++) for (let col = 0; col < n; col++) if (qr.isDark(r, col)) g.fillRect(pad + col * cell, pad + r * cell, cell, cell)
return c
}
DB.tool({ id: 'qrcode', name: '二维码生成', group: 'web', icon: 'grid', desc: '文本/网址转二维码,可下载 PNG', keywords: ['二维码', 'qrcode', '扫码'],
mount(root) {
const inp = el('textarea', { class: 'ta', rows: 3, placeholder: 'https://example.com 或任意文本' })
const lvl = el('select', { class: 'inp' }); [['L', '低(容错 7%)'], ['M', '中(15%)'], ['Q', '较高(25%)'], ['H', '高(30%)']].forEach(([v, t]) => lvl.append(el('option', { value: v, text: t })))
lvl.value = 'M'
const box = el('div', { class: 'qr-box' }); const st = kv('')
const paint = () => { box.textContent = ''; if (!inp.value) return; try { const c = qrCanvas(inp.value, 300, lvl.value); box.append(c); st.textContent = `内容 ${inp.value.length} 字` } catch (e) { st.textContent = '内容太长:' + e.message } }
inp.addEventListener('input', paint); lvl.addEventListener('change', paint)
root.append(pane('二维码生成'), inp, row(lvl, btn('下载 PNG', () => { const c = box.querySelector('canvas'); if (c) c.toBlob((b) => download(b, 'qrcode.png')) }, 'ghost')), box, st)
} })
DB.tool({ id: 'wifi-qr', name: 'WiFi 二维码', group: 'web', icon: 'grid', desc: '生成扫码直连 WiFi 的二维码', keywords: ['wifi', '二维码', '密码'],
mount(root) {
const ssid = el('input', { class: 'inp', placeholder: 'WiFi 名称' })
const pwd = el('input', { class: 'inp', placeholder: '密码(开放网络留空)' })
const enc = el('select', { class: 'inp' }); [['WPA', 'WPA/WPA2'], ['WEP', 'WEP'], ['nopass', '无密码']].forEach(([v, t]) => enc.append(el('option', { value: v, text: t })))
const box = el('div', { class: 'qr-box' })
const esc = (s) => s.replace(/([\\;,:"])/g, '\\$1')
const paint = () => { box.textContent = ''; if (!ssid.value) return
const t = `WIFI:T:${enc.value};S:${esc(ssid.value)};${enc.value === 'nopass' ? '' : 'P:' + esc(pwd.value) + ';'};`
try { box.append(qrCanvas(t, 300)); } catch (e) { box.textContent = e.message } }
;[ssid, pwd].forEach((i) => i.addEventListener('input', paint)); enc.addEventListener('change', paint)
root.append(pane('WiFi 二维码'), ssid, pwd, enc, box, el('p', { class: 'hint', text: '安卓/iOS 相机对着码就能连;注意别把码发给人多的地方。' }))
} })
DB.tool({ id: 'vcard-generator', name: '名片 vCard', group: 'office', icon: 'file', desc: '生成 .vcf,扫码或发给别人直接存联系人', keywords: ['vcf', '名片', '联系人'],
mount(root) {
const f = {}
;[['fn', '姓名'], ['org', '公司'], ['title', '职位'], ['tel', '手机'], ['email', '邮箱'], ['url', '网址'], ['adr', '地址']].forEach(([k, l]) => { f[k] = el('input', { class: 'inp', placeholder: l }) })
const out = el('textarea', { class: 'ta', rows: 8, readonly: true })
const go = () => {
const lines = ['BEGIN:VCARD', 'VERSION:3.0', `FN:${f.fn.value}`, f.org.value && `ORG:${f.org.value}`, f.title.value && `TITLE:${f.title.value}`,
f.tel.value && `TEL;TYPE=CELL:${f.tel.value}`, f.email.value && `EMAIL:${f.email.value}`, f.url.value && `URL:${f.url.value}`, f.adr.value && `ADR:;;${f.adr.value};;;;`, 'END:VCARD']
out.value = lines.filter(Boolean).join('\r\n')
}
Object.values(f).forEach((i) => i.addEventListener('input', go))
root.append(pane('名片 vCard'), ...Object.values(f), out, row(btn('下载 .vcf', () => download(new Blob([out.value], { type: 'text/vcard' }), 'contact.vcf')), btn('复制', () => copy(out.value), 'ghost')))
} })
/* ---------- bcrypt(vendor) ---------- */
DB.tool({ id: 'bcrypt', name: 'bcrypt 哈希', group: 'crypto', icon: 'lock', desc: '生成 / 校验 bcrypt 密码哈希(10 轮)', keywords: ['bcrypt', '密码', '哈希'],
mount(root) {
const pwd = el('input', { class: 'inp', type: 'password', placeholder: '密码' })
const hash = el('input', { class: 'inp', placeholder: '要校验的哈希($2a$...)' })
const out = kv('')
const gen = () => { try { out.textContent = dcodeIO.bcrypt.hashSync(pwd.value || 'x', 10) } catch (e) { out.textContent = e.message } }
const chk = () => { try { out.textContent = dcodeIO.bcrypt.compareSync(pwd.value, hash.value) ? '匹配 ✓' : '不匹配 ✗' } catch (e) { out.textContent = e.message } }
root.append(pane('bcrypt'), pwd, row(btn('生成哈希', gen), btn('校验', chk, 'ghost')), hash, out)
} })
/* ---------- Markdown(vendor: marked) ---------- */
DB.tool({ id: 'markdown-to-html', name: 'Markdown 转 HTML', group: 'text', icon: 'file', desc: '标准 GFM 渲染,可复制或下载', keywords: ['markdown', 'md', 'html'],
mount(root) {
const inp = el('textarea', { class: 'ta', rows: 8, placeholder: '# 标题\n\n- 列表\n- 项目' })
const out = el('textarea', { class: 'ta', rows: 10, readonly: true }); const prev = el('div', { class: 'preview-box' })
const go = () => { try { const html = marked.parse(inp.value); out.value = html; prev.innerHTML = html } catch (e) { out.value = e.message } }
inp.addEventListener('input', go); go()
root.append(pane('Markdown 转 HTML'), inp, row(btn('复制 HTML', () => copy(out.value)), btn('下载 .html', () => downloadText(out.value, 'doc.html'), 'ghost')), prev, out)
} })
DB.tool({ id: 'markdown-editor', name: 'Markdown 编辑器', group: 'text', icon: 'edit', desc: '左写右看,自动存本地', keywords: ['markdown', '编辑器', 'md'],
mount(root) {
const key = 'devbox.md'
const inp = el('textarea', { class: 'ta', rows: 14 }); inp.value = localStorage.getItem(key) || '# 标题\n\n开始写…'
const prev = el('div', { class: 'preview-box' })
const go = () => { localStorage.setItem(key, inp.value); try { prev.innerHTML = marked.parse(inp.value) } catch (e) {} }
inp.addEventListener('input', go); go()
root.append(pane('Markdown 编辑器'), inp, row(btn('复制 Markdown', () => copy(inp.value), 'ghost'), btn('下载 .md', () => downloadText(inp.value, 'note.md'), 'ghost')), prev)
} })
DB.tool({ id: 'markdown-to-word', name: 'Markdown 转 Word', group: 'office', icon: 'file', desc: '导出 .doc(Word/WPS 可编辑)', keywords: ['markdown', 'word', 'doc'],
mount(root) {
const inp = el('textarea', { class: 'ta', rows: 10, placeholder: '# 标题' })
const go = () => { const html = `<html><head><meta charset="utf-8"></head><body style="font-family:宋体;font-size:12pt">` + marked.parse(inp.value) + '</body></html>'
download(new Blob([html], { type: 'application/msword' }), 'doc.doc') }
root.append(pane('Markdown 转 Word'), inp, btn('下载 .doc', go))
} })
/* ---------- 其它生成类 ---------- */
DB.tool({ id: 'rmb-capital', name: '人民币大写', group: 'office', icon: 'edit', desc: '数字转中文大写金额(含角分)', keywords: ['大写', '金额', '人民币'],
mount(root) {
const inp = el('input', { class: 'inp', placeholder: '1234.56' }); const out = kv('')
const D = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
const U = ['', '拾', '佰', '仟'], B = ['', '万', '亿', '万亿']
const conv = (n) => {
if (!isFinite(n)) return '请输入数字'
const neg = n < 0; n = Math.abs(n)
let [i, f] = n.toFixed(2).split('.'); let s = ''
const groups = i.replace(/^0+/, '').match(/\d{1,4}(?=(\d{4})*$)/g) || ['0']
groups.forEach((g, gi) => {
let part = '', zero = false
for (let k = 0; k < g.length; k++) { const d = +g[k]; const pos = g.length - 1 - k
if (d === 0) zero = true
else { if (zero && part) part += '零'; zero = false; part += D[d] + U[pos] }
}
if (part) s += part + B[groups.length - 1 - gi]
})
s = s || '零'
const jiao = +f[0], fen = +f[1]
let tail = ''
if (jiao) tail += D[jiao] + '角'
if (fen) tail += (jiao ? '' : '零') + D[fen] + '分'
if (!jiao && !fen) tail = '整'
return (neg ? '负' : '') + s + '元' + tail
}
const go = () => { out.textContent = conv(parseFloat(inp.value)) }
inp.addEventListener('input', go); go()
root.append(pane('人民币大写'), inp, out, btn('复制', () => copy(out.textContent), 'ghost'))
} })
DB.tool({ id: 'social-image-sizes', name: '各平台图片尺寸', group: 'image', icon: 'image', desc: '各家封面、头图、故事尺寸速查', keywords: ['尺寸', '封面', '比例'],
mount(root) {
const data = [['微信公众号封面', '900 × 383', '2.35:1'], ['公众号首图', '1080 × 1080', '1:1'], ['小红书竖图', '1242 × 1660', '3:4'], ['抖音竖屏', '1080 × 1920', '9:16'], ['B 站封面', '1146 × 717', '16:10'], ['视频号封面', '1080 × 1260', '6:7'], ['知乎封面', '1200 × 675', '16:9'], ['微博配图', '1200 × 1200', '1:1'], ['淘宝主图', '800 × 800', '1:1'], ['朋友圈九宫格', '1080 × 1080', '1:1'], ['YouTube 缩略图', '1280 × 720', '16:9'], ['Instagram 故事', '1080 × 1920', '9:16']]
const t = el('table', { class: 'tbl' }); t.innerHTML = '<tr><th>场景</th><th>像素</th><th>比例</th></tr>' + data.map((r) => `<tr><td>${r[0]}</td><td>${r[1]}</td><td>${r[2]}</td></tr>`).join('')
root.append(pane('各平台图片尺寸'), t)
} })
DB.tool({ id: 'flexbox-playground', name: 'Flex 布局试验场', group: 'web', icon: 'grid', desc: '拖参数看效果,实时出 CSS', keywords: ['flex', 'css', '布局'],
mount(root) {
const dir = el('select', { class: 'inp' }); ['row', 'column', 'row-reverse', 'column-reverse'].forEach((v) => dir.append(el('option', { value: v, text: 'flex-direction: ' + v })))
const just = el('select', { class: 'inp' }); ['flex-start', 'center', 'flex-end', 'space-between', 'space-around', 'space-evenly'].forEach((v) => just.append(el('option', { value: v, text: 'justify-content: ' + v })))
const al = el('select', { class: 'inp' }); ['stretch', 'flex-start', 'center', 'flex-end', 'baseline'].forEach((v) => al.append(el('option', { value: v, text: 'align-items: ' + v })))
const gap = el('input', { type: 'range', min: 0, max: 40, value: 12 })
const box = el('div', { class: 'flexbox-demo' }); [1, 2, 3].forEach((i) => box.append(el('div', { class: 'flexbox-item', text: '项目 ' + i })))
const css = kv('')
const paint = () => { box.style.display = 'flex'; box.style.flexDirection = dir.value; box.style.justifyContent = just.value; box.style.alignItems = al.value; box.style.gap = gap.value + 'px'
css.textContent = `.box { display: flex; flex-direction: ${dir.value}; justify-content: ${just.value}; align-items: ${al.value}; gap: ${gap.value}px; }` }
;[dir, just, al].forEach((s) => s.addEventListener('change', paint)); gap.addEventListener('input', paint); paint()
root.append(pane('Flex 布局试验场'), dir, just, al, gap, box, css, btn('复制 CSS', () => copy(css.textContent), 'ghost'))
} })
DB.tool({ id: 'moments-preview', name: '朋友圈预览', group: 'creator', icon: 'image', desc: '看九宫格文案排版效果', keywords: ['朋友圈', '九宫格', '预览'],
mount(root) {
const inp = el('textarea', { class: 'ta', rows: 3, placeholder: '文案…' })
const n = el('select', { class: 'inp' }); [1, 2, 3, 4, 6, 9].forEach((v) => n.append(el('option', { value: v, text: v + ' 张图' })))
const card = el('div', { class: 'moment-card' }); const grid = el('div', { class: 'moment-grid' })
const paint = () => { card.textContent = ''; grid.textContent = ''
for (let i = 0; i < +n.value; i++) grid.append(el('div', { class: 'moment-cell', text: i + 1 }))
card.append(el('div', { class: 'moment-name', text: '我' }), el('div', { class: 'moment-text', text: inp.value || '文案预览' }), grid) }
inp.addEventListener('input', paint); n.addEventListener('change', paint); paint()
root.append(pane('朋友圈预览'), inp, n, card)
} })
DB.tool({ id: 'badge-generator', name: '标签生成器', group: 'office', icon: 'grid', desc: '生成带编号的标签/胸牌,可打印', keywords: ['标签', '胸牌', '打印'],
mount(root) {
const tpl = el('input', { class: 'inp', value: '参会证\n{name}\nNo.{n}' })
const names = el('textarea', { class: 'ta', rows: 4, placeholder: '每行一个名字' })
const grid = el('div', { class: 'badge-grid' })
const go = () => { grid.textContent = ''
names.value.split('\n').filter((x) => x.trim()).forEach((nm, i) => {
const d = el('div', { class: 'badge' }); d.innerHTML = tpl.value.replace(/\{name\}/g, nm.trim()).replace(/\{n\}/g, String(i + 1).padStart(2, '0')).split('\n').map((l) => `<div>${l}</div>`).join('')
grid.append(d) }) }
names.addEventListener('input', go); tpl.addEventListener('input', go); go()
root.append(pane('标签生成器'), tpl, names, grid, el('p', { class: 'hint', text: 'Ctrl/⌘+P 直接打印,一份 A4 排 8 张。' }))
} })
DB.tool({ id: 'envelope-print', name: '信封打印', group: 'office', icon: 'file', desc: '生成信封版式(收件人/寄件人)', keywords: ['信封', '打印', '地址'],
mount(root) {
const to = el('textarea', { class: 'ta', rows: 3, placeholder: '收件人地址\n姓名 电话' })
const from = el('input', { class: 'inp', placeholder: '寄件人' })
const env = el('div', { class: 'envelope' })
const go = () => { env.textContent = ''; const a = el('div', { class: 'env-to' }); a.textContent = to.value; const b = el('div', { class: 'env-from' }); b.textContent = from.value; env.append(a, b) }
to.addEventListener('input', go); from.addEventListener('input', go); go()
root.append(pane('信封打印'), to, from, env)
} })
DB.tool({ id: 'label-print', name: '快递贴打印', group: 'office', icon: 'file', desc: '生成 10×10cm 面单版式', keywords: ['面单', '快递', '打印'],
mount(root) {
const inp = el('textarea', { class: 'ta', rows: 6, placeholder: '收件人/电话/地址/单号' })
const box = el('div', { class: 'label-sheet' })
const go = () => { box.textContent = ''; box.append(el('pre', { class: 'label-pre', text: inp.value })) }
inp.addEventListener('input', go); go()
root.append(pane('快递贴'), inp, box)
} })
DB.tool({ id: 'letterhead', name: '信纸模板', group: 'office', icon: 'file', desc: '生成带抬头/页脚的公司信纸', keywords: ['信纸', '抬头', '模板'],
mount(root) {
const org = el('input', { class: 'inp', value: '某某公司' })
const foot = el('input', { class: 'inp', value: '地址 · 电话 · 邮箱' })
const body = el('textarea', { class: 'ta', rows: 6, placeholder: '正文…' })
const paper = el('div', { class: 'letter-paper' })
const go = () => { paper.textContent = ''; paper.append(el('div', { class: 'lh-head', text: org.value }), el('div', { class: 'lh-body', text: body.value }), el('div', { class: 'lh-foot', text: foot.value })) }
;[org, foot, body].forEach((i) => i.addEventListener('input', go)); go()
root.append(pane('信纸模板'), org, foot, body, paper)
} })
DB.tool({ id: 'group-maker', name: '随机分组', group: 'random', icon: 'users', desc: '把名单随机分成若干组,可一键复制', keywords: ['分组', '随机', '名单'],
mount(root) {
const names = el('textarea', { class: 'ta', rows: 5, placeholder: '每行一个名字' })
const n = el('input', { type: 'number', class: 'inp', value: 4, min: 2 })
const out = kv('')
const go = () => { const list = names.value.split('\n').map((s) => s.trim()).filter(Boolean).sort(() => Math.random() - .5)
const k = Math.max(2, +n.value || 2); const groups = Array.from({ length: k }, () => [])
list.forEach((v, i) => groups[i % k].push(v))
out.textContent = groups.map((g, i) => `第 ${i + 1} 组(${g.length} 人):${g.join('、')}`).join('\n') }
root.append(pane('随机分组'), names, n, row(btn('分组', go), btn('复制', () => copy(out.textContent), 'ghost')), out)
} })
DB.tool({ id: 'duty-schedule', name: '值日排班', group: 'office', icon: 'calendar', desc: '按名单自动排出每日值班', keywords: ['排班', '值班', '轮值'],
mount(root) {
const names = el('textarea', { class: 'ta', rows: 4, placeholder: '每行一人' })
const days = el('input', { type: 'number', class: 'inp', value: 7 })
const start = el('input', { type: 'date', class: 'inp' }); start.value = new Date().toISOString().slice(0, 10)
const out = kv('')
const go = () => { const list = names.value.split('\n').map((s) => s.trim()).filter(Boolean); if (!list.length) return
const d0 = new Date(start.value || Date.now()); const lines = []
for (let i = 0; i < (+days.value || 7); i++) { const d = new Date(d0.getTime() + i * 86400000); lines.push(`${d.getMonth() + 1}/${d.getDate()} 周${'日一二三四五六'[d.getDay()]} ${list[i % list.length]}`) }
out.textContent = lines.join('\n') }
root.append(pane('值日排班'), names, row(days, start), row(btn('生成', go), btn('复制', () => copy(out.textContent), 'ghost')), out)
} })
DB.tool({ id: 'work-schedule', name: '工作日历', group: 'time', icon: 'calendar', desc: '按上下班时间算工时,排除周末', keywords: ['工时', '打卡', '日历'],
mount(root) {
const month = el('input', { type: 'month', class: 'inp' }); month.value = new Date().toISOString().slice(0, 7)
const inT = el('input', { class: 'inp', value: '09:00' }); const outT = el('input', { class: 'inp', value: '18:00' })
const out = kv('')
const go = () => { const [y, m] = month.value.split('-').map(Number); const days = new Date(y, m, 0).getDate()
let work = 0; const lines = []
for (let d = 1; d <= days; d++) { const dt = new Date(y, m - 1, d); const w = dt.getDay(); const off = w === 0 || w === 6
lines.push(`${m}/${d} 周${'日一二三四五六'[w]} ${off ? '休息' : '上班'}`); if (!off) work++ }
const [h1, m1] = inT.value.split(':').map(Number), [h2, m2] = outT.value.split(':').map(Number)
const perDay = (h2 * 60 + m2 - h1 * 60 - m1) / 60
out.textContent = `本月上班 ${work} 天,每天 ${perDay.toFixed(1)} 小时,合计 ${(work * perDay).toFixed(1)} 小时\n\n` + lines.join('\n') }
;[month, inT, outT].forEach((i) => i.addEventListener('input', go)); go()
root.append(pane('工作日历'), row(month, inT, outT), row(btn('计算', go), btn('复制', () => copy(out.textContent), 'ghost')), out)
} })
DB.tool({ id: 'holiday-schedule', name: '假期日历', group: 'time', icon: 'calendar', desc: '按月看周末与剩余工作日', keywords: ['假期', '周末', '日历'],
mount(root) {
const y = el('input', { type: 'number', class: 'inp', value: new Date().getFullYear() })
const grid = el('div', { class: 'cal-grid' }); const st = kv('')
const go = () => { grid.textContent = ''; let total = 0, rest = 0
for (let m = 0; m < 12; m++) { const days = new Date(+y.value, m + 1, 0).getDate(); const cell = el('div', { class: 'cal-month' })
cell.append(el('div', { class: 'cal-title', text: (m + 1) + ' 月' }))
for (let d = 1; d <= days; d++) { const w = new Date(+y.value, m, d).getDay(); const off = w === 0 || w === 6; if (off) rest++; else total++
cell.append(el('span', { class: 'cal-day' + (off ? ' off' : ''), text: String(d), title: '周' + '日一二三四五六'[w] })) }
grid.append(cell) }
st.textContent = `${y.value} 年:工作日 ${total} 天,休息日 ${rest} 天` }
y.addEventListener('input', go); go()
root.append(pane('假期日历'), y, st, grid)
} })
DB.tool({ id: 'anniversary-display', name: '纪念日倒计时', group: 'time', icon: 'clock', desc: '还有多少天,在一起多久了', keywords: ['纪念日', '倒计时', '天数'],
mount(root) {
const date = el('input', { type: 'date', class: 'inp' }); const label = el('input', { class: 'inp', value: '纪念日' })
const out = kv('')
const go = () => { const d = new Date(date.value || Date.now()); const now = new Date(); const diff = Math.floor((now - d) / 86400000)
const next = new Date(now.getFullYear(), d.getMonth(), d.getDate()); if (next < now) next.setFullYear(now.getFullYear() + 1)
out.textContent = `${label.value}:${d.toLocaleDateString()}\n已经 ${Math.abs(diff)} 天\n下次还有 ${Math.ceil((next - now) / 86400000)} 天` }
;[date, label].forEach((i) => i.addEventListener('input', go)); go()
root.append(pane('纪念日倒计时'), date, label, out)
} })
DB.tool({ id: 'calendar', name: '年历', group: 'time', icon: 'calendar', desc: '一整年的月历,可打印', keywords: ['年历', '日历', '打印'],
mount(root) {
const y = el('input', { type: 'number', class: 'inp', value: new Date().getFullYear() }); const grid = el('div', { class: 'cal-grid' })
const go = () => { grid.textContent = ''
for (let m = 0; m < 12; m++) { const cell = el('div', { class: 'cal-month' }); cell.append(el('div', { class: 'cal-title', text: (m + 1) + ' 月' }))
;['一', '二', '三', '四', '五', '六', '日'].forEach((d) => cell.append(el('span', { class: 'cal-day head', text: d })))
const first = new Date(+y.value, m, 1).getDay(), days = new Date(+y.value, m + 1, 0).getDate()
for (let i = 0; i < (first + 6) % 7; i++) cell.append(el('span', { class: 'cal-day' }))
for (let d = 1; d <= days; d++) { const w = new Date(+y.value, m, d).getDay(); cell.append(el('span', { class: 'cal-day' + (w === 0 || w === 6 ? ' off' : ''), text: String(d) })) }
grid.append(cell) } }
y.addEventListener('input', go); go()
root.append(pane('年历'), y, grid)
} })
DB.tool({ id: 'moyu-calendar', name: '摸鱼日历', group: 'fun', icon: 'sun', desc: '距离下个假期还有几天(估算)', keywords: ['摸鱼', '假期', '还有几天'],
mount(root) {
const today = new Date(); const mk = (m, d) => new Date(today.getFullYear() + (m < today.getMonth() + 1 ? 1 : 0), m - 1, d)
const list = [['元旦', mk(1, 1)], ['春节(估)', mk(2, 10)], ['清明', mk(4, 4)], ['劳动节', mk(5, 1)], ['端午(估)', mk(6, 10)], ['中秋(估)', mk(9, 17)], ['国庆', mk(10, 1)], ['元旦(次年)', new Date(today.getFullYear() + 1, 0, 1)]]
const out = list.map(([n, d]) => { const left = Math.ceil((d - today) / 86400000); return left >= 0 ? `${n}:还有 ${left} 天` : null }).filter(Boolean).join('\n')
root.append(pane('摸鱼日历'), kv(out + '\n\n(法定假期以国务院通知为准,这里按常用日期估算)'))
} })
DB.tool({ id: 'typing-test', name: '打字速度测试', group: 'study', icon: 'keyboard', desc: '60 秒英文/中文打字,算 WPM', keywords: ['打字', '打字速度', 'wpm'],
mount(root) {
const text = 'The quick brown fox jumps over the lazy dog while the sun sets behind the mountain and everything becomes quiet.'
const show = el('div', { class: 'type-text', text }); const inp = el('input', { class: 'inp', placeholder: '照着上面打,开始计时' })
const out = kv(''); let start = 0
inp.addEventListener('input', () => {
if (!start) start = Date.now()
const typed = inp.value; const ok = [...typed].filter((c, i) => c === text[i]).length
const min = (Date.now() - start) / 60000
out.textContent = `已打 ${typed.length} 字,正确 ${ok},错误 ${typed.length - ok}\n速度 ${(typed.length / 5 / min || 0).toFixed(1)} WPM,准确率 ${((ok / typed.length || 0) * 100).toFixed(0)}%`
})
root.append(pane('打字速度测试'), show, inp, out)
} })
DB.tool({ id: 'word-dictation', name: '单词听写', group: 'study', icon: 'book', desc: '浏览器念单词,你拼写', keywords: ['听写', '英语', '单词'],
mount(root) {
const words = ['environment', 'necessary', 'business', 'knowledge', 'beautiful', 'difficult', 'government', 'particular', 'experience', 'important']
let i = 0; const out = kv(''); const inp = el('input', { class: 'inp', placeholder: '拼写听到的单词' })
const say = () => { out.textContent = `第 ${i + 1}/${words.length} 个`; const u = new SpeechSynthesisUtterance(words[i]); u.lang = 'en-US'; speechSynthesis.speak(u) }
const check = () => { const ok = inp.value.trim().toLowerCase() === words[i]; out.textContent += ok ? ' ✓ 正确' : ' ✗ 应该是 ' + words[i]; inp.value = ''; i = (i + 1) % words.length; setTimeout(say, 700) }
root.append(pane('单词听写'), row(btn('念一个', say), btn('检查', check)), inp, out)
} })
DB.tool({ id: 'chinese-dictation', name: '汉字听写', group: 'study', icon: 'book', desc: '念词、你写,练听写', keywords: ['听写', '汉字', '语文'],
mount(root) {
const words = ['忐忑', '蹒跚', '憧憬', '缱绻', '蜿蜒', '踟蹰', '斑驳', '霓虹', '旖旎', '氤氲', '荏苒', '翩跹']
let i = 0; const out = kv(''); const inp = el('input', { class: 'inp', placeholder: '写下听到的词' })
const say = () => { out.textContent = `第 ${i + 1}/${words.length} 个`; const u = new SpeechSynthesisUtterance(words[i]); u.lang = 'zh-CN'; speechSynthesis.speak(u) }
const check = () => { const ok = inp.value.trim() === words[i]; out.textContent += ok ? ' ✓ 对' : ' ✗ 是「' + words[i] + '」'; inp.value = ''; i = (i + 1) % words.length; setTimeout(say, 800) }
root.append(pane('汉字听写'), row(btn('念一个', say), btn('检查', check)), inp, out)
} })
DB.tool({ id: 'english-copybook', name: '英语字帖', group: 'study', icon: 'edit', desc: '四线三格英文描红,可打印', keywords: ['字帖', '英语', '练字'],
mount(root) {
const txt = el('textarea', { class: 'ta', rows: 2, value: 'The quick brown fox jumps over the lazy dog.' })
const box = el('div', { class: 'copybook' })
const go = () => { box.textContent = ''
txt.value.split('').forEach((ch) => { const c = el('div', { class: 'cb-cell' }); c.append(el('span', { class: 'cb-ch', text: ch === ' ' ? '␣' : ch })); box.append(c) }) }
txt.addEventListener('input', go); go()
root.append(pane('英语字帖'), txt, box, el('p', { class: 'hint', text: '打印后沿四线描红练习。' }))
} })
DB.tool({ id: 'morse-trainer', name: '摩斯电码练习', group: 'study', icon: 'music', desc: '听声音练摩斯,看是否听得出字母', keywords: ['摩斯', '听写', '电码'],
mount(root) {
const map = { A: '.-', B: '-...', C: '-.-.', D: '-..', E: '.', F: '..-.', G: '--.', H: '....', I: '..', J: '.---', K: '-.-', L: '.-..', M: '--', N: '-.', O: '---', P: '.--.', Q: '--.-', R: '.-.', S: '...', T: '-', U: '..-', V: '...-', W: '.--', X: '-..-', Y: '-.--', Z: '--..' }
const keys = Object.keys(map); let cur = 'A'; const out = kv(''); const inp = el('input', { class: 'inp', placeholder: '听到什么字母' })
const play = (code) => { const ctx = new (window.AudioContext || window.webkitAudioContext)(); const o = ctx.createOscillator(); const g = ctx.createGain(); o.frequency.value = 700; g.gain.value = .2; o.connect(g); g.connect(ctx.destination)
const t0 = ctx.currentTime; let t = t0
for (const part of code) { const dur = part === '.' ? .08 : .24; o.start(t); o.stop(t + dur); t += dur + .08 }
setTimeout(() => ctx.close(), (t - t0) * 1000 + 300) }
const next = () => { cur = keys[Math.floor(Math.random() * keys.length)]; out.textContent = '听……'; play(map[cur]) }
const check = () => { out.textContent = inp.value.trim().toUpperCase() === cur ? '✓ 对!' : `✗ 是 ${cur}(${map[cur]})`; inp.value = '' }
root.append(pane('摩斯电码练习'), row(btn('播放', next), btn('检查', check)), inp, out)
} })
DB.tool({ id: 'schulte-grid', name: '舒尔特方格', group: 'study', icon: 'grid', desc: '注意力训练,按顺序点数字', keywords: ['注意力', '舒尔特', '训练'],
mount(root) {
const size = el('input', { type: 'number', class: 'inp', value: 5, min: 3, max: 8 })
const grid = el('div', { class: 'sc-grid' }); const out = kv(''); let next = 1, t0 = 0
const start = () => { next = 1; t0 = 0; grid.textContent = ''
const n = Math.min(8, Math.max(3, +size.value || 5)); grid.style.gridTemplateColumns = `repeat(${n},1fr)`
const nums = Array.from({ length: n * n }, (_, i) => i + 1).sort(() => Math.random() - .5)
nums.forEach((v) => { const b = el('button', { class: 'sc-cell', text: String(v) })
b.addEventListener('click', () => { if (v !== next) { out.textContent = '顺序错了,重来'; return }
if (!t0) t0 = Date.now(); next++; b.classList.add('done')
if (next > n * n) out.textContent = `完成!用时 ${((Date.now() - t0) / 1000).toFixed(1)} 秒` })
grid.append(b) }) }
start(); root.append(pane('舒尔特方格'), row(size, btn('重开', start, 'ghost')), out, grid)
} })
DB.tool({ id: 'bubble-pop', name: '捏泡泡', group: 'fun', icon: 'box', desc: '解压小游戏,随便点', keywords: ['解压', '捏泡泡', '放松'],
mount(root) {
const sheet = el('div', { class: 'bubble-sheet' }); const out = kv('已捏 0 个')
let n = 0
for (let i = 0; i < 60; i++) { const b = el('div', { class: 'bubble' }); b.addEventListener('click', () => { if (b.classList.contains('popped')) return; b.classList.add('popped'); n++; out.textContent = '已捏 ' + n + ' 个' }); sheet.append(b) }
root.append(pane('捏泡泡'), out, sheet)
} })
DB.tool({ id: 'campfire', name: '电子篝火', group: 'fun', icon: 'sun', desc: '跳动的火焰 + 柴火噼啪声', keywords: ['篝火', '白噪音', '火焰'],
mount(root) {
const c = el('canvas', { class: 'fire' }); c.width = 480; c.height = 260
const st = kv('点开始,带声音'); let raf = 0, ctxA = null, node = null
const g = c.getContext('2d')
const draw = () => { if (!g) return; g.fillStyle = '#0b0b0f'; g.fillRect(0, 0, 480, 260)
for (let i = 0; i < 60; i++) { const x = 240 + (Math.random() - .5) * 120, y = 200 - Math.random() * 120, r = 6 + Math.random() * 22
const grad = g.createRadialGradient(x, y, 0, x, y, r); grad.addColorStop(0, 'rgba(255,180,60,.8)'); grad.addColorStop(1, 'rgba(255,60,0,0)')
g.fillStyle = grad; g.beginPath(); g.arc(x, y, r, 0, 7); g.fill() }
g.fillStyle = '#2b1a10'; g.fillRect(180, 200, 120, 10)
raf = requestAnimationFrame(draw) }
const start = () => { if (raf) return; draw()
ctxA = new (window.AudioContext || window.webkitAudioContext)(); const len = ctxA.sampleRate * 3; const buf = ctxA.createBuffer(1, len, ctxA.sampleRate); const d = buf.getChannelData(0)
for (let i = 0; i < len; i++) d[i] = Math.random() < 0.0006 ? (Math.random() * 2 - 1) * .7 : (Math.random() - .5) * .03
node = ctxA.createBufferSource(); node.buffer = buf; node.loop = true; node.connect(ctxA.destination); node.start(); st.textContent = '噼啪中…' }
const stop = () => { cancelAnimationFrame(raf); raf = 0; try { node?.stop(); ctxA?.close() } catch (e) {} st.textContent = '已停止' }
root.append(pane('电子篝火'), st, c, row(btn('开始', start), btn('停止', stop, 'ghost')))
} })
DB.tool({ id: 'danmu-wall', name: '弹幕墙', group: 'creator', icon: 'monitor', desc: '输入文字全屏飘过,适合直播弹幕', keywords: ['弹幕', '直播', '全屏'],
mount(root) {
const inp = el('input', { class: 'inp', placeholder: '输入一句弹幕,回车发送' }); const wall = el('div', { class: 'danmu-wall' })
const send = () => { if (!inp.value.trim()) return; const d = el('div', { class: 'danmu-item', text: inp.value.trim() }); d.style.top = Math.random() * 80 + '%'; wall.append(d)
setTimeout(() => d.remove(), 9000); inp.value = '' }
inp.addEventListener('keydown', (e) => { if (e.key === 'Enter') send() })
root.append(pane('弹幕墙'), inp, wall, el('p', { class: 'hint', text: '点右下全屏更带感。' }))
} })
DB.tool({ id: 'handheld-danmu', name: '手举弹幕', group: 'creator', icon: 'monitor', desc: '黑底大字,举给镜头看', keywords: ['举牌', '弹幕', '应援'],
mount(root) {
const inp = el('input', { class: 'inp', value: '加油!' }); const col = el('input', { type: 'color', value: '#FFD400' })
const box = el('div', { class: 'handheld', text: inp.value })
const go = () => { box.textContent = inp.value; box.style.color = col.value }
;[inp, col].forEach((i) => i.addEventListener('input', go))
root.append(pane('手举弹幕'), inp, col, box, btn('全屏', () => box.requestFullscreen?.(), 'ghost'))
} })
DB.tool({ id: 'fake-identity', name: '虚构人设生成', group: 'creator', icon: 'users', desc: '生成完全虚构的写作人设(不对应真人)', keywords: ['人设', '角色', '写作'],
mount(root) {
const out = kv(''); const surnames = ['林', '陈', '沈', '陆', '顾', '江', '苏', '温', '许', '秦'], given = ['亦舟', '行者', '小满', '南舟', '听雪', '知遥']
const jobs = ['独立书店店主', '数据分析师', '植物学研究生', '夜班咖啡师', '插画师', '中学物理老师', '纪录片剪辑', '程序员']
const go = () => { out.textContent = `姓名:${surnames[Math.floor(Math.random() * surnames.length)]}${['小满', '知遥', '亦舟', '南舟', '听雪'][Math.floor(Math.random() * 5)]}\n年龄:${20 + Math.floor(Math.random() * 25)}\n职业:${jobs[Math.floor(Math.random() * jobs.length)]}\n性格:${['话少但靠谱', '急性子热心肠', '慢热、爱观察', '看起来凶其实怕虫子'][Math.floor(Math.random() * 4)]}\n\n(纯虚构,用来写小说/剧本,不对应任何真实人物)` }
go(); root.append(pane('虚构人设'), out, btn('换一个', go))
} })
DB.tool({ id: 'constellation-lookup', name: '星座查询', group: 'fun', icon: 'sun', desc: '按生日查星座、元素与守护星', keywords: ['星座', '生日'],
mount(root) {
const d = el('input', { type: 'date', class: 'inp' }); const out = kv('')
const S = [[1, 20, '摩羯', '土', '土星'], [2, 19, '水瓶', '风', '天王星'], [3, 21, '双鱼', '水', '海王星'], [4, 20, '白羊', '火', '火星'], [5, 21, '金牛', '土', '金星'], [6, 22, '双子', '风', '水星'], [7, 23, '巨蟹', '水', '月亮'], [8, 23, '狮子', '火', '太阳'], [9, 23, '处女', '土', '水星'], [10, 24, '天秤', '风', '金星'], [11, 23, '天蝎', '水', '冥王星'], [12, 22, '射手', '火', '木星']]
const go = () => { const dt = new Date(d.value || Date.now()); const m = dt.getMonth() + 1, day = dt.getDate()
let s = S.find((x, i) => (m === x[0] && day < x[1]) || (m === ((x[0] + 10) % 12) + 1 && day >= S[(i + 1) % 12][1]))
const cur = S.find((x) => x[0] === m); const pick = day < cur[1] ? S[(S.findIndex((x) => x[0] === m) + 11) % 12] : cur
out.textContent = `${m}/${day} 是 ${pick[2]}座\n元素:${pick[3]}象 守护星:${pick[4]}` }
d.addEventListener('input', go); go()
root.append(pane('星座查询'), d, out)
} })
DB.tool({ id: 'dayou-poem', name: '打油诗生成', group: 'fun', icon: 'edit', desc: '四句七字,凑个热闹(纯娱乐)', keywords: ['打油诗', '生成', '顺口溜'],
mount(root) {
const topic = el('input', { class: 'inp', value: '加班' }); const out = kv('')
const tails = ['一场空', '半夜钟', '慢慢熬', '又相逢', '不由人', '梦里游', '笑开颜', '不清闲']
const go = () => { const t = topic.value || '生活'
const l1 = `今日${t}又一天`, l2 = `端起茶杯${tails[Math.floor(Math.random() * 8)]}`, l3 = `莫问前路${tails[Math.floor(Math.random() * 8)]}`, l4 = `且把${t}${tails[Math.floor(Math.random() * 8)]}`
out.textContent = [l1, l2, l3, l4].join('\n') + '\n\n(机器拼的,图一乐)' }
go(); root.append(pane('打油诗'), topic, out, row(btn('再来一首', go), btn('复制', () => copy(out.textContent), 'ghost')))
} })
DB.tool({ id: 'comment-picker', name: '评论抽取', group: 'random', icon: 'users', desc: '从评论里随机抽几条中奖', keywords: ['抽奖', '评论', '抽取'],
mount(root) {
const inp = el('textarea', { class: 'ta', rows: 6, placeholder: '一行一个评论/ID' })
const n = el('input', { type: 'number', class: 'inp', value: 3, min: 1 })
const out = kv('')
const go = () => { const list = inp.value.split('\n').map((s) => s.trim()).filter(Boolean)
out.textContent = [...list].sort(() => Math.random() - .5).slice(0, +n.value || 1).join('\n') }
root.append(pane('评论抽取'), inp, n, row(btn('抽', go), btn('复制', () => copy(out.textContent), 'ghost')), out)
} })
DB.tool({ id: 'live-lottery', name: '抽奖转盘(现场)', group: 'random', icon: 'users', desc: '大屏滚动抽取,回车停', keywords: ['抽奖', '滚动', '现场'],
mount(root) {
const inp = el('textarea', { class: 'ta', rows: 4, placeholder: '每行一个奖品/名字' })
const big = el('div', { class: 'lottery-big', text: '准备' }); const st = kv('')
let timer = 0
const start = () => { const list = inp.value.split('\n').map((s) => s.trim()).filter(Boolean); if (!list.length) return toast('先填名单', true)
clearInterval(timer); timer = setInterval(() => { big.textContent = list[Math.floor(Math.random() * list.length)] }, 60); st.textContent = '滚动中…再点一次停' }
const stop = () => { clearInterval(timer); timer = 0; st.textContent = '中奖:' + big.textContent }
root.append(pane('现场抽奖'), inp, big, row(btn('开始/停止', () => (timer ? stop() : start())), btn('重置', () => { clearInterval(timer); timer = 0; big.textContent = '准备' }, 'ghost')), st)
} })
DB.tool({ id: 'live-vote-board', name: '现场投票板', group: 'random', icon: 'users', desc: '给选项加票,实时柱状图', keywords: ['投票', '计票', '现场'],
mount(root) {
const add = el('input', { class: 'inp', placeholder: '选项名' }); const list = el('div', { class: 'vote-list' }); const st = kv('')
const data = []
const paint = () => { list.textContent = ''; const max = Math.max(1, ...data.map((d) => d.n))
data.forEach((d) => { const row2 = el('div', { class: 'vote-row' }); const bar = el('div', { class: 'vote-bar' }); bar.style.width = (d.n / max * 100) + '%'
row2.append(el('span', { class: 'vote-name', text: d.k }), bar, el('span', { class: 'vote-n', text: d.n }), btn('+1', () => { d.n++; paint() }))
list.append(row2) })
st.textContent = '共 ' + data.reduce((a, d) => a + d.n, 0) + ' 票' }
const addOpt = () => { if (!add.value.trim()) return; data.push({ k: add.value.trim(), n: 0 }); add.value = ''; paint() }
root.append(pane('现场投票板'), row(add, btn('加选项', addOpt)), list, st)
} })
DB.tool({ id: 'jiaobei', name: '掷筊', group: 'fun', icon: 'box', desc: '一平一凸为「圣筊」,仅供参考娱乐', keywords: ['筊', '庙', '占卜'],
mount(root) {
const out = kv('点一下掷')
const go = () => { const a = Math.random() < .5 ? '平' : '凸', b = Math.random() < .5 ? '平' : '凸'
const r = a === b ? (a === '平' ? '笑筊(两平,神明笑而不答)' : '阴筊(两凸,暂不允)') : '圣筊(一平一凸,应允)'
out.textContent = `${a} / ${b} → ${r}` }
root.append(pane('掷筊'), out, btn('掷', go))
} })
DB.tool({ id: 'trivia-quiz', name: '冷知识问答', group: 'fun', icon: 'book', desc: '十道常识题,纯本地', keywords: ['问答', '冷知识', 'quiz'],
mount(root) {
const qs = [['一年有多少个时区?', ['24', '23', '25'], 0], ['光在真空中每秒约走多远?', ['3 万公里', '30 万公里', '300 万公里'], 1], ['人体最小的骨头在哪?', ['耳朵', '鼻子', '手指'], 0], ['世界上面积最大的国家?', ['加拿大', '俄罗斯', '中国'], 1], ['1 海里约等于多少米?', ['1852', '1609', '1000'], 0]]
let i = 0, score = 0; const st = kv(''); const box = el('div')
const render = () => { box.textContent = ''; if (i >= qs.length) { st.textContent = `答对 ${score}/${qs.length} 题`; return }
const [q, opts, ans] = qs[i]; st.textContent = `第 ${i + 1} 题:${q}`
opts.forEach((o, k) => box.append(btn(o, () => { if (k === ans) score++; i++; render() }, 'ghost'))) }
render(); root.append(pane('冷知识问答'), st, box)
} })
DB.tool({ id: 'abacus', name: '算盘', group: 'study', icon: 'grid', desc: '经典算盘,练珠算心算', keywords: ['算盘', '珠算', '心算'],
mount(root) {
const out = kv('读数:0'); let cols = 8
const wrap = el('div', { class: 'abacus' }); const vals = new Array(cols).fill(0)
const paint = () => { wrap.textContent = ''
for (let c = 0; c < cols; c++) { const col = el('div', { class: 'abacus-col' })
const up = el('button', { class: 'bead' + (vals[c] >= 5 ? ' on' : '') }); up.addEventListener('click', () => { vals[c] = vals[c] >= 5 ? vals[c] - 5 : vals[c] + 5; paint() })
col.append(up)
for (let k = 4; k >= 1; k--) { const b = el('button', { class: 'bead' + (vals[c] % 5 >= k ? ' on' : '') }); b.addEventListener('click', () => { const low = vals[c] % 5; vals[c] = Math.floor(vals[c] / 5) * 5 + (low >= k ? k - 1 : k); paint() }); col.append(b) }
wrap.append(col) }
out.textContent = '读数:' + vals.reduce((a, v) => a * 10 + v, 0) }
paint(); root.append(pane('算盘'), out, wrap)
} })
DB.tool({ id: 'plate-location', name: '车牌归属地', group: 'web', icon: 'search', desc: '查车牌号是哪个省市', keywords: ['车牌', '归属地'],
mount(root) {
const PROV = { 京: '北京', 津: '天津', 沪: '上海', 渝: '重庆', 冀: '河北', 豫: '河南', 云: '云南', 辽: '辽宁', 黑: '黑龙江', 湘: '湖南', 皖: '安徽', 鲁: '山东', 新: '新疆', 苏: '江苏', 浙: '浙江', 赣: '江西', 鄂: '湖北', 桂: '广西', 甘: '甘肃', 晋: '山西', 蒙: '内蒙古', 陕: '陕西', 吉: '吉林', 闽: '福建', 贵: '贵州', 粤: '广东', 青: '青海', 藏: '西藏', 川: '四川', 宁: '宁夏', 琼: '海南' }
const CITY = { 京A: '北京市区', 京B: '北京出租', 沪A: '上海市区', 粤A: '广州', 粤B: '深圳', 苏A: '南京', 苏E: '苏州', 浙A: '杭州', 川A: '成都', 鄂A: '武汉', 陕A: '西安', 鲁A: '济南', 豫A: '郑州', 冀A: '石家庄', 闽A: '福州', 湘A: '长沙', 皖A: '合肥', 辽A: '沈阳', 赣A: '南昌', 云A: '昆明' }
const inp = el('input', { class: 'inp', placeholder: '粤B12345' }); const out = kv('')
const go = () => { const s = inp.value.trim().toUpperCase(); if (!s) return
const p = PROV[s[0]]; const key = s.slice(0, 2)
out.textContent = `${s}\n省份:${p || '未知'}\n城市:${CITY[key] || '(只收录常见城市)'}` }
inp.addEventListener('input', go)
root.append(pane('车牌归属地'), inp, out, el('p', { class: 'hint', text: '准确到市需要完整车牌库,这里只做省级和常见城市。' }))
} })
DB.tool({ id: 'stain-removal', name: '污渍处理', group: 'life', icon: 'info', desc: '常见污渍怎么洗(速查)', keywords: ['污渍', '清洗', '衣服'],
mount(root) {
const d = [['血渍', '冷水立即冲,别用热水(会凝固)'], ['油渍', '洗洁精干搓再洗,别先沾水'], ['咖啡茶', '冷水冲,氧净浸泡 30 分钟'], ['口红', '卸妆油先溶解,再正常洗涤'], ['墨汁', '牛奶或酒精轻搓'], ['汗黄', '小苏打+白醋浸泡 2 小时'], ['红酒', '盐吸干后冷水冲,别擦'], ['口香糖', '冰块冻硬后剥落']]
root.append(pane('污渍处理'), el('div', { class: 'kv-out', text: d.map(([a, b]) => `· ${a}:${b}`).join('\n') }))
} })
DB.tool({ id: 'seasonal-fruits', name: '当季水果', group: 'life', icon: 'sun', desc: '按月看当季吃什么划算', keywords: ['水果', '当季', '月份'],
mount(root) {
const m = new Date().getMonth() + 1
const map = { 1: ['橙子', '砂糖橘', '甘蔗', '猕猴桃'], 2: ['草莓', '青枣', '枇杷'], 3: ['草莓', '菠萝', '芒果'], 4: ['菠萝', '樱桃', '枇杷'], 5: ['樱桃', '菠萝', '杏'], 6: ['西瓜', '荔枝', '桃'], 7: ['西瓜', '葡萄', '黄桃'], 8: ['西瓜', '葡萄', '无花果'], 9: ['葡萄', '苹果', '梨'], 10: ['柿子', '石榴', '柚子'], 11: ['柚子', '橘子', '冬枣'], 12: ['砂糖橘', '橙子', '草莓'] }
const out = kv(`${m} 月当季:${map[m].join('、')}\n\n逐月表:\n` + Object.entries(map).map(([k, v]) => `${k} 月:${v.join('、')}`).join('\n'))
root.append(pane('当季水果'), out)
} })
DB.tool({ id: 'torrent-viewer', name: '种子信息查看', group: 'web', icon: 'box', desc: '读 .torrent 的文件列表与哈希(不下载内容)', keywords: ['torrent', '种子', 'bt'],
mount(root) {
const out = kv('')
const bdec = (u8) => { let i = 0
const p = () => { const c = String.fromCharCode(u8[i])
if (c === 'i') { const e = u8.indexOf(58, i); const n = Number(new TextDecoder().decode(u8.subarray(i + 1, u8.indexOf(101, i)))); i = u8.indexOf(101, i) + 1; return n }
if (c === 'l') { i++; const a = []; while (String.fromCharCode(u8[i]) !== 'e') a.push(p()); i++; return a }
if (c === 'd') { i++; const o = {}; while (String.fromCharCode(u8[i]) !== 'e') { const k = p(); o[k] = p() } i++; return o }
const s = u8.indexOf(58, i); const len = Number(new TextDecoder().decode(u8.subarray(i, s))); const v = new TextDecoder().decode(u8.subarray(s + 1, s + 1 + len)); i = s + 1 + len; return v }
return p() }
const run = async (files) => { if (!files[0]) return
try { const u8 = new Uint8Array(await new Promise((r) => { const fr = new FileReader(); fr.onload = () => r(fr.result); fr.readAsArrayBuffer(files[0]) }))
const t = bdec(u8); const info = t.info || {}
const list = (info.files || [{ path: [info.name], length: info.length }]).map((f) => `${bytes(f.length).padStart(9)} ${(f.path || []).join('/')}`)
out.textContent = `名称:${info.name}\n大小:${bytes(info.length || info.files?.reduce((a, f) => a + f.length, 0))}\n分片:${bytes(info['piece length'] || 0)}\n\n` + list.slice(0, 200).join('\n')
} catch (e) { out.textContent = '解析失败:' + e.message } }
root.append(pane('种子信息'), el('input', { type: 'file', class: 'inp', accept: '.torrent' , onchange: (e) => run([...e.target.files]) }), out)
} })
})()