mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 14:07:13 +03:00
Merge pull request #676 from caneleex/feature/uuid-button
add uuid copy button to the popup
This commit is contained in:
1
public/icons/clipboard.svg
Normal file
1
public/icons/clipboard.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white" width="18px" height="18px"><path d="M0 0h24v24H0z" fill="none"/><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"/></svg>
|
||||||
|
After Width: | Height: | Size: 291 B |
15
src/popup.ts
15
src/popup.ts
@@ -425,9 +425,18 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||||||
downvoteButton.src = chrome.extension.getURL("icons/thumbs_down.svg");
|
downvoteButton.src = chrome.extension.getURL("icons/thumbs_down.svg");
|
||||||
downvoteButton.addEventListener("click", () => vote(0, UUID));
|
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 = "voteButton";
|
||||||
|
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(upvoteButton);
|
||||||
voteButtonsContainer.appendChild(downvoteButton);
|
voteButtonsContainer.appendChild(downvoteButton);
|
||||||
|
voteButtonsContainer.appendChild(uuidButton);
|
||||||
|
|
||||||
//add click listener to open up vote panel
|
//add click listener to open up vote panel
|
||||||
sponsorTimeButton.addEventListener("click", function() {
|
sponsorTimeButton.addEventListener("click", function() {
|
||||||
@@ -576,13 +585,13 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
|||||||
function vote(type, UUID) {
|
function vote(type, UUID) {
|
||||||
//add loading info
|
//add loading info
|
||||||
addVoteMessage(chrome.i18n.getMessage("Loading"), UUID);
|
addVoteMessage(chrome.i18n.getMessage("Loading"), UUID);
|
||||||
|
|
||||||
//send the vote message to the tab
|
//send the vote message to the tab
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
message: "submitVote",
|
message: "submitVote",
|
||||||
type: type,
|
type: type,
|
||||||
UUID: UUID
|
UUID: UUID
|
||||||
}, function(response) {
|
}, function (response) {
|
||||||
if (response != undefined) {
|
if (response != undefined) {
|
||||||
//see if it was a success or failure
|
//see if it was a success or failure
|
||||||
if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) {
|
if (response.successType == 1 || (response.successType == -1 && response.statusCode == 429)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user