Is it possible to transfer data from content-script to a server?


#1

Hello, I’m new to firefox add-ons.
I’m currently thinking of transferring data from content-script to a server and I have a few questions regarding this.

  1. Is it possible? (I have tried transferring data from background script to a server via websocket so I’m guessing that sending data from content-script is possible, too…)

  2. Is there any useful documents to learn how to do this?

Thank you for your concern!


(Jorge) #2

This article explains content scripts and their limitations:

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts

I believe you can use XHR from a content script, but it will be limited by cross-domain security checks. You’d need to add a permission for the server you want to communicate with. If that doesn’t work, going through the background script should work.