From 1f67db9258990d60761f7a10733bb58c78e078ef Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 22 Jul 2022 06:20:52 +0200 Subject: [PATCH] Move buttons to below the "add items" list --- extension/add_items_to_collection.css | 6 +++++- extension/add_items_to_collection.js | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/extension/add_items_to_collection.css b/extension/add_items_to_collection.css index 22fc233..82b329b 100644 --- a/extension/add_items_to_collection.css +++ b/extension/add_items_to_collection.css @@ -1,3 +1,7 @@ +#tidebringer-container { + margin-top: 16px; +} + .tidebringer-running { opacity: 0.5; -} \ No newline at end of file +} diff --git a/extension/add_items_to_collection.js b/extension/add_items_to_collection.js index d1258fb..92a9919 100644 --- a/extension/add_items_to_collection.js +++ b/extension/add_items_to_collection.js @@ -21,7 +21,7 @@ async function addItemToCollection(itemElement) { } async function addAllSubscribedToCollection() { - const buttonElement = document.querySelector("#tidebringer-add-all-subscribed"); + const buttonElement = document.querySelector("#tidebringer-btn-add-all-subscribed"); buttonElement.className += " tidebringer-running"; const itemElements = document.querySelectorAll(".itemChoice"); @@ -42,16 +42,24 @@ async function addAllSubscribedToCollection() { function tidebringer() { console.log("%c Tidebringer %chttps://github.com/Steffo99/tidebringer-firefox", "background-color: black; color: #a0f3f6;"); - const buttonsLine = document.querySelector(".collectionAddItemsTitle"); + + const whereTheContainerShouldBePlaced = document.querySelector(".collectionAddItemsSection"); + if(!whereTheContainerShouldBePlaced) return + + const container = document.createElement("div") + container.id = "tidebringer-container" + whereTheContainerShouldBePlaced.appendChild(container) + const addAllSubscribedButton = document.createElement("button"); addAllSubscribedButton.className = "btn_darkblue_white_innerfade btn_medium" addAllSubscribedButton.addEventListener("click", addAllSubscribedToCollection); - addAllSubscribedButton.id = "tidebringer-add-all-subscribed"; + addAllSubscribedButton.id = "tidebringer-btn-add-all-subscribed"; const addAllSubscribedSpan = document.createElement("span"); const addAllSubscribedText = document.createTextNode("Add all subscribed elements"); addAllSubscribedSpan.appendChild(addAllSubscribedText); addAllSubscribedButton.appendChild(addAllSubscribedSpan); - buttonsLine.appendChild(addAllSubscribedButton); + + container.appendChild(addAllSubscribedButton); } tidebringer(); \ No newline at end of file