mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-13 02:14:23 +01:00
Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into chapters
This commit is contained in:
commit
0fb2d8df79
4 changed files with 23 additions and 4 deletions
|
@ -86,7 +86,7 @@
|
||||||
<sub class="sponsorStartHint grey-text">__MSG_popupHint__</sub>
|
<sub class="sponsorStartHint grey-text">__MSG_popupHint__</sub>
|
||||||
<div align="center" style="margin: 8px 0;">
|
<div align="center" style="margin: 8px 0;">
|
||||||
<button id="sponsorStart" class="sbMediumButton" style="margin-right: 8px">__MSG_sponsorStart__</button>
|
<button id="sponsorStart" class="sbMediumButton" style="margin-right: 8px">__MSG_sponsorStart__</button>
|
||||||
<button id="submitTimes" class="sbMediumButton" style="display: none; margin: 0 !important;">__MSG_submitTimesButton__</button>
|
<button id="submitTimes" class="sbMediumButton" style="display: none;">__MSG_submitTimesButton__</button>
|
||||||
</div>
|
</div>
|
||||||
<span id="submissionHint" style="display: none;">__MSG_submissionEditHint__</span>
|
<span id="submissionHint" style="display: none;">__MSG_submissionEditHint__</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -228,6 +228,9 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
|
||||||
case "closePopup":
|
case "closePopup":
|
||||||
closeInfoMenu();
|
closeInfoMenu();
|
||||||
break;
|
break;
|
||||||
|
case "copyToClipboard":
|
||||||
|
navigator.clipboard.writeText(request.text);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,12 @@ interface HideSegmentMessage {
|
||||||
UUID: SegmentUUID;
|
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 {
|
export interface IsInfoFoundMessageResponse {
|
||||||
found: boolean;
|
found: boolean;
|
||||||
|
|
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.optionsButton.addEventListener("click", openOptions);
|
||||||
PageElements.helpButton.addEventListener("click", openHelp);
|
PageElements.helpButton.addEventListener("click", openHelp);
|
||||||
PageElements.refreshSegmentsButton.addEventListener("click", refreshSegments);
|
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
|
//show proper disable skipping button
|
||||||
const disableSkipping = Config.config.disableSkipping;
|
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.src = chrome.runtime.getURL("icons/clipboard.svg");
|
||||||
uuidButton.title = chrome.i18n.getMessage("copySegmentID");
|
uuidButton.title = chrome.i18n.getMessage("copySegmentID");
|
||||||
uuidButton.addEventListener("click", () => {
|
uuidButton.addEventListener("click", () => {
|
||||||
navigator.clipboard.writeText(UUID);
|
copyToClipboard(UUID);
|
||||||
const stopAnimation = AnimationUtils.applyLoadingAnimation(uuidButton, 0.3);
|
const stopAnimation = AnimationUtils.applyLoadingAnimation(uuidButton, 0.3);
|
||||||
stopAnimation();
|
stopAnimation();
|
||||||
});
|
});
|
||||||
|
@ -938,6 +938,17 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
|
||||||
hiddenButton.style.display = "none";
|
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
|
* Converts time in minutes to 2d 5h 25.1
|
||||||
* If less than 1 hour, just returns minutes
|
* If less than 1 hour, just returns minutes
|
||||||
|
|
Loading…
Reference in a new issue