You're viewing a comment by Jens Bauer and its responses.

Jens Bauer Permalink
June 18, 2017, 08:38

Here's my modification; this modification removes all HTML from the web-page.
(not very useful I think, but the goal is to modify the HTML on-the-fly):


var http = require('http');

http.createServer(function(request, response) {
  var proxy = http.createClient(80, request.headers['host'])
  var proxy_request = proxy.request(request.method, request.url, request.headers);

  proxy_request.addListener('response', function (proxy_response) {
    proxy_response.buf = "";
    proxy_response.process = function(chunk){
      chunk = this.buf + chunk;
      var match = /^(.*)(\<[^>]*?)$/.exec(chunk);
      this.buf = match ? match[2] : "";
      if(match) chunk = match[1];
      chunk = chunk.replace(/\<[^>]*?\>/g, "");
      response.write(chunk, 'binary');
    proxy_response.addListener('data', function(chunk) {
    proxy_response.addListener('end', function() {
    response.writeHead(proxy_response.statusCode, proxy_response.headers);
  request.addListener('data', function(chunk) {
    proxy_request.write(chunk, 'binary');
  request.addListener('end', function() {

What am I up to ?
-My web-browser is extremely slow (Apple Safari 5.0.6) and I cannot upgrade it because I'm on Mac OS X on a PowerMac.
Especially eBay is using extremely much CPU time (due to the hundreds of 'ad pictures' on a page for a single item).
As I tend to open more than 10 eBay windows/tabs when looking for stuff, I spend a lot of time with a spinning beachball.

So I'll try creating a proxy-server, which modifies my HTML (especially inserting width and height in IMG tags if they're missing ... perhaps an improved version could also check CSS - or do a real pre-rendering).
If I had my way, I'd have cloud-rendering (like Opera Turbo). ;)

-It's likely that I'll change the proxy port from 8080 to something else (my squid3 currently runs on port 3128).

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "antispam_215": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.