I am facing an issue where I am getting an error saying "resetTime is not defined" when running the code below. I have tried passing the function as an argument, but that did not solve the problem. Do I need to come up with a new logic to reset the time inside the "chrome.scripting.executeScript" method?
let time = 0;
function resetTime() {
time = 0;
chrome.storage.sync.set({ time: time });
console.log("Timer reset");
}
setInterval(() => {
chrome.storage.sync.get(["time"], (result) => {
console.log("Current time: " + result.time);
});
}, 1000);
chrome.tabs.onActivated.addListener((activeInfo) => {
chrome.tabs.get(activeInfo.tabId, (tab) => {
chrome.scripting.executeScript({
target: { tabId: activeInfo.tabId },
function: (resetTime) => {
document.addEventListener("mousemove", (e) => {
resetTime();
});
document.addEventListener("mousedown", (e) => {
resetTime();
});
},
args: [resetTime],
});
});
});