summaryrefslogtreecommitdiff
path: root/adblock/adblock.pyi
blob: 6c4398f0bb4143c5c283dbcad49af6024c6bd28f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
from typing import Optional, Dict, List, Set

__version__: str

class AdblockException(Exception):
    pass

class BlockerException(AdblockException):
    pass

class SerializationError(BlockerException):
    pass

class DeserializationError(BlockerException):
    pass

class OptimizedFilterExistence(BlockerException):
    pass

class BadFilterAddUnsupported(BlockerException):
    pass

class FilterExists(BlockerException):
    pass

class AddResourceException(AdblockException):
    pass

class InvalidUtf8ContentError(AddResourceException):
    pass

class InvalidBase64ContentError(AddResourceException):
    pass

class BlockerResult:
    matched: bool
    explicit_cancel: bool
    important: bool
    redirect_type: Optional[str]
    redirect: Optional[str]
    exception: Optional[str]
    filter: Optional[str]
    error: Optional[str]
    def __repr__(self) -> str:
        pass

class UrlSpecificResources:
    hide_selectors: Set[str]
    style_selectors: Dict[str, List[str]]
    exceptions: Set[str]
    injected_script: str
    def __repr__(self) -> str:
        pass

class FilterSet:
    def __init__(self, debug: bool = False) -> None:
        pass
    def add_filter_list(
        self,
        filter_list: str,
        format: str = "standard",
        include_redirect_urls: bool = False,
        rule_types: str = "all",
    ) -> None:
        pass
    def add_filters(
        self,
        filters: List[str],
        format: str = "standard",
        include_redirect_urls: bool = False,
        rule_types: str = "all",
    ) -> 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:
        pass
    def check_network_urls_with_hostnames(
        self,
        url: str,
        hostname: str,
        source_hostname: str,
        request_type: str,
        third_party_request: Optional[bool],
    ) -> BlockerResult:
        pass
    def check_network_urls_with_hostnames_subset(
        self,
        url: str,
        hostname: str,
        source_hostname: str,
        request_type: str,
        third_party_request: Optional[bool],
        previously_matched_rule: bool,
        force_check_exceptions: bool,
    ) -> BlockerResult:
        pass
    def serialize(self) -> bytes:
        pass
    def serialize_to_file(self, file: str) -> None:
        pass
    def deserialize(self, serialized: bytes) -> None:
        pass
    def deserialize_from_file(self, file: str) -> None:
        pass
    def filter_exists(self, filter: str) -> bool:
        pass
    def use_tags(self, tags: List[str]) -> None:
        pass
    def enable_tags(self, tags: List[str]) -> None:
        pass
    def disable_tags(self, tags: List[str]) -> None:
        pass
    def tag_exists(self, tag: str) -> bool:
        pass
    def add_resource(
        self,
        name: str,
        content_type: str,
        content: str,
        aliases: Optional[List[str]] = None,
    ) -> bool:
        pass
    def url_cosmetic_resources(self, url: str) -> UrlSpecificResources:
        pass
    def hidden_class_id_selectors(
        self, classes: List[str], ids: List[str], exceptions: Set[str]
    ) -> List[str]:
        pass