views:

460

answers:

1

I would like to hide any text matching a pattern from any HTML page, before it is displayed.

I tried something like that with Greasemonkey :

var html = document.body.innerHTML;
html = html.replace( /some pattern/g, '???' );
document.body.innerHTML = html;

The text I want to hide is correctly replaced with '???', but for a brief moment while the page is loading, I can see the original text. As crescentfresh said, it cannot be fixed with Greasemonkey.

I know I could use a proxy like Proximodo to solve it, but I prefer to avoid having to install it.

What is the simplest way to do this, knowing that it must work on Firefox?

For those interested, I want to use it to hide prices from any page on my girlfriend computer, to let her choose a gift.

+1  A: 

With an extension you can probably do it.

I don't remember exactly, but it may be possible that LiveHttpHeaders captures the http traffic before getting to the browser, enabling you to remove what you want.

Also, if instead of waiting for the whole page to load you replace it in the DOMNodeInserted event, it may be fast enough for the actual content not to be displayed.

Also also, if you have never done a Firefox extension before, don't panic! there is even a greasemonkey extension compiler that does the dirty work, and gives you a good foundation to start. I would do that and then look for a window.onload event, and there, instead of the greasemonkey code, attach a DOMNodeInserted event into the document.

Also also also (fourth edit!), what she really wants is that you read her mind and pick the gift she wants XD

Victor
I will try to make my own extension to this. If only I could make an extension to read her mind!
Jazz