-
随机子域
-
-
-
依赖后端 RANDOM_SUBDOMAIN_DOMAINS
+
-
-
-
Temp 域名
-
-
-
-
+
+ 邮件接收
+
+
+
+
随机子域
+
+
+ 依赖后端 RANDOM_SUBDOMAIN_DOMAINS
+
+
+
diff --git a/sidepanel/sidepanel.js b/sidepanel/sidepanel.js
index 9b326c8..05d88f4 100644
--- a/sidepanel/sidepanel.js
+++ b/sidepanel/sidepanel.js
@@ -187,6 +187,8 @@ const selectTempEmailDomain = document.getElementById('select-temp-email-domain'
const inputTempEmailDomain = document.getElementById('input-temp-email-domain');
const btnTempEmailDomainMode = document.getElementById('btn-temp-email-domain-mode');
const cloudflareTempEmailSection = document.getElementById('cloudflare-temp-email-section');
+const btnToggleCloudflareTempEmailSection = document.getElementById('btn-toggle-cloudflare-temp-email-section');
+const cloudflareTempEmailSectionBody = document.getElementById('cloudflare-temp-email-section-body');
const btnCloudflareTempEmailUsageGuide = document.getElementById('btn-cloudflare-temp-email-usage-guide');
const btnCloudflareTempEmailGithub = document.getElementById('btn-cloudflare-temp-email-github');
const hotmailSection = document.getElementById('hotmail-section');
@@ -372,6 +374,7 @@ const AUTO_RUN_PLUS_RISK_WARNING_MAX_SAFE_RUNS = 3;
const PLUS_CONTRIBUTION_PROMPT_THRESHOLD = 5;
const PLUS_CONTRIBUTION_ACCOUNT_CREDIT = 5;
const PLUS_CONTRIBUTION_DONATION_CREDIT = 20;
+const CLOUDFLARE_TEMP_EMAIL_SECTION_EXPANDED_STORAGE_KEY = 'multipage-cloudflare-temp-email-section-expanded';
const HOTMAIL_SERVICE_MODE_REMOTE = 'remote';
const HOTMAIL_SERVICE_MODE_LOCAL = 'local';
const HOTMAIL_SECTION_EXPANDED_STORAGE_KEY = 'multipage-hotmail-section-expanded';
@@ -652,6 +655,7 @@ let settingsAutoSaveTimer = null;
let settingsSaveRevision = 0;
let cloudflareDomainEditMode = false;
let cloudflareTempEmailDomainEditMode = false;
+let cloudflareTempEmailSectionExpanded = false;
let hotmailSectionExpanded = false;
let modalChoiceResolver = null;
let currentModalActions = [];
@@ -2490,6 +2494,61 @@ function setHotmailServiceMode(mode) {
});
}
+function readCloudflareTempEmailSectionExpanded() {
+ try {
+ return localStorage.getItem(CLOUDFLARE_TEMP_EMAIL_SECTION_EXPANDED_STORAGE_KEY) === '1';
+ } catch (err) {
+ return false;
+ }
+}
+
+function persistCloudflareTempEmailSectionExpanded(expanded) {
+ try {
+ if (expanded) {
+ localStorage.setItem(CLOUDFLARE_TEMP_EMAIL_SECTION_EXPANDED_STORAGE_KEY, '1');
+ } else {
+ localStorage.removeItem(CLOUDFLARE_TEMP_EMAIL_SECTION_EXPANDED_STORAGE_KEY);
+ }
+ } catch (err) {
+ // Keep the current session state even if storage is unavailable.
+ }
+}
+
+function isCloudflareTempEmailSectionVisible() {
+ return Boolean(cloudflareTempEmailSection && cloudflareTempEmailSection.style.display !== 'none');
+}
+
+function updateCloudflareTempEmailSectionExpandedUI() {
+ const expanded = isCloudflareTempEmailSectionVisible() && cloudflareTempEmailSectionExpanded;
+ if (cloudflareTempEmailSectionBody) {
+ cloudflareTempEmailSectionBody.hidden = !expanded;
+ }
+ if (btnToggleCloudflareTempEmailSection) {
+ btnToggleCloudflareTempEmailSection.textContent = expanded ? '收起设置' : '展开设置';
+ btnToggleCloudflareTempEmailSection.title = expanded
+ ? '收起 Cloudflare Temp Email 设置'
+ : '展开 Cloudflare Temp Email 设置';
+ btnToggleCloudflareTempEmailSection.setAttribute('aria-expanded', String(expanded));
+ }
+}
+
+function setCloudflareTempEmailSectionExpanded(expanded, options = {}) {
+ const { persist = true } = options;
+ cloudflareTempEmailSectionExpanded = Boolean(expanded);
+ updateCloudflareTempEmailSectionExpandedUI();
+ if (persist) {
+ persistCloudflareTempEmailSectionExpanded(cloudflareTempEmailSectionExpanded);
+ }
+}
+
+function toggleCloudflareTempEmailSectionExpanded() {
+ setCloudflareTempEmailSectionExpanded(!cloudflareTempEmailSectionExpanded);
+}
+
+function initCloudflareTempEmailSectionExpandedState() {
+ setCloudflareTempEmailSectionExpanded(readCloudflareTempEmailSectionExpanded(), { persist: false });
+}
+
function readHotmailSectionExpanded() {
try {
return localStorage.getItem(HOTMAIL_SECTION_EXPANDED_STORAGE_KEY) === '1';
@@ -4031,6 +4090,9 @@ function updateMailProviderUI() {
if (cloudflareTempEmailSection) {
cloudflareTempEmailSection.style.display = showCloudflareTempEmailSettings ? '' : 'none';
}
+ if (typeof updateCloudflareTempEmailSectionExpandedUI === 'function') {
+ updateCloudflareTempEmailSectionExpandedUI();
+ }
if (icloudSection) {
const showIcloudSection = (useEmailGenerator && useIcloud) || useIcloudProvider;
icloudSection.style.display = showIcloudSection ? '' : 'none';
@@ -5274,6 +5336,10 @@ btnToggleIpProxySection?.addEventListener('click', () => {
}
});
+btnToggleCloudflareTempEmailSection?.addEventListener('click', () => {
+ toggleCloudflareTempEmailSectionExpanded();
+});
+
btnToggleHotmailSection?.addEventListener('click', () => {
toggleHotmailSectionExpanded();
});
@@ -7109,6 +7175,7 @@ bindPasswordVisibilityToggles();
initTheme();
initHotmailListExpandedState();
initMail2925ListExpandedState();
+initCloudflareTempEmailSectionExpandedState();
initHotmailSectionExpandedState();
if (typeof initIpProxySectionExpandedState === 'function') {
initIpProxySectionExpandedState();
diff --git a/tests/sidepanel-cloudflare-temp-email-random-subdomain.test.js b/tests/sidepanel-cloudflare-temp-email-random-subdomain.test.js
index d553d40..0e7a28c 100644
--- a/tests/sidepanel-cloudflare-temp-email-random-subdomain.test.js
+++ b/tests/sidepanel-cloudflare-temp-email-random-subdomain.test.js
@@ -61,6 +61,9 @@ function createRow(initialDisplay = 'none') {
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"/);
+ assert.match(html, /id="btn-toggle-cloudflare-temp-email-section"/);
+ assert.match(html, /aria-controls="cloudflare-temp-email-section-body"/);
+ assert.match(html, /id="cloudflare-temp-email-section-body" class="section-collapse-body" hidden/);
assert.match(html, /id="btn-cloudflare-temp-email-usage-guide"/);
assert.match(html, /id="btn-cloudflare-temp-email-github"/);
assert.match(html, /id="row-temp-email-random-subdomain-toggle"/);
@@ -68,6 +71,16 @@ test('sidepanel html places cloudflare temp email controls in a standalone secti
assert.doesNotMatch(html, /id="row-temp-email-random-subdomain-domain"/);
});
+test('sidepanel persists cloudflare temp email section collapse state', () => {
+ assert.match(source, /CLOUDFLARE_TEMP_EMAIL_SECTION_EXPANDED_STORAGE_KEY = 'multipage-cloudflare-temp-email-section-expanded'/);
+ assert.match(source, /let cloudflareTempEmailSectionExpanded = false/);
+ assert.match(source, /function updateCloudflareTempEmailSectionExpandedUI\(\)/);
+ assert.match(source, /cloudflareTempEmailSectionBody\.hidden = !expanded/);
+ assert.match(source, /btnToggleCloudflareTempEmailSection\.setAttribute\('aria-expanded', String\(expanded\)\)/);
+ assert.match(source, /btnToggleCloudflareTempEmailSection\?\.addEventListener\('click', \(\) => \{\s*toggleCloudflareTempEmailSectionExpanded\(\)/);
+ assert.match(source, /initCloudflareTempEmailSectionExpandedState\(\)/);
+});
+
test('sidepanel modal message preserves line breaks and supports inline links', () => {
const css = fs.readFileSync('sidepanel/sidepanel.css', 'utf8');
assert.match(css, /\.modal-message\s*\{[\s\S]*white-space:\s*pre-line;/);