From 30d105ec8647ddfd5a91565794e123f2635e7916 Mon Sep 17 00:00:00 2001 From: Alexei Date: Tue, 8 Oct 2019 16:11:19 -0400 Subject: [PATCH] Fix Google search result image/video thumbnails. By ignoring "style" attributes on links. --- src/js/firstparties/google-search.js | 7 ++++--- src/js/firstparties/google-static.js | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/js/firstparties/google-search.js b/src/js/firstparties/google-search.js index 92ebbbff3f..c519ff2add 100644 --- a/src/js/firstparties/google-search.js +++ b/src/js/firstparties/google-search.js @@ -5,13 +5,14 @@ let trap_link = "a[onmousedown^='return rwt(this,'], a[ping]"; // Remove excessive attributes and event listeners from link a function cleanLink(a) { - // remove all attributes from a link except for href, + // remove all attributes except for href, // target (to support "Open each selected result in a new browser window"), - // class and ARIA attributes + // class, style and ARIA attributes for (let i = a.attributes.length - 1; i >= 0; --i) { const attr = a.attributes[i]; if (attr.name !== 'href' && attr.name !== 'target' && - attr.name !== 'class' && !attr.name.startsWith('aria-')) { + attr.name !== 'class' && attr.name !== 'style' && + !attr.name.startsWith('aria-')) { a.removeAttribute(attr.name); } } diff --git a/src/js/firstparties/google-static.js b/src/js/firstparties/google-static.js index 552cb050f2..4031fe4a86 100644 --- a/src/js/firstparties/google-static.js +++ b/src/js/firstparties/google-static.js @@ -7,13 +7,13 @@ function unwrapLink(a) { return; } - // remove all attributes from a link except for target, class, and aria-* + // remove all attributes except for target, class, style and aria-* // attributes. This should prevent the script from breaking styles and // features for people with disabilities. for (let i = a.attributes.length - 1; i >= 0; --i) { const attr = a.attributes[i]; if (attr.name !== 'target' && attr.name !== 'class' && - !attr.name.startsWith('aria-')) { + attr.name !== 'style' && !attr.name.startsWith('aria-')) { a.removeAttribute(attr.name); } }