From 3c50f70b3bdb1d6c50761e2c5a18ce0fd23895e5 Mon Sep 17 00:00:00 2001 From: caneleex Date: Thu, 11 Mar 2021 18:34:29 +0100 Subject: [PATCH 1/2] add uuid copy button to the popup --- public/icons/clipboard.svg | 1 + public/popup.css | 7 +++++++ src/popup.ts | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 public/icons/clipboard.svg diff --git a/public/icons/clipboard.svg b/public/icons/clipboard.svg new file mode 100644 index 00000000..01dffe9f --- /dev/null +++ b/public/icons/clipboard.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/popup.css b/public/popup.css index fda29da8..f7e173e3 100644 --- a/public/popup.css +++ b/public/popup.css @@ -63,6 +63,13 @@ cursor: pointer; } +.uuidButton { + height: 20px; + padding: 0 5px; + + cursor: pointer; +} + #videoInfo>p, #videoInfo>div>p { margin: 0; } diff --git a/src/popup.ts b/src/popup.ts index 347678f3..7025b286 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -425,9 +425,18 @@ async function runThePopup(messageListener?: MessageListener): Promise { downvoteButton.src = chrome.extension.getURL("icons/thumbs_down.svg"); downvoteButton.addEventListener("click", () => vote(0, UUID)); - //add thumbs up and down buttons to the container + //uuid button + + const uuidButton = document.createElement("img"); + uuidButton.id = "sponsorTimesCopyUUIDButtonContainer" + UUID; + uuidButton.className = "uuidButton"; + uuidButton.src = chrome.extension.getURL("icons/clipboard.svg"); + uuidButton.addEventListener("click", () => navigator.clipboard.writeText(UUID)); + + //add thumbs up, thumbs down and uuid copy buttons to the container voteButtonsContainer.appendChild(upvoteButton); voteButtonsContainer.appendChild(downvoteButton); + voteButtonsContainer.appendChild(uuidButton); //add click listener to open up vote panel sponsorTimeButton.addEventListener("click", function() { @@ -576,13 +585,13 @@ async function runThePopup(messageListener?: MessageListener): Promise { function vote(type, UUID) { //add loading info addVoteMessage(chrome.i18n.getMessage("Loading"), UUID); - + //send the vote message to the tab chrome.runtime.sendMessage({ message: "submitVote", type: type, UUID: UUID - }, function(response) { + }, function (response) { if (response != undefined) { //see if it was a success or failure if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) { From ca3732315c6f704663e20096470ecb33c3cf4d23 Mon Sep 17 00:00:00 2001 From: caneleex Date: Fri, 12 Mar 2021 11:23:25 +0100 Subject: [PATCH 2/2] remove unnecessary additional css --- public/popup.css | 7 ------- src/popup.ts | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/public/popup.css b/public/popup.css index f7e173e3..fda29da8 100644 --- a/public/popup.css +++ b/public/popup.css @@ -63,13 +63,6 @@ cursor: pointer; } -.uuidButton { - height: 20px; - padding: 0 5px; - - cursor: pointer; -} - #videoInfo>p, #videoInfo>div>p { margin: 0; } diff --git a/src/popup.ts b/src/popup.ts index 7025b286..d13af4a0 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -429,7 +429,7 @@ async function runThePopup(messageListener?: MessageListener): Promise { const uuidButton = document.createElement("img"); uuidButton.id = "sponsorTimesCopyUUIDButtonContainer" + UUID; - uuidButton.className = "uuidButton"; + uuidButton.className = "voteButton"; uuidButton.src = chrome.extension.getURL("icons/clipboard.svg"); uuidButton.addEventListener("click", () => navigator.clipboard.writeText(UUID));