Is this possible in FF? search and replace incoming HTML before rendering to screen - Mozilla

This is a discussion on Is this possible in FF? search and replace incoming HTML before rendering to screen - Mozilla ; It seems like this would fall into the extensions category, but please feel free to point me to a more appropriate newsgroup if necessary. We have an IT environment that serves internal data via intranet web pages. I'm using a ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Is this possible in FF? search and replace incoming HTML before rendering to screen

  1. Is this possible in FF? search and replace incoming HTML before rendering to screen

    It seems like this would fall into the extensions category, but please feel
    free to point me to a more appropriate newsgroup if necessary.

    We have an IT environment that serves internal data via intranet web pages.
    I'm using a screen capture program (adobe captivate) to create some system
    demos from the live system, but I need to change some of the onscreen data
    to make it more generic for the purposes of the demo.

    My short-term solution is to export screen captures from adobe captivate to
    a graphics program, make my changes, then import it back into captivate to
    create the demos. The problem is that Captivate stores multiple copies of
    the screenshots, so I have to make these graphics changes on dozens or even
    hundreds of slides. That's a lot of non-value added work.

    It seems to me there has to be a way to write code that would allow an
    on-the-fly seach and replace of text before rendering a web page to
    the screen. So for example, if I decide to use Joe Manager's area, I could
    have the script set up to automatically intercept all instances of "Joe
    Manager" (with regex?) and replace it with "Anonymous Manager". Then all my
    captivate screenshots would already have the desired (generic) data in them.

    I'm imagining a text file with a list of seach/replace terms- so I could
    navigate the pages manually first (no captivate), identify piece of data
    that needs to be 'anonymized' and add them to my seach/replace list with a
    fake value. The extension/script would load that file and use it on every
    page I visit during the actual capture session.

    When active, the script would allow normal browsing of the system, and
    transparently replace the values so that I could just capture my demo
    material without having to do a lot of image editing.Underlying HTML links
    would need to remain as-is (to capture everything at one time, I need to
    click to various pages); just the rendered/visible text would need to
    change.

    Is there anything like this already in existence? Something that functions
    in similar ways that I could adapt?
    If not, can anyone give me pointers on what I need to learn quickly to get
    something like this up and running?

    Many, many thanks-
    Keith



  2. Re: Is this possible in FF? search and replace incoming HTML beforerendering to screen

    On May 30, 6:38*am, "Ker_01" wrote:
    > It seems like this would fall into the extensions category, but please feel
    > free to point me to a more appropriate newsgroup if necessary.
    >
    > We have an IT environment that serves internal data via intranet web pages..
    > I'm using a screen capture program (adobe captivate) to create some system
    > demos from the live system, but I need to change some of the onscreen data
    > to make it more generic for the purposes of the demo.
    >
    > My short-term solution is to export screen captures from adobe captivate to
    > a graphics program, make my changes, then import it back into captivate to
    > create the demos. The problem is that Captivate stores multiple copies of
    > the screenshots, so I have to make these graphics changes on dozens or even
    > hundreds of slides. That's a lot of non-value added work.
    >
    > It seems to me there has to be a way to write code that would allow an
    > on-the-fly seach and replace of text before rendering a web page to
    > the screen. So for example, if I decide to use Joe Manager's area, I could
    > have the script set up to automatically intercept all instances of "Joe
    > Manager" (with regex?) and replace it with "Anonymous Manager". Then all my
    > captivate screenshots would already have the desired (generic) data in them.
    >
    > I'm imagining a text file with a list of seach/replace terms- so I could
    > navigate the pages manually first (no captivate), identify piece of data
    > that needs to be 'anonymized' and add them to my seach/replace list with a
    > fake value. The extension/script would load that file and use it on every
    > page I visit during the actual capture session.
    >
    > When active, the script would allow normal browsing of the system, and
    > transparently replace the values so that I could just capture my demo
    > material without having to do a lot of image editing.Underlying HTML links
    > would need to remain as-is (to capture everything at one time, I need to
    > click to various pages); just the rendered/visible text would need to
    > change.
    >
    > Is there anything like this already in existence? Something that functions
    > in similar ways that I could adapt?
    > If not, can anyone give me pointers on what I need to learn quickly to get
    > something like this up and running?
    >
    > Many, many thanks-
    > Keith


    Hi Keith,

    Take a look at Greasemonkey. You should be able to manipulate the
    HTML using a userscript. They are much more lightweight than Firefox
    Extensions. In fact, there may already be a user script out there
    that does what you are looking for.

    You may be able to use the:
    window.addEventListener("load",function()
    { document.getElementById("managerName").innerHTML = "Anon"; },false);

    Like Eric mentioned, you may have trouble manipulating content before
    it's rendered in the browser. One hack you could try is something
    like this:

    function loop() {
    var domElem = document.getElementById("container");
    if(domElem == null) { // this element is not available on the page
    yet
    setTimeout(function() { loop(); },100);
    }
    }

    My example wasn't tested and is likely to be syntactically incorrect,
    but the concept should be solid.

    Good luck,
    James

  3. Re: Is this possible in FF? search and replace incoming HTML beforerendering to screen

    On Jun 3, 10:36*pm, James M wrote:
    > On May 30, 6:38*am, "Ker_01" wrote:
    >
    >
    >
    > > It seems like this would fall into the extensions category, but please feel
    > > free to point me to a more appropriate newsgroup if necessary.

    >
    > > We have an IT environment that serves internal data via intranet web pages.
    > > I'm using a screen capture program (adobe captivate) to create some system
    > > demos from the live system, but I need to change some of the onscreen data
    > > to make it more generic for the purposes of the demo.

    >
    > > My short-term solution is to export screen captures from adobe captivateto
    > > a graphics program, make my changes, then import it back into captivate to
    > > create the demos. The problem is that Captivate stores multiple copies of
    > > the screenshots, so I have to make these graphics changes on dozens or even
    > > hundreds of slides. That's a lot of non-value added work.

    >
    > > It seems to me there has to be a way to write code that would allow an
    > > on-the-fly seach and replace of text before rendering a web page to
    > > the screen. So for example, if I decide to use Joe Manager's area, I could
    > > have the script set up to automatically intercept all instances of "Joe
    > > Manager" (with regex?) and replace it with "Anonymous Manager". Then allmy
    > > captivate screenshots would already have the desired (generic) data in them.

    >
    > > I'm imagining a text file with a list of seach/replace terms- so I could
    > > navigate the pages manually first (no captivate), identify piece of data
    > > that needs to be 'anonymized' and add them to my seach/replace list witha
    > > fake value. The extension/script would load that file and use it on every
    > > page I visit during the actual capture session.

    >
    > > When active, the script would allow normal browsing of the system, and
    > > transparently replace the values so that I could just capture my demo
    > > material without having to do a lot of image editing.Underlying HTML links
    > > would need to remain as-is (to capture everything at one time, I need to
    > > click to various pages); just the rendered/visible text would need to
    > > change.

    >
    > > Is there anything like this already in existence? Something that functions
    > > in similar ways that I could adapt?
    > > If not, can anyone give me pointers on what I need to learn quickly to get
    > > something like this up and running?

    >
    > > Many, many thanks-
    > > Keith

    >
    > Hi Keith,
    >
    > Take a look at Greasemonkey. *You should be able to manipulate the
    > HTML using a userscript. *They are much more lightweight than Firefox
    > Extensions. *In fact, there may already be a user script out there
    > that does what you are looking for.
    >
    > You may be able to use the:
    > window.addEventListener("load",function()
    > { document.getElementById("managerName").innerHTML = "Anon"; },false);
    >
    > Like Eric mentioned, you may have trouble manipulating content before
    > it's rendered in the browser. *One hack you could try is something
    > like this:
    >
    > function loop() {
    > * var domElem = document.getElementById("container");
    > * if(domElem == null) { * // this element is not available on the page
    > yet
    > * * * *setTimeout(function() { loop(); },100);
    > * }
    >
    > }
    >
    > My example wasn't tested and is likely to be syntactically incorrect,
    > but the concept should be solid.
    >
    > Good luck,
    > James


    Keith,

    I just realized that you would need to run that on every HTML element
    on your page that contains the names you want to change, and unless
    you know what those are this could be troublesome.

    Have you considered banging out a quick proxy? Have a server act as a
    middleman and make the request for the pages, then process them server-
    side on your proxy using a regular expression and render them in a JSP/
    PHP/ASP/etc page.

    Ok, another idea would be to simply access the body element directly
    like so:

    // in the FF ext
    var bodyContent = window.content.document.body.innerHTML;
    bodyContent.replace(/Robert Frost/i,"Joe Schmo");
    wndow.content.document.body.innerHTML = bodyContent;

    Hope this helps,
    James

+ Reply to Thread