From 7b8975d8f53e882ad74f0c11b20beae4efebaafc Mon Sep 17 00:00:00 2001 From: Kohei Yoshino Date: Tue, 2 Jan 2018 12:03:05 -0500 Subject: Bug 1426673 - The logout link cannot be found as what Sessions page says --- js/global.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'js') diff --git a/js/global.js b/js/global.js index a590c6ac6..2b353a69e 100644 --- a/js/global.js +++ b/js/global.js @@ -191,6 +191,18 @@ $().ready(function() { }); }); +/** + * Check if Gravatar images on the page are successfully loaded, and if blocked + * (by any content blocker), replace them with the default/fallback image. + */ +const detect_blocked_gravatars = () => { + document.querySelectorAll('img[src^="https://secure.gravatar.com/avatar/"]').forEach($img => { + if (!$img.complete || !$img.naturalHeight) { + $img.src = 'extensions/Gravatar/web/default.jpg'; + } + }); +} + /** * If the URL contains a hash like #c10, scroll down the page to show the * element below the fixed global header. This workaround is required for @@ -209,5 +221,6 @@ const scroll_element_into_view = () => { } } +window.addEventListener('load', detect_blocked_gravatars, { once: true }); window.addEventListener('load', scroll_element_into_view, { once: true }); window.addEventListener('hashchange', scroll_element_into_view); -- cgit v1.2.3-24-g4f1b