优化 Cloudflare Temp Email 子域模式配置
This commit is contained in:
@@ -1378,6 +1378,10 @@ header {
|
||||
}
|
||||
.data-input::placeholder { color: var(--text-muted); }
|
||||
.data-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
|
||||
.data-input.is-invalid {
|
||||
border-color: var(--red);
|
||||
box-shadow: 0 0 0 3px var(--red-soft);
|
||||
}
|
||||
|
||||
.data-textarea {
|
||||
width: 100%;
|
||||
@@ -1490,6 +1494,38 @@ header {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.temp-email-subdomain-mode-wrap,
|
||||
.temp-email-subdomain-prefix-wrap {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.temp-email-subdomain-mode-wrap .choice-group,
|
||||
.temp-email-subdomain-prefix-wrap .data-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.temp-email-subdomain-mode-wrap .setting-caption {
|
||||
white-space: normal;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.field-feedback {
|
||||
min-height: 15px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 1.25;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.field-feedback.is-error {
|
||||
color: var(--red);
|
||||
}
|
||||
|
||||
.field-feedback-muted {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
#btn-fetch-email,
|
||||
#btn-save-settings {
|
||||
padding-inline: 10px;
|
||||
|
||||
+20
-27
@@ -812,41 +812,34 @@
|
||||
<input type="text" id="input-temp-email-receive-mailbox" class="data-input"
|
||||
placeholder="用于接收转发邮件的邮箱,例如 1@email.example.com" />
|
||||
</div>
|
||||
<div class="data-row" id="row-temp-email-random-subdomain-toggle" style="display:none;">
|
||||
<span class="data-label">随机子域</span>
|
||||
<div class="data-inline">
|
||||
<label class="toggle-switch" for="input-temp-email-use-random-subdomain"
|
||||
title="依赖后端 RANDOM_SUBDOMAIN_DOMAINS 配置">
|
||||
<input type="checkbox" id="input-temp-email-use-random-subdomain" />
|
||||
<span class="toggle-switch-track" aria-hidden="true">
|
||||
<span class="toggle-switch-thumb"></span>
|
||||
</span>
|
||||
<span>启用</span>
|
||||
</label>
|
||||
<span class="setting-caption">依赖后端 RANDOM_SUBDOMAIN_DOMAINS</span>
|
||||
<div class="data-row" id="row-temp-email-subdomain-mode" style="display:none;">
|
||||
<span class="data-label">子域模式</span>
|
||||
<div class="data-inline temp-email-subdomain-mode-wrap">
|
||||
<input type="checkbox" id="input-temp-email-use-random-subdomain" hidden />
|
||||
<input type="checkbox" id="input-temp-email-use-fixed-subdomain" hidden />
|
||||
<div id="temp-email-subdomain-mode-group" class="choice-group" role="group"
|
||||
aria-label="Cloudflare Temp Email 子域模式">
|
||||
<button type="button" class="choice-btn" data-temp-email-subdomain-mode="none">不使用</button>
|
||||
<button type="button" class="choice-btn" data-temp-email-subdomain-mode="random"
|
||||
title="依赖后端 RANDOM_SUBDOMAIN_DOMAINS 配置">随机</button>
|
||||
<button type="button" class="choice-btn" data-temp-email-subdomain-mode="fixed"
|
||||
title="依赖后端 ENABLE_CREATE_ADDRESS_SUBDOMAIN_MATCH 配置">固定</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row" id="row-temp-email-fixed-subdomain-toggle" style="display:none;">
|
||||
<span class="data-label">固定子域</span>
|
||||
<div class="data-inline">
|
||||
<label class="toggle-switch" for="input-temp-email-use-fixed-subdomain"
|
||||
title="依赖后端 ENABLE_CREATE_ADDRESS_SUBDOMAIN_MATCH 配置">
|
||||
<input type="checkbox" id="input-temp-email-use-fixed-subdomain" />
|
||||
<span class="toggle-switch-track" aria-hidden="true">
|
||||
<span class="toggle-switch-thumb"></span>
|
||||
</span>
|
||||
<span>启用</span>
|
||||
</label>
|
||||
<span class="setting-caption">与随机子域互斥</span>
|
||||
<span id="temp-email-subdomain-mode-caption" class="setting-caption setting-caption-left">按基础域名直接生成</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row" id="row-temp-email-fixed-subdomain-prefix" style="display:none;">
|
||||
<span class="data-label">子域前缀</span>
|
||||
<div class="data-inline temp-email-subdomain-prefix-wrap">
|
||||
<input type="text" id="input-temp-email-subdomain-prefix" class="data-input"
|
||||
placeholder="例如 a;当前域名为 b.com 时生成 xxx@a.b.com" />
|
||||
placeholder="例如 team;基础域名为 mail.example.com 时生成 xxx@team.mail.example.com"
|
||||
aria-describedby="temp-email-subdomain-prefix-feedback temp-email-effective-domain-preview" />
|
||||
<span id="temp-email-subdomain-prefix-feedback" class="field-feedback" aria-live="polite"></span>
|
||||
<span id="temp-email-effective-domain-preview" class="field-feedback field-feedback-muted"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row" id="row-temp-email-domain" style="display:none;">
|
||||
<span class="data-label">Temp 域名</span>
|
||||
<span class="data-label" id="label-temp-email-domain">Temp 域名</span>
|
||||
<div class="data-inline">
|
||||
<input type="hidden" id="select-temp-email-domain" value="" />
|
||||
<div id="temp-email-domain-picker" class="editable-list-picker">
|
||||
|
||||
+174
-55
@@ -297,13 +297,17 @@ const rowTempEmailLookupMode = document.getElementById('row-temp-email-lookup-mo
|
||||
const tempEmailLookupModeButtons = Array.from(document.querySelectorAll('[data-temp-email-lookup-mode]'));
|
||||
const rowTempEmailReceiveMailbox = document.getElementById('row-temp-email-receive-mailbox');
|
||||
const inputTempEmailReceiveMailbox = document.getElementById('input-temp-email-receive-mailbox');
|
||||
const rowTempEmailRandomSubdomainToggle = document.getElementById('row-temp-email-random-subdomain-toggle');
|
||||
const rowTempEmailSubdomainMode = document.getElementById('row-temp-email-subdomain-mode');
|
||||
const tempEmailSubdomainModeButtons = Array.from(document.querySelectorAll('[data-temp-email-subdomain-mode]'));
|
||||
const tempEmailSubdomainModeCaption = document.getElementById('temp-email-subdomain-mode-caption');
|
||||
const inputTempEmailUseRandomSubdomain = document.getElementById('input-temp-email-use-random-subdomain');
|
||||
const rowTempEmailFixedSubdomainToggle = document.getElementById('row-temp-email-fixed-subdomain-toggle');
|
||||
const inputTempEmailUseFixedSubdomain = document.getElementById('input-temp-email-use-fixed-subdomain');
|
||||
const rowTempEmailFixedSubdomainPrefix = document.getElementById('row-temp-email-fixed-subdomain-prefix');
|
||||
const inputTempEmailSubdomainPrefix = document.getElementById('input-temp-email-subdomain-prefix');
|
||||
const tempEmailSubdomainPrefixFeedback = document.getElementById('temp-email-subdomain-prefix-feedback');
|
||||
const tempEmailEffectiveDomainPreview = document.getElementById('temp-email-effective-domain-preview');
|
||||
const rowTempEmailDomain = document.getElementById('row-temp-email-domain');
|
||||
const labelTempEmailDomain = document.getElementById('label-temp-email-domain');
|
||||
const selectTempEmailDomain = document.getElementById('select-temp-email-domain');
|
||||
const tempEmailDomainPickerRoot = document.getElementById('temp-email-domain-picker');
|
||||
const btnTempEmailDomainMenu = document.getElementById('btn-temp-email-domain-menu');
|
||||
@@ -829,6 +833,10 @@ const DEFAULT_MAIL_2925_MODE = MAIL_2925_MODE_PROVIDE;
|
||||
const CLOUDFLARE_TEMP_EMAIL_LOOKUP_MODE_RECEIVE_MAILBOX = 'receive-mailbox';
|
||||
const CLOUDFLARE_TEMP_EMAIL_LOOKUP_MODE_REGISTRATION_EMAIL = 'registration-email';
|
||||
const DEFAULT_CLOUDFLARE_TEMP_EMAIL_LOOKUP_MODE = CLOUDFLARE_TEMP_EMAIL_LOOKUP_MODE_RECEIVE_MAILBOX;
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_NONE = 'none';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM = 'random';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED = 'fixed';
|
||||
const DEFAULT_CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE = CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_NONE;
|
||||
const NEW_USER_GUIDE_PROMPT_DISMISSED_STORAGE_KEY = 'multipage-new-user-guide-prompt-dismissed';
|
||||
const AUTO_SKIP_FAILURES_PROMPT_DISMISSED_STORAGE_KEY = 'multipage-auto-skip-failures-prompt-dismissed';
|
||||
const AUTO_RUN_FALLBACK_RISK_PROMPT_DISMISSED_STORAGE_KEY = 'multipage-auto-run-fallback-risk-prompt-dismissed';
|
||||
@@ -4117,6 +4125,33 @@ function buildCloudflareTempEmailEffectiveDomainValue(domain = '', subdomainPref
|
||||
return normalizedPrefix ? `${normalizedPrefix}.${normalizedDomain}` : normalizedDomain;
|
||||
}
|
||||
|
||||
function getCloudflareTempEmailSubdomainPrefixValidation(value = '') {
|
||||
const raw = String(value || '').trim();
|
||||
if (!raw) {
|
||||
return {
|
||||
raw,
|
||||
normalized: '',
|
||||
valid: false,
|
||||
message: '请填写子域前缀',
|
||||
};
|
||||
}
|
||||
const normalized = normalizeCloudflareTempEmailSubdomainPrefixValue(raw);
|
||||
if (!normalized) {
|
||||
return {
|
||||
raw,
|
||||
normalized: '',
|
||||
valid: false,
|
||||
message: '仅支持 1-63 位字母、数字或中划线,且不能以中划线开头或结尾',
|
||||
};
|
||||
}
|
||||
return {
|
||||
raw,
|
||||
normalized,
|
||||
valid: true,
|
||||
message: '',
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeCloudflareTempEmailDomains(values = []) {
|
||||
const seen = new Set();
|
||||
const domains = [];
|
||||
@@ -4206,13 +4241,13 @@ function applyCloudflareTempEmailSettingsState(state = {}) {
|
||||
inputTempEmailCustomAuth.value = state?.cloudflareTempEmailCustomAuth || '';
|
||||
inputTempEmailReceiveMailbox.value = state?.cloudflareTempEmailReceiveMailbox || '';
|
||||
setCloudflareTempEmailLookupMode(state?.cloudflareTempEmailLookupMode);
|
||||
if (inputTempEmailUseRandomSubdomain) {
|
||||
inputTempEmailUseRandomSubdomain.checked = Boolean(state?.cloudflareTempEmailUseRandomSubdomain)
|
||||
&& !Boolean(state?.cloudflareTempEmailUseFixedSubdomain);
|
||||
}
|
||||
if (inputTempEmailUseFixedSubdomain) {
|
||||
inputTempEmailUseFixedSubdomain.checked = Boolean(state?.cloudflareTempEmailUseFixedSubdomain);
|
||||
}
|
||||
setCloudflareTempEmailSubdomainMode(
|
||||
state?.cloudflareTempEmailUseFixedSubdomain
|
||||
? CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED
|
||||
: (state?.cloudflareTempEmailUseRandomSubdomain
|
||||
? CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM
|
||||
: CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_NONE)
|
||||
);
|
||||
if (inputTempEmailSubdomainPrefix) {
|
||||
inputTempEmailSubdomainPrefix.value = normalizeCloudflareTempEmailSubdomainPrefixValue(
|
||||
state?.cloudflareTempEmailSubdomainPrefix || ''
|
||||
@@ -4267,6 +4302,7 @@ function collectSettingsPayload() {
|
||||
const selectedCloudflareTempEmailDomain = normalizeCloudflareTempEmailDomainValue(
|
||||
!cloudflareTempEmailDomainEditMode ? selectTempEmailDomain.value : tempEmailActiveDomain
|
||||
) || tempEmailActiveDomain;
|
||||
const cloudflareTempEmailSubdomainMode = getSelectedCloudflareTempEmailSubdomainMode();
|
||||
const normalizeCloudMailBaseUrlInput = typeof normalizeCloudMailBaseUrlValue === 'function'
|
||||
? normalizeCloudMailBaseUrlValue
|
||||
: normalizeCloudflareTempEmailBaseUrlValue;
|
||||
@@ -5162,9 +5198,10 @@ function collectSettingsPayload() {
|
||||
? getSelectedCloudflareTempEmailLookupMode()
|
||||
: 'receive-mailbox',
|
||||
cloudflareTempEmailReceiveMailbox: normalizeCloudflareTempEmailReceiveMailboxValue(inputTempEmailReceiveMailbox.value),
|
||||
cloudflareTempEmailUseRandomSubdomain: Boolean(inputTempEmailUseRandomSubdomain?.checked)
|
||||
&& !Boolean(inputTempEmailUseFixedSubdomain?.checked),
|
||||
cloudflareTempEmailUseFixedSubdomain: Boolean(inputTempEmailUseFixedSubdomain?.checked),
|
||||
cloudflareTempEmailUseRandomSubdomain: cloudflareTempEmailSubdomainMode
|
||||
=== CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM,
|
||||
cloudflareTempEmailUseFixedSubdomain: cloudflareTempEmailSubdomainMode
|
||||
=== CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED,
|
||||
cloudflareTempEmailSubdomainPrefix: normalizeCloudflareTempEmailSubdomainPrefixValue(
|
||||
inputTempEmailSubdomainPrefix?.value || ''
|
||||
),
|
||||
@@ -5248,6 +5285,17 @@ function normalizeCloudflareTempEmailLookupMode(value = '') {
|
||||
: DEFAULT_CLOUDFLARE_TEMP_EMAIL_LOOKUP_MODE;
|
||||
}
|
||||
|
||||
function normalizeCloudflareTempEmailSubdomainMode(value = '') {
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
if (normalized === CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM) {
|
||||
return CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM;
|
||||
}
|
||||
if (normalized === CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED) {
|
||||
return CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED;
|
||||
}
|
||||
return DEFAULT_CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE;
|
||||
}
|
||||
|
||||
function normalizeHotmailServiceMode(value = '') {
|
||||
if (typeof normalizeHotmailServiceModeFromUtils === 'function') {
|
||||
return normalizeHotmailServiceModeFromUtils(value);
|
||||
@@ -8881,6 +8929,37 @@ function setCloudflareTempEmailLookupMode(mode) {
|
||||
});
|
||||
}
|
||||
|
||||
function syncCloudflareTempEmailSubdomainModeButtons(mode) {
|
||||
const resolvedMode = normalizeCloudflareTempEmailSubdomainMode(mode);
|
||||
tempEmailSubdomainModeButtons.forEach((button) => {
|
||||
const active = button.dataset.tempEmailSubdomainMode === resolvedMode;
|
||||
button.classList.toggle('is-active', active);
|
||||
button.setAttribute('aria-pressed', String(active));
|
||||
});
|
||||
}
|
||||
|
||||
function getSelectedCloudflareTempEmailSubdomainMode() {
|
||||
if (inputTempEmailUseFixedSubdomain?.checked) {
|
||||
return CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED;
|
||||
}
|
||||
if (inputTempEmailUseRandomSubdomain?.checked) {
|
||||
return CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM;
|
||||
}
|
||||
const activeButton = tempEmailSubdomainModeButtons.find((button) => button.classList.contains('is-active'));
|
||||
return normalizeCloudflareTempEmailSubdomainMode(activeButton?.dataset.tempEmailSubdomainMode);
|
||||
}
|
||||
|
||||
function setCloudflareTempEmailSubdomainMode(mode) {
|
||||
const resolvedMode = normalizeCloudflareTempEmailSubdomainMode(mode);
|
||||
if (inputTempEmailUseRandomSubdomain) {
|
||||
inputTempEmailUseRandomSubdomain.checked = resolvedMode === CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM;
|
||||
}
|
||||
if (inputTempEmailUseFixedSubdomain) {
|
||||
inputTempEmailUseFixedSubdomain.checked = resolvedMode === CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED;
|
||||
}
|
||||
syncCloudflareTempEmailSubdomainModeButtons(resolvedMode);
|
||||
}
|
||||
|
||||
function getSelectedHotmailServiceMode() {
|
||||
const activeButton = hotmailServiceModeButtons.find((button) => button.classList.contains('is-active'));
|
||||
return normalizeHotmailServiceMode(activeButton?.dataset.hotmailServiceMode);
|
||||
@@ -12997,11 +13076,26 @@ function updateMailProviderUI() {
|
||||
const isIcloudComCnHost = selectedIcloudHost === 'icloud.com.cn';
|
||||
const showIcloudTargetMailboxType = useIcloudProvider;
|
||||
const showIcloudForwardMailProvider = useIcloudProvider && icloudTargetMailboxType === 'forward-mailbox';
|
||||
const showCloudflareTempEmailRandomSubdomainToggle = useEmailGenerator && useCloudflareTempEmailGenerator;
|
||||
const showCloudflareTempEmailFixedSubdomainToggle = useEmailGenerator && useCloudflareTempEmailGenerator;
|
||||
const showCloudflareTempEmailFixedSubdomainPrefix = showCloudflareTempEmailFixedSubdomainToggle
|
||||
&& Boolean(inputTempEmailUseFixedSubdomain?.checked);
|
||||
const showCloudflareTempEmailSubdomainMode = useEmailGenerator && useCloudflareTempEmailGenerator;
|
||||
const cloudflareTempEmailSubdomainMode = getSelectedCloudflareTempEmailSubdomainMode();
|
||||
syncCloudflareTempEmailSubdomainModeButtons(cloudflareTempEmailSubdomainMode);
|
||||
const showCloudflareTempEmailFixedSubdomainPrefix = showCloudflareTempEmailSubdomainMode
|
||||
&& cloudflareTempEmailSubdomainMode === CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED;
|
||||
const showCloudflareTempEmailDomain = useEmailGenerator && useCloudflareTempEmailGenerator;
|
||||
const { domains: tempEmailDomains, activeDomain: tempEmailActiveDomain } = getCloudflareTempEmailDomainsFromState();
|
||||
const selectedTempEmailDomain = normalizeCloudflareTempEmailDomainValue(
|
||||
selectTempEmailDomain?.value || tempEmailActiveDomain
|
||||
) || tempEmailActiveDomain;
|
||||
const fixedSubdomainValidation = getCloudflareTempEmailSubdomainPrefixValidation(
|
||||
inputTempEmailSubdomainPrefix?.value || ''
|
||||
);
|
||||
const fixedSubdomainConfigInvalid = showCloudflareTempEmailFixedSubdomainPrefix
|
||||
&& !fixedSubdomainValidation.valid;
|
||||
const tempEmailEffectiveDomain = buildCloudflareTempEmailEffectiveDomainValue(
|
||||
selectedTempEmailDomain,
|
||||
fixedSubdomainValidation.normalized,
|
||||
{ requirePrefix: true }
|
||||
);
|
||||
if (rowEmailGenerator) {
|
||||
rowEmailGenerator.style.display = useEmailGenerator ? '' : 'none';
|
||||
}
|
||||
@@ -13057,17 +13151,38 @@ function updateMailProviderUI() {
|
||||
rowTempEmailLookupMode.style.display = showCloudflareTempEmailLookupMode ? '' : 'none';
|
||||
}
|
||||
rowTempEmailReceiveMailbox.style.display = showCloudflareTempEmailReceiveMailbox ? '' : 'none';
|
||||
if (rowTempEmailRandomSubdomainToggle) {
|
||||
rowTempEmailRandomSubdomainToggle.style.display = showCloudflareTempEmailRandomSubdomainToggle ? '' : 'none';
|
||||
if (rowTempEmailSubdomainMode) {
|
||||
rowTempEmailSubdomainMode.style.display = showCloudflareTempEmailSubdomainMode ? '' : 'none';
|
||||
}
|
||||
if (rowTempEmailFixedSubdomainToggle) {
|
||||
rowTempEmailFixedSubdomainToggle.style.display = showCloudflareTempEmailFixedSubdomainToggle ? '' : 'none';
|
||||
if (tempEmailSubdomainModeCaption) {
|
||||
tempEmailSubdomainModeCaption.textContent = cloudflareTempEmailSubdomainMode === CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM
|
||||
? '需后端、DNS、Email Routing/MX 覆盖随机子域'
|
||||
: (cloudflareTempEmailSubdomainMode === CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED
|
||||
? '需后端、DNS、Email Routing/MX 覆盖固定子域'
|
||||
: '按基础域名直接生成');
|
||||
}
|
||||
if (rowTempEmailFixedSubdomainPrefix) {
|
||||
rowTempEmailFixedSubdomainPrefix.style.display = showCloudflareTempEmailFixedSubdomainPrefix ? '' : 'none';
|
||||
}
|
||||
if (inputTempEmailSubdomainPrefix) {
|
||||
inputTempEmailSubdomainPrefix.classList.toggle('is-invalid', fixedSubdomainConfigInvalid);
|
||||
inputTempEmailSubdomainPrefix.setAttribute('aria-invalid', String(fixedSubdomainConfigInvalid));
|
||||
}
|
||||
if (tempEmailSubdomainPrefixFeedback) {
|
||||
tempEmailSubdomainPrefixFeedback.textContent = fixedSubdomainConfigInvalid
|
||||
? fixedSubdomainValidation.message
|
||||
: '';
|
||||
tempEmailSubdomainPrefixFeedback.classList.toggle('is-error', fixedSubdomainConfigInvalid);
|
||||
}
|
||||
if (tempEmailEffectiveDomainPreview) {
|
||||
tempEmailEffectiveDomainPreview.textContent = showCloudflareTempEmailFixedSubdomainPrefix && tempEmailEffectiveDomain
|
||||
? `最终域名:${tempEmailEffectiveDomain}`
|
||||
: '';
|
||||
}
|
||||
rowTempEmailDomain.style.display = showCloudflareTempEmailDomain ? '' : 'none';
|
||||
const { domains: tempEmailDomains } = getCloudflareTempEmailDomainsFromState();
|
||||
if (labelTempEmailDomain) {
|
||||
labelTempEmailDomain.textContent = showCloudflareTempEmailFixedSubdomainPrefix ? '基础域名' : 'Temp 域名';
|
||||
}
|
||||
if (showCloudflareTempEmailDomain) {
|
||||
setCloudflareTempEmailDomainEditMode(cloudflareTempEmailDomainEditMode || tempEmailDomains.length === 0, { clearInput: false });
|
||||
} else {
|
||||
@@ -13127,7 +13242,7 @@ function updateMailProviderUI() {
|
||||
if (useCustomEmail && useCustomMailProviderPool) {
|
||||
inputEmail.placeholder = '号池会按顺序自动回填当前轮邮箱,也可以手动覆盖';
|
||||
}
|
||||
btnFetchEmail.disabled = useLuckmail || useCustomEmail || useCustomEmailPool || isAutoRunLockedPhase();
|
||||
btnFetchEmail.disabled = useLuckmail || useCustomEmail || useCustomEmailPool || fixedSubdomainConfigInvalid || isAutoRunLockedPhase();
|
||||
if (!btnFetchEmail.disabled) {
|
||||
btnFetchEmail.textContent = uiCopy.buttonLabel;
|
||||
}
|
||||
@@ -13164,19 +13279,17 @@ function updateMailProviderUI() {
|
||||
if (autoHintText && showCloudflareTempEmailReceiveMailbox && !useCustomEmailPool) {
|
||||
autoHintText.textContent = '若注册邮箱会转发到 Cloudflare Temp Email,请在“邮件接收”中填写实际接收转发邮件的邮箱。';
|
||||
}
|
||||
if (autoHintText && showCloudflareTempEmailRandomSubdomainToggle && inputTempEmailUseRandomSubdomain?.checked) {
|
||||
autoHintText.textContent = '已启用随机子域名:扩展会按当前选中的 Temp 域名提交,并额外携带 enableRandomSubdomain;是否生效取决于后端 RANDOM_SUBDOMAIN_DOMAINS 配置。';
|
||||
if (
|
||||
autoHintText
|
||||
&& showCloudflareTempEmailSubdomainMode
|
||||
&& cloudflareTempEmailSubdomainMode === CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM
|
||||
) {
|
||||
autoHintText.textContent = '已启用随机子域名:扩展会按当前选中的基础域名提交,并额外携带 enableRandomSubdomain;后端 RANDOM_SUBDOMAIN_DOMAINS、DNS、Email Routing/MX 都需要覆盖对应子域。';
|
||||
}
|
||||
if (autoHintText && showCloudflareTempEmailFixedSubdomainPrefix && inputTempEmailUseFixedSubdomain?.checked) {
|
||||
const { activeDomain: tempEmailActiveDomain } = getCloudflareTempEmailDomainsFromState();
|
||||
const effectiveDomain = buildCloudflareTempEmailEffectiveDomainValue(
|
||||
selectTempEmailDomain?.value || tempEmailActiveDomain,
|
||||
inputTempEmailSubdomainPrefix?.value || '',
|
||||
{ requirePrefix: true }
|
||||
);
|
||||
autoHintText.textContent = effectiveDomain
|
||||
? `已启用固定子域名:本次会向后端提交 ${effectiveDomain},后端需开启 ENABLE_CREATE_ADDRESS_SUBDOMAIN_MATCH。`
|
||||
: '已启用固定子域名:请填写有效的子域前缀;后端需开启 ENABLE_CREATE_ADDRESS_SUBDOMAIN_MATCH。';
|
||||
if (autoHintText && showCloudflareTempEmailFixedSubdomainPrefix) {
|
||||
autoHintText.textContent = tempEmailEffectiveDomain
|
||||
? `已启用固定子域名:本次会向后端提交 ${tempEmailEffectiveDomain};后端 ENABLE_CREATE_ADDRESS_SUBDOMAIN_MATCH、DNS、Email Routing/MX 都需要覆盖该子域。`
|
||||
: `已启用固定子域名:${fixedSubdomainValidation.message};后端、DNS、Email Routing/MX 都需要覆盖该子域。`;
|
||||
}
|
||||
if (autoHintText && useIcloudProvider && showIcloudForwardMailProvider) {
|
||||
const forwardProvider = normalizeIcloudForwardMailProvider(icloudForwardMailProviderValue);
|
||||
@@ -16566,24 +16679,19 @@ inputTempEmailReceiveMailbox.addEventListener('blur', () => {
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
inputTempEmailUseRandomSubdomain?.addEventListener('change', () => {
|
||||
if (inputTempEmailUseRandomSubdomain.checked && inputTempEmailUseFixedSubdomain) {
|
||||
inputTempEmailUseFixedSubdomain.checked = false;
|
||||
tempEmailSubdomainModeButtons.forEach((button) => {
|
||||
button.addEventListener('click', () => {
|
||||
const nextMode = normalizeCloudflareTempEmailSubdomainMode(button.dataset.tempEmailSubdomainMode);
|
||||
const previousMode = getSelectedCloudflareTempEmailSubdomainMode();
|
||||
if (nextMode === previousMode) {
|
||||
return;
|
||||
}
|
||||
setCloudflareTempEmailSubdomainMode(nextMode);
|
||||
updateMailProviderUI();
|
||||
clearRegistrationEmail({ silent: true }).catch(() => { });
|
||||
markSettingsDirty(true);
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
inputTempEmailUseFixedSubdomain?.addEventListener('change', () => {
|
||||
if (inputTempEmailUseFixedSubdomain.checked && inputTempEmailUseRandomSubdomain) {
|
||||
inputTempEmailUseRandomSubdomain.checked = false;
|
||||
}
|
||||
updateMailProviderUI();
|
||||
clearRegistrationEmail({ silent: true }).catch(() => { });
|
||||
markSettingsDirty(true);
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
inputTempEmailSubdomainPrefix?.addEventListener('input', () => {
|
||||
@@ -17772,15 +17880,25 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
if (message.payload.cloudflareTempEmailReceiveMailbox !== undefined) {
|
||||
inputTempEmailReceiveMailbox.value = message.payload.cloudflareTempEmailReceiveMailbox || '';
|
||||
}
|
||||
if (message.payload.cloudflareTempEmailUseRandomSubdomain !== undefined && inputTempEmailUseRandomSubdomain) {
|
||||
inputTempEmailUseRandomSubdomain.checked = Boolean(message.payload.cloudflareTempEmailUseRandomSubdomain)
|
||||
&& !Boolean(message.payload.cloudflareTempEmailUseFixedSubdomain ?? latestState?.cloudflareTempEmailUseFixedSubdomain);
|
||||
}
|
||||
if (message.payload.cloudflareTempEmailUseFixedSubdomain !== undefined && inputTempEmailUseFixedSubdomain) {
|
||||
inputTempEmailUseFixedSubdomain.checked = Boolean(message.payload.cloudflareTempEmailUseFixedSubdomain);
|
||||
if (inputTempEmailUseFixedSubdomain.checked && inputTempEmailUseRandomSubdomain) {
|
||||
inputTempEmailUseRandomSubdomain.checked = false;
|
||||
}
|
||||
if (
|
||||
message.payload.cloudflareTempEmailUseRandomSubdomain !== undefined
|
||||
|| message.payload.cloudflareTempEmailUseFixedSubdomain !== undefined
|
||||
) {
|
||||
const useFixedSubdomain = Boolean(
|
||||
message.payload.cloudflareTempEmailUseFixedSubdomain
|
||||
?? latestState?.cloudflareTempEmailUseFixedSubdomain
|
||||
);
|
||||
const useRandomSubdomain = Boolean(
|
||||
message.payload.cloudflareTempEmailUseRandomSubdomain
|
||||
?? latestState?.cloudflareTempEmailUseRandomSubdomain
|
||||
);
|
||||
setCloudflareTempEmailSubdomainMode(
|
||||
useFixedSubdomain
|
||||
? CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED
|
||||
: (useRandomSubdomain
|
||||
? CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM
|
||||
: CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_NONE)
|
||||
);
|
||||
}
|
||||
if (message.payload.cloudflareTempEmailSubdomainPrefix !== undefined && inputTempEmailSubdomainPrefix) {
|
||||
inputTempEmailSubdomainPrefix.value = normalizeCloudflareTempEmailSubdomainPrefixValue(
|
||||
@@ -18398,6 +18516,7 @@ updateConfigMenuControls();
|
||||
setLocalCpaStep9Mode(DEFAULT_LOCAL_CPA_STEP9_MODE);
|
||||
setMail2925Mode(DEFAULT_MAIL_2925_MODE);
|
||||
setCloudflareTempEmailLookupMode(DEFAULT_CLOUDFLARE_TEMP_EMAIL_LOOKUP_MODE);
|
||||
setCloudflareTempEmailSubdomainMode(DEFAULT_CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE);
|
||||
initializeReleaseInfo().catch((err) => {
|
||||
console.error('Failed to initialize release info:', err);
|
||||
});
|
||||
|
||||
@@ -58,6 +58,31 @@ function createRow(initialDisplay = 'none') {
|
||||
};
|
||||
}
|
||||
|
||||
function createClassList(initial = []) {
|
||||
const values = new Set(initial);
|
||||
return {
|
||||
toggle(name, force) {
|
||||
if (force === undefined) {
|
||||
if (values.has(name)) {
|
||||
values.delete(name);
|
||||
return false;
|
||||
}
|
||||
values.add(name);
|
||||
return true;
|
||||
}
|
||||
if (force) {
|
||||
values.add(name);
|
||||
return true;
|
||||
}
|
||||
values.delete(name);
|
||||
return false;
|
||||
},
|
||||
contains(name) {
|
||||
return values.has(name);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test('sidepanel html places cloudflare temp email controls in a standalone section', () => {
|
||||
const html = fs.readFileSync('sidepanel/sidepanel.html', 'utf8');
|
||||
assert.match(html, /id="cloudflare-temp-email-section"/);
|
||||
@@ -67,13 +92,20 @@ test('sidepanel html places cloudflare temp email controls in a standalone secti
|
||||
assert.match(html, /id="row-temp-email-lookup-mode"/);
|
||||
assert.match(html, /data-temp-email-lookup-mode="receive-mailbox"/);
|
||||
assert.match(html, /data-temp-email-lookup-mode="registration-email"/);
|
||||
assert.match(html, /id="row-temp-email-random-subdomain-toggle"/);
|
||||
assert.match(html, /id="row-temp-email-subdomain-mode"/);
|
||||
assert.match(html, /data-temp-email-subdomain-mode="none"/);
|
||||
assert.match(html, /data-temp-email-subdomain-mode="random"/);
|
||||
assert.match(html, /data-temp-email-subdomain-mode="fixed"/);
|
||||
assert.match(html, /id="input-temp-email-use-random-subdomain"/);
|
||||
assert.match(html, /id="row-temp-email-fixed-subdomain-toggle"/);
|
||||
assert.match(html, /id="input-temp-email-use-fixed-subdomain"/);
|
||||
assert.match(html, /id="row-temp-email-fixed-subdomain-prefix"/);
|
||||
assert.match(html, /id="input-temp-email-subdomain-prefix"/);
|
||||
assert.match(html, /id="temp-email-subdomain-prefix-feedback"/);
|
||||
assert.match(html, /id="temp-email-effective-domain-preview"/);
|
||||
assert.match(html, /id="label-temp-email-domain"/);
|
||||
assert.match(html, /id="btn-temp-email-domain-mode"[^>]*>更新</);
|
||||
assert.doesNotMatch(html, /id="row-temp-email-random-subdomain-toggle"/);
|
||||
assert.doesNotMatch(html, /id="row-temp-email-fixed-subdomain-toggle"/);
|
||||
assert.doesNotMatch(html, /id="row-temp-email-random-subdomain-domain"/);
|
||||
});
|
||||
|
||||
@@ -148,6 +180,13 @@ const inputTempEmailReceiveMailbox = { value: '' };
|
||||
const inputTempEmailUseRandomSubdomain = { checked: false };
|
||||
const inputTempEmailUseFixedSubdomain = { checked: false };
|
||||
const inputTempEmailSubdomainPrefix = { value: '' };
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_NONE = 'none';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM = 'random';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED = 'fixed';
|
||||
function setCloudflareTempEmailSubdomainMode(mode) {
|
||||
inputTempEmailUseFixedSubdomain.checked = mode === CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED;
|
||||
inputTempEmailUseRandomSubdomain.checked = mode === CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM;
|
||||
}
|
||||
const calls = {
|
||||
domainOptions: [],
|
||||
domainEditMode: [],
|
||||
@@ -431,10 +470,55 @@ const rowTempEmailAdminAuth = ${JSON.stringify(createRow('none'))};
|
||||
const rowTempEmailCustomAuth = ${JSON.stringify(createRow('none'))};
|
||||
const rowTempEmailLookupMode = ${JSON.stringify(createRow('none'))};
|
||||
const rowTempEmailReceiveMailbox = ${JSON.stringify(createRow('none'))};
|
||||
const rowTempEmailRandomSubdomainToggle = ${JSON.stringify(createRow('none'))};
|
||||
const rowTempEmailFixedSubdomainToggle = ${JSON.stringify(createRow('none'))};
|
||||
const rowTempEmailSubdomainMode = ${JSON.stringify(createRow('none'))};
|
||||
function createClassList(initial = []) {
|
||||
const values = new Set(initial);
|
||||
return {
|
||||
toggle(name, force) {
|
||||
if (force === undefined) {
|
||||
if (values.has(name)) {
|
||||
values.delete(name);
|
||||
return false;
|
||||
}
|
||||
values.add(name);
|
||||
return true;
|
||||
}
|
||||
if (force) {
|
||||
values.add(name);
|
||||
return true;
|
||||
}
|
||||
values.delete(name);
|
||||
return false;
|
||||
},
|
||||
contains(name) {
|
||||
return values.has(name);
|
||||
},
|
||||
};
|
||||
}
|
||||
const tempEmailSubdomainModeButtons = [
|
||||
{
|
||||
dataset: { tempEmailSubdomainMode: 'none' },
|
||||
attributes: {},
|
||||
classList: createClassList(['is-active']),
|
||||
setAttribute(name, value) { this.attributes[name] = String(value); },
|
||||
},
|
||||
{
|
||||
dataset: { tempEmailSubdomainMode: 'random' },
|
||||
attributes: {},
|
||||
classList: createClassList(),
|
||||
setAttribute(name, value) { this.attributes[name] = String(value); },
|
||||
},
|
||||
{
|
||||
dataset: { tempEmailSubdomainMode: 'fixed' },
|
||||
attributes: {},
|
||||
classList: createClassList(),
|
||||
setAttribute(name, value) { this.attributes[name] = String(value); },
|
||||
},
|
||||
];
|
||||
const tempEmailSubdomainModeCaption = { textContent: '' };
|
||||
const rowTempEmailFixedSubdomainPrefix = ${JSON.stringify(createRow('none'))};
|
||||
const rowTempEmailDomain = ${JSON.stringify(createRow('none'))};
|
||||
const labelTempEmailDomain = { textContent: '' };
|
||||
const cloudflareTempEmailSection = ${JSON.stringify(createRow('none'))};
|
||||
const hotmailSection = ${JSON.stringify(createRow('none'))};
|
||||
const mail2925Section = ${JSON.stringify(createRow('none'))};
|
||||
@@ -457,7 +541,18 @@ const selectEmailGenerator = { value: 'cloudflare-temp-email', disabled: false }
|
||||
const selectTempEmailDomain = { value: 'mail.example.com' };
|
||||
const inputTempEmailUseRandomSubdomain = { checked: false };
|
||||
const inputTempEmailUseFixedSubdomain = { checked: false };
|
||||
const inputTempEmailSubdomainPrefix = { value: 'team' };
|
||||
const inputTempEmailSubdomainPrefix = {
|
||||
value: 'team',
|
||||
attributes: {},
|
||||
classList: createClassList(),
|
||||
setAttribute(name, value) { this.attributes[name] = String(value); },
|
||||
};
|
||||
const tempEmailSubdomainPrefixFeedback = { textContent: '', classList: createClassList() };
|
||||
const tempEmailEffectiveDomainPreview = { textContent: '' };
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_NONE = 'none';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM = 'random';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED = 'fixed';
|
||||
const DEFAULT_CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE = 'none';
|
||||
const calls = {
|
||||
tempDomainEditMode: [],
|
||||
};
|
||||
@@ -468,6 +563,31 @@ function usesGeneratedAliasMailProvider() { return false; }
|
||||
function getSelectedMail2925Mode() { return 'provide'; }
|
||||
let selectedCloudflareTempEmailLookupMode = 'receive-mailbox';
|
||||
function getSelectedCloudflareTempEmailLookupMode() { return selectedCloudflareTempEmailLookupMode; }
|
||||
function normalizeCloudflareTempEmailSubdomainMode(value = '') {
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
return ['random', 'fixed'].includes(normalized) ? normalized : 'none';
|
||||
}
|
||||
function syncCloudflareTempEmailSubdomainModeButtons(mode) {
|
||||
const resolvedMode = normalizeCloudflareTempEmailSubdomainMode(mode);
|
||||
tempEmailSubdomainModeButtons.forEach((button) => {
|
||||
const active = button.dataset.tempEmailSubdomainMode === resolvedMode;
|
||||
button.classList.toggle('is-active', active);
|
||||
button.setAttribute('aria-pressed', String(active));
|
||||
});
|
||||
}
|
||||
function getSelectedCloudflareTempEmailSubdomainMode() {
|
||||
if (inputTempEmailUseFixedSubdomain.checked) return 'fixed';
|
||||
if (inputTempEmailUseRandomSubdomain.checked) return 'random';
|
||||
return 'none';
|
||||
}
|
||||
function getCloudflareTempEmailSubdomainPrefixValidation(value = '') {
|
||||
const raw = String(value || '').trim();
|
||||
if (!raw) return { raw, normalized: '', valid: false, message: '请填写子域前缀' };
|
||||
const normalized = normalizeCloudflareTempEmailSubdomainPrefixValue(raw);
|
||||
return normalized
|
||||
? { raw, normalized, valid: true, message: '' }
|
||||
: { raw, normalized: '', valid: false, message: '仅支持 1-63 位字母、数字或中划线,且不能以中划线开头或结尾' };
|
||||
}
|
||||
function getManagedAliasProviderUiCopy() { return null; }
|
||||
function getCurrentRegistrationEmailUiCopy() {
|
||||
return {
|
||||
@@ -482,7 +602,10 @@ function getCloudflareDomainsFromState() { return { domains: [], activeDomain: '
|
||||
function setCloudflareDomainEditMode() {}
|
||||
function getCloudflareTempEmailDomainsFromState() { return { domains: ['mail.example.com'], activeDomain: 'mail.example.com' }; }
|
||||
function normalizeCloudflareTempEmailDomainValue(value = '') { return String(value || '').trim().toLowerCase(); }
|
||||
function normalizeCloudflareTempEmailSubdomainPrefixValue(value = '') { return String(value || '').trim().toLowerCase(); }
|
||||
function normalizeCloudflareTempEmailSubdomainPrefixValue(value = '') {
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
return /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(normalized) ? normalized : '';
|
||||
}
|
||||
function buildCloudflareTempEmailEffectiveDomainValue(domain = '', subdomainPrefix = '', options = {}) {
|
||||
const normalizedDomain = normalizeCloudflareTempEmailDomainValue(domain);
|
||||
const normalizedPrefix = normalizeCloudflareTempEmailSubdomainPrefixValue(subdomainPrefix);
|
||||
@@ -505,13 +628,17 @@ return {
|
||||
cloudflareTempEmailSection,
|
||||
rowTempEmailLookupMode,
|
||||
rowTempEmailReceiveMailbox,
|
||||
rowTempEmailRandomSubdomainToggle,
|
||||
rowTempEmailFixedSubdomainToggle,
|
||||
rowTempEmailSubdomainMode,
|
||||
rowTempEmailFixedSubdomainPrefix,
|
||||
rowTempEmailDomain,
|
||||
labelTempEmailDomain,
|
||||
inputTempEmailUseRandomSubdomain,
|
||||
inputTempEmailUseFixedSubdomain,
|
||||
inputTempEmailSubdomainPrefix,
|
||||
tempEmailSubdomainModeCaption,
|
||||
tempEmailSubdomainPrefixFeedback,
|
||||
tempEmailEffectiveDomainPreview,
|
||||
btnFetchEmail,
|
||||
selectMailProvider,
|
||||
selectEmailGenerator,
|
||||
setLookupMode(value) {
|
||||
@@ -524,10 +651,10 @@ return {
|
||||
|
||||
api.updateMailProviderUI();
|
||||
assert.equal(api.cloudflareTempEmailSection.style.display, '');
|
||||
assert.equal(api.rowTempEmailRandomSubdomainToggle.style.display, '');
|
||||
assert.equal(api.rowTempEmailFixedSubdomainToggle.style.display, '');
|
||||
assert.equal(api.rowTempEmailSubdomainMode.style.display, '');
|
||||
assert.equal(api.rowTempEmailFixedSubdomainPrefix.style.display, 'none');
|
||||
assert.equal(api.rowTempEmailDomain.style.display, '');
|
||||
assert.equal(api.labelTempEmailDomain.textContent, 'Temp 域名');
|
||||
|
||||
api.selectMailProvider.value = 'cloudflare-temp-email';
|
||||
api.selectEmailGenerator.value = 'duck';
|
||||
@@ -548,16 +675,29 @@ return {
|
||||
assert.equal(api.cloudflareTempEmailSection.style.display, '');
|
||||
assert.equal(api.rowTempEmailDomain.style.display, '');
|
||||
assert.match(api.autoHintText.textContent, /RANDOM_SUBDOMAIN_DOMAINS/);
|
||||
assert.match(api.autoHintText.textContent, /Email Routing\/MX/);
|
||||
assert.match(api.tempEmailSubdomainModeCaption.textContent, /随机子域/);
|
||||
|
||||
api.inputTempEmailUseRandomSubdomain.checked = false;
|
||||
api.inputTempEmailUseFixedSubdomain.checked = true;
|
||||
api.inputTempEmailSubdomainPrefix.value = 'team';
|
||||
api.updateMailProviderUI();
|
||||
assert.equal(api.rowTempEmailFixedSubdomainPrefix.style.display, '');
|
||||
assert.equal(api.labelTempEmailDomain.textContent, '基础域名');
|
||||
assert.equal(api.tempEmailEffectiveDomainPreview.textContent, '最终域名:team.mail.example.com');
|
||||
assert.equal(api.tempEmailSubdomainPrefixFeedback.textContent, '');
|
||||
assert.equal(api.inputTempEmailSubdomainPrefix.attributes['aria-invalid'], 'false');
|
||||
assert.equal(api.btnFetchEmail.disabled, false);
|
||||
assert.match(api.autoHintText.textContent, /team\.mail\.example\.com/);
|
||||
assert.match(api.autoHintText.textContent, /ENABLE_CREATE_ADDRESS_SUBDOMAIN_MATCH/);
|
||||
assert.match(api.autoHintText.textContent, /Email Routing\/MX/);
|
||||
|
||||
api.inputTempEmailSubdomainPrefix.value = '';
|
||||
api.updateMailProviderUI();
|
||||
assert.match(api.autoHintText.textContent, /请填写有效的子域前缀/);
|
||||
assert.equal(api.btnFetchEmail.disabled, true);
|
||||
assert.equal(api.tempEmailEffectiveDomainPreview.textContent, '');
|
||||
assert.equal(api.tempEmailSubdomainPrefixFeedback.textContent, '请填写子域前缀');
|
||||
assert.equal(api.tempEmailSubdomainPrefixFeedback.classList.contains('is-error'), true);
|
||||
assert.equal(api.inputTempEmailSubdomainPrefix.attributes['aria-invalid'], 'true');
|
||||
assert.match(api.autoHintText.textContent, /请填写子域前缀/);
|
||||
});
|
||||
|
||||
@@ -247,6 +247,13 @@ const inputTempEmailReceiveMailbox = { value: 'relay@example.com' };
|
||||
const inputTempEmailUseRandomSubdomain = { checked: true };
|
||||
const inputTempEmailUseFixedSubdomain = { checked: false };
|
||||
const inputTempEmailSubdomainPrefix = { value: '' };
|
||||
function getSelectedCloudflareTempEmailSubdomainMode() {
|
||||
if (inputTempEmailUseFixedSubdomain.checked) return 'fixed';
|
||||
if (inputTempEmailUseRandomSubdomain.checked) return 'random';
|
||||
return 'none';
|
||||
}
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM = 'random';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED = 'fixed';
|
||||
const inputAutoSkipFailures = { checked: false };
|
||||
const inputAutoSkipFailuresThreadIntervalMinutes = { value: '5' };
|
||||
const inputAutoStepDelaySeconds = { value: '10' };
|
||||
|
||||
@@ -132,6 +132,13 @@ const inputTempEmailReceiveMailbox = { value: '' };
|
||||
const inputTempEmailUseRandomSubdomain = { checked: false };
|
||||
const inputTempEmailUseFixedSubdomain = { checked: false };
|
||||
const inputTempEmailSubdomainPrefix = { value: '' };
|
||||
function getSelectedCloudflareTempEmailSubdomainMode() {
|
||||
if (inputTempEmailUseFixedSubdomain.checked) return 'fixed';
|
||||
if (inputTempEmailUseRandomSubdomain.checked) return 'random';
|
||||
return 'none';
|
||||
}
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM = 'random';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED = 'fixed';
|
||||
const inputAutoSkipFailures = { checked: false };
|
||||
const inputAutoSkipFailuresThreadIntervalMinutes = { value: '0' };
|
||||
const inputAutoStepDelaySeconds = { value: '' };
|
||||
@@ -275,10 +282,13 @@ const rowTempEmailBaseUrl = createRow();
|
||||
const rowTempEmailAdminAuth = createRow();
|
||||
const rowTempEmailCustomAuth = createRow();
|
||||
const rowTempEmailReceiveMailbox = createRow();
|
||||
const rowTempEmailRandomSubdomainToggle = createRow();
|
||||
const rowTempEmailFixedSubdomainToggle = createRow();
|
||||
const rowTempEmailLookupMode = createRow();
|
||||
const rowTempEmailSubdomainMode = createRow();
|
||||
const tempEmailSubdomainModeButtons = [];
|
||||
const tempEmailSubdomainModeCaption = { textContent: '' };
|
||||
const rowTempEmailFixedSubdomainPrefix = createRow();
|
||||
const rowTempEmailDomain = createRow();
|
||||
const labelTempEmailDomain = { textContent: '' };
|
||||
const cloudflareTempEmailSection = createRow();
|
||||
const hotmailSection = createRow();
|
||||
const mail2925Section = createRow();
|
||||
@@ -300,16 +310,30 @@ const rowHotmailLocalBaseUrl = createRow();
|
||||
const inputMail2925UseAccountPool = { checked: false };
|
||||
const selectMailProvider = { value: 'icloud' };
|
||||
const selectEmailGenerator = { value: 'duck', disabled: false, options: [] };
|
||||
const selectTempEmailDomain = { value: '' };
|
||||
const selectIcloudTargetMailboxType = { value: 'icloud-inbox' };
|
||||
const selectIcloudForwardMailProvider = { value: 'gmail' };
|
||||
const selectIcloudHostPreference = { value: 'icloud.com.cn' };
|
||||
const inputTempEmailUseRandomSubdomain = { checked: false };
|
||||
const inputTempEmailUseFixedSubdomain = { checked: false };
|
||||
const inputTempEmailSubdomainPrefix = { value: '' };
|
||||
const inputTempEmailSubdomainPrefix = {
|
||||
value: '',
|
||||
classList: { toggle() {} },
|
||||
setAttribute() {},
|
||||
};
|
||||
const tempEmailSubdomainPrefixFeedback = {
|
||||
textContent: '',
|
||||
classList: { toggle() {} },
|
||||
};
|
||||
const tempEmailEffectiveDomainPreview = { textContent: '' };
|
||||
const inputRunCount = { disabled: false };
|
||||
const currentAutoRun = { autoRunning: false };
|
||||
const MAIL_PROVIDER_LOGIN_CONFIGS = { gmail: { label: 'Gmail 邮箱' } };
|
||||
const ICLOUD_FORWARD_MAIL_PROVIDER_LABELS = { gmail: 'Gmail 邮箱' };
|
||||
const CLOUDFLARE_TEMP_EMAIL_LOOKUP_MODE_REGISTRATION_EMAIL = 'registration-email';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_NONE = 'none';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM = 'random';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED = 'fixed';
|
||||
function normalizeIcloudHost(value) { return String(value || '').trim().toLowerCase(); }
|
||||
function normalizeIcloudTargetMailboxType(value) { return String(value || '').trim().toLowerCase() === 'forward-mailbox' ? 'forward-mailbox' : 'icloud-inbox'; }
|
||||
function normalizeIcloudForwardMailProvider(value) { return String(value || '').trim().toLowerCase() === 'gmail' ? 'gmail' : 'qq'; }
|
||||
@@ -320,6 +344,27 @@ function isIcloudMailProvider() { return selectMailProvider.value === ICLOUD_PRO
|
||||
function usesCustomMailProviderPool() { return false; }
|
||||
function usesGeneratedAliasMailProvider() { return false; }
|
||||
function getSelectedMail2925Mode() { return 'provide'; }
|
||||
function getSelectedCloudflareTempEmailLookupMode() { return 'receive-mailbox'; }
|
||||
function syncCloudflareTempEmailSubdomainModeButtons() {}
|
||||
function getSelectedCloudflareTempEmailSubdomainMode() {
|
||||
if (inputTempEmailUseFixedSubdomain.checked) return 'fixed';
|
||||
if (inputTempEmailUseRandomSubdomain.checked) return 'random';
|
||||
return 'none';
|
||||
}
|
||||
function normalizeCloudflareTempEmailDomainValue(value = '') { return String(value || '').trim().toLowerCase(); }
|
||||
function normalizeCloudflareTempEmailSubdomainPrefixValue(value = '') { return String(value || '').trim().toLowerCase(); }
|
||||
function getCloudflareTempEmailSubdomainPrefixValidation(value = '') {
|
||||
const raw = String(value || '').trim();
|
||||
return raw
|
||||
? { raw, normalized: raw.toLowerCase(), valid: true, message: '' }
|
||||
: { raw, normalized: '', valid: false, message: '请填写子域前缀' };
|
||||
}
|
||||
function buildCloudflareTempEmailEffectiveDomainValue(domain = '', subdomainPrefix = '', options = {}) {
|
||||
const normalizedDomain = normalizeCloudflareTempEmailDomainValue(domain);
|
||||
const normalizedPrefix = normalizeCloudflareTempEmailSubdomainPrefixValue(subdomainPrefix);
|
||||
if (options.requirePrefix && !normalizedPrefix) return '';
|
||||
return normalizedPrefix && normalizedDomain ? \`\${normalizedPrefix}.\${normalizedDomain}\` : normalizedDomain;
|
||||
}
|
||||
function getManagedAliasProviderUiCopy() { return null; }
|
||||
function getCurrentRegistrationEmailUiCopy() { return { buttonLabel: '获取邮箱', placeholder: '邮箱', label: '邮箱' }; }
|
||||
function updateMailLoginButtonState() {}
|
||||
|
||||
@@ -203,6 +203,13 @@ const inputTempEmailReceiveMailbox = { value: '' };
|
||||
const inputTempEmailUseRandomSubdomain = { checked: false };
|
||||
const inputTempEmailUseFixedSubdomain = { checked: false };
|
||||
const inputTempEmailSubdomainPrefix = { value: '' };
|
||||
function getSelectedCloudflareTempEmailSubdomainMode() {
|
||||
if (inputTempEmailUseFixedSubdomain.checked) return 'fixed';
|
||||
if (inputTempEmailUseRandomSubdomain.checked) return 'random';
|
||||
return 'none';
|
||||
}
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM = 'random';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED = 'fixed';
|
||||
const inputAutoSkipFailures = { checked: false };
|
||||
const inputAutoSkipFailuresThreadIntervalMinutes = { value: '0' };
|
||||
const inputAutoStepDelaySeconds = { value: '' };
|
||||
|
||||
@@ -978,6 +978,13 @@ const inputTempEmailReceiveMailbox = { value: '' };
|
||||
const inputTempEmailUseRandomSubdomain = { checked: false };
|
||||
const inputTempEmailUseFixedSubdomain = { checked: false };
|
||||
const inputTempEmailSubdomainPrefix = { value: '' };
|
||||
function getSelectedCloudflareTempEmailSubdomainMode() {
|
||||
if (inputTempEmailUseFixedSubdomain.checked) return 'fixed';
|
||||
if (inputTempEmailUseRandomSubdomain.checked) return 'random';
|
||||
return 'none';
|
||||
}
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_RANDOM = 'random';
|
||||
const CLOUDFLARE_TEMP_EMAIL_SUBDOMAIN_MODE_FIXED = 'fixed';
|
||||
const inputAutoSkipFailures = { checked: false };
|
||||
const inputAutoSkipFailuresThreadIntervalMinutes = { value: '0' };
|
||||
const inputAutoStepDelaySeconds = { value: '' };
|
||||
|
||||
Reference in New Issue
Block a user