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
main
Ben Busby 2023-11-01 14:30:23 -06:00
parent 2a0b9a47b2
commit 9f68c843d6
No known key found for this signature in database
GPG Key ID: B9B7231E01D924A1
1 changed files with 5 additions and 2 deletions

View File

@ -29,9 +29,12 @@ unsupported_g_pages = [
'google.com/preferences', 'google.com/preferences',
'google.com/intl', 'google.com/intl',
'advanced_search', '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: def extract_q(q_str: str, href: str) -> str:
"""Extracts the 'q' element from a result link. This is typically """Extracts the 'q' element from a result link. This is typically
@ -554,7 +557,7 @@ class Filter:
link['href'] = link_netloc link['href'] = link_netloc
parent = link.parent 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 # Handle case where a search is performed in a different
# language than what is configured. This usually returns a # language than what is configured. This usually returns a
# div with the same classes as normal search results, but with # div with the same classes as normal search results, but with