Merge remote-tracking branch 'origin/master'
# Conflicts: # content/signup-page.js # tests/step6-login-state.test.js
This commit is contained in:
+122
-29
@@ -57,6 +57,7 @@ const btnSaveSettings = document.getElementById('btn-save-settings');
|
||||
const btnStop = document.getElementById('btn-stop');
|
||||
const btnReset = document.getElementById('btn-reset');
|
||||
const btnContributionMode = document.getElementById('btn-contribution-mode');
|
||||
const contributionUpdateLayer = document.getElementById('contribution-update-layer');
|
||||
const contributionUpdateHint = document.getElementById('contribution-update-hint');
|
||||
const contributionUpdateHintText = document.getElementById('contribution-update-hint-text');
|
||||
const btnDismissContributionUpdateHint = document.getElementById('btn-dismiss-contribution-update-hint');
|
||||
@@ -97,6 +98,7 @@ const rowCustomPassword = document.getElementById('row-custom-password');
|
||||
const selectMailProvider = document.getElementById('select-mail-provider');
|
||||
const btnMailLogin = document.getElementById('btn-mail-login');
|
||||
const rowMail2925Mode = document.getElementById('row-mail-2925-mode');
|
||||
const rowMail2925PoolSettings = document.getElementById('row-mail2925-pool-settings');
|
||||
const mail2925ModeButtons = Array.from(document.querySelectorAll('[data-mail2925-mode]'));
|
||||
const rowEmailGenerator = document.getElementById('row-email-generator');
|
||||
const selectEmailGenerator = document.getElementById('select-email-generator');
|
||||
@@ -148,20 +150,23 @@ const inputHotmailRefreshToken = document.getElementById('input-hotmail-refresh-
|
||||
const inputHotmailImport = document.getElementById('input-hotmail-import');
|
||||
const btnAddHotmailAccount = document.getElementById('btn-add-hotmail-account');
|
||||
const btnImportHotmailAccounts = document.getElementById('btn-import-hotmail-accounts');
|
||||
const btnToggleHotmailForm = document.getElementById('btn-toggle-hotmail-form');
|
||||
const btnHotmailUsageGuide = document.getElementById('btn-hotmail-usage-guide');
|
||||
const btnClearUsedHotmailAccounts = document.getElementById('btn-clear-used-hotmail-accounts');
|
||||
const btnDeleteAllHotmailAccounts = document.getElementById('btn-delete-all-hotmail-accounts');
|
||||
const btnToggleHotmailList = document.getElementById('btn-toggle-hotmail-list');
|
||||
const hotmailFormShell = document.getElementById('hotmail-form-shell');
|
||||
const hotmailListShell = document.getElementById('hotmail-list-shell');
|
||||
const hotmailAccountsList = document.getElementById('hotmail-accounts-list');
|
||||
const inputMail2925Email = document.getElementById('input-mail2925-email');
|
||||
const inputMail2925Password = document.getElementById('input-mail2925-password');
|
||||
const inputMail2925Import = document.getElementById('input-mail2925-import');
|
||||
const btnAddMail2925Account = document.getElementById('btn-add-mail2925-account');
|
||||
const btnCancelMail2925Edit = document.getElementById('btn-cancel-mail2925-edit');
|
||||
const btnToggleMail2925Form = document.getElementById('btn-toggle-mail2925-form');
|
||||
const btnImportMail2925Accounts = document.getElementById('btn-import-mail2925-accounts');
|
||||
const btnDeleteAllMail2925Accounts = document.getElementById('btn-delete-all-mail2925-accounts');
|
||||
const btnToggleMail2925List = document.getElementById('btn-toggle-mail2925-list');
|
||||
const mail2925FormShell = document.getElementById('mail2925-form-shell');
|
||||
const mail2925ListShell = document.getElementById('mail2925-list-shell');
|
||||
const mail2925AccountsList = document.getElementById('mail2925-accounts-list');
|
||||
const inputLuckmailApiKey = document.getElementById('input-luckmail-api-key');
|
||||
@@ -247,8 +252,7 @@ const DEFAULT_MAIL_2925_MODE = MAIL_2925_MODE_PROVIDE;
|
||||
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';
|
||||
const CONTRIBUTION_CONTENT_PROMPT_DISMISSED_VERSION_STORAGE_KEY = 'multipage-contribution-content-prompt-dismissed-version';
|
||||
const AUTO_RUN_FALLBACK_RISK_WARNING_MIN_RUNS = 15;
|
||||
const AUTO_RUN_FALLBACK_RISK_RECOMMENDED_THREAD_INTERVAL_MINUTES = 5;
|
||||
const AUTO_RUN_FALLBACK_RISK_WARNING_MIN_RUNS = 3;
|
||||
const HOTMAIL_SERVICE_MODE_REMOTE = 'remote';
|
||||
const HOTMAIL_SERVICE_MODE_LOCAL = 'local';
|
||||
const ICLOUD_PROVIDER = 'icloud';
|
||||
@@ -266,12 +270,24 @@ function getManagedAliasUtils() {
|
||||
return window.MultiPageManagedAliasUtils || null;
|
||||
}
|
||||
|
||||
function isManagedAliasProvider(provider = selectMailProvider.value) {
|
||||
function isManagedAliasProvider(provider = selectMailProvider.value, mail2925Mode = getSelectedMail2925Mode()) {
|
||||
const utils = getManagedAliasUtils();
|
||||
if (utils?.usesManagedAliasGeneration) {
|
||||
return utils.usesManagedAliasGeneration(provider, { mail2925Mode });
|
||||
}
|
||||
if (utils?.isManagedAliasProvider) {
|
||||
const normalizedProvider = String(provider || '').trim().toLowerCase();
|
||||
if (normalizedProvider === '2925') {
|
||||
return utils.isManagedAliasProvider(provider)
|
||||
&& normalizeMail2925Mode(mail2925Mode) === MAIL_2925_MODE_PROVIDE;
|
||||
}
|
||||
return utils.isManagedAliasProvider(provider);
|
||||
}
|
||||
return [GMAIL_PROVIDER, '2925'].includes(String(provider || '').trim().toLowerCase());
|
||||
const normalizedProvider = String(provider || '').trim().toLowerCase();
|
||||
if (normalizedProvider === '2925') {
|
||||
return normalizeMail2925Mode(mail2925Mode) === MAIL_2925_MODE_PROVIDE;
|
||||
}
|
||||
return normalizedProvider === GMAIL_PROVIDER;
|
||||
}
|
||||
|
||||
function parseManagedAliasBaseEmail(rawValue, provider = selectMailProvider.value) {
|
||||
@@ -290,31 +306,34 @@ function isManagedAliasEmail(value, baseEmail = '', provider = selectMailProvide
|
||||
return false;
|
||||
}
|
||||
|
||||
function getManagedAliasProviderUiCopy(provider = selectMailProvider.value) {
|
||||
function getManagedAliasProviderUiCopy(provider = selectMailProvider.value, mail2925Mode = getSelectedMail2925Mode()) {
|
||||
if (!isManagedAliasProvider(provider, mail2925Mode)) {
|
||||
return null;
|
||||
}
|
||||
const utils = getManagedAliasUtils();
|
||||
if (utils?.getManagedAliasProviderUiCopy) {
|
||||
return utils.getManagedAliasProviderUiCopy(provider);
|
||||
}
|
||||
if (String(provider || '').trim().toLowerCase() === GMAIL_PROVIDER) {
|
||||
return {
|
||||
baseLabel: 'Gmail 原邮箱',
|
||||
baseLabel: '基邮箱',
|
||||
basePlaceholder: '例如 yourname@gmail.com',
|
||||
buttonLabel: '生成',
|
||||
successVerb: '生成',
|
||||
label: 'Gmail +tag 邮箱',
|
||||
placeholder: '点击生成 Gmail +tag 邮箱,或手动填写完整邮箱',
|
||||
hint: '先填写 Gmail 原邮箱后点“生成”,也可以直接手动填写完整的 Gmail 邮箱。',
|
||||
hint: '先填写基邮箱后点“生成”,也可以直接手动填写完整的 Gmail 邮箱。',
|
||||
};
|
||||
}
|
||||
if (String(provider || '').trim().toLowerCase() === '2925') {
|
||||
return {
|
||||
baseLabel: '2925 基邮箱',
|
||||
baseLabel: '基邮箱',
|
||||
basePlaceholder: '例如 yourname@2925.com',
|
||||
buttonLabel: '生成',
|
||||
successVerb: '生成',
|
||||
label: '2925 邮箱',
|
||||
placeholder: '点击生成 2925 邮箱,或手动填写完整邮箱',
|
||||
hint: '先填写 2925 基邮箱后点“生成”,也可以直接手动填写完整的 2925 邮箱。',
|
||||
hint: '先填写基邮箱后点“生成”,也可以直接手动填写完整的 2925 邮箱。',
|
||||
};
|
||||
}
|
||||
return null;
|
||||
@@ -379,7 +398,10 @@ async function syncSelectedMail2925PoolAccount(options = {}) {
|
||||
throw new Error(response.error);
|
||||
}
|
||||
|
||||
syncLatestState({ currentMail2925AccountId: response.account?.id || accountId });
|
||||
syncLatestState({
|
||||
currentMail2925AccountId: response.account?.id || accountId,
|
||||
...(response.account?.email ? { mail2925BaseEmail: String(response.account.email).trim() } : {}),
|
||||
});
|
||||
setManagedAliasBaseEmailInputForProvider('2925', latestState);
|
||||
if (!silent) {
|
||||
showToast(`已切换当前 2925 号池邮箱为 ${response.account?.email || accountId}`, 'success', 1800);
|
||||
@@ -591,7 +613,7 @@ const LOG_LEVEL_LABELS = {
|
||||
};
|
||||
|
||||
function usesGeneratedAliasMailProvider(provider, mail2925Mode = getSelectedMail2925Mode()) {
|
||||
return isManagedAliasProvider(provider);
|
||||
return isManagedAliasProvider(provider, mail2925Mode);
|
||||
}
|
||||
|
||||
function parseGmailBaseEmail(rawValue = '') {
|
||||
@@ -880,14 +902,10 @@ async function openAutoSkipFailuresConfirmModal() {
|
||||
};
|
||||
}
|
||||
|
||||
async function openAutoRunFallbackRiskConfirmModal(totalRuns, fallbackThreadIntervalMinutes) {
|
||||
const intervalLabel = Number.isFinite(fallbackThreadIntervalMinutes)
|
||||
? `${fallbackThreadIntervalMinutes} 分钟`
|
||||
: '未设置';
|
||||
|
||||
async function openAutoRunFallbackRiskConfirmModal(totalRuns) {
|
||||
const result = await openConfirmModalWithOption({
|
||||
title: '自动运行风险提醒',
|
||||
message: `当前设置为 ${totalRuns} 轮自动化,已开启自动重试,线程间隔为 ${intervalLabel}。轮数过多时,可能会因为 IP 短时间注册过多而集中失败。建议控制在 ${AUTO_RUN_FALLBACK_RISK_WARNING_MIN_RUNS} 轮以下,并将线程间隔设置在 ${AUTO_RUN_FALLBACK_RISK_RECOMMENDED_THREAD_INTERVAL_MINUTES} 分钟以上。是否继续?`,
|
||||
message: `当前轮数已经不适合单节点情况,请确保已经配置并打开节点轮询功能(若没有配置,请点击贡献/使用按钮,根据网页中使用教程进行配置),避免连续使用一个节点注册,导致出现手机号验证。`,
|
||||
confirmLabel: '继续',
|
||||
});
|
||||
|
||||
@@ -1162,7 +1180,7 @@ function formatAutoStepDelayInputValue(value) {
|
||||
}
|
||||
|
||||
function getRunCountValue() {
|
||||
return Math.min(50, Math.max(1, parseInt(inputRunCount.value, 10) || 1));
|
||||
return Math.max(1, parseInt(inputRunCount.value, 10) || 1);
|
||||
}
|
||||
|
||||
function updateFallbackThreadIntervalInputState() {
|
||||
@@ -2317,9 +2335,40 @@ function getContributionUpdateHintMessage(snapshot = currentContributionContentS
|
||||
return '公告 / 使用教程有更新了,可点上方“贡献/使用”查看。';
|
||||
}
|
||||
|
||||
function positionContributionUpdateHint() {
|
||||
if (!contributionUpdateLayer || !contributionUpdateHint || !btnContributionMode) {
|
||||
return;
|
||||
}
|
||||
if (contributionUpdateLayer.hidden || contributionUpdateHint.hidden) {
|
||||
return;
|
||||
}
|
||||
|
||||
const buttonRect = btnContributionMode.getBoundingClientRect();
|
||||
const viewportWidth = Math.max(document.documentElement?.clientWidth || 0, window.innerWidth || 0);
|
||||
const viewportHeight = Math.max(document.documentElement?.clientHeight || 0, window.innerHeight || 0);
|
||||
const hintWidth = contributionUpdateHint.offsetWidth || 220;
|
||||
const hintHeight = contributionUpdateHint.offsetHeight || 56;
|
||||
const viewportPadding = 12;
|
||||
const gap = 10;
|
||||
|
||||
const maxLeft = Math.max(viewportPadding, viewportWidth - hintWidth - viewportPadding);
|
||||
const left = Math.min(Math.max(viewportPadding, Math.round(buttonRect.left)), maxLeft);
|
||||
const shouldPlaceAbove = (buttonRect.bottom + gap + hintHeight) > (viewportHeight - viewportPadding)
|
||||
&& buttonRect.top > (hintHeight + gap + viewportPadding);
|
||||
const top = shouldPlaceAbove
|
||||
? Math.max(viewportPadding, Math.round(buttonRect.top - hintHeight - gap))
|
||||
: Math.max(viewportPadding, Math.round(buttonRect.bottom + gap));
|
||||
const buttonCenter = Math.round(buttonRect.left + (buttonRect.width / 2));
|
||||
const arrowOffset = Math.min(Math.max(16, buttonCenter - left), Math.max(16, hintWidth - 16));
|
||||
|
||||
contributionUpdateHint.style.left = `${left}px`;
|
||||
contributionUpdateHint.style.top = `${top}px`;
|
||||
contributionUpdateHint.style.setProperty('--contribution-update-arrow-left', `${arrowOffset}px`);
|
||||
}
|
||||
|
||||
function shouldShowContributionUpdateHint(snapshot = currentContributionContentSnapshot) {
|
||||
const promptVersion = String(snapshot?.promptVersion || '').trim();
|
||||
if (!contributionUpdateHint || !contributionUpdateHintText || !btnContributionMode) {
|
||||
if (!contributionUpdateLayer || !contributionUpdateHint || !contributionUpdateHintText || !btnContributionMode) {
|
||||
return false;
|
||||
}
|
||||
if (!promptVersion) {
|
||||
@@ -2335,17 +2384,23 @@ function shouldShowContributionUpdateHint(snapshot = currentContributionContentS
|
||||
}
|
||||
|
||||
function renderContributionUpdateHint(snapshot = currentContributionContentSnapshot) {
|
||||
if (!contributionUpdateHint) {
|
||||
if (!contributionUpdateLayer || !contributionUpdateHint) {
|
||||
return;
|
||||
}
|
||||
|
||||
const visible = shouldShowContributionUpdateHint(snapshot);
|
||||
contributionUpdateLayer.hidden = !visible;
|
||||
contributionUpdateHint.hidden = !visible;
|
||||
if (!visible || !contributionUpdateHintText) {
|
||||
return;
|
||||
}
|
||||
|
||||
contributionUpdateHintText.textContent = getContributionUpdateHintMessage(snapshot);
|
||||
if (typeof window.requestAnimationFrame === 'function') {
|
||||
window.requestAnimationFrame(() => positionContributionUpdateHint());
|
||||
return;
|
||||
}
|
||||
positionContributionUpdateHint();
|
||||
}
|
||||
|
||||
function dismissContributionUpdateHint() {
|
||||
@@ -2524,6 +2579,24 @@ function getCurrentMail2925Email(state = latestState) {
|
||||
return String(getCurrentMail2925Account(state)?.email || '').trim();
|
||||
}
|
||||
|
||||
function syncMail2925BaseEmailFromCurrentAccount(state = latestState, options = {}) {
|
||||
const { persist = false } = options;
|
||||
if (!isMail2925AccountPoolEnabled(state)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const currentEmail = getCurrentMail2925Email(state);
|
||||
if (!currentEmail || currentEmail === String(state?.mail2925BaseEmail || '').trim()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
syncLatestState({ mail2925BaseEmail: currentEmail });
|
||||
if (persist) {
|
||||
saveSettings({ silent: true }).catch(() => {});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getCurrentLuckmailPurchase(state = latestState) {
|
||||
return state?.currentLuckmailPurchase || null;
|
||||
}
|
||||
@@ -2674,13 +2747,18 @@ function updateMailProviderUI() {
|
||||
const useIcloudProvider = isIcloudMailProvider();
|
||||
const useEmailGenerator = !useHotmail && !useLuckmail && !useGeneratedAlias && !useCustomEmail;
|
||||
const useCloudflareTempEmailProvider = selectMailProvider.value === 'cloudflare-temp-email';
|
||||
const aliasUiCopy = useGeneratedAlias ? getManagedAliasProviderUiCopy(selectMailProvider.value) : null;
|
||||
const aliasUiCopy = useGeneratedAlias
|
||||
? getManagedAliasProviderUiCopy(selectMailProvider.value, mail2925Mode)
|
||||
: null;
|
||||
const uiCopy = getCurrentRegistrationEmailUiCopy();
|
||||
updateMailLoginButtonState();
|
||||
if (rowMail2925Mode) {
|
||||
rowMail2925Mode.style.display = 'none';
|
||||
rowMail2925Mode.style.display = use2925 ? '' : 'none';
|
||||
}
|
||||
rowEmailPrefix.style.display = useGeneratedAlias ? '' : 'none';
|
||||
if (rowMail2925PoolSettings) {
|
||||
rowMail2925PoolSettings.style.display = useMail2925 ? '' : 'none';
|
||||
}
|
||||
rowEmailPrefix.style.display = useGeneratedAlias && !useMail2925AccountPool ? '' : 'none';
|
||||
const hotmailServiceMode = getSelectedHotmailServiceMode();
|
||||
rowInbucketHost.style.display = useInbucket ? '' : 'none';
|
||||
rowInbucketMailbox.style.display = useInbucket ? '' : 'none';
|
||||
@@ -2743,8 +2821,8 @@ function updateMailProviderUI() {
|
||||
selectMail2925PoolAccount.style.display = useMail2925AccountPool ? '' : 'none';
|
||||
selectMail2925PoolAccount.disabled = !useMail2925AccountPool || getMail2925Accounts().length === 0;
|
||||
}
|
||||
inputEmailPrefix.style.display = useMail2925AccountPool ? 'none' : '';
|
||||
inputEmailPrefix.readOnly = useMail2925AccountPool;
|
||||
inputEmailPrefix.style.display = '';
|
||||
inputEmailPrefix.readOnly = false;
|
||||
selectEmailGenerator.disabled = useHotmail || useLuckmail || useGeneratedAlias || useCustomEmail;
|
||||
if (useGmail) {
|
||||
labelEmailPrefix.textContent = 'Gmail 原邮箱';
|
||||
@@ -2795,7 +2873,9 @@ function updateMailProviderUI() {
|
||||
}
|
||||
if (autoHintText && useMail2925AccountPool) {
|
||||
autoHintText.textContent = getMail2925Accounts().length
|
||||
? '当前已启用 2925 号池模式,步骤 3 会基于下拉框选中的号池邮箱生成别名地址'
|
||||
? (useGeneratedAlias
|
||||
? '当前已启用 2925 号池模式,步骤 3 会基于下拉框选中的号池邮箱生成别名地址'
|
||||
: '当前已启用 2925 号池模式,步骤 4 / 8 遇到登录页时会优先使用下拉框选中的账号自动登录')
|
||||
: '当前已启用 2925 号池模式,请先在下方 2925 账号池中添加账号并选择邮箱';
|
||||
}
|
||||
if (autoHintText && showCloudflareTempEmailReceiveMailbox) {
|
||||
@@ -3123,6 +3203,7 @@ async function fetchGeneratedEmail(options = {}) {
|
||||
generateNew: true,
|
||||
generator: selectEmailGenerator.value,
|
||||
mailProvider: selectMailProvider.value,
|
||||
mail2925Mode: getSelectedMail2925Mode(),
|
||||
...buildManagedAliasBaseEmailPayload(),
|
||||
},
|
||||
});
|
||||
@@ -3182,7 +3263,9 @@ const hotmailManager = window.SidepanelHotmailManager?.createHotmailManager({
|
||||
btnDeleteAllHotmailAccounts,
|
||||
btnHotmailUsageGuide,
|
||||
btnImportHotmailAccounts,
|
||||
btnToggleHotmailForm,
|
||||
btnToggleHotmailList,
|
||||
hotmailFormShell,
|
||||
hotmailAccountsList,
|
||||
hotmailListShell,
|
||||
inputEmail,
|
||||
@@ -3233,14 +3316,15 @@ const mail2925Manager = window.SidepanelMail2925Manager?.createMail2925Manager({
|
||||
},
|
||||
dom: {
|
||||
btnAddMail2925Account,
|
||||
btnCancelMail2925Edit,
|
||||
btnDeleteAllMail2925Accounts,
|
||||
btnImportMail2925Accounts,
|
||||
btnToggleMail2925Form,
|
||||
btnToggleMail2925List,
|
||||
inputMail2925Email,
|
||||
inputMail2925Import,
|
||||
inputMail2925Password,
|
||||
mail2925AccountsList,
|
||||
mail2925FormShell,
|
||||
mail2925ListShell,
|
||||
},
|
||||
helpers: {
|
||||
@@ -3249,6 +3333,7 @@ const mail2925Manager = window.SidepanelMail2925Manager?.createMail2925Manager({
|
||||
getMail2925Accounts,
|
||||
openConfirmModal,
|
||||
refreshManagedAliasBaseEmail: () => {
|
||||
syncMail2925BaseEmailFromCurrentAccount(latestState, { persist: true });
|
||||
setManagedAliasBaseEmailInputForProvider('2925', latestState);
|
||||
},
|
||||
showToast,
|
||||
@@ -3860,7 +3945,7 @@ async function startAutoRunFromCurrentSettings() {
|
||||
|
||||
if (shouldWarnAutoRunFallbackRisk(totalRuns, autoRunSkipFailures)
|
||||
&& !isAutoRunFallbackRiskPromptDismissed()) {
|
||||
const result = await openAutoRunFallbackRiskConfirmModal(totalRuns, fallbackThreadIntervalMinutes);
|
||||
const result = await openAutoRunFallbackRiskConfirmModal(totalRuns);
|
||||
if (!result.confirmed) {
|
||||
return false;
|
||||
}
|
||||
@@ -4822,6 +4907,14 @@ document.addEventListener('keydown', (event) => {
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
positionContributionUpdateHint();
|
||||
});
|
||||
|
||||
document.addEventListener('scroll', () => {
|
||||
positionContributionUpdateHint();
|
||||
}, true);
|
||||
|
||||
// ============================================================
|
||||
// Init
|
||||
// ============================================================
|
||||
|
||||
Reference in New Issue
Block a user