[Magisk] Zackptg5:
This mod has since been discontinued in favor of Adaway. Read on for information on how to use Unified Hosts with Adaway

What are Unified Host Files?

Unified host files combine many reputable sources into a single hosts file (with duplicates removed). Some examples include adaway, mvps, yoyo.org, and malware domain list (see Steven Black's page here for a complete list).

Adaway Installation for Magisk:

Adaway version 4.x now works properly with magisk systemless hosts. To enable it, just install the latest version from here (the main xda thread for it hasn't been updated for it yet). Then go to Preferences -> Enable systemless mode. This automatically enables the Systemless hosts option in magisk manager so no need to bother with that. Then use the app as normal.

How to Add Unified Hosts to Adaway:

In the adaway app, go to Preferences -> Redirection IP (NOT Allow Redirects). Change the value to 0.0.0.0. Read the readme on Steven Black's GitHub linked above for why.

Then go to Hosts Sources. Then add the url of the unified hosts you want (ONLY CHOOSE 1):

Master: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts

Master+FakeNews: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews/hosts

Master+Gambling: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling/hosts

Master+Porn: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/porn/hosts

Master+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/social/hosts

Master+FakeNews+Gambling: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling/hosts

Master+FakeNews+Porn: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-porn/hosts

Master+FakeNews+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-social/hosts

Master+Gambling+Porn: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling-porn/hosts

Master+Gambling+Social https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling-social/hosts

Master+Porn+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/porn-social/hosts

Master+Fakenews+Gambling+Porn (This is the one I use): https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts

Master+Fakenews+Gambling+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-social/hosts

Master+Fakenews+Porn+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-porn-social/hosts

Master+Gambling+Porn+Social: https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling-porn-social/hosts

Master+Fakenews+Gambling+Porn+social: https://raw.githubusercontent.com/S...lternates/fakenews-gambling-porn-social/hosts

You can then uncheck the host sources already added by default to adaway since they're included in unified hosts sources already

**Note that the 'Social' filter does exactly what you think: blocks social networks. So if you use any kind of social networking, DO NOT CHOOSE THIS ANY SOURCE WITH THIS IN IT**

Using a APN that uses a proxy server or a subsidiary provider and unable to get adblocking working? See here for a fix

Original Mod Information:

Description

Blocks ads by using Steven Black's Unified Hosts

Comes with a small utility based off of LarappsOfDongle's RP modular host module that allows you to choose which kind of host file you want (adware/malware, fakenews, gambling, porn, social, or any combination)

Installation

Go to Settings in Magisk Manager and enable 'Systemless Hosts'

Flash module

Open terminal and type:

su
hosts

Then follow the prompts to install the host file of your choice.

OR

- Open terminal and type:

su -c hosts arg1 arg2 arg3

- The script will apply your arguments all at once and close. Useful for automation purposes

- For example: `su -c hosts m wr b`

- Script will apply the master filter, then your regex whitelist, then your blacklist

Updating Hosts:

Just run the hosts file again in terminal and it'll overwrite the old one

Note: The script will now notify you to say if you need to update or not at the top of it

Disabling Host Mod:

Just toggle the enable systemless hosts option in magisk manager

Whitelist Instructions:

Create an empty file on sdcard card called "whitelist"

Either add exact lines you want remove to it -> Run hosts script and choose whitelist option

For example:

0.0.0.0 facebook.com

Will unblock facebook.com

Or add regex for lines you want removed -> Run hosts script and choose whitelist regex option

For example:

.*facebook.*

Will unblock all domains with "facebook" in them

Blacklist Instructions:

Create an empty file on sdcard card called "blacklist"

Add exact lines you want to remove it (do not include the 0.0.0.0 -> so for example: "facebook.com")

Run hosts script and choose blacklist option

For example:

google-analytics.com

Will block the google-analytics.com domain (it will add the entry "0.0.0.0 google-analytics.com" to the hosts file - note the lack of the 0's here. The script takes care of it automatically for the blacklist feature)

To Remove Whitelist:

Just run hosts script and reinstall host file of choice

Latest Magisk Version Compatibility:

15.x

Source

Can't Boot?

Try rebooting into the bootloader, then boot into system. Thanks [MENTION=3290808]rignfool[/MENTION] for the tip

Bonus!

I made a quick automate flow to update the hosts file. Just import it, add a shortcut to your home screen, and you can update it in one click :)

Just change the 2nd block to whatever options you want

[MENTION=4667597]Didgeridoohan[/MENTION] made a tasker profile here for any who use tasker: https://xdaforums.com/showpost.php?p=73369050&postcount=451

Download