diff --git a/addon/init.py b/addon/init.py index d820f92..4ea8a18 100644 --- a/addon/init.py +++ b/addon/init.py @@ -29,8 +29,40 @@ class AddonBase: else: self.google_login_hint = None + def should_ignore(self, flow: http.HTTPFlow) -> bool: + """Check if the request should be ignored.""" + ignore_domains = [ + ".googleapis.com", + "android.clients.google.com", # Added missing comma here + ".adtrafficquality.google", + ".googlesyndication.com", + "cdn.jsdelivr.net", + "update.googleapis.com", + ] + # Ignore .googleapis.com domains + for domain in ignore_domains: + if domain in flow.request.pretty_host: + return True + + # Ignore static files (JS, CSS, fonts, images, etc.) + # Split on '?' to remove query parameters before checking extension + path = flow.request.path.split('?')[0].lower() + static_extensions = [ + '.js', '.css', '.woff2', '.woff', '.ttf', '.otf', '.svg', + '.png', '.jpg', '.jpeg', '.gif', '.webp', '.ico', '.bmp', + '.tiff', '.tif', '.webm', '.mp4', '.avi', '.mov', '.pdf', '.md', + '.txt', '.csv' + ] + + if any(path.endswith(ext) for ext in static_extensions): + return True + + return False + + + async def request(self, flow: http.HTTPFlow): - if false_true_varifing_task.is_verifing_false_true(): + if false_true_varifing_task.is_verifing_false_true() or self.should_ignore(flow): return tasks = [ @@ -40,7 +72,7 @@ class AddonBase: await asyncio.gather(*tasks) async def response(self, flow: http.HTTPFlow): - if false_true_varifing_task.is_verifing_false_true(): + if false_true_varifing_task.is_verifing_false_true() or self.should_ignore(flow): return tasks = [