Browserify can't be used with `tabs.executeScript`
See original GitHub issueI get this error in the console:
Error: Script returned non-structured-clonable data
You can test it by browserify-ing an empty file and then using browser.runtime.executeScript
to attempt to add it to a page.
Webpack’s module wrapping code doesn’t seem to have this issue.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6
Top Results From Across the Web
chrome.tabs.executeScript with new browser tab not working?
chrome.tabs.executeScript can't be used on newtab page because it instantly fails for the main frame due to unsupported scheme chrome:// and ...
Read more >WebExtensions 101 | Cloudbees Blog
The package.json file is there because I use browserify and npm to manage the dependencies and build the scripts for (most of) my...
Read more >tabs.executeScript doesn't work with remote files
Is it allowed to pass a remote file URL to tabs.executeScript()? This works: chrome.tabs.executeScript(null, {file: "js/myScript.js"} ); This DOES NOT work:
Read more >Webextension-polyfill NPM - npm.io
This library allows extensions that use the Promise-based WebExtension/BrowserExt API being ... And for dynamically-injected content scripts loaded by tabs.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@derwaldgeist use two executeScript’s…one for the dependency and one for your applications code that’s formatted in a way to do the return.
Alternatively, you can avoid the who return value thing (which feels very awkward most days…) and use
postMessage()
and friends.Oh! and one other possible solution for using a single
executeScript
the usesrequire
and browserify is to wrap the whole thing in an immediate called function with a return value. Then you get both clarity and lack of cumbersomeness (or…at least less cumbersomeness 😄).For example…
inject.js
:But then…you may still hit that “structured clonable” thing and have to do some type coercion and such, but at least it’s more obvious than ending your code with a variable name all by its lonesome.
Hope that helps! 🎩
Closing this, as it’s not a bug in the examples in this repo specifically.