-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
29 lines (24 loc) · 996 Bytes
/
Copy pathbackground.js
File metadata and controls
29 lines (24 loc) · 996 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
28
29
// background.js
// chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
// if (message.type === "record_action") {
// console.log("Action recorded:", message.action);
// // Store the action or send it to a server
// }
// sendResponse({ status: "Action received" });
// });
// background.js
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.type === "record_action") {
console.log("Action recorded:", message.action);
// Retrieve existing actions from storage
chrome.storage.local.get(["recordedActions"], (result) => {
const recordedActions = result.recordedActions || [];
recordedActions.push(message.action); // Add new action
// Save updated actions back to storage
chrome.storage.local.set({ recordedActions }, () => {
console.log("Actions updated:", recordedActions);
});
});
sendResponse({ status: "Action received and recorded" });
}
});