简体   繁体   中英

Data interchange between main and content script — Firefox Addon SDK

My Mozilla Addon (coded with the Addon SDK) needs to encrypt information in a webpage form before the form submits to the webpage's servers. The encryption library I use is only accessible in lib/main.js and the information to be encrypted on the webpage is gathered by a content script.

My idea was to have my Addon encrypt the data with the following process:

  1. When the form's submit button is clicked, the content script sends the form's data (text in a text input) to main.js .
  2. main.js encrypts the data using a library, then sends the cipher text back to the content script.
  3. The content script inserts the cipher text from main.js into the form, which then submits to the webpage's servers.

Can I perform synchronous communication between the Addon's main code and the content script such that I can encrypt the form data after the submit button is clicked, but before the form submits the data to the servers? If not, can I halt the form's submission until I have encrypted the data, then manually prompt the form to submit with my newly encrypted input?

Any help in resolving this problem is much appreciated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM