0

Out of no where chrome.tabs.executeScript is undefined, I'm really not sure what happened, I rolled back almost everything that matters but still undefined, I posted a simple code where it's also not working, this code is from the background.js script, what am I missing?

chrome.alarms.onAlarm.addListener(async (alarm) => {

  if (alarm.name == "CheckJobs") {
    d4rTabId 0;
    console.log('from cahce: '+d4rTabId);

      chrome.tabs.create({ url: "https://stackoverflow.com/questions/66618167/chrome-extension-alarm-interval-working-after-a-while", active: false }, async tab => {
        d4rTabId = tab.id;
        console.log(d4rTabId);
        chrome.tabs.executeScript(d4rTabId,
          {
            code: "document.title ='aaaa'"
          })
      });
    }});


{
  "name": "aaa",
  "version": "0.0.1",
  "manifest_version": 3,
  "background": {
    "service_worker":"background.js" //"bgjob2.js" //
  },
  "permissions": [
    "tabs",
    "alarms",
    "activeTab",
    //"background",
    "storage"
    //"identity",
    //"identity.email"
  ],
  "host_permissions": [
    "http://*/",
    "https://*/",
    "*://*/*"
  ],
  "icons": {
    "16": "aaa.png",
    "48": "aaaa.png",
    "128": "aaaaa.png"
  },
  "action": {

    "default_popup": "/popout/pop.html",
    "default_title": "aaa"
  },
  "content_scripts": [
    {
      "matches": [
        "http://*/*",
        "https://*/*",
        "*://*/*"
      ],
      "js": [
        "jquery-3.6.0.slim.min.js"
      ]
    }
  ]
}
Amit Shadadi
  • 617
  • 2
  • 7
  • 20
  • Have you tried something simple like restarting the browser? – Lil Devil Mar 17 '21 at 00:29
  • I haven't used Manifest Version 3 myself yet, but I found [this](https://developer.chrome.com/docs/extensions/reference/scripting/) - perhaps you need to use `chrome.scripting.executeScript` ? – Lil Devil Mar 17 '21 at 00:39
  • Thanks Lil, seems I mixed v2 with v3, now everything back to work, the odd thing is that it worked up to this moment with chrome.tabs, thanks again! – Amit Shadadi Mar 17 '21 at 07:54

0 Answers0