Add support for small displays to CW-toggle script.

This commit is contained in:
tastytea 2019-06-06 04:00:26 +02:00
parent 41e4e2f22b
commit 21198efd51
Signed by untrusted user: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 5 additions and 1 deletions

View File

@ -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");