Files
RSSHub-Radar/src/background/index.ts
T
DIYgod ec2f091235 feat: migrate extension from Plasmo to WXT (#1172)
* feat: migrate extension framework to wxt

- Replace Plasmo entrypoints, messaging, and storage usage with WXT-compatible implementations

- Update workflows, build scripts, and locale paths for WXT outputs

- Switch store submission to wxt submit with optional dry-run input

* fix(ci): fallback to vars for submit credentials

- Resolve missing required config in submit workflow when values are stored in GitHub Variables instead of Secrets

- Keep existing secrets first and add vars fallback for Chrome, Firefox, and Edge credentials
2026-02-11 15:33:09 +08:00

72 lines
1.9 KiB
TypeScript

import contentReady from "./messages/contentReady"
import popupReady from "./messages/popupReady"
import refreshRules from "./messages/refreshRules"
import requestDisplayedRules from "./messages/requestDisplayedRules"
import responseDisplayedRules from "./messages/responseDisplayedRules"
import responseRSS from "./messages/responseRSS"
import { deleteCachedRSS, getRSS } from "./rss"
import { initSchedule } from "./rules"
import { initUpdateNotifications } from "./update-notifications"
export {}
chrome.tabs.onActivated.addListener((tab) => {
chrome.tabs.get(tab.tabId, (info) => {
if (info.url) {
getRSS(tab.tabId, info.url)
}
})
})
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (tab.active) {
if (changeInfo.url) {
deleteCachedRSS(tabId)
getRSS(tabId, changeInfo.url)
} else if (changeInfo.status === "loading") {
deleteCachedRSS(tabId)
} else if (changeInfo.status === "complete") {
getRSS(tabId, tab.url)
}
}
})
chrome.tabs.onRemoved.addListener((tabId) => {
deleteCachedRSS(tabId)
})
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
const run = async () => {
switch (msg?.name) {
case "contentReady":
return contentReady(msg, sender)
case "popupReady":
return popupReady(msg, sender)
case "refreshRules":
return refreshRules(msg, sender)
case "requestDisplayedRules":
return requestDisplayedRules(msg, sender)
case "responseDisplayedRules":
return responseDisplayedRules(msg, sender)
case "responseRSS":
return responseRSS(msg, sender)
default:
return undefined
}
}
run()
.then((res) => {
sendResponse(res)
})
.catch((error) => {
console.error(error)
sendResponse(undefined)
})
return true
})
initSchedule()
initUpdateNotifications()