Increased Browser Speed
aka. Life without facebook and google-analytics.
I've noticed that whenever my webpages are slow, the browser is looking up faceboon.com or google-analytics.com.
I looked into NoScript , but found it too intrusive. Instead I've made a setup with Apache and DnsMasq, that takes over the sites I don't want to see.
I've made a php page that returns html document if such is requested otherwise an 1x1 pixel gif /var/www/censored.php.
<?php if( preg_match("!,text/html,!", ",".$_SERVER[HTTP_ACCEPT].",") ) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <body onload="document.body.replaceChild(document.createTextNode(location.host),document.body.firstChild);setTimeout('while(document.body.hasChildNodes())document.body.removeChild(document.body.firstChild);document.body.style.backgroundColor=\'transparent\';', 2500);" style="background-color: #aaaaaa; font-weight: bold; font-size: tiny;">cencored</body> </html> <?php } else { header("Content-Type: image/gif"); foreach(explode(" ", "47 49 46 38 39 61 01 00 01 00 80 00 00 ff ff ff ff ff ff 21 f9 04 01 0a 00 01 00 2c 00 00 00 00 01 00 01 00 00 02 02 4c 01 00 3b") as $a) { printf("%c", hex($a)); } } ?>
and an dnsmasq setup /etc/dnsmasq.d/dns.conf:
address=/facebook.com/127.0.0.1 address=/2o7.net/127.0.0.1 address=/imrworldwide.com/127.0.0.1 address=/intellitxt.com/127.0.0.1 address=/google-analytics.com/127.0.0.1 address=/double-click.net/127.0.0.1 address=/doubleclick.net/127.0.0.1 address=/emediate.dk/127.0.0.1 address=/tribalfusion.com/127.0.0.1
/etc/apache2/sites-enabled/000-default:
RewriteEngine On RewriteCond %{REMOTE_ADDR} =127.0.0.1 RewriteCond %{HTTP_HOST} !=127.0.0.1 RewriteCond %{HTTP_HOST} !=localhost RewriteRule . /var/www/censored.php [L]
So the setup is this:
- Looking up a site we don't want to be browsing we get 127.0.0.1
Apache serves a file for domains on 127.0.0.1 that isn't 127.0.0.1 & localhost
- The browser renders an transparent image or a subframe that is gray with the domainname in black for a couple of seconds and then turns transparent.
Simple without changing the appearance significantly.
This is easily expanded for https by adding the same rules to the apache config file: 001-default-ssl
Happy fast browsing.