-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackground.ts
More file actions
27 lines (23 loc) · 822 Bytes
/
background.ts
File metadata and controls
27 lines (23 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { Storage } from "@plasmohq/storage"
const storage = new Storage()
// Initialize default theme
chrome.runtime.onInstalled.addListener(async () => {
const currentTheme = await storage.get("chooseTheme")
if (!currentTheme) {
await storage.set("chooseTheme", "stackoverflow-dark.css")
}
})
// Listen for network requests to Flomo notes API
chrome.webRequest.onCompleted.addListener(
(details) => {
if (details.url.includes("https://h5.udrig.com/app/v1")) {
console.log("Captured target request:", details.url)
if (details.tabId >= 0) {
chrome.tabs.sendMessage(details.tabId, { action: "highlightCode" }).catch(() => {
// Ignore error if tab is not ready or content script not injected
})
}
}
},
{ urls: ["https://h5.udrig.com/app/v1*"] }
)