Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 217357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:38:59+00:00 2026-05-11T18:38:59+00:00

Background I have an existing extension designed to accompany a browser-based game (The extension

  • 0

Background
I have an existing extension designed to accompany a browser-based game (The extension is mine, the game is not). The extension had been scraping the pages as they came in for the data it needed and making ajax requests for taking any actions.

Problem
The game developers recently changed a number of actions on the site to use ajax requests and I am thus far unable to get the data from those requests.

What I have so far

function TracingListener() {
}

TracingListener.prototype =
{
    originalListener: null,
    receivedData: [],   // array for incoming data.

    onDataAvailable: function(request, context, inputStream, offset, count)
    {
       var binaryInputStream = CCIN("@mozilla.org/binaryinputstream;1",
                "nsIBinaryInputStream");
        var storageStream = CCIN("@mozilla.org/storagestream;1", "nsIStorageStream");
        binaryInputStream.setInputStream(inputStream);
        storageStream.init(8192, count, null);

        var binaryOutputStream = CCIN("@mozilla.org/binaryoutputstream;1",
                "nsIBinaryOutputStream");

        binaryOutputStream.setOutputStream(storageStream.getOutputStream(0));

        // Copy received data as they come.
        var data = binaryInputStream.readBytes(count);

        this.receivedData.push(data);

        binaryOutputStream.writeBytes(data, count);
        this.originalListener.onDataAvailable(request, context,storageStream.newInputStream(0), offset, count);
    },

    onStartRequest: function(request, context) {
        this.originalListener.onStartRequest(request, context);
    },

    onStopRequest: function(request, context, statusCode)
    {
        try {
            if (request.originalURI && piratequesting.baseURL == request.originalURI.prePath && request.originalURI.path.indexOf("/index.php?ajax=") == 0) {

                dump("\nProcessing: " + request.originalURI.spec + "\n");
                var date = request.getResponseHeader("Date");

                var responseSource = this.receivedData.join();
                dump("\nResponse: " + responseSource + "\n");

                piratequesting.ProcessRawResponse(request.originalURI.spec, responseSource, date);
            }
        } catch(e) { dumpError(e);}

        this.originalListener.onStopRequest(request, context, statusCode);
    },

    QueryInterface: function (aIID) {
        if (aIID.equals(Ci.nsIStreamListener) ||
            aIID.equals(Ci.nsISupports)) {
            return this;
        }
        throw Components.results.NS_NOINTERFACE;
    }
}


hRO = {

    observe: function(aSubject, aTopic, aData){
        try {
            if (aTopic == "http-on-examine-response") {
                if (aSubject.originalURI && piratequesting.baseURL == aSubject.originalURI.prePath && aSubject.originalURI.path.indexOf("/index.php?ajax=") == 0) {
                    var newListener = new TracingListener();
                    aSubject.QueryInterface(Ci.nsITraceableChannel);
                    newListener.originalListener = aSubject.setNewListener(newListener);

                    dump("\n\nObserver Processing: " + aSubject.originalURI.spec + "\n");
                    for (var i in aSubject) {
                        dump("\n\trequest." + i);
                    }
                }
            }
        } catch (e) {
            dumpError(e);

        }
    },

    QueryInterface: function(aIID){
        if (aIID.equals(Ci.nsIObserver) ||
        aIID.equals(Ci.nsISupports)) {
            return this;
        }

        throw Components.results.NS_NOINTERFACE;

    }
};


var observerService = Cc["@mozilla.org/observer-service;1"] .getService(Ci.nsIObserverService);

observerService.addObserver(hRO, "http-on-examine-response", false);

What’s happening
The above code is notified properly when an http request is processed. The uri is also available and is correct (it passes the domain/path check) but the responseSource that gets dumped is, as far as I can tell, always the contents of the first http request made after the browser opened and, obviously, not what I was expecting.

The code above comes in large part from http://www.softwareishard.com/blog/firebug/nsitraceablechannel-intercept-http-traffic/. I’m really hoping that it’s just something small that I’ve overlooked but I’ve been banging my head against the desk for days on this one, and so now I turn to the wisdom of SO. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:39:00+00:00Added an answer on May 11, 2026 at 6:39 pm

    but the responseSource that gets
    dumped is, as far as I can tell,
    always the contents of the first http
    request made after the browser opened
    and, obviously, not what I was
    expecting.

    There is a problem with the code above. The “receivedData” member is declared on prototype object and have empty array assigned. This leads to every instantiation of the TracingListener class to be using the same object in memory for receivedData. Changing your code to might solve he problem:

    function TracingListener() {
        this.receivedData = [];
    }
    
    TracingListener.prototype =
    {
        originalListener: null,
        receivedData: null,   // array for incoming data.
    
    /* skipped */
    
    }
    

    Not sure though if this will solve your original problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I have been working on a platformer game written in C++ for a
I have an existing site that requires a background image on the home page.
Background: I have an MVC based polaroid object. The model keeps the photo's metadata,
First some brief background: I have an existing ASP.NET MVC 1 application using Entity
Ubuntu 11.10, Python 2.6. Background: I have an existing Python app that is using
I am trying to create a extension from an existing view where I have
I have had mysql query to check any particular reservations existing in database .
Background: I have some existing apps in the App Store and I have just
Background is I have an existing application which lists directory entries; strace reveals it
Background I have an array of objects (Users) defined and set as follows: //

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.