pleroma_cw_toggle: Place button left of “Collapse”.

This commit is contained in:
tastytea 2019-06-13 20:54:39 +02:00
parent 1712e8c2f9
commit 0456ef4246
Signed by untrusted user: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 14 additions and 4 deletions

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @name Pleroma CW toggle
// @description Adds a button to toggle the visibility of all statuses with content warnings on status-pages, profile-pages and timelines.
// @version 2019.06.12.3
// @version 2019.06.13.1
// @author tastytea
// @copyright 2019, tastytea (https://tastytea.de/)
// @license GPL-3.0-only
@ -55,14 +55,24 @@ function add_button(parent)
{
const span = document.createElement("span");
const button = document.createElement("a");
button.setAttribute("class", "global-cw-toggle");
button.setAttribute("style", "margin-left: 1em; cursor: pointer;");
button.setAttribute(
"style", "margin-left: 1em; margin-right: 0.5em; cursor: pointer;");
button.appendChild(document.createTextNode("Toggle all CWs"));
button.addEventListener('click', function()
{ toggle(parent.parentElement); });
span.append(button);
parent.append(span);
const otherspans = parent.getElementsByTagName("span");
if (otherspans.length > 1) // Place it left of “Collapse”.
{
parent.insertBefore(span, otherspans[1]);
}
else
{
parent.append(span);
}
}
// Check if we need to add a button.