Paypal增加轻量级号池
This commit is contained in:
@@ -3,10 +3,12 @@
|
||||
importScripts(
|
||||
'managed-alias-utils.js',
|
||||
'mail2925-utils.js',
|
||||
'paypal-utils.js',
|
||||
'background/phone-verification-flow.js',
|
||||
'background/account-run-history.js',
|
||||
'background/contribution-oauth.js',
|
||||
'background/mail-2925-session.js',
|
||||
'background/paypal-account-store.js',
|
||||
'background/ip-proxy-provider-711proxy.js',
|
||||
'background/ip-proxy-core.js',
|
||||
'background/panel-bridge.js',
|
||||
@@ -436,6 +438,7 @@ const PERSISTED_SETTING_DEFAULTS = {
|
||||
plusModeEnabled: false,
|
||||
paypalEmail: '',
|
||||
paypalPassword: '',
|
||||
currentPayPalAccountId: '',
|
||||
autoRunSkipFailures: false,
|
||||
autoRunFallbackThreadIntervalMinutes: 0,
|
||||
autoRunDelayEnabled: false,
|
||||
@@ -476,6 +479,7 @@ const PERSISTED_SETTING_DEFAULTS = {
|
||||
cloudflareTempEmailDomains: [],
|
||||
hotmailAccounts: [],
|
||||
mail2925Accounts: [],
|
||||
paypalAccounts: [],
|
||||
heroSmsApiKey: '',
|
||||
heroSmsCountryId: HERO_SMS_COUNTRY_ID,
|
||||
heroSmsCountryLabel: HERO_SMS_COUNTRY_LABEL,
|
||||
@@ -575,6 +579,7 @@ const DEFAULT_STATE = {
|
||||
loginVerificationRequestedAt: null,
|
||||
oauthFlowDeadlineAt: null,
|
||||
oauthFlowDeadlineSourceUrl: null,
|
||||
currentPayPalAccountId: null,
|
||||
currentHotmailAccountId: null,
|
||||
currentMail2925AccountId: null,
|
||||
preferredIcloudHost: '',
|
||||
@@ -1242,6 +1247,8 @@ function normalizePersistentSettingValue(key, value) {
|
||||
return String(value || '').trim();
|
||||
case 'paypalPassword':
|
||||
return String(value || '');
|
||||
case 'currentPayPalAccountId':
|
||||
return String(value || '').trim();
|
||||
case 'autoRunSkipFailures':
|
||||
case 'autoRunDelayEnabled':
|
||||
case 'phoneVerificationEnabled':
|
||||
@@ -1314,6 +1321,8 @@ function normalizePersistentSettingValue(key, value) {
|
||||
return normalizeHotmailAccounts(value);
|
||||
case 'mail2925Accounts':
|
||||
return normalizeMail2925Accounts(value);
|
||||
case 'paypalAccounts':
|
||||
return normalizePayPalAccounts(value);
|
||||
case 'heroSmsApiKey':
|
||||
return String(value || '');
|
||||
case 'heroSmsCountryId':
|
||||
@@ -1929,6 +1938,50 @@ function generatePassword() {
|
||||
return pw.split('').sort(() => Math.random() - 0.5).join('');
|
||||
}
|
||||
|
||||
function normalizePayPalAccount(account = {}) {
|
||||
if (self.PayPalUtils?.normalizePayPalAccount) {
|
||||
return self.PayPalUtils.normalizePayPalAccount(account);
|
||||
}
|
||||
return {
|
||||
id: String(account.id || crypto.randomUUID()),
|
||||
email: String(account.email || '').trim().toLowerCase(),
|
||||
password: String(account.password || ''),
|
||||
createdAt: Number.isFinite(Number(account.createdAt)) ? Number(account.createdAt) : Date.now(),
|
||||
updatedAt: Number.isFinite(Number(account.updatedAt)) ? Number(account.updatedAt) : Date.now(),
|
||||
lastUsedAt: Number.isFinite(Number(account.lastUsedAt)) ? Number(account.lastUsedAt) : 0,
|
||||
};
|
||||
}
|
||||
|
||||
function normalizePayPalAccounts(accounts) {
|
||||
if (self.PayPalUtils?.normalizePayPalAccounts) {
|
||||
return self.PayPalUtils.normalizePayPalAccounts(accounts);
|
||||
}
|
||||
return Array.isArray(accounts) ? accounts.map((account) => normalizePayPalAccount(account)) : [];
|
||||
}
|
||||
|
||||
function findPayPalAccount(accounts, accountId) {
|
||||
if (self.PayPalUtils?.findPayPalAccount) {
|
||||
return self.PayPalUtils.findPayPalAccount(accounts, accountId);
|
||||
}
|
||||
const normalizedId = String(accountId || '').trim();
|
||||
if (!normalizedId) return null;
|
||||
return normalizePayPalAccounts(accounts).find((account) => account.id === normalizedId) || null;
|
||||
}
|
||||
|
||||
function upsertPayPalAccountInList(accounts, nextAccount) {
|
||||
if (self.PayPalUtils?.upsertPayPalAccountInList) {
|
||||
return self.PayPalUtils.upsertPayPalAccountInList(accounts, nextAccount);
|
||||
}
|
||||
const normalizedNext = normalizePayPalAccount(nextAccount);
|
||||
const list = normalizePayPalAccounts(accounts);
|
||||
const existingIndex = list.findIndex((account) => account.id === normalizedNext.id);
|
||||
if (existingIndex >= 0) {
|
||||
list[existingIndex] = normalizedNext;
|
||||
return list;
|
||||
}
|
||||
return [...list, normalizedNext];
|
||||
}
|
||||
|
||||
function normalizeHotmailAccount(account = {}) {
|
||||
const normalizedLastAuthAt = Number.isFinite(Number(account.lastAuthAt)) ? Number(account.lastAuthAt) : 0;
|
||||
const normalizedStatus = String(
|
||||
@@ -7544,6 +7597,39 @@ function isMail2925PoolExhaustedPauseError(error) {
|
||||
return /^MAIL2925_POOL_EXHAUSTED_PAUSE::/.test(message);
|
||||
}
|
||||
|
||||
const payPalAccountStore = self.MultiPageBackgroundPayPalAccountStore?.createPayPalAccountStore({
|
||||
broadcastDataUpdate,
|
||||
findPayPalAccount,
|
||||
getState,
|
||||
normalizePayPalAccount,
|
||||
normalizePayPalAccounts,
|
||||
setPersistentSettings,
|
||||
setState,
|
||||
upsertPayPalAccountInList,
|
||||
});
|
||||
|
||||
async function syncPayPalAccounts(accounts) {
|
||||
return payPalAccountStore?.syncPayPalAccounts?.(accounts) || [];
|
||||
}
|
||||
|
||||
async function upsertPayPalAccount(input = {}) {
|
||||
if (!payPalAccountStore?.upsertPayPalAccount) {
|
||||
throw new Error('PayPal 账号存储能力尚未接入。');
|
||||
}
|
||||
return payPalAccountStore.upsertPayPalAccount(input);
|
||||
}
|
||||
|
||||
async function setCurrentPayPalAccount(accountId) {
|
||||
if (!payPalAccountStore?.setCurrentPayPalAccount) {
|
||||
throw new Error('PayPal 账号选择能力尚未接入。');
|
||||
}
|
||||
return payPalAccountStore.setCurrentPayPalAccount(accountId);
|
||||
}
|
||||
|
||||
function getCurrentPayPalAccount(state = null) {
|
||||
return payPalAccountStore?.getCurrentPayPalAccount?.(state || {}) || null;
|
||||
}
|
||||
|
||||
const generatedEmailHelpers = self.MultiPageGeneratedEmailHelpers?.createGeneratedEmailHelpers({
|
||||
addLog,
|
||||
buildGeneratedAliasEmail,
|
||||
@@ -8729,6 +8815,7 @@ const messageRouter = self.MultiPageBackgroundMessageRouter?.createMessageRouter
|
||||
deleteHotmailAccounts,
|
||||
deleteIcloudAlias,
|
||||
deleteUsedIcloudAliases,
|
||||
findPayPalAccount,
|
||||
disableUsedLuckmailPurchases,
|
||||
doesStepUseCompletionSignal,
|
||||
ensureMail2925MailboxSession,
|
||||
@@ -8773,9 +8860,11 @@ const messageRouter = self.MultiPageBackgroundMessageRouter?.createMessageRouter
|
||||
listIcloudAliases,
|
||||
listLuckmailPurchasesForManagement,
|
||||
refreshIpProxyPool,
|
||||
getCurrentPayPalAccount,
|
||||
getCurrentMail2925Account,
|
||||
normalizeHotmailAccounts,
|
||||
normalizeMail2925Accounts,
|
||||
normalizePayPalAccounts,
|
||||
normalizeRunCount,
|
||||
AUTO_RUN_TIMER_KIND_SCHEDULED_START,
|
||||
notifyStepComplete,
|
||||
@@ -8791,6 +8880,7 @@ const messageRouter = self.MultiPageBackgroundMessageRouter?.createMessageRouter
|
||||
selectLuckmailPurchase,
|
||||
switchIpProxy,
|
||||
changeIpProxyExit,
|
||||
setCurrentPayPalAccount,
|
||||
setCurrentHotmailAccount,
|
||||
setCurrentMail2925Account,
|
||||
setContributionMode,
|
||||
@@ -8810,9 +8900,11 @@ const messageRouter = self.MultiPageBackgroundMessageRouter?.createMessageRouter
|
||||
startAutoRunLoop,
|
||||
pollContributionStatus: (...args) => contributionOAuthManager?.pollContributionStatus?.(...args),
|
||||
syncHotmailAccounts,
|
||||
syncPayPalAccounts,
|
||||
deleteMail2925Account,
|
||||
deleteMail2925Accounts,
|
||||
testHotmailAccountMailAccess,
|
||||
upsertPayPalAccount,
|
||||
upsertMail2925Account,
|
||||
upsertHotmailAccount,
|
||||
verifyHotmailAccount,
|
||||
|
||||
@@ -35,8 +35,10 @@
|
||||
finalizeStep3Completion,
|
||||
finalizeIcloudAliasAfterSuccessfulFlow,
|
||||
findHotmailAccount,
|
||||
findPayPalAccount,
|
||||
flushCommand,
|
||||
getCurrentLuckmailPurchase,
|
||||
getCurrentPayPalAccount,
|
||||
getCurrentMail2925Account,
|
||||
getPendingAutoRunTimerPlan,
|
||||
getSourceLabel,
|
||||
@@ -62,6 +64,7 @@
|
||||
refreshIpProxyPool,
|
||||
normalizeHotmailAccounts,
|
||||
normalizeMail2925Accounts,
|
||||
normalizePayPalAccounts,
|
||||
normalizeRunCount,
|
||||
AUTO_RUN_TIMER_KIND_SCHEDULED_START,
|
||||
notifyStepComplete,
|
||||
@@ -79,6 +82,7 @@
|
||||
selectLuckmailPurchase,
|
||||
switchIpProxy,
|
||||
changeIpProxyExit,
|
||||
setCurrentPayPalAccount,
|
||||
setCurrentMail2925Account,
|
||||
setCurrentHotmailAccount,
|
||||
setContributionMode,
|
||||
@@ -99,7 +103,9 @@
|
||||
deleteMail2925Account,
|
||||
deleteMail2925Accounts,
|
||||
syncHotmailAccounts,
|
||||
syncPayPalAccounts,
|
||||
testHotmailAccountMailAccess,
|
||||
upsertPayPalAccount,
|
||||
upsertMail2925Account,
|
||||
upsertHotmailAccount,
|
||||
verifyHotmailAccount,
|
||||
@@ -779,6 +785,16 @@
|
||||
return { ok: true, account };
|
||||
}
|
||||
|
||||
case 'UPSERT_PAYPAL_ACCOUNT': {
|
||||
const account = await upsertPayPalAccount(message.payload || {});
|
||||
return { ok: true, account };
|
||||
}
|
||||
|
||||
case 'SELECT_PAYPAL_ACCOUNT': {
|
||||
const account = await setCurrentPayPalAccount(String(message.payload?.accountId || ''));
|
||||
return { ok: true, account };
|
||||
}
|
||||
|
||||
case 'DELETE_HOTMAIL_ACCOUNT': {
|
||||
await deleteHotmailAccount(String(message.payload?.accountId || ''));
|
||||
return { ok: true };
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
(function attachBackgroundPayPalAccountStore(root, factory) {
|
||||
root.MultiPageBackgroundPayPalAccountStore = factory();
|
||||
})(typeof self !== 'undefined' ? self : globalThis, function createBackgroundPayPalAccountStoreModule() {
|
||||
function createPayPalAccountStore(deps = {}) {
|
||||
const {
|
||||
broadcastDataUpdate,
|
||||
findPayPalAccount,
|
||||
getState,
|
||||
normalizePayPalAccount,
|
||||
normalizePayPalAccounts,
|
||||
setPersistentSettings,
|
||||
setState,
|
||||
upsertPayPalAccountInList,
|
||||
} = deps;
|
||||
|
||||
async function syncSelectedPayPalAccountState(account = null) {
|
||||
const updates = account
|
||||
? {
|
||||
currentPayPalAccountId: account.id,
|
||||
paypalEmail: String(account.email || '').trim(),
|
||||
paypalPassword: String(account.password || ''),
|
||||
}
|
||||
: {
|
||||
currentPayPalAccountId: '',
|
||||
paypalEmail: '',
|
||||
paypalPassword: '',
|
||||
};
|
||||
|
||||
await setPersistentSettings(updates);
|
||||
await setState({
|
||||
currentPayPalAccountId: updates.currentPayPalAccountId || null,
|
||||
paypalEmail: updates.paypalEmail,
|
||||
paypalPassword: updates.paypalPassword,
|
||||
});
|
||||
broadcastDataUpdate({
|
||||
currentPayPalAccountId: updates.currentPayPalAccountId || null,
|
||||
paypalEmail: updates.paypalEmail,
|
||||
paypalPassword: updates.paypalPassword,
|
||||
});
|
||||
}
|
||||
|
||||
async function syncPayPalAccounts(accounts) {
|
||||
const normalized = normalizePayPalAccounts(accounts);
|
||||
await setPersistentSettings({ paypalAccounts: normalized });
|
||||
await setState({ paypalAccounts: normalized });
|
||||
broadcastDataUpdate({ paypalAccounts: normalized });
|
||||
|
||||
const state = await getState();
|
||||
if (state.currentPayPalAccountId && !findPayPalAccount(normalized, state.currentPayPalAccountId)) {
|
||||
await syncSelectedPayPalAccountState(null);
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function getCurrentPayPalAccount(state = {}) {
|
||||
return findPayPalAccount(state.paypalAccounts, state.currentPayPalAccountId) || null;
|
||||
}
|
||||
|
||||
async function upsertPayPalAccount(input = {}) {
|
||||
const state = await getState();
|
||||
const accounts = normalizePayPalAccounts(state.paypalAccounts);
|
||||
const normalizedEmail = String(input?.email || '').trim().toLowerCase();
|
||||
const existing = input?.id
|
||||
? findPayPalAccount(accounts, input.id)
|
||||
: accounts.find((account) => account.email === normalizedEmail) || null;
|
||||
const normalized = normalizePayPalAccount({
|
||||
...(existing || {}),
|
||||
...input,
|
||||
id: input?.id || existing?.id || crypto.randomUUID(),
|
||||
createdAt: existing?.createdAt || Date.now(),
|
||||
updatedAt: Date.now(),
|
||||
});
|
||||
|
||||
const nextAccounts = typeof upsertPayPalAccountInList === 'function'
|
||||
? upsertPayPalAccountInList(accounts, normalized)
|
||||
: accounts.concat(normalized);
|
||||
|
||||
await syncPayPalAccounts(nextAccounts);
|
||||
|
||||
if (state.currentPayPalAccountId === normalized.id) {
|
||||
await syncSelectedPayPalAccountState(normalized);
|
||||
}
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
async function setCurrentPayPalAccount(accountId) {
|
||||
const state = await getState();
|
||||
const accounts = normalizePayPalAccounts(state.paypalAccounts);
|
||||
const account = findPayPalAccount(accounts, accountId);
|
||||
if (!account) {
|
||||
throw new Error('未找到对应的 PayPal 账号。');
|
||||
}
|
||||
|
||||
await syncSelectedPayPalAccountState(account);
|
||||
return account;
|
||||
}
|
||||
|
||||
return {
|
||||
getCurrentPayPalAccount,
|
||||
setCurrentPayPalAccount,
|
||||
syncPayPalAccounts,
|
||||
upsertPayPalAccount,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
createPayPalAccountStore,
|
||||
};
|
||||
});
|
||||
@@ -99,17 +99,30 @@
|
||||
return result || {};
|
||||
}
|
||||
|
||||
function resolvePayPalCredentials(state = {}) {
|
||||
const currentId = String(state?.currentPayPalAccountId || '').trim();
|
||||
const accounts = Array.isArray(state?.paypalAccounts) ? state.paypalAccounts : [];
|
||||
const selectedAccount = currentId
|
||||
? accounts.find((account) => String(account?.id || '').trim() === currentId) || null
|
||||
: null;
|
||||
return {
|
||||
email: String(selectedAccount?.email || state?.paypalEmail || '').trim(),
|
||||
password: String(selectedAccount?.password || state?.paypalPassword || ''),
|
||||
};
|
||||
}
|
||||
|
||||
async function submitLogin(tabId, state = {}) {
|
||||
if (!state.paypalPassword) {
|
||||
throw new Error('步骤 8:未配置 PayPal 密码,请先在侧边栏填写。');
|
||||
const credentials = resolvePayPalCredentials(state);
|
||||
if (!credentials.password) {
|
||||
throw new Error('步骤 8:未配置可用的 PayPal 账号,请先在侧边栏添加并选择账号。');
|
||||
}
|
||||
await addLog('步骤 8:正在填写 PayPal 登录信息并提交...', 'info');
|
||||
const result = await sendTabMessageUntilStopped(tabId, PAYPAL_SOURCE, {
|
||||
type: 'PAYPAL_SUBMIT_LOGIN',
|
||||
source: 'background',
|
||||
payload: {
|
||||
email: state.paypalEmail || '',
|
||||
password: state.paypalPassword || '',
|
||||
email: credentials.email,
|
||||
password: credentials.password,
|
||||
},
|
||||
});
|
||||
if (result?.error) {
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
(function attachPayPalUtils(root, factory) {
|
||||
root.PayPalUtils = factory();
|
||||
})(typeof self !== 'undefined' ? self : globalThis, function createPayPalUtils() {
|
||||
function normalizePayPalAccount(account = {}) {
|
||||
const normalizedEmail = String(account.email || '').trim().toLowerCase();
|
||||
const now = Date.now();
|
||||
return {
|
||||
id: String(account.id || crypto.randomUUID()),
|
||||
email: normalizedEmail,
|
||||
password: String(account.password || ''),
|
||||
createdAt: Number.isFinite(Number(account.createdAt)) ? Number(account.createdAt) : now,
|
||||
updatedAt: Number.isFinite(Number(account.updatedAt)) ? Number(account.updatedAt) : now,
|
||||
lastUsedAt: Number.isFinite(Number(account.lastUsedAt)) ? Number(account.lastUsedAt) : 0,
|
||||
};
|
||||
}
|
||||
|
||||
function normalizePayPalAccounts(accounts) {
|
||||
if (!Array.isArray(accounts)) return [];
|
||||
|
||||
const deduped = new Map();
|
||||
for (const account of accounts) {
|
||||
const normalized = normalizePayPalAccount(account);
|
||||
if (!normalized.email) continue;
|
||||
deduped.set(normalized.id, normalized);
|
||||
}
|
||||
return [...deduped.values()];
|
||||
}
|
||||
|
||||
function findPayPalAccount(accounts = [], accountId = '') {
|
||||
const normalizedId = String(accountId || '').trim();
|
||||
if (!normalizedId) return null;
|
||||
return normalizePayPalAccounts(accounts).find((account) => account.id === normalizedId) || null;
|
||||
}
|
||||
|
||||
function upsertPayPalAccountInList(accounts = [], nextAccount = null) {
|
||||
if (!nextAccount) {
|
||||
return normalizePayPalAccounts(accounts);
|
||||
}
|
||||
|
||||
const normalizedNext = normalizePayPalAccount(nextAccount);
|
||||
const list = normalizePayPalAccounts(accounts);
|
||||
const existingIndex = list.findIndex((account) => account.id === normalizedNext.id);
|
||||
if (existingIndex >= 0) {
|
||||
list[existingIndex] = normalizedNext;
|
||||
return list;
|
||||
}
|
||||
return [...list, normalizedNext];
|
||||
}
|
||||
|
||||
return {
|
||||
findPayPalAccount,
|
||||
normalizePayPalAccount,
|
||||
normalizePayPalAccounts,
|
||||
upsertPayPalAccountInList,
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,233 @@
|
||||
(function attachSidepanelFormDialog(globalScope) {
|
||||
function createFormDialog(context = {}) {
|
||||
const {
|
||||
overlay = null,
|
||||
titleNode = null,
|
||||
closeButton = null,
|
||||
messageNode = null,
|
||||
alertNode = null,
|
||||
fieldsContainer = null,
|
||||
cancelButton = null,
|
||||
confirmButton = null,
|
||||
documentRef = globalScope.document,
|
||||
} = context;
|
||||
|
||||
let resolver = null;
|
||||
let currentConfig = null;
|
||||
let currentInputs = [];
|
||||
|
||||
function setHidden(node, hidden) {
|
||||
if (!node) return;
|
||||
node.hidden = Boolean(hidden);
|
||||
}
|
||||
|
||||
function resetAlert() {
|
||||
if (!alertNode) return;
|
||||
alertNode.textContent = '';
|
||||
alertNode.className = 'modal-alert modal-form-alert';
|
||||
alertNode.hidden = true;
|
||||
}
|
||||
|
||||
function setAlert(message = '', tone = 'danger') {
|
||||
if (!alertNode) return;
|
||||
const text = String(message || '').trim();
|
||||
if (!text) {
|
||||
resetAlert();
|
||||
return;
|
||||
}
|
||||
alertNode.textContent = text;
|
||||
alertNode.className = `modal-alert modal-form-alert${tone === 'danger' ? ' is-danger' : ''}`;
|
||||
alertNode.hidden = false;
|
||||
}
|
||||
|
||||
function close(result = null) {
|
||||
if (resolver) {
|
||||
resolver(result);
|
||||
resolver = null;
|
||||
}
|
||||
currentConfig = null;
|
||||
currentInputs = [];
|
||||
resetAlert();
|
||||
if (fieldsContainer) {
|
||||
fieldsContainer.innerHTML = '';
|
||||
}
|
||||
if (overlay) {
|
||||
overlay.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
function buildFieldNode(field, values) {
|
||||
const wrapper = documentRef.createElement('div');
|
||||
wrapper.className = 'modal-form-row';
|
||||
|
||||
const label = documentRef.createElement('label');
|
||||
label.className = 'modal-form-label';
|
||||
label.textContent = String(field.label || field.key || '').trim();
|
||||
wrapper.appendChild(label);
|
||||
|
||||
let input = null;
|
||||
if (field.type === 'textarea') {
|
||||
input = documentRef.createElement('textarea');
|
||||
input.className = 'data-textarea';
|
||||
} else if (field.type === 'select') {
|
||||
input = documentRef.createElement('select');
|
||||
input.className = 'data-select';
|
||||
const options = Array.isArray(field.options) ? field.options : [];
|
||||
options.forEach((option) => {
|
||||
const optionNode = documentRef.createElement('option');
|
||||
optionNode.value = String(option?.value || '');
|
||||
optionNode.textContent = String(option?.label || option?.value || '');
|
||||
input.appendChild(optionNode);
|
||||
});
|
||||
} else {
|
||||
input = documentRef.createElement('input');
|
||||
input.type = field.type === 'password' ? 'password' : 'text';
|
||||
input.className = 'data-input';
|
||||
}
|
||||
|
||||
const normalizedValue = Object.prototype.hasOwnProperty.call(values, field.key)
|
||||
? values[field.key]
|
||||
: field.value;
|
||||
if (normalizedValue !== undefined && normalizedValue !== null) {
|
||||
input.value = String(normalizedValue);
|
||||
}
|
||||
if (field.placeholder) {
|
||||
input.placeholder = String(field.placeholder);
|
||||
}
|
||||
if (field.autocomplete) {
|
||||
input.autocomplete = String(field.autocomplete);
|
||||
}
|
||||
if (field.inputMode) {
|
||||
input.inputMode = String(field.inputMode);
|
||||
}
|
||||
if (field.rows && field.type === 'textarea') {
|
||||
input.rows = Number(field.rows) || 3;
|
||||
}
|
||||
input.dataset.fieldKey = String(field.key || '');
|
||||
label.htmlFor = field.key;
|
||||
input.id = field.key;
|
||||
wrapper.appendChild(input);
|
||||
|
||||
if (field.type !== 'textarea') {
|
||||
input.addEventListener('keydown', (event) => {
|
||||
if (event.key !== 'Enter') {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
void handleConfirm();
|
||||
});
|
||||
}
|
||||
|
||||
currentInputs.push({ field, input });
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
function collectValues() {
|
||||
return currentInputs.reduce((result, item) => {
|
||||
result[item.field.key] = item.input.value;
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
async function handleConfirm() {
|
||||
if (!currentConfig) {
|
||||
close(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const values = collectValues();
|
||||
resetAlert();
|
||||
|
||||
for (const item of currentInputs) {
|
||||
const { field, input } = item;
|
||||
const rawValue = values[field.key];
|
||||
const textValue = String(rawValue || '').trim();
|
||||
if (field.required && !textValue) {
|
||||
setAlert(field.requiredMessage || `${field.label || field.key}不能为空。`);
|
||||
input.focus?.();
|
||||
return;
|
||||
}
|
||||
if (typeof field.validate === 'function') {
|
||||
const validationMessage = await field.validate(rawValue, values);
|
||||
if (validationMessage) {
|
||||
setAlert(validationMessage);
|
||||
input.focus?.();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(values);
|
||||
}
|
||||
|
||||
function bindEvents() {
|
||||
overlay?.addEventListener('click', (event) => {
|
||||
if (event.target === overlay) {
|
||||
close(null);
|
||||
}
|
||||
});
|
||||
closeButton?.addEventListener('click', () => close(null));
|
||||
cancelButton?.addEventListener('click', () => close(null));
|
||||
confirmButton?.addEventListener('click', () => {
|
||||
void handleConfirm();
|
||||
});
|
||||
}
|
||||
|
||||
async function open(config = {}) {
|
||||
if (!overlay || !titleNode || !fieldsContainer || !confirmButton) {
|
||||
return null;
|
||||
}
|
||||
if (resolver) {
|
||||
close(null);
|
||||
}
|
||||
|
||||
currentConfig = config || {};
|
||||
currentInputs = [];
|
||||
titleNode.textContent = String(currentConfig.title || '填写表单');
|
||||
if (messageNode) {
|
||||
const message = String(currentConfig.message || '').trim();
|
||||
messageNode.textContent = message;
|
||||
setHidden(messageNode, !message);
|
||||
}
|
||||
resetAlert();
|
||||
if (currentConfig.alert?.text) {
|
||||
setAlert(currentConfig.alert.text, currentConfig.alert.tone || 'danger');
|
||||
}
|
||||
|
||||
confirmButton.textContent = String(currentConfig.confirmLabel || '确认');
|
||||
confirmButton.className = `btn ${currentConfig.confirmVariant || 'btn-primary'} btn-sm`;
|
||||
fieldsContainer.innerHTML = '';
|
||||
|
||||
const initialValues = currentConfig.initialValues && typeof currentConfig.initialValues === 'object'
|
||||
? currentConfig.initialValues
|
||||
: {};
|
||||
const fields = Array.isArray(currentConfig.fields) ? currentConfig.fields : [];
|
||||
fields.forEach((field) => {
|
||||
fieldsContainer.appendChild(buildFieldNode(field, initialValues));
|
||||
});
|
||||
|
||||
overlay.hidden = false;
|
||||
const firstInput = currentInputs[0]?.input || null;
|
||||
if (firstInput && typeof globalScope.requestAnimationFrame === 'function') {
|
||||
globalScope.requestAnimationFrame(() => firstInput.focus?.());
|
||||
} else {
|
||||
firstInput?.focus?.();
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
resolver = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
bindEvents();
|
||||
|
||||
return {
|
||||
close,
|
||||
open,
|
||||
};
|
||||
}
|
||||
|
||||
globalScope.SidepanelFormDialog = {
|
||||
createFormDialog,
|
||||
};
|
||||
})(window);
|
||||
@@ -0,0 +1,191 @@
|
||||
(function attachSidepanelPayPalManager(globalScope) {
|
||||
function createPayPalManager(context = {}) {
|
||||
const {
|
||||
state,
|
||||
dom,
|
||||
helpers,
|
||||
runtime,
|
||||
paypalUtils = {},
|
||||
} = context;
|
||||
|
||||
let actionInFlight = false;
|
||||
|
||||
function getPayPalAccounts(currentState = state.getLatestState()) {
|
||||
return helpers.getPayPalAccounts(currentState);
|
||||
}
|
||||
|
||||
function getCurrentPayPalAccountId(currentState = state.getLatestState()) {
|
||||
return String(currentState?.currentPayPalAccountId || '').trim();
|
||||
}
|
||||
|
||||
function buildSelectOptions(accounts = []) {
|
||||
if (!accounts.length) {
|
||||
return '<option value="">请先添加 PayPal 账号</option>';
|
||||
}
|
||||
return accounts.map((account) => (
|
||||
`<option value="${helpers.escapeHtml(account.id)}">${helpers.escapeHtml(account.email || '(未命名账号)')}</option>`
|
||||
)).join('');
|
||||
}
|
||||
|
||||
function applyPayPalAccountMutation(account) {
|
||||
if (!account?.id) return;
|
||||
const latestState = state.getLatestState();
|
||||
const nextAccounts = typeof paypalUtils.upsertPayPalAccountInList === 'function'
|
||||
? paypalUtils.upsertPayPalAccountInList(getPayPalAccounts(latestState), account)
|
||||
: [...getPayPalAccounts(latestState), account];
|
||||
state.syncLatestState({ paypalAccounts: nextAccounts });
|
||||
renderPayPalAccounts();
|
||||
}
|
||||
|
||||
function renderPayPalAccounts() {
|
||||
if (!dom.selectPayPalAccount) return;
|
||||
|
||||
const latestState = state.getLatestState();
|
||||
const accounts = getPayPalAccounts(latestState);
|
||||
const currentId = getCurrentPayPalAccountId(latestState);
|
||||
|
||||
dom.selectPayPalAccount.innerHTML = buildSelectOptions(accounts);
|
||||
dom.selectPayPalAccount.disabled = accounts.length === 0;
|
||||
dom.selectPayPalAccount.value = accounts.some((account) => account.id === currentId) ? currentId : '';
|
||||
}
|
||||
|
||||
async function syncSelectedPayPalAccount(options = {}) {
|
||||
const { silent = false } = options;
|
||||
const accountId = String(dom.selectPayPalAccount?.value || '').trim();
|
||||
if (!accountId) {
|
||||
state.syncLatestState({
|
||||
currentPayPalAccountId: null,
|
||||
paypalEmail: '',
|
||||
paypalPassword: '',
|
||||
});
|
||||
renderPayPalAccounts();
|
||||
return null;
|
||||
}
|
||||
|
||||
const response = await runtime.sendMessage({
|
||||
type: 'SELECT_PAYPAL_ACCOUNT',
|
||||
source: 'sidepanel',
|
||||
payload: { accountId },
|
||||
});
|
||||
if (response?.error) {
|
||||
throw new Error(response.error);
|
||||
}
|
||||
|
||||
state.syncLatestState({
|
||||
currentPayPalAccountId: response.account?.id || accountId,
|
||||
paypalEmail: String(response.account?.email || '').trim(),
|
||||
paypalPassword: String(response.account?.password || ''),
|
||||
});
|
||||
renderPayPalAccounts();
|
||||
if (!silent) {
|
||||
helpers.showToast(`已切换当前 PayPal 账号为 ${response.account?.email || accountId}`, 'success', 1800);
|
||||
}
|
||||
return response.account || null;
|
||||
}
|
||||
|
||||
async function openPayPalAccountDialog() {
|
||||
if (typeof helpers.openFormDialog !== 'function') {
|
||||
throw new Error('表单弹窗能力未加载,请刷新扩展后重试。');
|
||||
}
|
||||
return helpers.openFormDialog({
|
||||
title: '添加 PayPal 账号',
|
||||
confirmLabel: '保存账号',
|
||||
confirmVariant: 'btn-primary',
|
||||
fields: [
|
||||
{
|
||||
key: 'email',
|
||||
label: 'PayPal 账号',
|
||||
type: 'text',
|
||||
placeholder: '请输入 PayPal 登录邮箱',
|
||||
autocomplete: 'username',
|
||||
required: true,
|
||||
requiredMessage: '请先填写 PayPal 账号。',
|
||||
validate: (value) => {
|
||||
const normalized = String(value || '').trim();
|
||||
if (!normalized.includes('@')) {
|
||||
return 'PayPal 账号需填写邮箱格式。';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'password',
|
||||
label: 'PayPal 密码',
|
||||
type: 'password',
|
||||
placeholder: '请输入 PayPal 登录密码',
|
||||
autocomplete: 'current-password',
|
||||
required: true,
|
||||
requiredMessage: '请先填写 PayPal 密码。',
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
async function handleAddPayPalAccount() {
|
||||
if (actionInFlight) return;
|
||||
|
||||
const formValues = await openPayPalAccountDialog();
|
||||
if (!formValues) {
|
||||
return;
|
||||
}
|
||||
|
||||
actionInFlight = true;
|
||||
if (dom.btnAddPayPalAccount) {
|
||||
dom.btnAddPayPalAccount.disabled = true;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await runtime.sendMessage({
|
||||
type: 'UPSERT_PAYPAL_ACCOUNT',
|
||||
source: 'sidepanel',
|
||||
payload: {
|
||||
email: String(formValues.email || '').trim(),
|
||||
password: String(formValues.password || ''),
|
||||
},
|
||||
});
|
||||
if (response?.error) {
|
||||
throw new Error(response.error);
|
||||
}
|
||||
|
||||
applyPayPalAccountMutation(response.account);
|
||||
if (response.account?.id) {
|
||||
state.syncLatestState({ currentPayPalAccountId: response.account.id });
|
||||
renderPayPalAccounts();
|
||||
dom.selectPayPalAccount.value = response.account.id;
|
||||
await syncSelectedPayPalAccount({ silent: true });
|
||||
}
|
||||
helpers.showToast(`已保存 PayPal 账号 ${response.account?.email || ''}`, 'success', 2200);
|
||||
} catch (error) {
|
||||
helpers.showToast(`保存 PayPal 账号失败:${error.message}`, 'error');
|
||||
throw error;
|
||||
} finally {
|
||||
actionInFlight = false;
|
||||
if (dom.btnAddPayPalAccount) {
|
||||
dom.btnAddPayPalAccount.disabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function bindPayPalEvents() {
|
||||
dom.btnAddPayPalAccount?.addEventListener('click', () => {
|
||||
void handleAddPayPalAccount();
|
||||
});
|
||||
dom.selectPayPalAccount?.addEventListener('change', () => {
|
||||
void syncSelectedPayPalAccount().catch((error) => {
|
||||
helpers.showToast(error.message, 'error');
|
||||
renderPayPalAccounts();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
bindPayPalEvents,
|
||||
renderPayPalAccounts,
|
||||
syncSelectedPayPalAccount,
|
||||
};
|
||||
}
|
||||
|
||||
globalScope.SidepanelPayPalManager = {
|
||||
createPayPalManager,
|
||||
};
|
||||
})(window);
|
||||
@@ -2722,6 +2722,36 @@ header {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-form-fields {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.modal-form-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.modal-form-label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.modal-form-row .data-input,
|
||||
.modal-form-row .data-select,
|
||||
.modal-form-row .data-textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.modal-form-alert {
|
||||
margin-top: -4px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
@@ -383,13 +383,14 @@
|
||||
<span class="setting-caption">PayPal 订阅链路</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row" id="row-paypal-email" style="display:none;">
|
||||
<div class="data-row" id="row-paypal-account" style="display:none;">
|
||||
<span class="data-label">PayPal 账号</span>
|
||||
<input type="text" id="input-paypal-email" class="data-input" placeholder="请输入 PayPal 登录邮箱" />
|
||||
</div>
|
||||
<div class="data-row" id="row-paypal-password" style="display:none;">
|
||||
<span class="data-label">PayPal 密码</span>
|
||||
<input type="password" id="input-paypal-password" class="data-input" placeholder="请输入 PayPal 登录密码" />
|
||||
<div class="data-inline">
|
||||
<select id="select-paypal-account" class="data-select">
|
||||
<option value="">请先添加 PayPal 账号</option>
|
||||
</select>
|
||||
<button id="btn-add-paypal-account" class="btn btn-outline btn-sm data-inline-btn" type="button">添加</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row">
|
||||
<span class="data-label">邮箱服务</span>
|
||||
@@ -986,6 +987,22 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="shared-form-modal" class="modal-overlay" hidden>
|
||||
<div class="modal-card modal-card-form">
|
||||
<div class="modal-header">
|
||||
<span id="shared-form-modal-title" class="modal-title">添加账号</span>
|
||||
<button id="btn-shared-form-modal-close" class="modal-close" type="button" aria-label="关闭">×</button>
|
||||
</div>
|
||||
<p id="shared-form-modal-message" class="modal-message" hidden></p>
|
||||
<p id="shared-form-modal-alert" class="modal-alert" hidden></p>
|
||||
<div id="shared-form-modal-fields" class="modal-form-fields"></div>
|
||||
<div class="modal-actions">
|
||||
<button id="btn-shared-form-modal-cancel" class="btn btn-ghost btn-sm" type="button">取消</button>
|
||||
<button id="btn-shared-form-modal-confirm" class="btn btn-primary btn-sm" type="button">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="auto-start-modal" class="modal-overlay" hidden>
|
||||
<div class="modal-card">
|
||||
<div class="modal-header">
|
||||
@@ -1012,6 +1029,7 @@
|
||||
<input id="input-import-settings-file" type="file" accept=".json,application/json" hidden />
|
||||
<script src="../managed-alias-utils.js"></script>
|
||||
<script src="../mail2925-utils.js"></script>
|
||||
<script src="../paypal-utils.js"></script>
|
||||
<script src="../icloud-utils.js"></script>
|
||||
<script src="../mail-provider-utils.js"></script>
|
||||
<script src="../hotmail-utils.js"></script>
|
||||
@@ -1020,8 +1038,10 @@
|
||||
<script src="update-service.js"></script>
|
||||
<script src="contribution-content-update-service.js"></script>
|
||||
<script src="account-pool-ui.js"></script>
|
||||
<script src="form-dialog.js"></script>
|
||||
<script src="hotmail-manager.js"></script>
|
||||
<script src="mail-2925-manager.js"></script>
|
||||
<script src="paypal-manager.js"></script>
|
||||
<script src="icloud-manager.js"></script>
|
||||
<script src="luckmail-manager.js"></script>
|
||||
<script src="ip-proxy-provider-711proxy.js"></script>
|
||||
|
||||
+83
-28
@@ -157,10 +157,9 @@ const inputCodex2ApiAdminKey = document.getElementById('input-codex2api-admin-ke
|
||||
const rowCustomPassword = document.getElementById('row-custom-password');
|
||||
const rowPlusMode = document.getElementById('row-plus-mode');
|
||||
const inputPlusModeEnabled = document.getElementById('input-plus-mode-enabled');
|
||||
const rowPaypalEmail = document.getElementById('row-paypal-email');
|
||||
const inputPaypalEmail = document.getElementById('input-paypal-email');
|
||||
const rowPaypalPassword = document.getElementById('row-paypal-password');
|
||||
const inputPaypalPassword = document.getElementById('input-paypal-password');
|
||||
const rowPayPalAccount = document.getElementById('row-paypal-account');
|
||||
const selectPayPalAccount = document.getElementById('select-paypal-account');
|
||||
const btnAddPayPalAccount = document.getElementById('btn-add-paypal-account');
|
||||
const selectMailProvider = document.getElementById('select-mail-provider');
|
||||
const btnMailLogin = document.getElementById('btn-mail-login');
|
||||
const rowCustomMailProviderPool = document.getElementById('row-custom-mail-provider-pool');
|
||||
@@ -299,6 +298,14 @@ const displayHeroSmsPlatform = document.getElementById('display-hero-sms-platfor
|
||||
const rowAccountRunHistoryHelperBaseUrl = document.getElementById('row-account-run-history-helper-base-url');
|
||||
const inputAccountRunHistoryHelperBaseUrl = document.getElementById('input-account-run-history-helper-base-url');
|
||||
const autoStartModal = document.getElementById('auto-start-modal');
|
||||
const sharedFormModal = document.getElementById('shared-form-modal');
|
||||
const sharedFormModalTitle = document.getElementById('shared-form-modal-title');
|
||||
const btnSharedFormModalClose = document.getElementById('btn-shared-form-modal-close');
|
||||
const sharedFormModalMessage = document.getElementById('shared-form-modal-message');
|
||||
const sharedFormModalAlert = document.getElementById('shared-form-modal-alert');
|
||||
const sharedFormModalFields = document.getElementById('shared-form-modal-fields');
|
||||
const btnSharedFormModalCancel = document.getElementById('btn-shared-form-modal-cancel');
|
||||
const btnSharedFormModalConfirm = document.getElementById('btn-shared-form-modal-confirm');
|
||||
const autoStartTitle = autoStartModal?.querySelector('.modal-title');
|
||||
const autoStartMessage = document.getElementById('auto-start-message');
|
||||
const autoStartAlert = document.getElementById('auto-start-alert');
|
||||
@@ -661,6 +668,7 @@ const upsertHotmailAccountInList = window.HotmailUtils?.upsertHotmailAccountInLi
|
||||
const filterHotmailAccountsByUsage = window.HotmailUtils?.filterHotmailAccountsByUsage;
|
||||
const getHotmailBulkActionLabel = window.HotmailUtils?.getHotmailBulkActionLabel;
|
||||
const getHotmailListToggleLabel = window.HotmailUtils?.getHotmailListToggleLabel;
|
||||
const upsertPayPalAccountInList = window.PayPalUtils?.upsertPayPalAccountInList;
|
||||
const normalizeLuckmailTimestampValue = window.LuckMailUtils?.normalizeTimestamp
|
||||
|| ((value) => {
|
||||
const timestamp = Date.parse(String(value || ''));
|
||||
@@ -668,6 +676,16 @@ const normalizeLuckmailTimestampValue = window.LuckMailUtils?.normalizeTimestamp
|
||||
});
|
||||
const sidepanelUpdateService = window.SidepanelUpdateService;
|
||||
const contributionContentService = window.SidepanelContributionContentService;
|
||||
const sharedFormDialog = window.SidepanelFormDialog?.createFormDialog?.({
|
||||
overlay: sharedFormModal,
|
||||
titleNode: sharedFormModalTitle,
|
||||
closeButton: btnSharedFormModalClose,
|
||||
messageNode: sharedFormModalMessage,
|
||||
alertNode: sharedFormModalAlert,
|
||||
fieldsContainer: sharedFormModalFields,
|
||||
cancelButton: btnSharedFormModalCancel,
|
||||
confirmButton: btnSharedFormModalConfirm,
|
||||
});
|
||||
const DEFAULT_LUCKMAIL_PRESERVE_TAG_NAME = window.LuckMailUtils?.DEFAULT_LUCKMAIL_PRESERVE_TAG_NAME || '保留';
|
||||
const normalizeIcloudHost = window.IcloudUtils?.normalizeIcloudHost
|
||||
|| ((value) => {
|
||||
@@ -793,6 +811,7 @@ function parseGmailBaseEmail(rawValue = '') {
|
||||
const value = String(rawValue || '').trim().toLowerCase();
|
||||
const match = value.match(/^([^@\s+]+)@((?:gmail|googlemail)\.com)$/i);
|
||||
if (!match) return null;
|
||||
|
||||
return {
|
||||
localPart: match[1],
|
||||
domain: match[2].toLowerCase(),
|
||||
@@ -2206,6 +2225,12 @@ function collectSettingsPayload() {
|
||||
id: typeof DEFAULT_HERO_SMS_COUNTRY_ID !== 'undefined' ? DEFAULT_HERO_SMS_COUNTRY_ID : 52,
|
||||
label: typeof DEFAULT_HERO_SMS_COUNTRY_LABEL !== 'undefined' ? DEFAULT_HERO_SMS_COUNTRY_LABEL : 'Thailand',
|
||||
};
|
||||
const payPalAccounts = typeof getPayPalAccounts === 'function'
|
||||
? getPayPalAccounts(latestState)
|
||||
: (Array.isArray(latestState?.paypalAccounts) ? latestState.paypalAccounts : []);
|
||||
const currentPayPalAccount = typeof getCurrentPayPalAccount === 'function'
|
||||
? getCurrentPayPalAccount(latestState)
|
||||
: payPalAccounts.find((account) => account?.id === String(latestState?.currentPayPalAccountId || '').trim()) || null;
|
||||
return {
|
||||
...(contributionModeEnabled ? {} : {
|
||||
panelMode: selectPanelMode.value,
|
||||
@@ -2238,12 +2263,10 @@ function collectSettingsPayload() {
|
||||
plusModeEnabled: typeof inputPlusModeEnabled !== 'undefined' && inputPlusModeEnabled
|
||||
? Boolean(inputPlusModeEnabled.checked)
|
||||
: Boolean(latestState?.plusModeEnabled),
|
||||
paypalEmail: typeof inputPaypalEmail !== 'undefined' && inputPaypalEmail
|
||||
? inputPaypalEmail.value.trim()
|
||||
: String(latestState?.paypalEmail || ''),
|
||||
paypalPassword: typeof inputPaypalPassword !== 'undefined' && inputPaypalPassword
|
||||
? inputPaypalPassword.value
|
||||
: String(latestState?.paypalPassword || ''),
|
||||
paypalEmail: String(currentPayPalAccount?.email || latestState?.paypalEmail || '').trim(),
|
||||
paypalPassword: String(currentPayPalAccount?.password || latestState?.paypalPassword || ''),
|
||||
currentPayPalAccountId: String(latestState?.currentPayPalAccountId || '').trim(),
|
||||
paypalAccounts: payPalAccounts,
|
||||
...(contributionModeEnabled ? {} : {
|
||||
customPassword: inputPassword.value,
|
||||
}),
|
||||
@@ -2485,8 +2508,7 @@ function updatePlusModeUI() {
|
||||
? Boolean(inputPlusModeEnabled.checked)
|
||||
: false;
|
||||
[
|
||||
typeof rowPaypalEmail !== 'undefined' ? rowPaypalEmail : null,
|
||||
typeof rowPaypalPassword !== 'undefined' ? rowPaypalPassword : null,
|
||||
typeof rowPayPalAccount !== 'undefined' ? rowPayPalAccount : null,
|
||||
].forEach((row) => {
|
||||
if (!row) {
|
||||
return;
|
||||
@@ -2793,12 +2815,6 @@ function applySettingsState(state) {
|
||||
if (typeof inputPlusModeEnabled !== 'undefined' && inputPlusModeEnabled) {
|
||||
inputPlusModeEnabled.checked = Boolean(state?.plusModeEnabled);
|
||||
}
|
||||
if (typeof inputPaypalEmail !== 'undefined' && inputPaypalEmail) {
|
||||
inputPaypalEmail.value = state?.paypalEmail || '';
|
||||
}
|
||||
if (typeof inputPaypalPassword !== 'undefined' && inputPaypalPassword) {
|
||||
inputPaypalPassword.value = state?.paypalPassword || '';
|
||||
}
|
||||
inputVpsUrl.value = state?.vpsUrl || '';
|
||||
inputVpsPassword.value = state?.vpsPassword || '';
|
||||
setLocalCpaStep9Mode(state?.localCpaStep9Mode);
|
||||
@@ -3000,6 +3016,9 @@ function applySettingsState(state) {
|
||||
updateFallbackThreadIntervalInputState();
|
||||
updateAccountRunHistorySettingsUI();
|
||||
updatePhoneVerificationSettingsUI();
|
||||
if (typeof renderPayPalAccounts === 'function') {
|
||||
renderPayPalAccounts();
|
||||
}
|
||||
if (typeof updatePlusModeUI === 'function') {
|
||||
updatePlusModeUI();
|
||||
}
|
||||
@@ -3664,6 +3683,15 @@ function getCurrentMail2925Email(state = latestState) {
|
||||
return String(getCurrentMail2925Account(state)?.email || '').trim();
|
||||
}
|
||||
|
||||
function getPayPalAccounts(state = latestState) {
|
||||
return Array.isArray(state?.paypalAccounts) ? state.paypalAccounts : [];
|
||||
}
|
||||
|
||||
function getCurrentPayPalAccount(state = latestState) {
|
||||
const currentId = String(state?.currentPayPalAccountId || '').trim();
|
||||
return getPayPalAccounts(state).find((account) => account.id === currentId) || null;
|
||||
}
|
||||
|
||||
function syncMail2925BaseEmailFromCurrentAccount(state = latestState, options = {}) {
|
||||
const { persist = false } = options;
|
||||
if (!isMail2925AccountPoolEnabled(state)) {
|
||||
@@ -4564,6 +4592,39 @@ const bindHotmailEvents = hotmailManager?.bindHotmailEvents
|
||||
|| (() => { });
|
||||
bindHotmailEvents();
|
||||
|
||||
const payPalManager = window.SidepanelPayPalManager?.createPayPalManager({
|
||||
state: {
|
||||
getLatestState: () => latestState,
|
||||
syncLatestState,
|
||||
},
|
||||
dom: {
|
||||
btnAddPayPalAccount,
|
||||
selectPayPalAccount,
|
||||
},
|
||||
helpers: {
|
||||
escapeHtml,
|
||||
getPayPalAccounts,
|
||||
openFormDialog: (options) => {
|
||||
if (!sharedFormDialog?.open) {
|
||||
throw new Error('表单弹窗能力未加载,请刷新扩展后重试。');
|
||||
}
|
||||
return sharedFormDialog.open(options);
|
||||
},
|
||||
showToast,
|
||||
},
|
||||
runtime: {
|
||||
sendMessage: (message) => chrome.runtime.sendMessage(message),
|
||||
},
|
||||
paypalUtils: {
|
||||
upsertPayPalAccountInList,
|
||||
},
|
||||
});
|
||||
const renderPayPalAccounts = payPalManager?.renderPayPalAccounts
|
||||
|| (() => { });
|
||||
const bindPayPalEvents = payPalManager?.bindPayPalEvents
|
||||
|| (() => { });
|
||||
bindPayPalEvents();
|
||||
|
||||
const mail2925Manager = window.SidepanelMail2925Manager?.createMail2925Manager({
|
||||
state: {
|
||||
getLatestState: () => latestState,
|
||||
@@ -5525,16 +5586,6 @@ inputPlusModeEnabled?.addEventListener('change', () => {
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
|
||||
[inputPaypalEmail, inputPaypalPassword].forEach((input) => {
|
||||
input?.addEventListener('input', () => {
|
||||
markSettingsDirty(true);
|
||||
scheduleSettingsAutoSave();
|
||||
});
|
||||
input?.addEventListener('blur', () => {
|
||||
saveSettings({ silent: true }).catch(() => { });
|
||||
});
|
||||
});
|
||||
|
||||
selectMailProvider.addEventListener('change', async () => {
|
||||
const previousProvider = latestState?.mailProvider || '';
|
||||
const previousMail2925Mode = latestState?.mail2925Mode;
|
||||
@@ -6519,6 +6570,7 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
applyAutoRunStatus(currentAutoRun);
|
||||
updateProgressCounter();
|
||||
updateButtonStates();
|
||||
renderPayPalAccounts();
|
||||
renderHotmailAccounts();
|
||||
renderMail2925Accounts();
|
||||
if (isLuckmailProvider()) {
|
||||
@@ -6721,6 +6773,9 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
inputEmail.value = getCurrentHotmailEmail();
|
||||
}
|
||||
}
|
||||
if (message.payload.currentPayPalAccountId !== undefined || message.payload.paypalAccounts !== undefined) {
|
||||
renderPayPalAccounts();
|
||||
}
|
||||
if (message.payload.currentMail2925AccountId !== undefined || message.payload.mail2925Accounts !== undefined) {
|
||||
renderMail2925Accounts();
|
||||
if (selectMailProvider.value === '2925') {
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
|
||||
test('background imports paypal account store module', () => {
|
||||
const source = fs.readFileSync('background.js', 'utf8');
|
||||
assert.match(source, /background\/paypal-account-store\.js/);
|
||||
assert.match(source, /paypal-utils\.js/);
|
||||
});
|
||||
|
||||
test('paypal account store module exposes a factory', () => {
|
||||
const source = fs.readFileSync('background/paypal-account-store.js', 'utf8');
|
||||
const globalScope = {};
|
||||
const api = new Function('self', `${source}; return self.MultiPageBackgroundPayPalAccountStore;`)(globalScope);
|
||||
|
||||
assert.equal(typeof api?.createPayPalAccountStore, 'function');
|
||||
});
|
||||
|
||||
test('paypal account store selects account and keeps legacy paypal credentials in sync', async () => {
|
||||
const source = fs.readFileSync('background/paypal-account-store.js', 'utf8');
|
||||
const globalScope = {};
|
||||
const api = new Function('self', `${source}; return self.MultiPageBackgroundPayPalAccountStore;`)(globalScope);
|
||||
|
||||
let latestState = {
|
||||
paypalAccounts: [],
|
||||
currentPayPalAccountId: '',
|
||||
paypalEmail: '',
|
||||
paypalPassword: '',
|
||||
};
|
||||
const broadcasts = [];
|
||||
|
||||
const store = api.createPayPalAccountStore({
|
||||
broadcastDataUpdate(payload) {
|
||||
broadcasts.push(payload);
|
||||
},
|
||||
findPayPalAccount(accounts, accountId) {
|
||||
return (Array.isArray(accounts) ? accounts : []).find((account) => account.id === accountId) || null;
|
||||
},
|
||||
getState: async () => latestState,
|
||||
normalizePayPalAccount(account = {}) {
|
||||
return {
|
||||
id: String(account.id || 'generated'),
|
||||
email: String(account.email || '').trim().toLowerCase(),
|
||||
password: String(account.password || ''),
|
||||
createdAt: Number(account.createdAt) || 1,
|
||||
updatedAt: Number(account.updatedAt) || 1,
|
||||
lastUsedAt: Number(account.lastUsedAt) || 0,
|
||||
};
|
||||
},
|
||||
normalizePayPalAccounts(accounts) {
|
||||
return Array.isArray(accounts) ? accounts.slice() : [];
|
||||
},
|
||||
setPersistentSettings: async (updates) => {
|
||||
latestState = { ...latestState, ...updates };
|
||||
},
|
||||
setState: async (updates) => {
|
||||
latestState = { ...latestState, ...updates };
|
||||
},
|
||||
upsertPayPalAccountInList(accounts, nextAccount) {
|
||||
const list = Array.isArray(accounts) ? accounts.slice() : [];
|
||||
const existingIndex = list.findIndex((account) => account.id === nextAccount.id);
|
||||
if (existingIndex >= 0) {
|
||||
list[existingIndex] = nextAccount;
|
||||
return list;
|
||||
}
|
||||
list.push(nextAccount);
|
||||
return list;
|
||||
},
|
||||
});
|
||||
|
||||
const account = await store.upsertPayPalAccount({
|
||||
id: 'pp-1',
|
||||
email: 'User@Example.com',
|
||||
password: 'secret',
|
||||
});
|
||||
assert.equal(account.email, 'user@example.com');
|
||||
|
||||
const selected = await store.setCurrentPayPalAccount('pp-1');
|
||||
assert.equal(selected.id, 'pp-1');
|
||||
assert.equal(latestState.currentPayPalAccountId, 'pp-1');
|
||||
assert.equal(latestState.paypalEmail, 'user@example.com');
|
||||
assert.equal(latestState.paypalPassword, 'secret');
|
||||
assert.deepStrictEqual(
|
||||
broadcasts.at(-1),
|
||||
{
|
||||
currentPayPalAccountId: 'pp-1',
|
||||
paypalEmail: 'user@example.com',
|
||||
paypalPassword: 'secret',
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -107,6 +107,32 @@ test('PayPal approve keeps original combined email and password login path', asy
|
||||
assert.equal(events.messages.includes('PAYPAL_CLICK_APPROVE'), true);
|
||||
});
|
||||
|
||||
test('PayPal approve prefers the selected paypal pool account over legacy fields', async () => {
|
||||
const { executor, events } = createExecutor({
|
||||
pageStates: [
|
||||
{ needsLogin: true, hasEmailInput: true, hasPasswordInput: true, loginPhase: 'login_combined' },
|
||||
{ needsLogin: false, approveReady: true },
|
||||
{ needsLogin: false, approveReady: true },
|
||||
],
|
||||
submitResults: [
|
||||
{ submitted: true, phase: 'password_submitted', awaiting: 'redirect_or_approval' },
|
||||
],
|
||||
});
|
||||
|
||||
await executor.executePayPalApprove({
|
||||
paypalEmail: '',
|
||||
paypalPassword: '',
|
||||
currentPayPalAccountId: 'pp-1',
|
||||
paypalAccounts: [
|
||||
{ id: 'pp-1', email: 'pool@example.com', password: 'pool-secret' },
|
||||
],
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(events.submittedPayloads, [
|
||||
{ email: 'pool@example.com', password: 'pool-secret' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('PayPal approve discovers an already open unregistered PayPal tab', async () => {
|
||||
const { executor, events } = createExecutor({
|
||||
pageStates: [
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
|
||||
test('sidepanel loads reusable form dialog and paypal manager before sidepanel bootstrap', () => {
|
||||
const html = fs.readFileSync('sidepanel/sidepanel.html', 'utf8');
|
||||
const formDialogIndex = html.indexOf('<script src="form-dialog.js"></script>');
|
||||
const managerIndex = html.indexOf('<script src="paypal-manager.js"></script>');
|
||||
const sidepanelIndex = html.indexOf('<script src="sidepanel.js"></script>');
|
||||
|
||||
assert.notEqual(formDialogIndex, -1);
|
||||
assert.notEqual(managerIndex, -1);
|
||||
assert.notEqual(sidepanelIndex, -1);
|
||||
assert.ok(formDialogIndex < managerIndex);
|
||||
assert.ok(managerIndex < sidepanelIndex);
|
||||
});
|
||||
|
||||
test('sidepanel html contains paypal select and add button controls', () => {
|
||||
const html = fs.readFileSync('sidepanel/sidepanel.html', 'utf8');
|
||||
|
||||
assert.match(html, /id="row-paypal-account"/);
|
||||
assert.match(html, /id="select-paypal-account"/);
|
||||
assert.match(html, /id="btn-add-paypal-account"/);
|
||||
assert.match(html, /id="shared-form-modal"/);
|
||||
});
|
||||
|
||||
test('paypal manager saves a paypal account and selects it immediately', async () => {
|
||||
const source = fs.readFileSync('sidepanel/paypal-manager.js', 'utf8');
|
||||
const windowObject = {};
|
||||
const api = new Function('window', `${source}; return window.SidepanelPayPalManager;`)(windowObject);
|
||||
|
||||
let latestState = {
|
||||
paypalAccounts: [],
|
||||
currentPayPalAccountId: null,
|
||||
paypalEmail: '',
|
||||
paypalPassword: '',
|
||||
};
|
||||
const events = [];
|
||||
const clickHandlers = {};
|
||||
const changeHandlers = {};
|
||||
const selectNode = {
|
||||
innerHTML: '',
|
||||
value: '',
|
||||
disabled: false,
|
||||
addEventListener(type, handler) {
|
||||
changeHandlers[type] = handler;
|
||||
},
|
||||
};
|
||||
const addButton = {
|
||||
disabled: false,
|
||||
addEventListener(type, handler) {
|
||||
clickHandlers[type] = handler;
|
||||
},
|
||||
};
|
||||
|
||||
const manager = api.createPayPalManager({
|
||||
state: {
|
||||
getLatestState: () => latestState,
|
||||
syncLatestState(updates) {
|
||||
latestState = { ...latestState, ...updates };
|
||||
},
|
||||
},
|
||||
dom: {
|
||||
btnAddPayPalAccount: addButton,
|
||||
selectPayPalAccount: selectNode,
|
||||
},
|
||||
helpers: {
|
||||
escapeHtml: (value) => String(value || ''),
|
||||
getPayPalAccounts: (state) => Array.isArray(state?.paypalAccounts) ? state.paypalAccounts : [],
|
||||
openFormDialog: async () => ({ email: 'user@example.com', password: 'secret' }),
|
||||
showToast(message, tone) {
|
||||
events.push({ type: 'toast', message, tone });
|
||||
},
|
||||
},
|
||||
runtime: {
|
||||
sendMessage: async (message) => {
|
||||
events.push({ type: 'message', message });
|
||||
if (message.type === 'UPSERT_PAYPAL_ACCOUNT') {
|
||||
return {
|
||||
ok: true,
|
||||
account: {
|
||||
id: 'pp-1',
|
||||
email: 'user@example.com',
|
||||
password: 'secret',
|
||||
},
|
||||
};
|
||||
}
|
||||
if (message.type === 'SELECT_PAYPAL_ACCOUNT') {
|
||||
return {
|
||||
ok: true,
|
||||
account: {
|
||||
id: 'pp-1',
|
||||
email: 'user@example.com',
|
||||
password: 'secret',
|
||||
},
|
||||
};
|
||||
}
|
||||
throw new Error(`unexpected message ${message.type}`);
|
||||
},
|
||||
},
|
||||
paypalUtils: {
|
||||
upsertPayPalAccountInList(accounts, nextAccount) {
|
||||
const list = Array.isArray(accounts) ? accounts.slice() : [];
|
||||
const existingIndex = list.findIndex((account) => account.id === nextAccount.id);
|
||||
if (existingIndex >= 0) {
|
||||
list[existingIndex] = nextAccount;
|
||||
return list;
|
||||
}
|
||||
list.push(nextAccount);
|
||||
return list;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
manager.bindPayPalEvents();
|
||||
manager.renderPayPalAccounts();
|
||||
|
||||
assert.match(selectNode.innerHTML, /请先添加 PayPal 账号/);
|
||||
clickHandlers.click();
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
|
||||
assert.deepStrictEqual(
|
||||
events.filter((event) => event.type === 'message').map((event) => event.message.type),
|
||||
['UPSERT_PAYPAL_ACCOUNT', 'SELECT_PAYPAL_ACCOUNT']
|
||||
);
|
||||
assert.equal(latestState.currentPayPalAccountId, 'pp-1');
|
||||
assert.equal(latestState.paypalEmail, 'user@example.com');
|
||||
assert.equal(latestState.paypalPassword, 'secret');
|
||||
assert.equal(selectNode.value, 'pp-1');
|
||||
assert.equal(selectNode.disabled, false);
|
||||
assert.match(events.at(-1)?.message || '', /已保存 PayPal 账号/);
|
||||
});
|
||||
@@ -68,6 +68,7 @@ test('sidepanel html loads shared step definitions before sidepanel bootstrap',
|
||||
test('sidepanel html exposes Plus mode and PayPal settings', () => {
|
||||
const html = fs.readFileSync('sidepanel/sidepanel.html', 'utf8');
|
||||
assert.match(html, /id="input-plus-mode-enabled"/);
|
||||
assert.match(html, /id="input-paypal-email"/);
|
||||
assert.match(html, /id="input-paypal-password"/);
|
||||
assert.match(html, /id="select-paypal-account"/);
|
||||
assert.match(html, /id="btn-add-paypal-account"/);
|
||||
assert.match(html, /id="shared-form-modal"/);
|
||||
});
|
||||
|
||||
+3
-3
@@ -45,7 +45,7 @@
|
||||
- 在日志区通过“记录”按钮打开独立的邮箱记录覆盖层,并展示成功/失败/停止/重试统计与分页列表
|
||||
- 查询 GitHub Releases 并展示更新卡片;当前更新服务会区分 `Ultra`、历史 `Pro` 与 legacy `v` 三个版本族,排序时固定以 `Ultra` 为最高正式系列,同时会在读取缓存后重新排序,避免历史 `Pro` 或 `v` 版本误显示为比 `Ultra` 更新
|
||||
- 展示一个单独的“接码”开关;开启后才展示 HeroSMS 的接码国家与 API Key 设置,用于 OAuth 登录链路命中手机号验证页时直接续跑手机验证
|
||||
- 展示 `Plus 模式` 开关与 PayPal 账号/密码配置;开启后步骤列表切换为 Plus 模式 13 步定义,普通模式的 Cookie 清理步骤不再显示或执行,登录验证码步骤会移动到 Plus 可见第 11 步
|
||||
- 展示 `Plus 模式` 开关与 PayPal 账号池配置;开启后 PayPal 配置行会切换为“账号下拉框 + 添加按钮”,添加按钮复用公共表单弹窗录入账号和密码;步骤列表切换为 Plus 模式 13 步定义,普通模式的 Cookie 清理步骤不再显示或执行,登录验证码步骤会移动到 Plus 可见第 11 步
|
||||
- 为 Hotmail / 2925 账号池复用同一套“添加账号 / 取消添加 / 批量导入 / 收起列表”表单交互;共享的显隐控制放在 `sidepanel/account-pool-ui.js`,各自 manager 只保留 provider 相关字段校验与业务操作
|
||||
|
||||
### 2.2 Background Service Worker
|
||||
@@ -163,7 +163,7 @@
|
||||
- Codex2API 配置
|
||||
- IP 代理持久配置:`ipProxyEnabled`、服务商、模式、API 地址、服务商配置快照、账号列表、固定 Host / Port / Protocol / Username / Password、地区参数、session 与自动切换阈值
|
||||
- Plus 模式开关 `plusModeEnabled`
|
||||
- PayPal 登录配置 `paypalEmail / paypalPassword`
|
||||
- PayPal 账号池配置 `paypalAccounts / currentPayPalAccountId`,以及供后台步骤兼容读取的 `paypalEmail / paypalPassword`
|
||||
- 邮箱 provider 配置
|
||||
- Hotmail 账号池
|
||||
- 2925 账号池
|
||||
@@ -500,7 +500,7 @@ Plus 模式可见步骤:
|
||||
1. 第 1~5 步:沿用普通注册入口、邮箱、密码、注册验证码、资料填写链路。
|
||||
2. 第 6 步 `创建 Plus Checkout`:打开已登录 ChatGPT 页面,通过 `/api/auth/session` 读取 accessToken,再请求 `https://chatgpt.com/backend-api/payments/checkout` 创建 `chatgptplusplan` 的 checkout session,并打开 `https://chatgpt.com/checkout/openai_ie/{checkout_session_id}`。
|
||||
3. 第 7 步 `填写账单并提交订阅`:选择 PayPal,生成账单全名,从 `data/address-sources.js` 读取同国家 seed query,触发 checkout 内置 Google 地址推荐,选择推荐项并校验地址第 1 行、城市、州/省、邮编等结构化字段,再点击“订阅”。运行时会按 Stripe iframe 拆分执行:付款方式在 `elements-inner-payment` frame,账单地址在 `elements-inner-address` frame,Google 推荐在 `elements-inner-autocompl` frame 时单独点击推荐项。
|
||||
4. 第 8 步 `PayPal 登录与授权`:在 PayPal 页面填写 `paypalEmail / paypalPassword`。当页面处于账号输入阶段时,内容脚本会固定对邮箱输入框执行 `focus -> clear -> fill -> blur -> click next`,即使文本框里已经预填了同一个账号,也会重新触发输入事件,避免 PayPal 因跳过重填而停在邮箱页;登录前固定等待 1 秒,关闭可见通行密钥提示,点击“同意并继续”。
|
||||
4. 第 8 步 `PayPal 登录与授权`:后台优先读取侧边栏当前选中的 PayPal 账号;为兼容旧链路,也会把该账号同步回 `paypalEmail / paypalPassword`。当页面处于账号输入阶段时,内容脚本会固定对邮箱输入框执行 `focus -> clear -> fill -> blur -> click next`,即使文本框里已经预填了同一个账号,也会重新触发输入事件,避免 PayPal 因跳过重填而停在邮箱页;登录前固定等待 1 秒,关闭可见通行密钥提示,点击“同意并继续”。
|
||||
5. 第 9 步 `订阅回跳确认`:等待 PayPal 授权后回跳到 ChatGPT / OpenAI 页面,页面加载完成后固定等待 1 秒。
|
||||
6. 第 10 步:复用原 Step 7 OAuth 登录执行器,但状态和日志按 Plus 可见第 10 步记录。
|
||||
7. 第 11 步:复用原 Step 8 登录验证码执行器,但状态和日志按 Plus 可见第 11 步记录。
|
||||
|
||||
+11
-4
@@ -29,6 +29,7 @@
|
||||
- `mail-provider-utils.js`:网页邮箱 provider 配置纯工具,负责 `163 / 163 VIP / 126 / QQ / Inbucket / Hotmail` 的基础归一化与页面入口配置,并统一承接 iCloud 转发收码目标邮箱 provider 的归一化、选项列表和收码入口配置。
|
||||
- `mail2925-utils.js`:2925 账号池相关的纯工具函数,负责账号归一化、冷却期判断、可用账号挑选、批量导入解析与列表更新。
|
||||
- `managed-alias-utils.js`:共享 Gmail / 2925 的别名邮箱规则,负责解析基邮箱、校验“当前完整注册邮箱”是否仍与基邮箱兼容、生成 Gmail `+tag` 与 2925 随机后缀邮箱,并输出 sidepanel 可复用的 UI 文案;当前还统一承接 `mail2925Mode` 的归一化与“2925 仅在 provide 模式下参与别名生成”的共享判定。
|
||||
- `paypal-utils.js`:PayPal 账号池相关的纯工具函数,负责账号归一化、按 ID 查找和列表 upsert。
|
||||
- `manifest.json`:Chrome 扩展清单,声明权限、背景脚本、侧边栏、内容脚本与规则集;当前额外声明 `proxy / webRequest / webRequestAuthProvider`,用于 IP 代理 PAC 接管和代理鉴权回填。
|
||||
- `microsoft-email.js`:Microsoft Graph / Outlook 邮件读取辅助模块,负责刷新令牌换 token、邮箱夹轮询和验证码提取。
|
||||
- `package.json`:仓库最小 Node 包配置,目前主要提供测试脚本定义。
|
||||
@@ -50,8 +51,9 @@
|
||||
- `background/ip-proxy-provider-711proxy.js`:711Proxy provider 规则模块,负责从账号串中识别和写回 `region / session / sessTime` 等参数,并在固定账号模式下把侧栏配置转换为最终生效的代理账号。
|
||||
- `background/logging-status.js`:后台日志、步骤状态、错误信息和若干状态判断的公共工具层;当前额外承接 `add-phone / 手机号页` 这类认证 fatal 错误的共享判定,并会把 Step 2 的“手机号输入模式未切成功”与真正的 auth `add-phone` 页面区分开,避免自动运行误停机。
|
||||
- `background/mail-2925-session.js`:2925 会话模块,负责 2925 账号池持久化、当前账号切换、cookie 清理登出、自动登录、命中“子邮箱已达上限邮箱”后的 24 小时禁用与自动切号。
|
||||
- `background/message-router.js`:后台消息路由层,负责处理 `chrome.runtime.onMessage` 进入的所有业务消息;当前额外接入 2925 账号池的新增、导入、切换、登录、禁用与删除消息,以及 IP 代理的同步、切换、Change 与出口检测消息。
|
||||
- `background/message-router.js`:后台消息路由层,负责处理 `chrome.runtime.onMessage` 进入的所有业务消息;当前额外接入 PayPal 账号池的新增与切换、2925 账号池的新增、导入、切换、登录、禁用与删除消息,以及 IP 代理的同步、切换、Change 与出口检测消息。
|
||||
- `background/navigation-utils.js`:导航与 URL 判断工具层,负责 callback、入口页、CPA / SUB2API / Codex2API 地址归一化、来源标签页家族判断与步骤跳转相关判断。
|
||||
- `background/paypal-account-store.js`:PayPal 账号池持久化模块,负责保存账号列表、切换当前账号,并把当前选中账号同步回兼容字段 `paypalEmail / paypalPassword`。
|
||||
- `background/phone-verification-flow.js`:手机号验证共享流程模块,负责在 OAuth 链路命中 `add-phone / phone-verification` 页面后向 HeroSMS 申请或复用号码、轮询短信验证码、提交手机号码与短信验证码,并在号码长期收不到短信时把后续自动流拉回步骤 7 重新拿号。
|
||||
- `background/panel-bridge.js`:来源桥接层;CPA / SUB2API 继续封装页面打开、脚本注入和通信,Codex2API 则直接通过后台协议生成 OAuth 地址。
|
||||
- `background/signup-flow-helpers.js`:注册页辅助层,负责打开注册入口、等待密码页以及解析当前流程所用邮箱;在 Gmail 与 `2925 + provide` 模式下会优先复用已经存在且仍兼容的完整注册邮箱,只有不兼容或为空时才重新生成;当 provider 为 2925 且启用了 provide 模式下的号池时,会先确保账号池中已选中可用账号。
|
||||
@@ -130,6 +132,7 @@
|
||||
- `sidepanel/icloud-manager.js`:侧边栏 iCloud 隐私邮箱管理器,负责列表、筛选、保留、删除和批量操作。
|
||||
- `sidepanel/luckmail-manager.js`:侧边栏 LuckMail 管理器,负责邮箱列表、筛选、启停、保留与批量操作。
|
||||
- `sidepanel/mail-2925-manager.js`:侧边栏 2925 账号池管理器,负责 2925 账号的新增、导入、切换、手动登录、启停、清冷却与删除。
|
||||
- `sidepanel/form-dialog.js`:侧边栏公共表单弹窗模块,负责渲染可复用的小型表单弹窗,支持动态字段、校验、确认与取消。
|
||||
- `sidepanel/account-records-manager.js`:侧边栏邮箱记录面板管理器,负责“记录”按钮、覆盖层开关、分页列表、成功/失败/停止统计摘要和清理确认。
|
||||
- `sidepanel/contribution-content-update-service.js`:侧边栏贡献内容更新服务,负责拉取 `https://apikey.qzz.io/api/content-summary`、缓存公开公告/教程摘要,并输出可用于提示展示的 `promptVersion` 与最新更新时间。
|
||||
- `sidepanel/contribution-mode.js`:侧边栏贡献模式管理器,负责顶部“贡献”按钮、确认弹窗、贡献模式显隐、复用主自动流程启动、侧栏内贡献状态轮询、上传页跳转,以及贡献模式下对来源选择、配置入口、记录入口和敏感配置行(包括 Codex2API 配置)的禁用与隐藏。
|
||||
@@ -144,7 +147,8 @@
|
||||
receive 模式把账号池开关一起隐藏;当前在 `邮箱生成` 区域新增 `自定义邮箱池` 选项和多行邮箱池输入框,并在 `邮箱服务 = 自定义邮箱` 时
|
||||
额外显示 `自定义号池` 文本框;当邮箱服务为 iCloud 时,额外提供目标邮箱类型与转发邮箱 provider 配置,用于选择直接从 iCloud 收件箱收
|
||||
码或从 QQ / 网易 / Gmail 转发目标邮箱收码;来源下拉框当前支持 `CPA / SUB2API / Codex2API`,其中 Codex2API 额外提供后台地址和管理密
|
||||
钥配置行;设置卡片新增 `IP代理` 开关与代理配置折叠区,支持 711Proxy 账号密码模式、代理状态卡与出口检测按钮;设置卡片新增 `Plus 模式` 开关与 PayPal 账号/密码输入行;Hotmail / 2925 两个账号池当前都使用统一的头部“添加账号/取消添加”按钮和共享表单容器。
|
||||
钥配置行;设置卡片新增 `IP代理` 开关与代理配置折叠区,支持 711Proxy 账号密码模式、代理状态卡与出口检测按钮;设置卡片新增 `Plus 模式` 开关与 PayPal 账号下拉框,右侧使用公共表单弹窗添加账号;Hotmail / 2925 两个账号池当前都使用统一的头部“添加账号/取消添加”按钮和共享表单容器。
|
||||
- `sidepanel/paypal-manager.js`:侧边栏 PayPal 账号管理器,负责 Plus 模式下的账号下拉框渲染、添加账号弹窗、保存账号与切换当前账号。
|
||||
- `sidepanel/sidepanel.js`:侧边栏主入口脚本,负责 UI 状态同步、动态步骤渲染、按钮交互、共享验证码自动重发次数配置与广播接收,并装
|
||||
配 Hotmail / 2925 / iCloud / LuckMail / 贡献模式 / 邮箱记录面板 / 贡献内容更新服务;当前贡献模式的“开始贡献”会直接复用主自动流程启
|
||||
动逻辑,而独立 manager 负责贡献运行态展示与轮询,同时把 Gmail / 2925 的基邮箱输入、完整注册邮箱输入、自动生成按钮与兼容性校验统一接
|
||||
@@ -152,8 +156,9 @@
|
||||
示并同时服务于 provide / receive 两种模式;当 provider 为 iCloud 时,会保存并回显目标邮箱类型与转发邮箱 provider,相关 provider 选
|
||||
项和 label 复用 `mail-provider-utils.js`;`自定义邮箱池` 模式会按邮箱池长度锁定自动轮数,并把当前输入的邮箱池配置参与自动启动前保
|
||||
存;`邮箱服务 = 自定义邮箱` 时,如果配置了 `customMailProviderPool`,也会按号池长度锁定自动轮数并在 Auto 中按轮次分配注册邮箱,同时
|
||||
在普通失败时继续复用当前邮箱,只有成功或出现手机号验证时才切换下一个邮箱;Plus 模式开启后,步骤列表会切换为 13 步,并显示 PayPal 凭
|
||||
据配置;Step 8 的自定义邮箱确认弹窗当前额外提供“出现手机号验证”按钮,用于直接走与真实 add-phone 一致的 fatal 分支;HeroSMS 国家列表
|
||||
在普通失败时继续复用当前邮箱,只有成功或出现手机号验证时才切换下一个邮箱;Plus 模式开启后,步骤列表会切换为 13 步,并显示 PayPal 账
|
||||
号下拉框与添加入口;当前选中的 PayPal 账号会同步回兼容字段 `paypalEmail / paypalPassword` 供后台步骤复用;Step 8 的自定义邮箱确认弹
|
||||
窗当前额外提供“出现手机号验证”按钮,用于直接走与真实 add-phone 一致的 fatal 分支;HeroSMS 国家列表
|
||||
会在 sidepanel 初始化时拉取并恢复到本地保存的国家/API 设置,接码开关关闭时会直接隐藏相关配置;账号记录快照同步改为默认自动模式,只
|
||||
要本地 helper 可用就会自动落盘;新来源 Codex2API 在这里仅补充来源配置接线、表单显隐和 Step 10 按钮文案,不承接协议业务逻辑;
|
||||
Hotmail / 2925 的新增表单显隐统一接到 `sidepanel/account-pool-ui.js` 这一层共享 helper;IP 代理配置保存、服务配置快照、开关应用和运行态回显由这里接入消息路由,具体解析/状态渲染下沉到 `sidepanel/ip-proxy-panel.js`;侧边栏初始化与点击“自动”前会刷新一次贡献站
|
||||
@@ -189,6 +194,7 @@
|
||||
- `tests/background-message-router-step2-skip.test.js`:测试步骤 2 直接落到验证码页时的跳步与状态保护逻辑。
|
||||
- `tests/background-navigation-utils-module.test.js`:测试导航工具模块已接入且导出工厂。
|
||||
- `tests/background-panel-bridge-module.test.js`:测试面板桥接模块已接入且导出工厂。
|
||||
- `tests/background-paypal-account-store-module.test.js`:测试 PayPal 账号池后台模块已接入、导出工厂,并覆盖当前账号选择会同步回兼容字段 `paypalEmail / paypalPassword`。
|
||||
- `tests/background-platform-verify-codex2api.test.js`:测试 Codex2API 新来源在步骤 10 走协议式 callback 交换,不依赖后台页面注入。
|
||||
- `tests/background-signup-flow-module.test.js`:测试注册页辅助模块已接入且导出工厂。
|
||||
- `tests/background-skip-step-linking.test.js`:测试手动跳过步骤 1 时,会级联跳过步骤 2~5,并仅跳过其中未完成且未运行的步骤。
|
||||
@@ -231,6 +237,7 @@
|
||||
- `tests/sidepanel-luckmail-manager.test.js`:测试侧边栏 LuckMail 管理器模块接线与空态渲染。
|
||||
- `tests/sidepanel-mail2925-manager.test.js`:测试侧边栏 2925 管理器模块接线、共享号池表单脚本加载顺序、显隐交互与空态渲染。
|
||||
- `tests/sidepanel-mail2925-mode.test.js`:测试侧边栏保留 `2925 provide / receive` 模式行与独立的号池配置行,并验证 sidepanel 只在 provide 模式下把 2925 视为别名邮箱 provider。
|
||||
- `tests/sidepanel-paypal-manager.test.js`:测试侧边栏公共表单弹窗脚本与 PayPal manager 的加载顺序,以及 PayPal 账号保存后会立即选中当前账号。
|
||||
- `tests/signup-entry-diagnostics.test.js`:测试注册入口诊断快照输出。
|
||||
- `tests/signup-step2-email-switch.test.js`:测试 Step 2 在手机号输入模式下切回邮箱输入模式,以及本地化邮箱输入框识别。
|
||||
- `tests/signup-page-tab-cleanup.test.js`:测试注册页来源标签的冲突清理逻辑。
|
||||
|
||||
Reference in New Issue
Block a user