Sfoglia il codice sorgente

Fix navigator.share insertRule (#4321)

#fix https://github.com/FreshRSS/FreshRSS/pull/4271#discussion_r834288556
Moved to after `DOMContentLoaded`
Alexandre Alapetite 4 anni fa
parent
commit
20e0b848b1
1 ha cambiato i file con 9 aggiunte e 9 eliminazioni
  1. 9 9
      p/scripts/main.js

+ 9 - 9
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;