From 9f68c843d6673a81fa439c7e1c240d2a07f5e954 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Wed, 1 Nov 2023 14:30:23 -0600 Subject: [PATCH] Specify links that should trigger div removal from results There are certain links (such as the age verification link mentioned in issue #1083) that should trigger removal of the entire container div on the results page, rather than just hiding the link itself. This introduces a new `unsupported_g_divs` list that holds links that will trigger a removal of the result div on the result page. Fixes #1083 --- app/filter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/filter.py b/app/filter.py index 355b358..3a80535 100644 --- a/app/filter.py +++ b/app/filter.py @@ -29,9 +29,12 @@ unsupported_g_pages = [ 'google.com/preferences', 'google.com/intl', 'advanced_search', - 'tbm=shop' + 'tbm=shop', + 'ageverification.google.co.kr' ] +unsupported_g_divs = ['google.com/preferences?hl=', 'ageverification.google.co.kr'] + def extract_q(q_str: str, href: str) -> str: """Extracts the 'q' element from a result link. This is typically @@ -554,7 +557,7 @@ class Filter: link['href'] = link_netloc parent = link.parent - if 'google.com/preferences?hl=' in link_netloc: + if any(divlink in link_netloc for divlink in unsupported_g_divs): # Handle case where a search is performed in a different # language than what is configured. This usually returns a # div with the same classes as normal search results, but with