mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2026-01-28 21:30:56 +03:00
Clean up segment creation code
Noteworthy changes: - Adds ability to cancel creating a segment - Makes segment creation fully the responsibility of the content script, with the popup script buttons simply doing RPC - Adds types to the Utils.wait function - Fixes segment timestamps backwards if user marks segment end earlier than the start - Makes the info menu (in-page popup) workaround clearer and easier to remove in the future.
This commit is contained in:
@@ -23,8 +23,8 @@ class Utils {
|
||||
this.backgroundScriptContainer = backgroundScriptContainer;
|
||||
}
|
||||
|
||||
// Function that can be used to wait for a condition before returning
|
||||
async wait(condition: () => HTMLElement | boolean, timeout = 5000, check = 100): Promise<HTMLElement | boolean> {
|
||||
/** Function that can be used to wait for a condition before returning. */
|
||||
async wait<T>(condition: () => T | false, timeout = 5000, check = 100): Promise<T> {
|
||||
return await new Promise((resolve, reject) => {
|
||||
setTimeout(() => reject("TIMEOUT"), timeout);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user