From fa415ecee1821ae72d3bb9e16c36b523871e1448 Mon Sep 17 00:00:00 2001 From: Blumenkohl6 Date: Thu, 30 Nov 2023 20:28:09 +0100 Subject: [PATCH] delete option + button active state added --- script.js | 17 +++++++++++++++++ style.css | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/script.js b/script.js index be4ce72..779cd42 100644 --- a/script.js +++ b/script.js @@ -99,6 +99,23 @@ async function loadData() { frame.addEventListener("click", (e) => { navigator.clipboard.writeText(e.currentTarget.getAttribute("data-code")); }); + frame.addEventListener("contextmenu", async function(e) { + e.preventDefault(); + + let cTarget = e.currentTarget; + + const userConfirmation = window.confirm("Do you want to delete " + cTarget.children[0].innerHTML + "?"); + + if (userConfirmation) { + let data = await fetchData(); + delete data[cTarget.children[0].innerHTML]; + console.log(cTarget.children[0].innerHTML); + await chrome.storage.sync.set({ data: data }, function() { + console.log('deleted'); + }); + loadData(); + } + }); parent.appendChild(frame); } } catch (error) { diff --git a/style.css b/style.css index d887553..32b3279 100644 --- a/style.css +++ b/style.css @@ -33,6 +33,10 @@ body { } .frame:hover { + background-color: rgba(30, 30, 30, 0.031); +} + +.frame:active { background-color: rgba(255, 255, 255, 0.031); }