From 21198efd517b248effed87a5777ea4cd5ba15b95 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 6 Jun 2019 04:00:26 +0200 Subject: [PATCH] Add support for small displays to CW-toggle script. --- fediverse/mastodon_cw_toggle.user.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fediverse/mastodon_cw_toggle.user.js b/fediverse/mastodon_cw_toggle.user.js index c7c70da..69c7c36 100644 --- a/fediverse/mastodon_cw_toggle.user.js +++ b/fediverse/mastodon_cw_toggle.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Mastodon 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.06.2 +// @version 2019.06.06.3 // @author tastytea // @copyright 2019, tastytea (https://tastytea.de/) // @license GPL-3.0-only @@ -53,6 +53,10 @@ function add_button() return; } } + else if (root.offsetParent === null) // If element is hidden, + { // we are probably on a device with a small display. + root = document.getElementsByClassName("column-2")[0]; + } // Create a div, necessary to get the correct styling for the button. const div = document.createElement("div");