diff --git a/public/popup.html b/public/popup.html
index 104badf2..6a47da8a 100644
--- a/public/popup.html
+++ b/public/popup.html
@@ -86,7 +86,7 @@
-
+
__MSG_submissionEditHint__
diff --git a/src/content.ts b/src/content.ts
index 356049fd..b96479b7 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -228,6 +228,9 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
case "closePopup":
closeInfoMenu();
break;
+ case "copyToClipboard":
+ navigator.clipboard.writeText(request.text);
+ break;
}
}
diff --git a/src/messageTypes.ts b/src/messageTypes.ts
index 6c108f2d..3d3575cb 100644
--- a/src/messageTypes.ts
+++ b/src/messageTypes.ts
@@ -47,7 +47,12 @@ interface HideSegmentMessage {
UUID: SegmentUUID;
}
-export type Message = BaseMessage & (DefaultMessage | BoolValueMessage | IsInfoFoundMessage | SkipMessage | SubmitVoteMessage | HideSegmentMessage);
+interface CopyToClipboardMessage {
+ message: "copyToClipboard";
+ text: string;
+}
+
+export type Message = BaseMessage & (DefaultMessage | BoolValueMessage | IsInfoFoundMessage | SkipMessage | SubmitVoteMessage | HideSegmentMessage | CopyToClipboardMessage);
export interface IsInfoFoundMessageResponse {
found: boolean;
diff --git a/src/popup.ts b/src/popup.ts
index 2986d9d7..48a724d5 100644
--- a/src/popup.ts
+++ b/src/popup.ts
@@ -188,7 +188,7 @@ async function runThePopup(messageListener?: MessageListener): Promise {
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 {
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 {
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