开发者

Replace some text from any HTML page before it is displayed

开发者 https://www.devze.com 2022-12-09 05:22 出处:网络
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 :

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.i开发者_JAVA百科nnerHTML = 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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消