forked from tastytea/userscripts
Make button work on older Mastodon versions.
This commit is contained in:
parent
71421c08e2
commit
7a47818e62
|
@ -2,7 +2,7 @@
|
||||||
// @name Mastodon CW toggle
|
// @name Mastodon CW toggle
|
||||||
// @description Toggles the visibility of all statuses with content warnings.
|
// @description Toggles the visibility of all statuses with content warnings.
|
||||||
// @namespace tastytea.de
|
// @namespace tastytea.de
|
||||||
// @version 2019-05-27
|
// @version 2019-05-27_2
|
||||||
// @grant none
|
// @grant none
|
||||||
// @run-at document-end
|
// @run-at document-end
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
@ -30,16 +30,18 @@ function toggle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a “Show more”-button, add our “Toggle all CWs”-button, if we
|
// Add a “Toggle all CWs”-button.
|
||||||
// didn't do so before.
|
function add_button()
|
||||||
if (document.getElementsByClassName("status__content__spoiler-link").length > 0
|
|
||||||
&& document.getElementById("global-cw-toggle") === null)
|
|
||||||
{
|
{
|
||||||
// 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];
|
var root = document.getElementsByClassName("column-1")[0];
|
||||||
if (root == null)
|
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.
|
// 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;
|
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