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.
Requirements
- 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 AutoProxy, or a browser that supports proxy settings, such as Firefox Mobile with the Proxy Mobile add-on.
Instructions
- 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!
[Note: This is my earlier post explaining what I did to make this solution work. Please note that I am a complete development noob! I hope this information is helpful and other people will improve on my solution.]
- There is an Android port of Privoxy on the Android Market called Privoxy (BETA 1). Install it and see if it works for you. On my phone, the app interface does not work. If I try to manually start Privoxy in a terminal window, it gives me a seg fault. Anyway, run the app once regardless, so that it copies the Privoxy files to the app data directory (/data/data/com.galoula.Privoxy/). We will use this directory as our base.
- A *working* Android port of Privoxy is included in Orbot: Tor on Android. (Tor uses Privoxy to pass the HTTP requests to a SOCKS proxy.) Download, install and run Orbot. You just need to run it once so that it copies the Privoxy binary to the app data folder.
- You'll find Orbot's Privoxy binary in /data/data/org.torproject.android/app_bin. Copy the "privoxy" binary and use it to replace the binary that came with Privoxy (BETA 1) (located in /data/data/com.galoula.Privoxy/bin). Set appropriate permissions. (We only installed Orbot for the binary, so you can uninstall Orbot now if you don't want it always loading in the background.)
- Now set up the filters. Download the attached force_colors.zip below. Extract the three files (force_colors.action, force_colors.filter, and privoxy_conf). Copy these files to /data/data/com.galoula.Privoxy/etc.
- Open a terminal window, navigate to /data/data/com.galoula.Privoxy/bin and start privoxy by running "./privoxy ../etc/privoxy_conf"
- By default, Privoxy will listen on port 8118. Go to your WiFi settings or APN settings. Set the Proxy name to "localhost" and the port to "8118". Now all web data will pass through Privoxy.
- Browse to a few websites and you'll see white text on black backgrounds! The default colors in the force_colors.filter are black for backgrounds, light gray for text, and green for links. Feel free to edit force_colors.filter to whatever color combination you prefer. I used HTML color names instead of hex codes to make it more readable.
- To run Privoxy every time at startup, I use an app from the Market called Autostart (Root). The directions are limited but basically, you just need to install the app and make a file called /data/opt/autostart.sh (set appropriate permissions). Then in autostart.sh, put this line: "/data/data/com.galoula.Privoxy/bin/privoxy /data/data/com.galoula.Privoxy/etc/privoxy_conf". The next time you reboot (might have to try it one or two times), Autostart will ask for superuser permission, and start Privoxy automatically.
Hope this is helpful for anybody else who wants to experiment.
hey claimui, this looks like a great approach! i'm looking forward to giving it a try this weekend and learning more about how the filtering works!
I spent a couple of days learning regular expressions (or at least some of them) and throwing together a simpler set of filters to force certain colors on a webpage. With this set, all backgrounds are black, all text is light grey, and links are green.
EDIT: My filters are now included in the force_colors.zip attached in the OP.
added to
black energy saving android apps for AMOLED screens
I made several updates to the original posts, including a suggestion on how to get Privoxy to start automatically on boot. After going through this whole process, this is a really effective solution. Privoxy starts automatically and invisibly whenever I start up my phone, and all of my webpages automatically pass through Privoxy and get displayed in my preferred colors.
For future tweaking, it would be nice to have a simple shortcut to enable/disable the filtering. (Although honestly I never want to disable it -- I always like my colors better!) Note that you can't simply kill Privoxy because your browser won't be able to find the proxy to connect to. So you either need a Privoxy command to toggle filtering on and off, or toggle the proxy settings to either use or bypass Privoxy.
In the meantime though, I think this still works really well. Hope others give it a try and can improve on the procedure.
Major update: I have finally consolidated all the steps into a small zip file and some simple instructions. You will need root access and a file manager or some basic knowledge of how to get around your phone. Just follow the instructions in the first post and you should be able to get it working very quickly.
Would like to test this but couldn't things to work...
Privoxy now updates to beta2.
Everything I try I get 404 Page can't loaded...
Have changed to localhost and port 8118 but doesn't work...
No need to install Privoxy from the Market. Just follow the instructions in my first post. After you install the Autostart app and put the files in the /data/opt folder, Privoxy will start at the next reboot.
Thx! Think it was a problem with SiyahKernel! After flashing from 2.0b2 to 2.0b3 now privoxy work!
Thx a lot! Have long time searched for something similar!
when I try to create the folder /data/opt it says it is created but in doesn't show up. also when I create the same folder and then move it to root folder it automatically renames it opt. I'm using root explorer.
In Root Explorer, first navigate to the /data folder, then click the button to Mount as R/W, then create the opt folder. Does that work?
Updated the OP to include some more suggestions for folks who are having trouble finding proxy settings. The basic options are:
1. See if your firmware comes with proxy settings. Under Wireless and Network Settings, look in Wi-Fi settings -> (menu button) Advanced, or Mobile Networks -> Access Point Names.
2. You can also try an app like Transproxy or AutoProxy.
3. Try a browser that supports proxy settings, such as Firefox Mobile with the Proxy Mobile add-on.
Nice.
Have you by any chance conducted a battery test or otherwise made any effort to notice the impact of this modification on battery life?
I haven't personally done any battery experiments (at least not for the browser) but this is a good reference: http://forum.xda-developers.com/showthread.php?t=660853
Basically yes, black backgrounds do save battery power on AMOLED screens. Personally I think the difference between 5% and 3% (or 3% and 2% at lower brightness) is not that big of a deal, probably not even noticeable in normal use. But if you want to squeeze the most milliwatts out of your battery then this will help.
To me the main benefit is that black backgrounds are just much easier to read, especially at night, and especially with the deep blacks / high contrast of the AMOLED screen.
Don't need 10 chars for this replay.
AWESOME!
Edit:
Sadly, from the time that passed since I posted this post, I stumbled upon a few annoying bugs.
1. Proccess locked at 50% cpu, (100% of a single core)
2. Some sites just don't work, and then I have to restart the browser.
Yes google mobile site everytime I would like to search something I get this Error:
This page contains the following errors:
error on line 3 at colum 31: AttValue: " or ' expected
Reparse document as HTML
I know regexp pretty well, but Privoxy syntax is a little bit confusing.
I'm trying to figure out the filters supplied by the OP, and they are just too confusing
To OP : How do you set the delimiter for the filters in Privoxy?
I know / and | are possible, are you using + for some reason?
All your filters start with s+, what is the + ?
Great work. Autostart didn't work on my Galaxy Note for some reason.
But maybe changing CSS is easier. This method works on Opera Mobile:
http://forum.xda-developers.com/showthread.php?t=1326434
eitama said:
Sadly, from the time that passed since I posted this post, I stumbled upon a few annoying bugs.
1. Proccess locked at 50% cpu, (100% of a single core)
2. Some sites just don't work, and then I have to restart the browser.
Click to expand...
Click to collapse
Hm, I haven't encountered these bugs. I am using the same files that I uploaded in the zip. Does it only happen with certain sites? Maybe I just need to tweak the filters. My regexp is poor so they are very crude, and could easily screw up some sites.
bgx said:
Yes google mobile site everytime I would like to search something I get this Error:
This page contains the following errors:
error on line 3 at colum 31: AttValue: " or ' expected
Reparse document as HTML
Click to expand...
Click to collapse
Can you tell me the specific URL? I notice you're on T-Mobile so maybe you have a carrier-specific browser/search settings.
eitama said:
I know regexp pretty well, but Privoxy syntax is a little bit confusing.
I'm trying to figure out the filters supplied by the OP, and they are just too confusing
To OP : How do you set the delimiter for the filters in Privoxy?
I know / and | are possible, are you using + for some reason?
All your filters start with s+, what is the + ?
Click to expand...
Click to collapse
Privoxy syntax is supposed to be like Perl -- well I don't know Perl so I'm just copying what I read. The basic reference is here: http://www.privoxy.org/user-manual/filter-file.html
In my filters, I'm using + as the delimiter. In Privoxy you can use whatever delimiter you want, and it doesn't make a difference (I think). I just copied the + from another filter set -- probably because it's easier to read than / when working with HTML.
The first couple of filters should not be too hard to figure out. For example:
Code:
# Set default colors
s+<body+<body bgcolor=black text=LightGray link=LimeGreen vlink=Green+isUg
This just makes sure every <body> tag starts with "<body bgcolor=black text=LightGray link=LimeGreen vlink=Green" (very crude, I know). The isUg at the end are the modifiers:
i = case insensitive matching
s = allow string to span multiple lines
U = ungreedy matching
g = global matching
Two filters substitute a tag with "JED-C-Anchor-color". This is not a valid tag; the browser will just skip it so the effect is basically the same as deleting the tag. Substituting instead of deleting just makes debugging easier. I used "JED-C" because I modified these filters from http://members.cox.net/pu61ic.1inux.dunc4n/software/privoxy.jed
tamarian said:
But maybe changing CSS is easier. This method works on Opera Mobile:
http://forum.xda-developers.com/showthread.php?t=1326434
Click to expand...
Click to collapse
Thanks for the tip! Yeah I know about changing CSS and that would be a better solution. But I don't think there is a way to change the CSS with the stock browser, and some people still like using the stock Samsung browser for hardware acceleration or whatever other reason. But maybe somebody could make a Privoxy filter that adds the same CSS code into all webpages?
If this thread helped you, Don't forget to hit THANKS.
WifiKill - disable internet for network hoggers
With this app you can disable internet connection for a device on the same network. So if someone (anyone) is abusing the internet wasting precious bandwidth for a Justin Bieber videoclips you could just kill their connection and stay happy with a full bandwidth just for yourself.
You can download WiFiKill using WiFiKill Downloader
!!! PRO version !!! requires you to make a donation through PayPal (using WiFiKill Downloader)
dSploit - An Android network penetration suite
dSploit is an Android network analysis and penetration suite which aims to offer to IT security experts/geeks the most complete and advanced professional toolkit to perform network security assesments on a mobile device.
Once dSploit is started, you will be able to easily map your network, fingerprint alive hosts operating systems and running services, search for known vulnerabilities, crack logon procedures of many tcp protocols, perform man in the middle attacks such as password sniffing ( with common protocols dissection ), real time traffic manipulation, etc, etc .
The precompiled apk can be downloaded from https://github.com/evilsocket/dsploit/downloads ( download the latest release you find ), make sure you have the option to install apps from third party sources enabled.
It's still in beta stage so unexpected behaviour could happen.
If this thread helped you, Don't forget to hit THANKS.
Greenify
Greenify help you identify and put the bad behaving apps into hibernation when you are not using them, stop them from battery leeching, memory hogging and stealthy running, in an elegant and unique way! They could do nothing without your explicit launch, while still have full functionality when running in foreground. Like what iOS apps act!
The built-in App Analyzer will analyze and show apps in your device that keep running persistent services and those launch itself automatically on a regular basis (when network connectivity changes, or every time you unlock your device, install / uninstall / update your apps, etc).
ROOT is required. If you are experiencing hibernation issue, this may be caused by your root management app (e.g. "SuperUser"), please try installing "SuperSU" instead.
Get it for free HERE
BBM Controller
This application was created to make it easier for us to manage BlackBerry Messenger ( BBM ) .
Requirements to be able to use BBM Controller application is :
+ Android Smartphone already in ROOT .
+ Android Smartphone already installed BBM application.
+ Minimal Android is version 4.0 ( ICS ) .
+ Minimum ROM storage is 3 Megabytes. This app only use 3 MB of ROM storage when active.
Download BBM Controller
USB OTG Helper (Stock/Custom kernel)
It stands for USB On-the-Go!
"It is a specification that allows USB devices such as digital audio players or mobile phones to act as a host allowing a USB flash drive, mouse, or keyboard to be attached." - Wikipedia
The stock kernel allows Mouse & Keyboard, but USB storage is missing..
Features:
Stock and custom kernels supported
Mount and Unmount drive with a single click
No Ads!
Full NTFS support built-in!! (from v3.0.3)
Automatically start on device connect (intent broadcast) (from v3.0.3)
Notification when drives mounted! (from v3.0.3)
One click access to unmount (from v3.0.3)
Option to enable UTF-8 if kernel support (from v4)
Automatically open explorer after drive mounted (from v3.0.7)
One click debugging and feedback (in app) [Donate version only]
Download APK From Play Store
WhatsMore - Allow 2 phone numbers to be linked to WhatsApp
WhatsMore is an add-on account management to make WhatsApp holding more than 1 phone number even on a single-SIM mobile phone. Now, we can give different phone numbers to the family, co-workers, customers, net-friends, and etc…
Features:
- Allow Up to 2 phone numbers to be used with WhatsApp on the same device.
- Auto swapping WhatsApp accounts in a user preset interval.
- Show notifications when swapping WhatsApp accounts.
- Show notifications if there are unread messages of swapped out WhatsApp accounts.
- Launch any inactive WhatsApp account from within WhatsMore.
- Perform auto recovery upon the App starts (or the phone starts up) if the previous swapping process is interrupted. (ie. Power off, reboot of the mobile phone, upgrade from the play store)
Download From Play Store
If this thread helped you, Don't forget to hit THANKS.
ANote Overlay - Draw on your screen and screenshot from everywhere
ANote Overlay is an application with which you can take note on your screen wherever you are !
ANO launch itself as an overlay above any applications, images, web pages etc so you can fastly draw anywhere.
Then simply save and share your screenshot.
Your device must be rooted to enable ANO to save the background of your screen shot
With ANO you can :
Navigate through your phone, ANO stills opened
Display / hide ANO
Set up the white background opacity so you can see more or less your background application
Change the pen color and size
Undo or undo all (long press)
Redo or redo all (long press)
Save your screenshot and share it (only the overlay with white background for not rooted device)
Display / hide a resizable rectangle to highlight a portion of your screen.
Play Store link : Free , Donate
RepetiTouch for Android - Record touch events and replay them
RepetiTouch, an app which enables touchscreen input recording and replaying directly on the device. It's available on Google Play, also as a limited free version. This app is tested it on a Nexus 7 and Samsung Galaxy Y but it should work on every rooted device with Android 2.3 or later.
Limitations (of free version, the pro version doesn't have this limitations and, e.g., includes Locale/Tasker support):
- no multitouch recording
- recording time limited to 10 minutes
- no loop mode
- saving record only to a single default file in app directory
- panel not movable/flippable
- no automation tool support (e.g., Tasker or Locale)
If this thread helped you, Don't forget to hit THANKS.
TLDR: Got new phone, don't want to root now but still want to do things I needed root for. I need a non-root packet capture solution, or to decide if I should still root my new phone, or to get into development again. What is my best option? Use case below.
I have always rooted my phones which have always been as easy as 'fastboot oem unlock'. Not with ROG3. It needs an OEM tool and from what I read here I only get one chance.
After all the years though my uses of root fall into one of 3 categories: ad blocking, back up, and one specific case of packet capture.
I used AdAway for DNS level ad blocking. Private DNS with dns.adguard.com seems to be fine for that. Easy enough to set up.
Backup is with Titanium Backup. I am going to install all apps I ever had on my last phone (which has root and Ti) hoping that the stock transfer tool would pick them up and carry them over. Storage is not an issue; I have 512G. Apps I really don't care about anymore can be deleted later.
Next, my sticking point: Packet capture.
For that I have been running a tcpdump binary inside Terminal Emulator a week at a time. I am after the network traffic of one game, which I am not going to name for fear of ruining the fun. Its traffic has been in clear HTTP since I started playing in 2015. Through it I have gathered how units level up, enemy patterns in battles, and scripts for story scenes. I so enjoyed having these data that I kept playing, as long as it remains viable. My setup writes a pcap file to external storage that I can copy to my laptop for analysis. I configured tcpdump to capture only traffic to/from one IP to save space.
To get the same functionality I need a packet capture app to capture only the game's traffic, and save one pcap file per session. I tried 3 such apps and they all fall short in one way or another.
TPacketCapture captures all; app filter is its very expensive paid feature. Plus it stalls all traffic within 3 minutes of starting.
Greyshirts SSL Packet Capture splits capture by HTTP streams. Each must be selected manually for export with no option for a whole session export. Is a problem because every transaction of the game is its own HTTP stream. Is also a known beef among users and author seems unwilling to address. It keeps its data files to itself; I was only able to get them via root and they are not straight pcap, yet not difficult to figure out. It does decode the game traffic very nicely, to the point it becomes human-readable.
PCAPDroid does not save files; it only streams off its builtin HTTP server or UDP. I could not get useful capture out of it, but it is open source, so I could try adding that feature myself, hence the question of getting into development.
I did find a way to mass export data out of Greyshirts. I can use adb backup to back up that entire app's data. Then I found information on how to extract from it the data files it kept to itself. Then because those data is in a lighter format than pcap, it's actually easier for me to script a parser and work on them directly!
-- EDIT --
I found that some public wifi break if used with a private DNS.
Then for some time I totally lost adb backup functionality! I would get an empty backup even though everything else goes as expected. I resigned to defer moving that game over and set up Android Studio to start that development work I mentioned (in essence, attempt to modify PCAPDroid to save captures to external storage and add AdAway functionality).
Instead of using just the command line tools like I always have, I installed Android Studio. The SDK tools got updated along the way to 1.0.41 on SDK Tools 30.0.5 (I got the "ADB backup deprecated" message too, but the [email protected]% I care) . Then when I tried adb backup again I got my full backups again.
-- END EDIT --
I think there's my solution and I can now go without rooting. If I do need root in the future, adb backup should save the day.
The Work Profile on my phone isn't something related to my work. I will always use a separate phone for my Work. Yet, I install Work Profile on all my phones. On top of that, I also use the Multiple Users feature (if available), although I'm the only one using my phones.
The one word answer for why I do it is Privacy.
MULTIPLE USERS
Multiple Users feature of Android allows users to create an isolated environment with its own set of apps, accounts and user files.
An app can be installed only once in a device. If you try to install an app, that is already installed in one profile, in another profile, all that happens is creation of a separate Data folder for that app in the new profile. So while it may appear that the app has been installed again, that's not what is actually happening. This is why an app can be updated from any user profile. This is also why you can't install different versions of the same app in different profiles.
The Work Profile is a special type of Multiple Users feature of Android, with some specific advantages:
1. Apps in the Work Profile run concurrently with apps in the Main Profile (Primary User). In case of Multiple Users, apps are frozen once you login to another user.
2. Since apps in Work Profile are always running along with apps in your Main Profile, you get notifications from Work apps along with those on your Main Profile.
3. You can launch apps in Work Profile without having to leave the Main Profile. This is not the case with apps in other Multiple Users.
HOW TO USE WORK PROFILE (OR OTHER MULTIPLE USERS) FOR PRIVACY
There are a few apps that we use which need access to both internet as well as internal storage. Examples would be downloaders, social media apps, etc.
This is one area of Android that is very privacy invasive. You either give full access to your internal storage or you can't download/ upload files. Hopefully, this is being addressed with Android 14.
It is because of this limitation of Android, that Work Profile can be used to isolate personal files from certain apps, without limiting their functionality.
No app in Work Profile shares data or is connected to apps in the Main Profile. They also do not have access to Contacts, SMS, etc. in the Main Profile. This includes Google Play Services too.
I install Downloaders, social media apps, etc. in the Work Profile and give them all the necessary permissions. While these apps have access to the internal storage, they still cannot access files in my Main Profile like my camera roll, or other files that may contain sensitive data.
This is how you can use Work Profile to increase your own privacy.
Note that Work Profile or Multiple Users do not increase your battery drain or cause lags. On the contrary, they may help conserve some battery and reduce lags because apps in Multiple Users do not run until you login to that User, and Work Profile can be turned OFF when you don't want those apps running.
You can enable Work Profile on most Android phones using this app:
Shelter | F-Droid - Free and Open Source Android App Repository
Isolate and run multiple instances of apps using Work Profiles
f-droid.org
Many OEMs hide this feature in their implementation of Android. This app only enables it and makes it accessible to you.