From f7e36507285b5eba2d8d0dce57380fc9d3f06028 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 1 Mar 2022 12:48:33 -0700 Subject: [PATCH] Only remove G links in footer Links that were directed at G domains were previously removed universally, when really they only needed to be removed from the footer to reduce possible confusion caused by mixed Whoogle and G links. Fixes #656 --- app/filter.py | 7 ++++++- app/models/g_classes.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/filter.py b/app/filter.py index dda07d8..731b6aa 100644 --- a/app/filter.py +++ b/app/filter.py @@ -349,7 +349,12 @@ class Filter: if any(url in link['href'] for url in unsupported_g_pages): # FIXME: The "Shopping" tab requires further filtering (see #136) # Temporarily removing all links to that tab for now. - link.decompose() + parent = link.parent + while parent: + p_cls = parent.attrs.get('class') or [] + if parent.name == 'footer' or f'{GClasses.footer}' in p_cls: + link.decompose() + parent = parent.parent return # Replace href with only the intended destination (no "utm" type tags) diff --git a/app/models/g_classes.py b/app/models/g_classes.py index 2bd53a3..9f394ce 100644 --- a/app/models/g_classes.py +++ b/app/models/g_classes.py @@ -11,6 +11,7 @@ class GClasses(Enum): """ main_tbm_tab = 'KP7LCb' images_tbm_tab = 'n692Zd' + footer = 'TuS8Ad' def __str__(self): return self.value