diff --git a/background.js b/background.js index 4e67c5c..dda6fda 100644 --- a/background.js +++ b/background.js @@ -237,7 +237,7 @@ const STEP7_MAIL_POLLING_RECOVERY_MAX_ATTEMPTS = 8; const OAUTH_FLOW_TIMEOUT_MS = 5 * 60 * 1000; const SUB2API_STEP1_RESPONSE_TIMEOUT_MS = 90000; const SUB2API_STEP9_RESPONSE_TIMEOUT_MS = 120000; -const DEFAULT_SUB2API_URL = 'https://sub2api.hisence.fun/admin/accounts'; +const DEFAULT_SUB2API_URL = ''; const DEFAULT_CODEX2API_URL = 'http://localhost:8080/admin/accounts'; const DEFAULT_GPC_HELPER_API_URL = 'https://gpc.qlhazycoder.top'; const DEFAULT_SUB2API_GROUP_NAME = 'codex'; @@ -2305,15 +2305,23 @@ function normalizePersistentSettingValue(key, value) { ); case 'gopayHelperApiUrl': { - const legacyGpcHelperApiUrl = 'https://gpc.leftcode.xyz'; const defaultGpcHelperApiUrl = PERSISTED_SETTING_DEFAULTS.gopayHelperApiUrl || (typeof DEFAULT_GPC_HELPER_API_URL !== 'undefined' ? DEFAULT_GPC_HELPER_API_URL : 'https://gpc.qlhazycoder.top'); const normalizedGpcHelperApiUrl = self.GoPayUtils?.normalizeGpcHelperBaseUrl ? self.GoPayUtils.normalizeGpcHelperBaseUrl(value || defaultGpcHelperApiUrl) : String(value || defaultGpcHelperApiUrl).trim().replace(/\/+$/g, ''); - return normalizedGpcHelperApiUrl === legacyGpcHelperApiUrl - ? defaultGpcHelperApiUrl - : normalizedGpcHelperApiUrl; + if (!self.GoPayUtils?.normalizeGpcHelperBaseUrl) { + try { + const parsed = new URL(normalizedGpcHelperApiUrl); + const hostname = parsed.hostname.toLowerCase(); + if (hostname !== 'gpc.qlhazycoder.top' && hostname !== 'localhost' && hostname !== '127.0.0.1') { + return defaultGpcHelperApiUrl; + } + } catch { + return defaultGpcHelperApiUrl; + } + } + return normalizedGpcHelperApiUrl; } case 'gopayHelperApiKey': case 'gopayHelperCardKey': @@ -6777,6 +6785,7 @@ function normalizeSub2ApiUrl(rawUrl) { return navigationUtils.normalizeSub2ApiUrl(rawUrl); } const input = (rawUrl || '').trim() || DEFAULT_SUB2API_URL; + if (!input) return ''; const withProtocol = /^https?:\/\//i.test(input) ? input : `https://${input}`; const parsed = new URL(withProtocol); if (!parsed.pathname || parsed.pathname === '/') { diff --git a/background/mail-2925-session.js b/background/mail-2925-session.js index e80dc4c..e0e79cd 100644 --- a/background/mail-2925-session.js +++ b/background/mail-2925-session.js @@ -37,12 +37,10 @@ const MAIL2925_COOKIE_DOMAINS = [ '2925.com', 'www.2925.com', - 'mail2.xiyouji.com', ]; const MAIL2925_COOKIE_ORIGINS = [ 'https://2925.com', 'https://www.2925.com', - 'https://mail2.xiyouji.com', ]; const MAIL2925_LIMIT_ERROR_PREFIX = 'MAIL2925_LIMIT_REACHED::'; const MAIL2925_THREAD_TERMINATED_ERROR_PREFIX = 'MAIL2925_THREAD_TERMINATED::'; diff --git a/background/navigation-utils.js b/background/navigation-utils.js index f1ceef3..9077502 100644 --- a/background/navigation-utils.js +++ b/background/navigation-utils.js @@ -19,6 +19,7 @@ function normalizeSub2ApiUrl(rawUrl) { const input = (rawUrl || '').trim() || DEFAULT_SUB2API_URL; + if (!input) return ''; const withProtocol = /^https?:\/\//i.test(input) ? input : `https://${input}`; const parsed = new URL(withProtocol); if (!parsed.pathname || parsed.pathname === '/') { diff --git a/background/panel-bridge.js b/background/panel-bridge.js index a4dff4c..8e204b5 100644 --- a/background/panel-bridge.js +++ b/background/panel-bridge.js @@ -251,6 +251,9 @@ const sub2apiUrl = normalizeSub2ApiUrl(state.sub2apiUrl); const groupName = (state.sub2apiGroupName || DEFAULT_SUB2API_GROUP_NAME).trim() || DEFAULT_SUB2API_GROUP_NAME; + if (!sub2apiUrl) { + throw new Error('SUB2API URL is not configured. Please fill it in the side panel first.'); + } if (!state.sub2apiEmail) { throw new Error('尚未配置 SUB2API 登录邮箱,请先在侧边栏填写。'); } diff --git a/background/steps/platform-verify.js b/background/steps/platform-verify.js index e9fb06c..2d39999 100644 --- a/background/steps/platform-verify.js +++ b/background/steps/platform-verify.js @@ -343,6 +343,9 @@ } const sub2apiUrl = normalizeSub2ApiUrl(state.sub2apiUrl); + if (!sub2apiUrl) { + throw new Error('SUB2API URL is not configured. Please fill it in the side panel first.'); + } const injectFiles = ['content/utils.js', 'content/sub2api-panel.js']; await addStepLog(visibleStep, '正在打开 SUB2API 后台...'); diff --git a/gopay-utils.js b/gopay-utils.js index 0fe3e9b..b2c2eee 100644 --- a/gopay-utils.js +++ b/gopay-utils.js @@ -5,7 +5,7 @@ const PLUS_PAYMENT_METHOD_GOPAY = 'gopay'; const PLUS_PAYMENT_METHOD_GPC_HELPER = 'gpc-helper'; const DEFAULT_GPC_HELPER_API_URL = 'https://gpc.qlhazycoder.top'; - const LEGACY_GPC_HELPER_API_URL = 'https://gpc.leftcode.xyz'; + const ALLOWED_GPC_HELPER_REMOTE_HOST = 'gpc.qlhazycoder.top'; function normalizePlusPaymentMethod(value = '') { const normalized = String(value || '').trim().toLowerCase(); @@ -67,10 +67,17 @@ normalized = normalized.replace(/\/api\/gp\/balance(?:\?.*)?$/i, ''); normalized = normalized.replace(/\/api\/card\/balance(?:\?.*)?$/i, ''); normalized = normalized.replace(/\/api\/card\/redeem-api-key(?:\?.*)?$/i, ''); - if (normalized === LEGACY_GPC_HELPER_API_URL) { + + try { + const parsed = new URL(normalized); + const hostname = parsed.hostname.toLowerCase(); + if (hostname === ALLOWED_GPC_HELPER_REMOTE_HOST || hostname === 'localhost' || hostname === '127.0.0.1') { + return normalized || DEFAULT_GPC_HELPER_API_URL; + } + return DEFAULT_GPC_HELPER_API_URL; + } catch { return DEFAULT_GPC_HELPER_API_URL; } - return normalized || DEFAULT_GPC_HELPER_API_URL; } function buildGpcHelperApiUrl(apiUrl = '', path = '') { diff --git a/hotmail-utils.js b/hotmail-utils.js index 14103c6..3ff4778 100644 --- a/hotmail-utils.js +++ b/hotmail-utils.js @@ -6,7 +6,6 @@ root.HotmailUtils = factory(); })(typeof self !== 'undefined' ? self : globalThis, function createHotmailUtils() { - const HOTMAIL_MAIL_API_URL = 'https://apple.882263.xyz/api/mail-new'; const HOTMAIL_SERVICE_MODE_REMOTE = 'remote'; const HOTMAIL_SERVICE_MODE_LOCAL = 'local'; @@ -287,8 +286,11 @@ return list.map((message) => normalizeHotmailMailApiMessage(message)); } - function buildHotmailMailApiLatestUrl(options) { - const apiUrl = String(options?.apiUrl || '').trim() || HOTMAIL_MAIL_API_URL; + function buildHotmailMailApiLatestUrl(options = {}) { + const apiUrl = String(options?.apiUrl || '').trim(); + if (!apiUrl) { + throw new Error('Hotmail mail API URL is required.'); + } const url = new URL(apiUrl); url.searchParams.set('refresh_token', String(options?.refreshToken || '')); url.searchParams.set('client_id', String(options?.clientId || '')); diff --git a/sidepanel/sidepanel.html b/sidepanel/sidepanel.html index fc04f6b..9d7b0b2 100644 --- a/sidepanel/sidepanel.html +++ b/sidepanel/sidepanel.html @@ -179,7 +179,7 @@