Take the 2-minute tour ×

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.

share|improve this question
greasemonkey scripts run after the DOM has been loaded and is ready to be interacted with; that is its nature. The flicker is unavoidable considering you are doing document.body.innerHTML=... (causing a hugely expensive redraw operation). –  Crescent Fresh Oct 26 '09 at 15:07
@crescentfresh - you should make that an actual answer. I'd upvote it. –  Matt Oct 26 '09 at 15:08
Seems like I'll have to install Poximodo... –  Jazz Oct 26 '09 at 15:10
@Matt: thanks. Perhaps Jazz can simply answer and accept the Poximodo sol'n (I have no idea what that is). –  Crescent Fresh Oct 26 '09 at 15:15
+1 for the last line.. Oh these programmers!!! –  Amarghosh Oct 26 '09 at 16:09
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
I will try to make my own extension to this. If only I could make an extension to read her mind! –  Jazz Oct 26 '09 at 17:36
add comment

Your Answer


