Web Browser With Black Background (Invert Colors / Night Mode) Through Proxy Filter
This is a solution for people looking to invert colors or force specific colors (e.g. white text / black background) on their web browser. Great for easier reading (especially at night) and saving power on OLED screens. CyanogenMod's browser has an invert colors option built in, but as far as I can tell, nobody has been able to port the CM browser to other ROMs. This solution works with any browser or ROM.
The basic idea is to run a web filter proxy such as Privoxy. Proxy filters are usually used for ad blocking, but they also have the power to completely rewrite a webpage. Privoxy is run in the background, and using the browser or WiFi/APN proxy settings, all web traffic is run through Privoxy. Privoxy rewrites the web pages based on the filters before it is displayed on your browser.
In the attached set, I've put together some
badly-written but effective filters
to force light text on black backgrounds. The filters rewrite the webpage so that the background is always black, text is always light gray, and links are always green. The filters only tweak the HTML/styles, so as a (usually) helpful side effect, the pictures remain unchanged. With my current configuration, Privoxy loads automatically in the background at startup, and all web pages run through Privoxy and are displayed in my designated colors. See the screenshots below to see it in action.
I put together a simple set of files that so folks can test this out.
- You must have a rooted phone.
- You must be able to access proxy settings. Depending on your firmware, you might be able to set a proxy in Wireless and Network Settings (Wi-Fi settings -> Advanced, or Mobile Networks -> Access Point Names). You can also try an app like Transproxy
, or a browser that supports proxy settings, such as Firefox Mobile with the Proxy Mobile add-on
- Download and install Autostart (Root)
from the Market.
- In your root folder, create a folder called /data/opt
- Download the attached "force_colors.zip" and extract the files
- Place all the files in /data/opt. Set appropriate permissions. (Privoxy and autostart.sh need to be executable.)
- Reboot your phone. Autostart should run the autostart.sh script (it will ask for superuser permission) and Privoxy will run in the background.
- Set your proxy host to localhost and the proxy port to 8118.
- If everything went correctly, all webpages should load in black background, light gray text and green links.
Note: If you use DroidWall or similar firewall settings, make sure that you allow access for "Applications running as root" so that Privoxy can access the network.
Note that these filters are infinitely customizable, if you know how to use regular expressions. Just edit force_colors.filter with the filters of your choice. For example, the Privoxy filters available here
are specifically designed to invert some colors and make other ones darker, so you can still preserve some website colors in a more readable format.
In the next post, I'll describe everything I researched in pursuit of this solution. I am hoping others will pick up this project and make it into an easy-to-use package, and also to create some alternative filters to make them cleaner and/or more effective.
I think this feature is sorely needed in Android. Please pass the word to any developers who can help make it a reality!