|
@@ -212,6 +212,152 @@ const DEFAULT_LUCKMAIL_EMAIL_TYPE = 'ms_graph';
|
|
|
const DISPLAY_TIMEZONE = 'Asia/Shanghai';
|
|
const DISPLAY_TIMEZONE = 'Asia/Shanghai';
|
|
|
const DEFAULT_ACCOUNT_RUN_HISTORY_HELPER_BASE_URL = 'http://127.0.0.1:17373';
|
|
const DEFAULT_ACCOUNT_RUN_HISTORY_HELPER_BASE_URL = 'http://127.0.0.1:17373';
|
|
|
|
|
|
|
|
|
|
+function getManagedAliasUtils() {
|
|
|
|
|
+ return window.MultiPageManagedAliasUtils || null;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function isManagedAliasProvider(provider = selectMailProvider.value) {
|
|
|
|
|
+ const utils = getManagedAliasUtils();
|
|
|
|
|
+ if (utils?.isManagedAliasProvider) {
|
|
|
|
|
+ return utils.isManagedAliasProvider(provider);
|
|
|
|
|
+ }
|
|
|
|
|
+ return [GMAIL_PROVIDER, '2925'].includes(String(provider || '').trim().toLowerCase());
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function parseManagedAliasBaseEmail(rawValue, provider = selectMailProvider.value) {
|
|
|
|
|
+ const utils = getManagedAliasUtils();
|
|
|
|
|
+ if (utils?.parseManagedAliasBaseEmail) {
|
|
|
|
|
+ return utils.parseManagedAliasBaseEmail(rawValue, provider);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function isManagedAliasEmail(value, baseEmail = '', provider = selectMailProvider.value) {
|
|
|
|
|
+ const utils = getManagedAliasUtils();
|
|
|
|
|
+ if (utils?.isManagedAliasEmail) {
|
|
|
|
|
+ return utils.isManagedAliasEmail(value, provider, baseEmail);
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function getManagedAliasProviderUiCopy(provider = selectMailProvider.value) {
|
|
|
|
|
+ const utils = getManagedAliasUtils();
|
|
|
|
|
+ if (utils?.getManagedAliasProviderUiCopy) {
|
|
|
|
|
+ return utils.getManagedAliasProviderUiCopy(provider);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (String(provider || '').trim().toLowerCase() === GMAIL_PROVIDER) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ baseLabel: 'Gmail 原邮箱',
|
|
|
|
|
+ basePlaceholder: '例如 yourname@gmail.com',
|
|
|
|
|
+ buttonLabel: '生成',
|
|
|
|
|
+ successVerb: '生成',
|
|
|
|
|
+ label: 'Gmail +tag 邮箱',
|
|
|
|
|
+ placeholder: '点击生成 Gmail +tag 邮箱,或手动填写完整邮箱',
|
|
|
|
|
+ hint: '先填写 Gmail 原邮箱后点“生成”,也可以直接手动填写完整的 Gmail 邮箱。',
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ if (String(provider || '').trim().toLowerCase() === '2925') {
|
|
|
|
|
+ return {
|
|
|
|
|
+ baseLabel: '2925 基邮箱',
|
|
|
|
|
+ basePlaceholder: '例如 yourname@2925.com',
|
|
|
|
|
+ buttonLabel: '生成',
|
|
|
|
|
+ successVerb: '生成',
|
|
|
|
|
+ label: '2925 邮箱',
|
|
|
|
|
+ placeholder: '点击生成 2925 邮箱,或手动填写完整邮箱',
|
|
|
|
|
+ hint: '先填写 2925 基邮箱后点“生成”,也可以直接手动填写完整的 2925 邮箱。',
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function getManagedAliasBaseEmailKey(provider = selectMailProvider.value) {
|
|
|
|
|
+ const normalizedProvider = String(provider || '').trim().toLowerCase();
|
|
|
|
|
+ if (normalizedProvider === GMAIL_PROVIDER) {
|
|
|
|
|
+ return 'gmailBaseEmail';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (normalizedProvider === '2925') {
|
|
|
|
|
+ return 'mail2925BaseEmail';
|
|
|
|
|
+ }
|
|
|
|
|
+ return '';
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function getManagedAliasBaseEmailForProvider(provider = selectMailProvider.value, state = latestState) {
|
|
|
|
|
+ const key = getManagedAliasBaseEmailKey(provider);
|
|
|
|
|
+ if (!key) {
|
|
|
|
|
+ return '';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const providerValue = String(state?.[key] || '').trim();
|
|
|
|
|
+ if (providerValue) {
|
|
|
|
|
+ return providerValue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const legacyEmailPrefix = String(state?.emailPrefix || '').trim();
|
|
|
|
|
+ return parseManagedAliasBaseEmail(legacyEmailPrefix, provider) ? legacyEmailPrefix : '';
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function buildManagedAliasBaseEmailPayload(state = latestState) {
|
|
|
|
|
+ const payload = {
|
|
|
|
|
+ gmailBaseEmail: String(state?.gmailBaseEmail || '').trim(),
|
|
|
|
|
+ mail2925BaseEmail: String(state?.mail2925BaseEmail || '').trim(),
|
|
|
|
|
+ emailPrefix: '',
|
|
|
|
|
+ };
|
|
|
|
|
+ const key = getManagedAliasBaseEmailKey();
|
|
|
|
|
+ if (key) {
|
|
|
|
|
+ payload[key] = inputEmailPrefix.value.trim();
|
|
|
|
|
+ }
|
|
|
|
|
+ return payload;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function syncManagedAliasBaseEmailDraftFromInput(provider = selectMailProvider.value) {
|
|
|
|
|
+ const key = getManagedAliasBaseEmailKey(provider);
|
|
|
|
|
+ if (!key) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ syncLatestState({ [key]: inputEmailPrefix.value.trim() });
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function setManagedAliasBaseEmailInputForProvider(provider = selectMailProvider.value, state = latestState) {
|
|
|
|
|
+ inputEmailPrefix.value = getManagedAliasBaseEmailForProvider(provider, state);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function getCurrentRegistrationEmailUiCopy() {
|
|
|
|
|
+ if (isCustomMailProvider()) {
|
|
|
|
|
+ return getCustomMailProviderUiCopy();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isManagedAliasProvider()) {
|
|
|
|
|
+ return getManagedAliasProviderUiCopy();
|
|
|
|
|
+ }
|
|
|
|
|
+ return getEmailGeneratorUiCopy();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function isCurrentRegistrationEmailCompatible(email = inputEmail.value.trim(), provider = selectMailProvider.value, state = latestState) {
|
|
|
|
|
+ if (!isManagedAliasProvider(provider) || !email) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ const baseEmail = getManagedAliasBaseEmailForProvider(provider, state);
|
|
|
|
|
+ return isManagedAliasEmail(email, baseEmail, provider);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function validateCurrentRegistrationEmail(email = inputEmail.value.trim(), options = {}) {
|
|
|
|
|
+ const { showToastOnFailure = false } = options;
|
|
|
|
|
+ if (isCurrentRegistrationEmailCompatible(email)) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (showToastOnFailure) {
|
|
|
|
|
+ const uiCopy = getManagedAliasProviderUiCopy();
|
|
|
|
|
+ const baseEmail = getManagedAliasBaseEmailForProvider();
|
|
|
|
|
+ showToast(
|
|
|
|
|
+ baseEmail
|
|
|
|
|
+ ? `当前邮箱服务为“${uiCopy?.label || '别名邮箱'}”,注册邮箱需与 ${uiCopy?.baseLabel || '基邮箱'} 对应。`
|
|
|
|
|
+ : `当前邮箱服务为“${uiCopy?.label || '别名邮箱'}”,请直接填写完整邮箱,或先填写基邮箱后点击“生成”。`,
|
|
|
|
|
+ 'warn'
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
let latestState = null;
|
|
let latestState = null;
|
|
|
let currentAutoRun = {
|
|
let currentAutoRun = {
|
|
|
autoRunning: false,
|
|
autoRunning: false,
|
|
@@ -320,12 +466,7 @@ const LOG_LEVEL_LABELS = {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
function usesGeneratedAliasMailProvider(provider, mail2925Mode = getSelectedMail2925Mode()) {
|
|
function usesGeneratedAliasMailProvider(provider, mail2925Mode = getSelectedMail2925Mode()) {
|
|
|
- const normalizedProvider = String(provider || '').trim().toLowerCase();
|
|
|
|
|
- if (normalizedProvider === GMAIL_PROVIDER) {
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- return normalizedProvider === '2925'
|
|
|
|
|
- && normalizeMail2925Mode(mail2925Mode) === MAIL_2925_MODE_PROVIDE;
|
|
|
|
|
|
|
+ return isManagedAliasProvider(provider);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function parseGmailBaseEmail(rawValue = '') {
|
|
function parseGmailBaseEmail(rawValue = '') {
|
|
@@ -1146,7 +1287,7 @@ function collectSettingsPayload() {
|
|
|
icloudHostPreference: selectIcloudHostPreference?.value || 'auto',
|
|
icloudHostPreference: selectIcloudHostPreference?.value || 'auto',
|
|
|
accountRunHistoryTextEnabled: Boolean(inputAccountRunHistoryTextEnabled?.checked),
|
|
accountRunHistoryTextEnabled: Boolean(inputAccountRunHistoryTextEnabled?.checked),
|
|
|
accountRunHistoryHelperBaseUrl: normalizeAccountRunHistoryHelperBaseUrlValue(inputAccountRunHistoryHelperBaseUrl?.value),
|
|
accountRunHistoryHelperBaseUrl: normalizeAccountRunHistoryHelperBaseUrlValue(inputAccountRunHistoryHelperBaseUrl?.value),
|
|
|
- emailPrefix: inputEmailPrefix.value.trim(),
|
|
|
|
|
|
|
+ ...buildManagedAliasBaseEmailPayload(),
|
|
|
inbucketHost: inputInbucketHost.value.trim(),
|
|
inbucketHost: inputInbucketHost.value.trim(),
|
|
|
inbucketMailbox: inputInbucketMailbox.value.trim(),
|
|
inbucketMailbox: inputInbucketMailbox.value.trim(),
|
|
|
hotmailServiceMode: getSelectedHotmailServiceMode(),
|
|
hotmailServiceMode: getSelectedHotmailServiceMode(),
|
|
@@ -1409,7 +1550,6 @@ function applyAutoRunStatus(payload = currentAutoRun) {
|
|
|
inputRunCount.disabled = currentAutoRun.autoRunning;
|
|
inputRunCount.disabled = currentAutoRun.autoRunning;
|
|
|
btnAutoRun.disabled = currentAutoRun.autoRunning;
|
|
btnAutoRun.disabled = currentAutoRun.autoRunning;
|
|
|
btnFetchEmail.disabled = locked
|
|
btnFetchEmail.disabled = locked
|
|
|
- || usesGeneratedAliasMailProvider(selectMailProvider.value)
|
|
|
|
|
|| isCustomMailProvider();
|
|
|| isCustomMailProvider();
|
|
|
inputEmail.disabled = locked;
|
|
inputEmail.disabled = locked;
|
|
|
inputAutoSkipFailures.disabled = scheduled;
|
|
inputAutoSkipFailures.disabled = scheduled;
|
|
@@ -1448,8 +1588,7 @@ function applyAutoRunStatus(payload = currentAutoRun) {
|
|
|
setDefaultAutoRunButton();
|
|
setDefaultAutoRunButton();
|
|
|
inputEmail.disabled = false;
|
|
inputEmail.disabled = false;
|
|
|
if (!locked) {
|
|
if (!locked) {
|
|
|
- btnFetchEmail.disabled = usesGeneratedAliasMailProvider(selectMailProvider.value)
|
|
|
|
|
- || isCustomMailProvider();
|
|
|
|
|
|
|
+ btnFetchEmail.disabled = isCustomMailProvider();
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -1562,7 +1701,7 @@ function applySettingsState(state) {
|
|
|
if (inputAccountRunHistoryHelperBaseUrl) {
|
|
if (inputAccountRunHistoryHelperBaseUrl) {
|
|
|
inputAccountRunHistoryHelperBaseUrl.value = normalizeAccountRunHistoryHelperBaseUrlValue(state?.accountRunHistoryHelperBaseUrl);
|
|
inputAccountRunHistoryHelperBaseUrl.value = normalizeAccountRunHistoryHelperBaseUrlValue(state?.accountRunHistoryHelperBaseUrl);
|
|
|
}
|
|
}
|
|
|
- inputEmailPrefix.value = state?.emailPrefix || '';
|
|
|
|
|
|
|
+ setManagedAliasBaseEmailInputForProvider(restoredMailProvider, state);
|
|
|
inputInbucketHost.value = state?.inbucketHost || '';
|
|
inputInbucketHost.value = state?.inbucketHost || '';
|
|
|
inputInbucketMailbox.value = state?.inbucketMailbox || '';
|
|
inputInbucketMailbox.value = state?.inbucketMailbox || '';
|
|
|
setHotmailServiceMode(state?.hotmailServiceMode);
|
|
setHotmailServiceMode(state?.hotmailServiceMode);
|
|
@@ -2066,33 +2205,28 @@ function isCurrentEmailManagedByGeneratedAlias(
|
|
|
|
|
|
|
|
const inputEmailValue = String(inputEmail.value || '').trim().toLowerCase();
|
|
const inputEmailValue = String(inputEmail.value || '').trim().toLowerCase();
|
|
|
const stateEmailValue = String(state?.email || '').trim().toLowerCase();
|
|
const stateEmailValue = String(state?.email || '').trim().toLowerCase();
|
|
|
-
|
|
|
|
|
- if (normalizedProvider === GMAIL_PROVIDER) {
|
|
|
|
|
- const baseEmail = String(state?.emailPrefix || inputEmailPrefix.value || '').trim();
|
|
|
|
|
- return isManagedGmailAlias(inputEmailValue, baseEmail) || isManagedGmailAlias(stateEmailValue, baseEmail);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (normalizedProvider === '2925') {
|
|
|
|
|
- return inputEmailValue.endsWith('@2925.com') || stateEmailValue.endsWith('@2925.com');
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ const baseEmail = getManagedAliasBaseEmailForProvider(normalizedProvider, state);
|
|
|
|
|
+ return isManagedAliasEmail(inputEmailValue, baseEmail, normalizedProvider)
|
|
|
|
|
+ || isManagedAliasEmail(stateEmailValue, baseEmail, normalizedProvider);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function maybeClearGeneratedAliasAfterEmailPrefixChange() {
|
|
async function maybeClearGeneratedAliasAfterEmailPrefixChange() {
|
|
|
const provider = selectMailProvider.value;
|
|
const provider = selectMailProvider.value;
|
|
|
- const mail2925Mode = latestState?.mail2925Mode;
|
|
|
|
|
- if (!usesGeneratedAliasMailProvider(provider, mail2925Mode)) {
|
|
|
|
|
|
|
+ if (!usesGeneratedAliasMailProvider(provider, latestState?.mail2925Mode)) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const previousPrefix = String(latestState?.emailPrefix || '').trim();
|
|
|
|
|
|
|
+ const previousPrefix = getManagedAliasBaseEmailForProvider(provider, latestState);
|
|
|
const nextPrefix = inputEmailPrefix.value.trim();
|
|
const nextPrefix = inputEmailPrefix.value.trim();
|
|
|
if (previousPrefix === nextPrefix) {
|
|
if (previousPrefix === nextPrefix) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!isCurrentEmailManagedByGeneratedAlias(provider, latestState, mail2925Mode)) {
|
|
|
|
|
|
|
+ if (!previousPrefix) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!isCurrentEmailManagedByGeneratedAlias(provider, latestState, latestState?.mail2925Mode)) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2123,9 +2257,11 @@ function updateMailProviderUI() {
|
|
|
const useIcloudProvider = isIcloudMailProvider();
|
|
const useIcloudProvider = isIcloudMailProvider();
|
|
|
const useEmailGenerator = !useHotmail && !useLuckmail && !useGeneratedAlias && !useCustomEmail;
|
|
const useEmailGenerator = !useHotmail && !useLuckmail && !useGeneratedAlias && !useCustomEmail;
|
|
|
const useCloudflareTempEmailProvider = selectMailProvider.value === 'cloudflare-temp-email';
|
|
const useCloudflareTempEmailProvider = selectMailProvider.value === 'cloudflare-temp-email';
|
|
|
|
|
+ const aliasUiCopy = useGeneratedAlias ? getManagedAliasProviderUiCopy(selectMailProvider.value) : null;
|
|
|
|
|
+ const uiCopy = getCurrentRegistrationEmailUiCopy();
|
|
|
updateMailLoginButtonState();
|
|
updateMailLoginButtonState();
|
|
|
if (rowMail2925Mode) {
|
|
if (rowMail2925Mode) {
|
|
|
- rowMail2925Mode.style.display = use2925 ? '' : 'none';
|
|
|
|
|
|
|
+ rowMail2925Mode.style.display = 'none';
|
|
|
}
|
|
}
|
|
|
rowEmailPrefix.style.display = useGeneratedAlias ? '' : 'none';
|
|
rowEmailPrefix.style.display = useGeneratedAlias ? '' : 'none';
|
|
|
const hotmailServiceMode = getSelectedHotmailServiceMode();
|
|
const hotmailServiceMode = getSelectedHotmailServiceMode();
|
|
@@ -2184,6 +2320,8 @@ function updateMailProviderUI() {
|
|
|
labelEmailPrefix.textContent = 'Gmail 原邮箱';
|
|
labelEmailPrefix.textContent = 'Gmail 原邮箱';
|
|
|
inputEmailPrefix.placeholder = '例如 yourname@gmail.com';
|
|
inputEmailPrefix.placeholder = '例如 yourname@gmail.com';
|
|
|
}
|
|
}
|
|
|
|
|
+ labelEmailPrefix.textContent = aliasUiCopy?.baseLabel || labelEmailPrefix.textContent;
|
|
|
|
|
+ inputEmailPrefix.placeholder = aliasUiCopy?.basePlaceholder || inputEmailPrefix.placeholder;
|
|
|
if (rowHotmailServiceMode) {
|
|
if (rowHotmailServiceMode) {
|
|
|
rowHotmailServiceMode.style.display = useHotmail ? '' : 'none';
|
|
rowHotmailServiceMode.style.display = useHotmail ? '' : 'none';
|
|
|
}
|
|
}
|
|
@@ -2194,8 +2332,7 @@ function updateMailProviderUI() {
|
|
|
rowHotmailLocalBaseUrl.style.display = useHotmail && hotmailServiceMode === HOTMAIL_SERVICE_MODE_LOCAL ? '' : 'none';
|
|
rowHotmailLocalBaseUrl.style.display = useHotmail && hotmailServiceMode === HOTMAIL_SERVICE_MODE_LOCAL ? '' : 'none';
|
|
|
}
|
|
}
|
|
|
btnFetchEmail.hidden = useHotmail || useLuckmail || useCustomEmail;
|
|
btnFetchEmail.hidden = useHotmail || useLuckmail || useCustomEmail;
|
|
|
- inputEmail.readOnly = useHotmail || useLuckmail || useGeneratedAlias;
|
|
|
|
|
- const uiCopy = useCustomEmail ? getCustomMailProviderUiCopy() : getEmailGeneratorUiCopy();
|
|
|
|
|
|
|
+ inputEmail.readOnly = useHotmail || useLuckmail;
|
|
|
inputEmail.placeholder = useHotmail
|
|
inputEmail.placeholder = useHotmail
|
|
|
? '由 Hotmail 账号池自动分配'
|
|
? '由 Hotmail 账号池自动分配'
|
|
|
: (useLuckmail
|
|
: (useLuckmail
|
|
@@ -2204,7 +2341,10 @@ function updateMailProviderUI() {
|
|
|
if (useGmail && useGeneratedAlias) {
|
|
if (useGmail && useGeneratedAlias) {
|
|
|
inputEmail.placeholder = '步骤 3 自动生成 Gmail +tag 邮箱并回填';
|
|
inputEmail.placeholder = '步骤 3 自动生成 Gmail +tag 邮箱并回填';
|
|
|
}
|
|
}
|
|
|
- btnFetchEmail.disabled = useGeneratedAlias || useLuckmail || useCustomEmail || isAutoRunLockedPhase();
|
|
|
|
|
|
|
+ if (!useHotmail && !useLuckmail) {
|
|
|
|
|
+ inputEmail.placeholder = uiCopy.placeholder;
|
|
|
|
|
+ }
|
|
|
|
|
+ btnFetchEmail.disabled = useLuckmail || useCustomEmail || isAutoRunLockedPhase();
|
|
|
if (!btnFetchEmail.disabled) {
|
|
if (!btnFetchEmail.disabled) {
|
|
|
btnFetchEmail.textContent = uiCopy.buttonLabel;
|
|
btnFetchEmail.textContent = uiCopy.buttonLabel;
|
|
|
}
|
|
}
|
|
@@ -2220,6 +2360,9 @@ function updateMailProviderUI() {
|
|
|
if (autoHintText && useGmail && useGeneratedAlias) {
|
|
if (autoHintText && useGmail && useGeneratedAlias) {
|
|
|
autoHintText.textContent = '请先填写 Gmail 原邮箱,步骤 3 会自动生成 Gmail +tag 地址';
|
|
autoHintText.textContent = '请先填写 Gmail 原邮箱,步骤 3 会自动生成 Gmail +tag 地址';
|
|
|
}
|
|
}
|
|
|
|
|
+ if (autoHintText && useGeneratedAlias && aliasUiCopy?.hint) {
|
|
|
|
|
+ autoHintText.textContent = aliasUiCopy.hint;
|
|
|
|
|
+ }
|
|
|
if (autoHintText && showCloudflareTempEmailReceiveMailbox) {
|
|
if (autoHintText && showCloudflareTempEmailReceiveMailbox) {
|
|
|
autoHintText.textContent = '若注册邮箱会转发到 Cloudflare Temp Email,请在“邮件接收”中填写实际接收转发邮件的邮箱。';
|
|
autoHintText.textContent = '若注册邮箱会转发到 Cloudflare Temp Email,请在“邮件接收”中填写实际接收转发邮件的邮箱。';
|
|
|
}
|
|
}
|
|
@@ -2711,7 +2854,7 @@ function escapeHtml(text) {
|
|
|
|
|
|
|
|
async function fetchGeneratedEmail(options = {}) {
|
|
async function fetchGeneratedEmail(options = {}) {
|
|
|
const { showFailureToast = true } = options;
|
|
const { showFailureToast = true } = options;
|
|
|
- const uiCopy = getEmailGeneratorUiCopy();
|
|
|
|
|
|
|
+ const uiCopy = getCurrentRegistrationEmailUiCopy();
|
|
|
if (isCustomMailProvider()) {
|
|
if (isCustomMailProvider()) {
|
|
|
throw new Error('当前邮箱服务为自定义邮箱,请直接填写注册邮箱。');
|
|
throw new Error('当前邮箱服务为自定义邮箱,请直接填写注册邮箱。');
|
|
|
}
|
|
}
|
|
@@ -2726,6 +2869,8 @@ async function fetchGeneratedEmail(options = {}) {
|
|
|
payload: {
|
|
payload: {
|
|
|
generateNew: true,
|
|
generateNew: true,
|
|
|
generator: selectEmailGenerator.value,
|
|
generator: selectEmailGenerator.value,
|
|
|
|
|
+ mailProvider: selectMailProvider.value,
|
|
|
|
|
+ ...buildManagedAliasBaseEmailPayload(),
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -3108,7 +3253,7 @@ stepsList?.addEventListener('click', async (event) => {
|
|
|
if (response?.error) {
|
|
if (response?.error) {
|
|
|
throw new Error(response.error);
|
|
throw new Error(response.error);
|
|
|
}
|
|
}
|
|
|
- } else if (usesGeneratedAliasMailProvider(selectMailProvider.value)) {
|
|
|
|
|
|
|
+ } else if (false && usesGeneratedAliasMailProvider(selectMailProvider.value)) {
|
|
|
const emailPrefix = inputEmailPrefix.value.trim();
|
|
const emailPrefix = inputEmailPrefix.value.trim();
|
|
|
if (!emailPrefix) {
|
|
if (!emailPrefix) {
|
|
|
showToast(selectMailProvider.value === GMAIL_PROVIDER ? '请先填写 Gmail 原邮箱。' : '请先填写 2925 邮箱前缀。', 'warn');
|
|
showToast(selectMailProvider.value === GMAIL_PROVIDER ? '请先填写 Gmail 原邮箱。' : '请先填写 2925 邮箱前缀。', 'warn');
|
|
@@ -3132,6 +3277,9 @@ stepsList?.addEventListener('click', async (event) => {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!validateCurrentRegistrationEmail(email, { showToastOnFailure: true })) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
const response = await chrome.runtime.sendMessage({ type: 'EXECUTE_STEP', source: 'sidepanel', payload: { step, email } });
|
|
const response = await chrome.runtime.sendMessage({ type: 'EXECUTE_STEP', source: 'sidepanel', payload: { step, email } });
|
|
|
if (response?.error) {
|
|
if (response?.error) {
|
|
|
throw new Error(response.error);
|
|
throw new Error(response.error);
|
|
@@ -3450,6 +3598,9 @@ inputEmail.addEventListener('change', async () => {
|
|
|
inputEmail.value = email;
|
|
inputEmail.value = email;
|
|
|
try {
|
|
try {
|
|
|
if (email) {
|
|
if (email) {
|
|
|
|
|
+ if (!validateCurrentRegistrationEmail(email, { showToastOnFailure: true })) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
const response = await chrome.runtime.sendMessage({ type: 'SAVE_EMAIL', source: 'sidepanel', payload: { email } });
|
|
const response = await chrome.runtime.sendMessage({ type: 'SAVE_EMAIL', source: 'sidepanel', payload: { email } });
|
|
|
if (response?.error) {
|
|
if (response?.error) {
|
|
|
throw new Error(response.error);
|
|
throw new Error(response.error);
|
|
@@ -3516,6 +3667,8 @@ selectMailProvider.addEventListener('change', async () => {
|
|
|
const previousProvider = latestState?.mailProvider || '';
|
|
const previousProvider = latestState?.mailProvider || '';
|
|
|
const previousMail2925Mode = latestState?.mail2925Mode;
|
|
const previousMail2925Mode = latestState?.mail2925Mode;
|
|
|
const nextProvider = selectMailProvider.value;
|
|
const nextProvider = selectMailProvider.value;
|
|
|
|
|
+ syncManagedAliasBaseEmailDraftFromInput(previousProvider);
|
|
|
|
|
+ setManagedAliasBaseEmailInputForProvider(nextProvider, latestState);
|
|
|
updateMailProviderUI();
|
|
updateMailProviderUI();
|
|
|
const leavingHotmail = previousProvider === 'hotmail-api'
|
|
const leavingHotmail = previousProvider === 'hotmail-api'
|
|
|
&& nextProvider !== 'hotmail-api'
|
|
&& nextProvider !== 'hotmail-api'
|
|
@@ -3694,11 +3847,13 @@ inputSub2ApiGroup.addEventListener('blur', () => {
|
|
|
|
|
|
|
|
inputEmailPrefix.addEventListener('input', () => {
|
|
inputEmailPrefix.addEventListener('input', () => {
|
|
|
maybeClearGeneratedAliasAfterEmailPrefixChange().catch(() => { });
|
|
maybeClearGeneratedAliasAfterEmailPrefixChange().catch(() => { });
|
|
|
|
|
+ syncManagedAliasBaseEmailDraftFromInput();
|
|
|
markSettingsDirty(true);
|
|
markSettingsDirty(true);
|
|
|
scheduleSettingsAutoSave();
|
|
scheduleSettingsAutoSave();
|
|
|
});
|
|
});
|
|
|
inputEmailPrefix.addEventListener('blur', () => {
|
|
inputEmailPrefix.addEventListener('blur', () => {
|
|
|
maybeClearGeneratedAliasAfterEmailPrefixChange().catch(() => {});
|
|
maybeClearGeneratedAliasAfterEmailPrefixChange().catch(() => {});
|
|
|
|
|
+ syncManagedAliasBaseEmailDraftFromInput();
|
|
|
saveSettings({ silent: true }).catch(() => {});
|
|
saveSettings({ silent: true }).catch(() => {});
|
|
|
});
|
|
});
|
|
|
|
|
|