From 20e0b848b177e7cfd6554eb831489a51dd03964a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 19 Apr 2022 23:33:27 +0200 Subject: Fix navigator.share insertRule (#4321) #fix https://github.com/FreshRSS/FreshRSS/pull/4271#discussion_r834288556 Moved to after `DOMContentLoaded` --- p/scripts/main.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'p/scripts') diff --git a/p/scripts/main.js b/p/scripts/main.js index 65a0afdbb..67c41f07a 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -736,6 +736,15 @@ function init_posts() { }; onScroll(); } + + if (!navigator.share && document.styleSheets.length > 0) { + // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share + // do not show the menu entry if browser does not support navigator.share + document.styleSheets[0].insertRule( + 'button.as-link[data-type="web-sharing-api"] {display: none !important;}', + document.styleSheets[0].cssRules.length + ); + } } function rememberOpenCategory(category_id, isOpen) { @@ -1078,15 +1087,6 @@ function init_stream(stream) { } }; - if (!navigator.share) { - // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share - // do not show the menu entry if browser does not support navigator.share - document.styleSheets[0].insertRule( - 'button.as-link[data-type="web-sharing-api"] {display: none !important;}', - document.styleSheets[0].cssRules.length - ); - } - stream.onmouseup = function (ev) { // Mouseup enables us to catch middle click, and control+click in IE/Edge if (ev.altKey || ev.metaKey || ev.shiftKey) { return; -- cgit v1.2.3