diff --git a/fediverse/mastodon_cw_toggle.js b/fediverse/mastodon_cw_toggle.js index a82307d..d096daf 100644 --- a/fediverse/mastodon_cw_toggle.js +++ b/fediverse/mastodon_cw_toggle.js @@ -2,7 +2,7 @@ // @name Mastodon CW toggle // @description Toggles the visibility of all statuses with content warnings. // @namespace tastytea.de -// @version 2019-05-27 +// @version 2019-05-27_2 // @grant none // @run-at document-end // ==/UserScript== @@ -30,16 +30,18 @@ function toggle() } } -// If there is a “Show more”-button, add our “Toggle all CWs”-button, if we -// didn't do so before. -if (document.getElementsByClassName("status__content__spoiler-link").length > 0 - && document.getElementById("global-cw-toggle") === null) +// Add a “Toggle all CWs”-button. +function add_button() { - // If there is no element named “column-1”, do nothing. + // If there is no element named “column-1”, use the footer. var root = document.getElementsByClassName("column-1")[0]; if (root == null) { - return; + root = document.getElementsByClassName("footer")[0]; + if (root == null) + { + return; + } } // Create a div, necessary to get the correct styling for the button. @@ -58,3 +60,10 @@ if (document.getElementsByClassName("status__content__spoiler-link").length > 0 button.onclick = toggle; } + +// If there is a “Show more”-button, add our button, if we didn't do so before. +if (document.getElementsByClassName("status__content__spoiler-link").length > 0 + && document.getElementById("global-cw-toggle") === null) +{ + add_button(); +}