mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 21:17:20 +03:00
Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into chapters
This commit is contained in:
15
src/popup.ts
15
src/popup.ts
@@ -188,7 +188,7 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
||||
PageElements.optionsButton.addEventListener("click", openOptions);
|
||||
PageElements.helpButton.addEventListener("click", openHelp);
|
||||
PageElements.refreshSegmentsButton.addEventListener("click", refreshSegments);
|
||||
PageElements.sbPopupIconCopyUserID.addEventListener("click", async () => navigator.clipboard.writeText(await utils.getHash(Config.config.userID)));
|
||||
PageElements.sbPopupIconCopyUserID.addEventListener("click", async () => copyToClipboard(await utils.getHash(Config.config.userID)));
|
||||
|
||||
//show proper disable skipping button
|
||||
const disableSkipping = Config.config.disableSkipping;
|
||||
@@ -542,7 +542,7 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
||||
uuidButton.src = chrome.runtime.getURL("icons/clipboard.svg");
|
||||
uuidButton.title = chrome.i18n.getMessage("copySegmentID");
|
||||
uuidButton.addEventListener("click", () => {
|
||||
navigator.clipboard.writeText(UUID);
|
||||
copyToClipboard(UUID);
|
||||
const stopAnimation = AnimationUtils.applyLoadingAnimation(uuidButton, 0.3);
|
||||
stopAnimation();
|
||||
});
|
||||
@@ -938,6 +938,17 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
||||
hiddenButton.style.display = "none";
|
||||
}
|
||||
|
||||
function copyToClipboard(text: string): void {
|
||||
if (window === window.top) {
|
||||
window.navigator.clipboard.writeText(text);
|
||||
} else {
|
||||
sendTabMessage({
|
||||
message: "copyToClipboard",
|
||||
text
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts time in minutes to 2d 5h 25.1
|
||||
* If less than 1 hour, just returns minutes
|
||||
|
||||
Reference in New Issue
Block a user