2 How to use the ad blocker
Twann edited this page 8 months ago

How to use the ad-blocker

Summary

Introduction

TBlock is an anticapitalist ad-blocker that uses the hosts file to block advertising domains. It is compatible with a lot of different filters format. To display the help page, simply run:

tblock -h

Enabling and disabling TBlock

At any time, you can restore the default hosts file (which will disable TBlock), by running:

tblock -D

To re-enable TBlock, you just have to add or remove a rule, as well as to update, remove or subscribe to a filter, or simply run:

tblock -H

Note: if you edited your hosts file when TBlock was disabled, new modifications will be kept when re-enabling TBlock.

You can also check at any time if TBlock is enabled or not, by running:

tblock -s

If TBlock is enabled, you should get an output like that:

Status
  TBlock       : version 0.0.6
  Platform     : linux
  Protection   : blocking
  Repository   : version 210510

Rules
  Total        : 30243
  User         : 0
  Allowing     : 0
  Blocking     : 30243
  Redirecting  : 0

Filters
  Active       : 5
  Custom       : 1

Security
  Redirecting  : 0 filter(s) allowed
  Hosts hijack : no threat detected

Otherwise, you should see not blocking instead of blocking.

Adding and removing rules

Rules are essential to TBlock. Filters are simply sets of rules, but you (the user) always have the priority when adding rules. To block a domain, run:

tblock -b example.org

To allow a domain (which means it won't be blocked by filters rules):

tblock -a example.org

To redirect a domain to another address:

tblock -r example.org 127.0.0.1

To remove a rule:

tblock -d example.org

You can also use every rule operation with more than one domain. For example, to block two domains:

tblock -b example.org example.com

Listing rules

To list all rules stored in the database:

tblock -l

To list only rules set by filters, (standard rules):

tblock -lt

To list only rules set by user, (user rules):

tblock -lu

Sync remote repository

The remote repository is updated sometimes, and that means there are new filters available. To be able to subscribe to these new filters, you need to sync your local filter repository with the upstream one:

tblock -Y

If the local filter repository is up-to-date with the upstream one, it won't do anything. However, you can force to sync, if you want:

tblock -Yf

Subscribing to filters

To subscribe to a filter available on the remote filter repository:

tblock -S easylist

If you wish to sync the remote repository too:

tblock -Sy easylist

To subscribe to an online custom filter:

tblock -C example-filter https://example.org/hosts.txt

You can also sync the remote filter repository when subscribing to an online custom filter:

tblock -Cy example-filter https://example.org/hosts.txt

To subscribe to a local custom filter

tblock -C local-filter /path/to/filter.txt

You can also sync the remote filter repository when subscribing to a local custom filter:

tblock -Cy local-filter /path/to/filter.txt

Changing filters permissions

You can decide which filter can add which rules. By default, a filter can only add blocking rules. To allow a filter to add allowing and blocking rules:

tblock -M ab easylist

To allow a filter to add redirecting rules only:

tblock -M r easylist

To allow a filter to add all rules:

tblock -M abr easylist

WARNING: every time you change filters permissions, new permissions overwrite older. That means, if your filter can already add blocking rules, and that you want it to add allowing rules, too, you will need to run:

tblock -M ab easylist

Renaming custom filters

Sometimes, a custom filter can be in conflict with a new filter that has been added in the remote repository (which means they both have the same name, also called ID). If that happens, you need to change the ID of the custom one, by running:

tblock -X my-custom-filter my-custom-filter-renamed

Please note that you can't rename filters with an ID that is already taken. You also can't rename filters that are not custom filters.

Updating filters

To update some specific filters:

tblock -U easylist easyprivacy

To update a specific filter and the remote filter repository:

tblock -Uy easylist

To update all filters:

tblock -U

To update all filters and the remote filter repository:

tblock -Uy

Removing filters

To remove a filter you are subscribing to:

tblock -R easylist

To remove a filter you are subscribing to and update the remote filter repository:

tblock -Ry easylist

Listing and display info about filters

To show information about a filter:

tblock -I easylist

To list all filters:

tblock -L

To list all filters you are subscribing to:

tblock -Lk

To list all filters you are not subscribing to:

tblock -Ln

To list all filters available on the remote filter repository:

tblock -Lw

To list all filters available on the remote filter repository that you are subscribing to:

tblock -Lkw

To list all filters available on the remote filter repository that you are not subscribing to:

tblock -Lnw

To list all custom filters:

tblock -Lc