vue-web-extension icon indicating copy to clipboard operation
vue-web-extension copied to clipboard

executeScript with a file?

Open pasikonik opened this issue 3 years ago • 0 comments

I'm wondering, how can I set script file for executeScipt?

  browser.tabs.executeScript(null, {
    file: 'script.js'
  }, (result) => {
    ...
  });

Is it require different build with separated file or is it possible to do it in a simpler way?

My current workaround looks like this:

  import { bodyOfMethod } from '@/js/script'

  browser.tabs.executeScript(null, {
    code: `(${bodyOfMethod})()`
  }, (result) => {
    ...
  });

but it looks hacky to me.

pasikonik avatar Mar 18 '21 09:03 pasikonik