From 0456ef42460b039510bea3848d5cfa04fd8364a3 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 13 Jun 2019 20:54:39 +0200 Subject: [PATCH] =?UTF-8?q?pleroma=5Fcw=5Ftoggle:=20Place=20button=20left?= =?UTF-8?q?=20of=20=E2=80=9CCollapse=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fediverse/pleroma_cw_toggle.user.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/fediverse/pleroma_cw_toggle.user.js b/fediverse/pleroma_cw_toggle.user.js index ba1f68f..99003f0 100644 --- a/fediverse/pleroma_cw_toggle.user.js +++ b/fediverse/pleroma_cw_toggle.user.js @@ -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.