How can I open a new tab in a Firefox add-on with POST variables?

How can I open a new tab in a Firefox add-on with POST variables?

For example, open http: // localhost / with these post variables:

a=NOMADE b=NOWAY another=IDONTKNOW 
+4
source share
1 answer

The gBrowser.addTab function is what you want. One of the parameters you pass to this function is postData , and allows you to set postData as you would like. The MDN documentation for this function also points to an article on preprocessing POST data . If I read this second article correctly, the POST data should be passed as nsIInputStream (specially created as nsIMIMEInputStream ). The article provides an example of a code snippet for converting from a standard GET-style format string (example: foo=1&goo=somestring ) to the intended format.

Edit: So, to use your example, you can do something like this:

 var myData = "a=NOMADE&b=NOWAY&another=IDONTKNOW"; // TODO: Translate myData into the nsIMIMEInputStream format using the example // from the second linked article above // Add the tab, with the variable data gBrowser.addTab("http://www.example.com/", {postData: myData}); 
+4
source

Source: https://habr.com/ru/post/1389021/


All Articles