3

I'm doing an extension for Firefox and I pick up the call to the URL, as I can capture the http request in firefox, when running a call to a URL.

For example in google chrome on the event: chrome.webRequest.onHeadersReceived.addListener (

Jonmar
  • 33
  • 6

1 Answers1

0

Use plain XMLHttpRequest, which, when run from some chrome-privileged (system principal) place, allows to access all resources without obeying the same-origin policy, just like the SDK request module does not obey it.

  • SDK: in a lib/ module get it via

    const {XMLHttpRequest} = require("sdk/net/xhr");
  • XUL overlays/windows, ChromeWorker: There already is a global XMLHttpRequest constructor.

  • JS code modules, etc:
    Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].
      createInstance(Components.interfaces.nsIXMLHttpRequest);

From there you can use onreadystatechange to look for a .readyState of HEADERS_RECEIVED. See the XMLHttpRequest docs.

To get cookies working for users with Deny Third-Party-Cookies you'll need to use forceAllowThirdPartyCookie in the SDK or otherwise:

if (xhr_instance.channel instanceof Components.interfaces.nsIHttpChannelInternal)
  xhr_instance.channel.forceAllowThirdPartyCookie = true;
nmaier
  • 32,336
  • 5
  • 63
  • 78