From dd90db5271a79b443c74a4335d6168b16451cc12 Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 7 Jun 2019 01:23:25 +0200 Subject: [PATCH] Check if we run on a Pleroma page, only try for 10 seconds. --- fediverse/pleroma_cw_toggle.user.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fediverse/pleroma_cw_toggle.user.js b/fediverse/pleroma_cw_toggle.user.js index 2286aae..4fa1169 100644 --- a/fediverse/pleroma_cw_toggle.user.js +++ b/fediverse/pleroma_cw_toggle.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Pleroma CW toggle // @description Adds a button to toggle the visibility of all statuses with content warnings on status-pages and profile-pages. -// @version 2019.06.07.2 +// @version 2019.06.07.3 // @author tastytea // @copyright 2019, tastytea (https://tastytea.de/) // @license GPL-3.0-only @@ -17,6 +17,7 @@ // ==/UserScript== let interval; +let counter = 0; // Toggle the visibility of statuses with CW. function toggle() @@ -36,6 +37,13 @@ function toggle() function add_button() { + ++counter; + // If this is not Pleroma or we tried 10 times, disable interval. + if (counter >= 10 || document.getElementById("app") === null) + { + clearInterval(interval); + return; + } const main = document.getElementsByClassName("main")[0]; // If conversation-heading is not there, try profile-tabs.