补 14 个工具:格式 / 编码 / 加密 / 图片 / 文本 / 时间

- 新分组「格式」:JSON ↔ YAML、XML ↔ JSON、SQL 美化、JSON ↔ 查询串
- 编码:Gzip 压缩 + CRC32、Cookie ↔ JSON、字符编码套件(Unicode/UTF-8/HEX/全角/罗马/摩斯)
- 加密:RSA 密钥对生成、私钥签名、公钥验签(WebCrypto)
- 图片:压缩、九宫格切图、EXIF 读取
- 文本:提取器(手机号/邮箱/链接/身份证/IP/卡号)、人民币与日期大写
- 时间:番茄钟 / 秒表 / 倒计时
- README 工具数 30 → 44
This commit is contained in:
gitea committed 2026-11-20 14:22:23 +08:00
1 parent f947a682b0
commit 80ecd02bfa
10 files changed
+996 -1

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
/* DevBox · 文本补齐:从一大段文本里抽手机号 / 邮箱 / 链接 / 身份证 / IP / 银行卡 */
(function () {
'use strict'
const { el, panelTitle, copy, toast, onInput } = DB
const btn = (label, fn, cls = '') => el('button', { class: 'btn ' + cls, text: label, onclick: fn })
const pane = (title, right) => { const p = el('div', { class: 'panel' }); if (title) p.append(panelTitle(title, right)); return p }
const ta = (ph, rows) => el('textarea', { class: 'ta', placeholder: ph, rows: rows || 10, spellcheck: 'false' })
const RULES = {
phone: { name: '手机号', re: /(?<!\d)1[3-9]\d{9}(?!\d)/g, hint: '中国大陆 11 位' },
email: { name: '邮箱', re: /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g, hint: '含常见 TLD' },
url: { name: '链接', re: /https?:\/\/[^\s<>"'))】\]]+/g, hint: 'http / https' },
idcard: { name: '身份证', re: /(?<!\d)\d{17}[\dXx](?!\d)/g, hint: '18 位,含 X 结尾' },
ip: { name: 'IP 地址', re: /(?<![\d.])(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}(?![\d.])/g, hint: 'IPv4' },
bank: { name: '银行卡号', re: /(?<!\d)(?:62|4\d|5[1-5])\d{13,17}(?!\d)/g, hint: '16-19 位' },
}
DB.tool({
id: 'text-extract',
name: '文本提取器',
group: 'text',
icon: 'filter',
desc: '从聊天记录、网页源码里批量抓手机号 / 邮箱 / 链接 / 身份证 / IP / 卡号,自动去重',
keywords: ['extract', 'regex', 'email', 'phone', 'url', 'ip', '提取', '手机号', '邮箱'],
mount(root) {
const src = ta('把一整段文本粘进来…', 12)
const picks = new Set(['phone', 'email', 'url'])
const chips = el('div', { class: 'chips' })
const out = el('pre', { class: 'out' })
const counts = el('div', { class: 'hint' })
for (const [k, r] of Object.entries(RULES)) {
const chip = el('button', { class: 'chip-btn' + (picks.has(k) ? ' on' : ''), text: r.name + ' · ' + r.hint })
chip.addEventListener('click', () => {
picks.has(k) ? picks.delete(k) : picks.add(k)
chip.classList.toggle('on', picks.has(k))
run()
})
chips.append(chip)
}
const run = () => {
const text = src.value
if (!text.trim()) { out.textContent = ''; counts.textContent = ''; return }
const blocks = []
let total = 0
for (const k of Object.keys(RULES)) {
if (!picks.has(k)) continue
const found = [...new Set(text.match(RULES[k].re) || [])]
total += found.length
if (found.length) blocks.push(`# ${RULES[k].name}(${found.length})\n` + found.join('\n'))
}
out.textContent = blocks.join('\n\n') || '这些规则都没有匹配到内容'
counts.textContent = `共 ${total} 条,已去重`
}
root.append(
pane('要抓什么', el('div', { class: 'row' }, btn('全选', () => { Object.keys(RULES).forEach((k) => picks.add(k)); root.querySelectorAll('.chip-btn').forEach((c) => c.classList.add('on')); run() }, 'ghost'), btn('只留链接', () => { picks.clear(); picks.add('url'); root.querySelectorAll('.chip-btn').forEach((c, i) => c.classList.toggle('on', Object.keys(RULES)[i] === 'url')); run() }, 'ghost'))),
chips, src, counts, out
)
onInput(src, run, 250)
},
})
})()