CHROME EXTENSION: chrome.scripting.addListener not working

Viewed 32

I am trying to run chrome.scripting.executeScript API in my project. However, it doesnt work at all.

Here is my background file:

const dene = () => {
  console.log('dene works')
  return 'dene'
}

chrome.tabs.onActivated.addListener((activeInfo) => {
  console.log('listener works')
  chrome.scripting.executeScript(
    {
      target: { tabId: activeInfo.tabId, allFrames: true },
      files: ['./func.js'],
    },
    () => {
      chrome.runtime.lastError
    }
  )
})

And of course I added permisions an host permissions to my manifest file.

 "permissions": [
    "tabs",
    "scripting",
    "activeTab",
    "http://*/*",
    "https://*/*"
  ],

  "host_permissions": ["<all_urls>"],

What is wrong?

0 Answers
Related