|
|
@@ -5862,6 +5862,7 @@ const step1Executor = self.MultiPageBackgroundStep1?.createStep1Executor({
|
|
|
addLog,
|
|
|
completeStepFromBackground,
|
|
|
openSignupEntryTab,
|
|
|
+ runPreStep1SessionCleanup,
|
|
|
});
|
|
|
const step2Executor = self.MultiPageBackgroundStep2?.createStep2Executor({
|
|
|
addLog,
|
|
|
@@ -6410,6 +6411,48 @@ async function runPreStep6CookieCleanup() {
|
|
|
await addLog(`步骤 6:已直接删除 ${removedCount} 个 ChatGPT / OpenAI cookies,准备继续获取链接并登录。`, 'ok');
|
|
|
}
|
|
|
|
|
|
+async function runPreStep1SessionCleanup() {
|
|
|
+ await addLog('步骤 1:正在清理 ChatGPT / OpenAI 登录态...', 'info');
|
|
|
+
|
|
|
+ let removedCookieCount = 0;
|
|
|
+ if (chrome.cookies?.getAll && chrome.cookies?.remove) {
|
|
|
+ const cookies = await collectCookiesForPreLoginCleanup();
|
|
|
+ for (const cookie of cookies) {
|
|
|
+ if (await removeCookieDirectly(cookie)) {
|
|
|
+ removedCookieCount += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (chrome.browsingData?.remove) {
|
|
|
+ try {
|
|
|
+ await chrome.browsingData.remove({
|
|
|
+ since: 0,
|
|
|
+ origins: PRE_LOGIN_COOKIE_CLEAR_ORIGINS,
|
|
|
+ }, {
|
|
|
+ cookies: true,
|
|
|
+ localStorage: true,
|
|
|
+ cacheStorage: true,
|
|
|
+ indexedDB: true,
|
|
|
+ serviceWorkers: true,
|
|
|
+ });
|
|
|
+ } catch (err) {
|
|
|
+ await addLog(`步骤 1:清理站点存储失败:${getErrorMessage(err)}`, 'warn');
|
|
|
+ }
|
|
|
+ } else if (chrome.browsingData?.removeCookies) {
|
|
|
+ try {
|
|
|
+ await chrome.browsingData.removeCookies({
|
|
|
+ since: 0,
|
|
|
+ origins: PRE_LOGIN_COOKIE_CLEAR_ORIGINS,
|
|
|
+ });
|
|
|
+ } catch (err) {
|
|
|
+ await addLog(`步骤 1:browsingData 清理 cookies 失败:${getErrorMessage(err)}`, 'warn');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ await addLog(`步骤 1:已清理登录态(cookies ${removedCookieCount} 个),准备以干净状态打开官网。`, 'ok');
|
|
|
+}
|
|
|
+
|
|
|
// ============================================================
|
|
|
// Step 7: Login and ensure the auth page reaches the login verification page
|
|
|
// ============================================================
|