-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
27 lines (25 loc) · 899 Bytes
/
background.js
File metadata and controls
27 lines (25 loc) · 899 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
// background.js - Handles extension initialization and cleanup
// Initialize extension state
chrome.runtime.onInstalled.addListener(() => {
chrome.storage.local.set({ eyeTrackerState: "idle" });
console.log("Eye-tracking tag game extension installed");
});
// Listen for tab updates to reinject content scripts if needed
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.status === "complete" && tab.active) {
chrome.storage.local.get(["eyeTrackerState"], function (result) {
if (
result.eyeTrackerState === "training" ||
result.eyeTrackerState === "active"
) {
// Re-activate on the tab if it was active before
chrome.tabs.sendMessage(tabId, {
action:
result.eyeTrackerState === "training"
? "startTraining"
: "activateGame",
});
}
});
}
});