From fbaf7629b850d87eea47ed15134174b0b55d7057 Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Mon, 13 Apr 2026 01:47:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(email-generator):=20=E6=9B=B4=E6=96=B0=20C?= =?UTF-8?q?loudflare=20=E9=82=AE=E7=AE=B1=E7=94=9F=E6=88=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E4=BD=BF=E7=94=A8=2010=20=E4=BD=8D=E9=9A=8F?= =?UTF-8?q?=E6=9C=BA=E5=89=8D=E7=BC=80=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++--- background.js | 29 ++++++++++++++++++----------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b120186..33a1a9b 100644 --- a/README.md +++ b/README.md @@ -182,9 +182,10 @@ Cloudflare 模式下,插件不会再调用 Cloudflare API 创建路由。 它现在只做一件事: 1. 根据你当前选中的 `CF 域名` -2. 本地生成一个随机前缀 -3. 直接得到一个类似 `user20260412153000123@example.xyz` 的注册邮箱 -4. 把这个邮箱写入当前流程继续往下跑 +2. 本地生成一个 10 位随机前缀 +3. 前缀由 `6 个小写字母 + 4 个数字` 组成,顺序随机打乱 +4. 直接得到一个类似 `a3b9cd1e2f@example.xyz` 的注册邮箱 +5. 把这个邮箱写入当前流程继续往下跑 也就是说,插件默认认为: diff --git a/background.js b/background.js index 1902e12..3657472 100644 --- a/background.js +++ b/background.js @@ -3027,17 +3027,24 @@ function getEmailGeneratorLabel(generator) { } function generateCloudflareAliasLocalPart() { - const now = new Date(); - const stamp = [ - now.getFullYear(), - String(now.getMonth() + 1).padStart(2, '0'), - String(now.getDate()).padStart(2, '0'), - String(now.getHours()).padStart(2, '0'), - String(now.getMinutes()).padStart(2, '0'), - String(now.getSeconds()).padStart(2, '0'), - ].join(''); - const randomPart = String(Math.floor(Math.random() * 900) + 100); - return `user${stamp}${randomPart}`.toLowerCase(); + const letters = 'abcdefghijklmnopqrstuvwxyz'; + const digits = '0123456789'; + const chars = []; + + for (let i = 0; i < 6; i++) { + chars.push(letters[Math.floor(Math.random() * letters.length)]); + } + + for (let i = 0; i < 4; i++) { + chars.push(digits[Math.floor(Math.random() * digits.length)]); + } + + for (let i = chars.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [chars[i], chars[j]] = [chars[j], chars[i]]; + } + + return chars.join(''); } async function fetchCloudflareEmail(state, options = {}) {