From 86ba5b7a5f65b6579813b86a4414270f896e6424 Mon Sep 17 00:00:00 2001 From: dm Date: Wed, 16 Feb 2022 12:06:25 +0800 Subject: feat: include complete redirect rule feature. 1. update adblock-rust => 0.4.3 2. add `include_redirect_urls` parameter for `FilterSet.add_filter_list` and `FilterSet.add_filters` 3. add `Engine.add_resource` method. 4. add `adblock.AddResourceError` Exception 5. add `redirect_type` for `BlockerResult` 6. add some tests for these functions. --- adblock/__init__.py | 2 ++ adblock/adblock.pyi | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'adblock') diff --git a/adblock/__init__.py b/adblock/__init__.py index 85d3614..4ba4c4b 100644 --- a/adblock/__init__.py +++ b/adblock/__init__.py @@ -11,6 +11,7 @@ from adblock.adblock import ( OptimizedFilterExistence, BadFilterAddUnsupported, FilterExists, + AddResourceError, ) @@ -26,4 +27,5 @@ __all__ = ( "OptimizedFilterExistence", "BadFilterAddUnsupported", "FilterExists", + "AddResourceError", ) diff --git a/adblock/adblock.pyi b/adblock/adblock.pyi index 0515674..83d2492 100644 --- a/adblock/adblock.pyi +++ b/adblock/adblock.pyi @@ -21,10 +21,14 @@ class BadFilterAddUnsupported(BlockerException): class FilterExists(BlockerException): pass +class AddResourceError(BlockerException): + pass + class BlockerResult: matched: bool explicit_cancel: bool important: bool + redirect_type: Optional[str] redirect: Optional[str] exception: Optional[str] filter: Optional[str] @@ -43,14 +47,15 @@ class UrlSpecificResources: class FilterSet: def __init__(self, debug: bool = False) -> None: pass - def add_filter_list(self, filter_list: str, format: str = "standard") -> None: + def add_filter_list(self, filter_list: str, format: str = "standard", include_redirect_urls: bool = False) -> None: pass - def add_filters(self, filters: List[str], format: str = "standard") -> None: + def add_filters(self, filters: List[str], format: str = "standard", include_redirect_urls: bool = False) -> None: pass class Engine: def __init__(self, filter_set: FilterSet, optimize: bool = True) -> None: pass + def check_network_urls( self, url: str, source_url: str, request_type: str ) -> BlockerResult: @@ -93,6 +98,8 @@ class Engine: pass def tag_exists(self, tag: str) -> bool: pass + def add_resource(self, name: str, content_type: str, content: str) -> bool: + pass def url_cosmetic_resources(self, url: str) -> UrlSpecificResources: pass def hidden_class_id_selectors( -- cgit v1.2.3