INNER CODE UNIT · Python

create_declarative_rules

blokadaorg/blokada · scripts/convert-domains-to-rules.py:70

def create_declarative_rules(domains, rule_id_prefix="oisd"):
    """Convert domains to declarativeNetRequest rules.

    Each rule follows the declarativeNetRequest format:
    - id: unique identifier (1-based)
    - priority: rule priority (higher = more important)
    - action: what to do (block, allow, etc.)
    - condition: when to apply the rule
      - urlFilter: domain pattern (||domain format blocks domain and subdomains)
      - resourceTypes: what types of resources to block
    """
    rules = []

    # Resource types to block
    resource_types = [
        "main_frame",
        "sub_frame",
        "stylesheet",

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…