diff --git a/background.js b/background.js
index 0525267..c23994e 100644
--- a/background.js
+++ b/background.js
@@ -207,7 +207,14 @@ function normalizeScheduledAutoRunPlan(plan) {
}
function normalizeEmailGenerator(value = '') {
- return String(value || '').trim().toLowerCase() === 'cloudflare' ? 'cloudflare' : 'duck';
+ const normalized = String(value || '').trim().toLowerCase();
+ if (normalized === 'custom' || normalized === 'manual') {
+ return 'custom';
+ }
+ if (normalized === 'cloudflare') {
+ return 'cloudflare';
+ }
+ return 'duck';
}
function normalizePanelMode(value = '') {
@@ -1258,6 +1265,12 @@ function isGeneratedAliasProvider(provider) {
return provider === '2925';
}
+function shouldUseCustomRegistrationEmail(state = {}) {
+ return !isHotmailProvider(state)
+ && !isGeneratedAliasProvider(state.mailProvider)
+ && normalizeEmailGenerator(state.emailGenerator) === 'custom';
+}
+
function buildGeneratedAliasEmail(state) {
const provider = state.mailProvider || '163';
const emailPrefix = (state.emailPrefix || '').trim();
@@ -3073,6 +3086,9 @@ async function handleStepData(step, payload) {
if (localhostPrefix) {
await closeTabsByUrlPrefix(localhostPrefix);
}
+ if (shouldUseCustomRegistrationEmail(latestState) && latestState.email) {
+ await setEmailStateSilently(null);
+ }
break;
}
}
@@ -3358,6 +3374,9 @@ async function executeStepAndWait(step, delayAfter = 2000) {
}
function getEmailGeneratorLabel(generator) {
+ if (generator === 'custom') {
+ return '自定义邮箱';
+ }
return generator === 'cloudflare' ? 'Cloudflare 邮箱' : 'Duck 邮箱';
}
@@ -3426,6 +3445,9 @@ async function fetchDuckEmail(options = {}) {
async function fetchGeneratedEmail(state, options = {}) {
const currentState = state || await getState();
const generator = normalizeEmailGenerator(options.generator ?? currentState.emailGenerator);
+ if (generator === 'custom') {
+ throw new Error('当前邮箱生成方式为自定义邮箱,请直接填写注册邮箱。');
+ }
if (generator === 'cloudflare') {
return fetchCloudflareEmail(currentState, options);
}
@@ -3497,6 +3519,23 @@ async function ensureAutoEmailReady(targetRun, totalRuns, attemptRuns) {
return currentState.email;
}
+ if (shouldUseCustomRegistrationEmail(currentState)) {
+ await addLog(`=== 目标 ${targetRun}/${totalRuns} 轮已暂停:请先填写自定义注册邮箱,然后继续 ===`, 'warn');
+ await broadcastAutoRunStatus('waiting_email', {
+ currentRun: targetRun,
+ totalRuns,
+ attemptRun: attemptRuns,
+ });
+
+ await waitForResume();
+
+ const resumedState = await getState();
+ if (!resumedState.email) {
+ throw new Error('无法继续:当前没有注册邮箱。');
+ }
+ return resumedState.email;
+ }
+
const generator = normalizeEmailGenerator(currentState.emailGenerator);
const generatorLabel = getEmailGeneratorLabel(generator);
let lastError = null;
diff --git a/sidepanel/sidepanel.html b/sidepanel/sidepanel.html
index 699fe95..a24f38a 100644
--- a/sidepanel/sidepanel.html
+++ b/sidepanel/sidepanel.html
@@ -165,6 +165,7 @@
邮箱生成
diff --git a/sidepanel/sidepanel.js b/sidepanel/sidepanel.js
index 40a5f4c..29a5c79 100644
--- a/sidepanel/sidepanel.js
+++ b/sidepanel/sidepanel.js
@@ -1014,7 +1014,9 @@ function applyAutoRunStatus(payload = currentAutoRun) {
inputRunCount.disabled = currentAutoRun.autoRunning;
btnAutoRun.disabled = currentAutoRun.autoRunning;
- btnFetchEmail.disabled = locked || usesGeneratedAliasMailProvider(selectMailProvider.value);
+ btnFetchEmail.disabled = locked
+ || usesGeneratedAliasMailProvider(selectMailProvider.value)
+ || isCustomEmailGeneratorSelected();
inputEmail.disabled = locked;
inputAutoSkipFailures.disabled = scheduled;
@@ -1048,7 +1050,8 @@ function applyAutoRunStatus(payload = currentAutoRun) {
setDefaultAutoRunButton();
inputEmail.disabled = false;
if (!locked) {
- btnFetchEmail.disabled = usesGeneratedAliasMailProvider(selectMailProvider.value);
+ btnFetchEmail.disabled = usesGeneratedAliasMailProvider(selectMailProvider.value)
+ || isCustomEmailGeneratorSelected();
}
break;
}
@@ -1380,10 +1383,26 @@ function syncPasswordField(state) {
}
function getSelectedEmailGenerator() {
- return selectEmailGenerator.value === 'cloudflare' ? 'cloudflare' : 'duck';
+ const generator = String(selectEmailGenerator.value || '').trim().toLowerCase();
+ if (generator === 'custom' || generator === 'manual') {
+ return 'custom';
+ }
+ if (generator === 'cloudflare') {
+ return 'cloudflare';
+ }
+ return 'duck';
}
function getEmailGeneratorUiCopy() {
+ if (getSelectedEmailGenerator() === 'custom') {
+ return {
+ buttonLabel: '自定义邮箱',
+ placeholder: '请填写本轮要使用的注册邮箱',
+ successVerb: '使用',
+ label: '自定义邮箱',
+ };
+ }
+
if (getSelectedEmailGenerator() === 'cloudflare') {
return {
buttonLabel: '生成',
@@ -1401,6 +1420,10 @@ function getEmailGeneratorUiCopy() {
};
}
+function isCustomEmailGeneratorSelected() {
+ return getSelectedEmailGenerator() === 'custom';
+}
+
function getHotmailAccounts(state = latestState) {
return Array.isArray(state?.hotmailAccounts) ? state.hotmailAccounts : [];
}
@@ -1664,6 +1687,7 @@ function updateMailProviderUI() {
const useGeneratedAlias = usesGeneratedAliasMailProvider(selectMailProvider.value);
const useInbucket = selectMailProvider.value === 'inbucket';
const useHotmail = selectMailProvider.value === 'hotmail-api';
+ const useCustomEmail = !useGeneratedAlias && !useHotmail && isCustomEmailGeneratorSelected();
const useEmailGenerator = !useHotmail && !useGeneratedAlias;
updateMailLoginButtonState();
rowEmailPrefix.style.display = useGeneratedAlias ? '' : 'none';
@@ -1698,20 +1722,22 @@ function updateMailProviderUI() {
if (rowHotmailLocalBaseUrl) {
rowHotmailLocalBaseUrl.style.display = useHotmail && hotmailServiceMode === HOTMAIL_SERVICE_MODE_LOCAL ? '' : 'none';
}
- btnFetchEmail.hidden = useHotmail;
+ btnFetchEmail.hidden = useHotmail || useCustomEmail;
inputEmail.readOnly = useHotmail || useGeneratedAlias;
const uiCopy = getEmailGeneratorUiCopy();
inputEmail.placeholder = useHotmail
? '由 Hotmail 账号池自动分配'
: (use2925 ? '步骤 3 自动生成 2925 邮箱并回填' : uiCopy.placeholder);
- btnFetchEmail.disabled = useGeneratedAlias || isAutoRunLockedPhase();
+ btnFetchEmail.disabled = useGeneratedAlias || useCustomEmail || isAutoRunLockedPhase();
if (!btnFetchEmail.disabled) {
btnFetchEmail.textContent = uiCopy.buttonLabel;
}
if (autoHintText) {
autoHintText.textContent = useHotmail
? '请先校验并选择一个 Hotmail 账号'
- : (useGeneratedAlias ? '步骤 3 会自动生成邮箱,无需手动获取' : '先自动获取邮箱,或手动粘贴邮箱后再继续');
+ : (useGeneratedAlias
+ ? '步骤 3 会自动生成邮箱,无需手动获取'
+ : (useCustomEmail ? '请先填写自定义注册邮箱,成功一轮后会自动清空' : '先自动获取邮箱,或手动粘贴邮箱后再继续'));
}
if (useHotmail) {
inputEmail.value = getCurrentHotmailEmail();
@@ -1955,6 +1981,9 @@ function escapeHtml(text) {
async function fetchGeneratedEmail(options = {}) {
const { showFailureToast = true } = options;
const uiCopy = getEmailGeneratorUiCopy();
+ if (isCustomEmailGeneratorSelected()) {
+ throw new Error('当前邮箱生成方式为自定义邮箱,请直接填写注册邮箱。');
+ }
const defaultLabel = uiCopy.buttonLabel;
btnFetchEmail.disabled = true;
btnFetchEmail.textContent = '...';
@@ -2254,6 +2283,10 @@ document.querySelectorAll('.step-btn').forEach(btn => {
} else {
let email = inputEmail.value.trim();
if (!email) {
+ if (isCustomEmailGeneratorSelected()) {
+ showToast('当前邮箱生成方式为自定义邮箱,请先填写注册邮箱后再执行第 3 步。', 'warn');
+ return;
+ }
try {
email = await fetchGeneratedEmail({ showFailureToast: false });
} catch (err) {
@@ -2279,7 +2312,7 @@ document.querySelectorAll('.step-btn').forEach(btn => {
});
btnFetchEmail.addEventListener('click', async () => {
- if (selectMailProvider.value === 'hotmail-api') {
+ if (selectMailProvider.value === 'hotmail-api' || isCustomEmailGeneratorSelected()) {
return;
}
await fetchGeneratedEmail().catch(() => { });
@@ -2691,7 +2724,10 @@ btnAutoRun.addEventListener('click', async () => {
btnAutoContinue.addEventListener('click', async () => {
const email = inputEmail.value.trim();
if (!email) {
- showToast('请先获取或粘贴邮箱。', 'warn');
+ showToast(
+ isCustomEmailGeneratorSelected() ? '请先填写自定义注册邮箱。' : '请先获取或粘贴邮箱。',
+ 'warn'
+ );
return;
}
autoContinueBar.style.display = 'none';