diff options
| author | dm <dm@work-pc> | 2022-02-16 12:06:25 +0800 |
|---|---|---|
| committer | Árni Dagur <arni@dagur.eu> | 2022-02-26 22:06:53 +0100 |
| commit | 86ba5b7a5f65b6579813b86a4414270f896e6424 (patch) | |
| tree | af72d518a9be2a57f58e78d57c4ee22fd369ea90 /adblock | |
| parent | c63e6534d9d00121e773688e2ccd897c93dbdc69 (diff) | |
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.
Diffstat (limited to 'adblock')
| -rw-r--r-- | adblock/__init__.py | 2 | ||||
| -rw-r--r-- | adblock/adblock.pyi | 11 |
2 files changed, 11 insertions, 2 deletions
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 ( | |||
| 11 | OptimizedFilterExistence, | 11 | OptimizedFilterExistence, |
| 12 | BadFilterAddUnsupported, | 12 | BadFilterAddUnsupported, |
| 13 | FilterExists, | 13 | FilterExists, |
| 14 | AddResourceError, | ||
| 14 | ) | 15 | ) |
| 15 | 16 | ||
| 16 | 17 | ||
| @@ -26,4 +27,5 @@ __all__ = ( | |||
| 26 | "OptimizedFilterExistence", | 27 | "OptimizedFilterExistence", |
| 27 | "BadFilterAddUnsupported", | 28 | "BadFilterAddUnsupported", |
| 28 | "FilterExists", | 29 | "FilterExists", |
| 30 | "AddResourceError", | ||
| 29 | ) | 31 | ) |
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): | |||
| 21 | class FilterExists(BlockerException): | 21 | class FilterExists(BlockerException): |
| 22 | pass | 22 | pass |
| 23 | 23 | ||
| 24 | class AddResourceError(BlockerException): | ||
| 25 | pass | ||
| 26 | |||
| 24 | class BlockerResult: | 27 | class BlockerResult: |
| 25 | matched: bool | 28 | matched: bool |
| 26 | explicit_cancel: bool | 29 | explicit_cancel: bool |
| 27 | important: bool | 30 | important: bool |
| 31 | redirect_type: Optional[str] | ||
| 28 | redirect: Optional[str] | 32 | redirect: Optional[str] |
| 29 | exception: Optional[str] | 33 | exception: Optional[str] |
| 30 | filter: Optional[str] | 34 | filter: Optional[str] |
| @@ -43,14 +47,15 @@ class UrlSpecificResources: | |||
| 43 | class FilterSet: | 47 | class FilterSet: |
| 44 | def __init__(self, debug: bool = False) -> None: | 48 | def __init__(self, debug: bool = False) -> None: |
| 45 | pass | 49 | pass |
| 46 | def add_filter_list(self, filter_list: str, format: str = "standard") -> None: | 50 | def add_filter_list(self, filter_list: str, format: str = "standard", include_redirect_urls: bool = False) -> None: |
| 47 | pass | 51 | pass |
| 48 | def add_filters(self, filters: List[str], format: str = "standard") -> None: | 52 | def add_filters(self, filters: List[str], format: str = "standard", include_redirect_urls: bool = False) -> None: |
| 49 | pass | 53 | pass |
| 50 | 54 | ||
| 51 | class Engine: | 55 | class Engine: |
| 52 | def __init__(self, filter_set: FilterSet, optimize: bool = True) -> None: | 56 | def __init__(self, filter_set: FilterSet, optimize: bool = True) -> None: |
| 53 | pass | 57 | pass |
| 58 | |||
| 54 | def check_network_urls( | 59 | def check_network_urls( |
| 55 | self, url: str, source_url: str, request_type: str | 60 | self, url: str, source_url: str, request_type: str |
| 56 | ) -> BlockerResult: | 61 | ) -> BlockerResult: |
| @@ -93,6 +98,8 @@ class Engine: | |||
| 93 | pass | 98 | pass |
| 94 | def tag_exists(self, tag: str) -> bool: | 99 | def tag_exists(self, tag: str) -> bool: |
| 95 | pass | 100 | pass |
| 101 | def add_resource(self, name: str, content_type: str, content: str) -> bool: | ||
| 102 | pass | ||
| 96 | def url_cosmetic_resources(self, url: str) -> UrlSpecificResources: | 103 | def url_cosmetic_resources(self, url: str) -> UrlSpecificResources: |
| 97 | pass | 104 | pass |
| 98 | def hidden_class_id_selectors( | 105 | def hidden_class_id_selectors( |
