fix embeds not being detected correctly

- add awaiter for key element
- refresh ID with segments if videoID is invalid
This commit is contained in:
Michael C
2022-06-30 16:38:11 -04:00
parent 67b510e628
commit 75f426f456

View File

@@ -100,7 +100,10 @@ const playerButtons: Record<string, {button: HTMLButtonElement, image: HTMLImage
// Direct Links after the config is loaded // Direct Links after the config is loaded
utils.wait(() => Config.config !== null, 1000, 1).then(() => videoIDChange(getYouTubeVideoID(document))); utils.wait(() => Config.config !== null, 1000, 1).then(() => videoIDChange(getYouTubeVideoID(document)));
// wait for hover preview to appear, and refresh attachments if ever found // wait for hover preview to appear, and refresh attachments if ever found
window.addEventListener("DOMContentLoaded", () => utils.waitForElement(".ytp-inline-preview-ui").then(() => refreshVideoAttachments())); window.addEventListener("DOMContentLoaded", () => {
utils.waitForElement(".ytp-inline-preview-ui").then(() => refreshVideoAttachments())
utils.waitForElement("[data-sessionlink='feature=player-title']").then(() => videoIDChange(getYouTubeVideoID(document)))
});
addPageListeners(); addPageListeners();
addHotkeyListener(); addHotkeyListener();
@@ -206,6 +209,9 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
submitSponsorTimes(); submitSponsorTimes();
break; break;
case "refreshSegments": case "refreshSegments":
// update video on refresh if videoID invalid
if (!sponsorVideoID) videoIDChange(getYouTubeVideoID(document));
// fetch segments
sponsorsLookup(false).then(() => sendResponse({ sponsorsLookup(false).then(() => sendResponse({
found: sponsorDataFound, found: sponsorDataFound,
status: lastResponseStatus, status: lastResponseStatus,