Make button work on older Mastodon versions.
This commit is contained in:
parent
71421c08e2
commit
7a47818e62
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user