0

Just started looking into Chrome Extensions and this issue has me stumped, especially because the previous extensions I made had no such issue. The project is supposed to be timer but whenever I add anything more complex than a console.log to background.js it gives me the error mentioned above.

manifest.json:

{
    "manifest_version": 3,
    "name": "Pomodoro Timer",
    "version": "1.0.0",
    "description": "Beta",
    "permissions": ["storage"],
    "icons": {
        "16": "icon.png",
        "48": "icon.png",
        "128": "icon.png"
    },
    "action": {
        "default_icon": {
            "16": "icon.png",
            "24": "icon.png",
            "32": "icon.png"            
        },
    "default_title": "TIMER EXTENSION",
    "default_popup": "popup/popup.html"        
    },
    "options_page": "options/options.html",
    "background": {
        "service_worker": "background.js"
    }
}

background.js:

chrome.alarms.create("Timer", {
  periodInMinutes: 1 / 60,
});

chrome.alarms.onAlarm.addListener((alarm) => {
  if (alarm.name === "Timer") {
    chrome.storage.local.get(["timer", "isRunning"], (result) => {
      if (result.isRunning) {
        let timer = res.timer + 1;
        chrome.storage.local.set({
          timer,
        });
      }
    });
  }
});

chrome.storage.local.get(["timer", "isRunning"], (result) => {
  chrome.storage.local.set({
    timer: "timer" in result ? res.timer : 0,
    isRunning: "isRunning" in res ? res.isRunning : false,
  });
});

starbvuks
  • 61
  • 2
  • 8

0 Answers0