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 5998521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:25:05+00:00 2026-05-23T00:25:05+00:00

I am working on a browser plugin for Firefox, Safari, Chrome that will intercept

  • 0

I am working on a browser plugin for Firefox, Safari, Chrome that will intercept data on the page, run it against a regex and then if it matches – reformat it. I have this working on page load using:

var meth = {
  replaceInElement : function(element, find, replace) {
        // iterate over child nodes and replace
  },
  run : function(evt){
    // doc is the document that triggered "run" event
    if (!(evt.target.nodeName === "#document")) { return; }
    var doc = evt.target; // document that triggered "onload" event
    if (!(doc instanceof HTMLDocument)) { return; }
    if (!doc.location) { return; }

    // perform substitutions on the loaded document
    var find = /regex/gi

    meth.replaceInElement(doc.body, find, function(match) {
        var new_content;
        //do stuff
        return new_content;
    });

    //content.document.addEventListener('DOMNodeInserted', ezcall.node_inserted, false);
  }
}

window.addEventListener("load", meth.run, false);

This is working for static pages, but for anything using ajax calls, it fails. I cannot find the right listener or figure out how to intercept the XMLHttpRequest.

I have tried similar event listeners for XMLHttpRequest with no luck.

XMLHttpRequest.addEventListener('load', meth.run, false);

I would like to either intercept the request and modify the content. Or find the target that was updated and scan it after the ajax call is finished.

UPDATE:

I will accept an answer that says it cannot be done, but I will need some supporting data as to why it cannot be done.

  • 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-23T00:25:06+00:00Added an answer on May 23, 2026 at 12:25 am

    Rather dirty but you can overwrite XMLHttpRequest.prototype.open. Here is a Demo page. Since you’re writing an extension, you must put this code in page context:

    (function() {
        // save reference to the native method
        var oldOpen = XMLHttpRequest.prototype.open;
        // overwrite open with our own function
        XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
            // intercept readyState changes
            this.addEventListener("readystatechange", function() {
                // your code goes here...
                console.log("Interception :) " + this.readyState);
            }, false);
            // finally call the original open method
            oldOpen.call(this, method, url, async, user, pass);
        };
    })();
    

    After this you can do anything I guess. Replace instance.readystatechange, replace instance.addEventListener, or listen to mutation events (although they are deprecated).

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

Sidebar

Related Questions

I use a Firefox plugin that can refresh the browser window every X seconds.
Does anyone know of a browser plugin or application that will save form values
I am working on a browser plugin that takes the URL of the current
I run a browser based game at www.darknovagames.com. Recently, I've been working on reformatting
I am working on a browser plug-in for Firefox, and I would like to
I'm a newbie. I'm using a browser plugin that hits my node server, and
I'm working on a page ( http://oscarspad.co.uk/Gallery/ ) which uses the Galleria plugin to
Background I am working on a browser-based UI that needs to fill the entire
I'm working on very, very simple jQuery plugin that simply changes position of element
I'm working on a type of 'spotlight' plugin that puts four boxes around a

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.