Replace the existing DuckDuckGo plus webmail polling flow with a Hotmail account pool that:
The existing 1~9 step flow should remain intact wherever possible. The new work should be isolated to account selection, authorization, and email retrieval.
background.js.The new Hotmail path introduces three focused subsystems:
hotmail-account-pool
Maintains a reusable list of Hotmail accounts and their OAuth credentials.microsoft-oauth
Handles Microsoft authorization code flow with PKCE through chrome.identity.launchWebAuthFlow.hotmail-graph-mail
Reads inbox messages from Microsoft Graph and extracts verification codes for Step 4 and Step 7.The main flow continues to use the existing step state machine in background.js.
Persist a new hotmailAccounts array in chrome.storage.local.
Each account record stores:
idemailpasswordclientIdaccessTokenrefreshTokenexpiresAtstatuslastUsedAtlastAuthAtlastErrorThe current run stores currentHotmailAccountId in chrome.storage.session.
When mailProvider = hotmail-api, Auto mode must allocate one account at the start of a fresh run, write its email into the existing email runtime field, and reuse the same account through Step 3, Step 4, Step 6, and Step 7.
Each account is authorized separately from the side panel.
Flow:
Authorize on an account row.state.chrome.identity.launchWebAuthFlow.state, exchanges code for tokens, and updates the account record.The extension requests delegated scopes only:
openidprofileoffline_accesshttps://graph.microsoft.com/Mail.Readhttps://graph.microsoft.com/User.ReadThe design assumes one shared clientId across accounts is valid, while refreshToken remains per account.
Hotmail mail retrieval runs inside background logic and does not require a mail tab or content script.
The provider performs:
The first iteration should prefer stable fields such as:
from.emailAddress.addresssubjectreceivedDateTimebodyPreviewFull HTML body parsing is explicitly deferred unless needed.
Step 3 keeps filling the OpenAI page in the same way, but when mailProvider = hotmail-api, the email comes from the selected account pool entry instead of the manual email box or Duck address.
The existing retry and resend behavior stays in place, but the provider path changes:
qq, 163, inbuckethotmail-apiThe orchestration layer should branch before opening any mailbox tab. For hotmail-api, it calls a background helper instead of sendToMailContentScriptResilient.
Auto run changes:
hotmail-api is selectedThe current single email entry remains for backward compatibility, but a new account-pool section is added when hotmail-api is selected.
New UI capabilities:
The existing provider selector gains a hotmail-api option.
The new path must surface actionable errors:
clientIdAccount-level failures should update the account record status and lastError without corrupting unrelated accounts.
chrome.storage.local for operator convenience.Because the project has no automated test harness today, implementation should carve out pure helper functions where possible and validate them with focused runtime checks.
The minimum verification surface:
The first version intentionally excludes:
Modify only the minimum set of files needed to add the new provider while keeping current providers operational:
manifest.jsonbackground.jssidepanel/sidepanel.htmlsidepanel/sidepanel.csssidepanel/sidepanel.jsIf helper extraction becomes necessary, prefer adding small new files under content/ or the repo root only if they clearly reduce complexity in background.js.