feat(ext): handcraft the whole ext from scratch

AI coding doesn't work for MV3 extensions.
Threading was an unfixable mess.
Removed everything and rebuilt by hand.
This commit is contained in:
Simon
2026-01-27 17:21:32 +08:00
parent 8efa8e18c1
commit fdc3cf4e6d
18 changed files with 797 additions and 1749 deletions

View File

@@ -0,0 +1,40 @@
/**
* background logics for RemotePageController
* - redirect messages from RemotePageController(Agent, extension pages) to ContentScript
*/
// chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
// if (message.type !== 'PAGE_CONTROL') {
// return
// }
export function handlePageControlMessage(
message: { type: 'PAGE_CONTROL'; action: string; payload: any; targetTabId: number },
sender: chrome.runtime.MessageSender,
sendResponse: (response: unknown) => void
): boolean {
const { action, payload, targetTabId } = message
if (action === 'get_my_tab_id') {
sendResponse({ tabId: sender.tab?.id || null })
return false
}
chrome.tabs
.sendMessage(targetTabId, {
type: 'PAGE_CONTROL',
action,
payload,
})
.then((result) => {
sendResponse(result)
})
.catch((error) => {
sendResponse({
success: false,
error: error instanceof Error ? error.message : String(error),
})
})
return true // async response
}