Ensure G logo doesn't appear in mobile img results

Adds a separate check to remove all images sourced from www.gstatic.com,
which is where the mobile logo in particular is coming from.
main
Ben Busby 2021-02-20 15:04:32 -05:00 committed by Ben Busby
parent 03bd4b6871
commit 64567a63ea
2 changed files with 9 additions and 13 deletions

View File

@ -127,28 +127,24 @@ class Filter:
question['style'] = 'padding: 10px; font-style: italic;'
def update_element_src(self, element, mime):
element_src = element['src']
if element_src.startswith('//'):
element_src = 'https:' + element_src
elif element_src.startswith(LOGO_URL):
src = element['src']
if src.startswith('//'):
src = 'https:' + src
if src.startswith(LOGO_URL):
# Re-brand with Whoogle logo
element['src'] = 'static/img/logo.png'
element['style'] = 'height:40px;width:162px'
return
elif element_src.startswith(GOOG_IMG):
elif src.startswith(GOOG_IMG) or GOOG_STATIC in src:
element['src'] = BLANK_B64
return
element['src'] = 'element?url=' + self.encrypt_path(
element_src,
src,
is_element=True) + '&type=' + urlparse.quote(mime)
# FIXME: Non-mobile image results link to website instead of image
# if not self.mobile:
# img.append(
# BeautifulSoup(FULL_RES_IMG.format(element_src),
# 'html.parser'))
def update_styling(self, soup):
# Remove unnecessary button(s)
for button in soup.find_all('button'):

View File

@ -5,7 +5,7 @@ from urllib.parse import parse_qs
SKIP_ARGS = ['ref_src', 'utm']
SKIP_PREFIX = ['//www.', '//mobile.', '//m.']
FULL_RES_IMG = '<br/><a href="{}">Full Image</a>'
GOOG_STATIC = 'www.gstatic.com'
GOOG_IMG = '/images/branding/searchlogo/1x/googlelogo'
LOGO_URL = GOOG_IMG + '_desk'
BLANK_B64 = ('data:image/png;base64,'