Custom Filter Rules Guide

Understanding Filter Rules

Custom filter rules allow precise control over ad blocking behavior. Key components include:

  • Pattern matching
  • Element hiding
  • Network filtering
  • Exception handling

Rule Syntax

Basic Rules

! Basic blocking rule
||example.com/ads/*
! Element hiding rule
example.com##.ad-container
! Network filter
||analytics.$third-party

Advanced Rules

! Exception rule
@@||example.com/content/*$image
! Regex rule
/banner\d+\.gif/$domain=example.com
! Important rule
||tracker.com^$important

Rule Types

Network Rules

  • Domain blocking
  • Path filtering
  • Protocol rules
  • Resource types

Cosmetic Rules

  • Element hiding
  • CSS selectors
  • HTML filtering
  • Style injection

Rule Options

Resource Types

! Block specific types
||example.com^$script
||example.com^$image
||example.com^$stylesheet
||example.com^$xmlhttprequest

Domain Options

! Domain targeting
||ads.com^$domain=example.com
||ads.com^$domain=~trusted.com
$third-party,domain=example.com

Rule Creation

  1. Identify target
  2. Choose rule type
  3. Set parameters
  4. Test effectiveness
  5. Refine as needed

Advanced Techniques

Regex Rules

! Match patterns
/^https?:\/\/[a-z0-9]+\.ads\.com/
/banner[0-9]+\.jpg$/
/pop(up|under)\d+\./

Scriptlets

! Inject scripts
example.com##+js(abort-on-property-read, adblock)
example.com##+js(set-constant, ads, true)
example.com##+js(remove-attr, onclick)

Best Practices

  • Rule documentation
  • Performance testing
  • Regular updates
  • Compatibility checks

Common Patterns

Ad Networks

||ad-network.com^$third-party
||*.ads.com^$script,image
||analytics.$important

Social Widgets

||platform.com/widgets/$third-party
||social-buttons.$script
##.social-share-container