Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #29159
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Catching http request with JavaScript |
| Date | 2016-01-07 09:44 +0000 |
| Message-ID | <070120160944222492%timstreater@greenbee.net> (permalink) |
| References | <568e31ca$0$19736$426a74cc@news.free.fr> |
In article <568e31ca$0$19736$426a74cc@news.free.fr>, mireero <mireero@free.fr> wrote: >Hi, > >Some addons like adblocks, ghostery... are using some browser specific >functionalities to "regular expression block" some specific http requests. > >Is there any cross-browser way of achieving something similar using >regular JavaScript? > >For example I'd like to block some <img> tag or to modify on the fly >involved request headers. > >I know you cannot act on the DOM before it is loaded and after it looks >too late but I'm still asking as my knowledge isn't 100% wide. What I do is create a new DOM element, load the html into that, then modify *that* DOM to remove <img> or other tags I don't trust, and then load that modified DOM into an <iframe> for display. This also prevents the browser from doing speculative downloading of (e.g.) images while your javascript is still running. What I had done originally was load the HTML into the live DOM, and then modify it, on the basis that I could do that before rendering started because javascript is supposed to be single-threaded. But I still saw network activity of images being downloaded and then guessed that the browser was doing stuff behind my back. -- "If you're not able to ask questions and deal with the answers without feeling that someone has called your intelligence or competence into question, don't ask questions on Usenet where the answers won't be carefully tailored to avoid tripping your hair-trigger insecurities." - D M Procida, UCSM
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Catching http request with JavaScript mireero <mireero@free.fr> - 2016-01-07 10:36 +0100 Re: Catching http request with JavaScript Tim Streater <timstreater@greenbee.net> - 2016-01-07 09:44 +0000 Re: Catching http request with JavaScript Stefan Weiss <krewecherl@gmail.com> - 2016-01-07 13:49 +0100 Re: Catching http request with JavaScript JJ <jj4public@vfemail.net> - 2016-01-08 13:08 +0700
csiph-web