From bc1263c341ed6128e9b32455b5fe7a97f6d1a5ca Mon Sep 17 00:00:00 2001 From: Alec Rust Date: Sun, 21 Aug 2022 11:56:31 +0100 Subject: [PATCH 1/2] Fix popup width when embedded in page --- public/popup.css | 10 +++++++--- src/popup.ts | 10 ++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/public/popup.css b/public/popup.css index 783300ab..f314ae03 100644 --- a/public/popup.css +++ b/public/popup.css @@ -100,6 +100,10 @@ margin-bottom: 16px; } +#sponsorBlockPopupContainer iframe { + width: 100%; +} + /* * Disable popup max height when displayed in-page (content.ts) */ @@ -110,7 +114,7 @@ /* * Disable fixed popup width when displayed in-page (content.ts) */ -#sponsorBlockPopupContainer #sponsorBlockPopupBody { +#sponsorBlockPopupBody.is-embedded { width: auto; } @@ -207,7 +211,7 @@ border-radius: 50%; display: inline-block; } -/* +/* * Category name in segment */ .summaryLabel { @@ -511,7 +515,7 @@ background: var(--sb-grey-bg-color); } -/* +/* * Submissions */ #sponsorTimesContributionsContainer { diff --git a/src/popup.ts b/src/popup.ts index 6be1f330..73d33f18 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -75,6 +75,7 @@ async function runThePopup(messageListener?: MessageListener): Promise { const PageElements: PageElements = {}; [ + "sponsorBlockPopupBody", "sponsorblockPopup", "sponsorStart", // Top toggles @@ -132,7 +133,7 @@ async function runThePopup(messageListener?: MessageListener): Promise { getSegmentsFromContentScript(false); await utils.wait(() => Config.config !== null && allowPopup, 5000, 5); - document.querySelector("body").style.removeProperty("visibility"); + PageElements.sponsorBlockPopupBody.style.removeProperty("visibility"); if (!Config.configSyncListeners.includes(contentConfigUpdateListener)) { Config.configSyncListeners.push(contentConfigUpdateListener); } @@ -145,6 +146,7 @@ async function runThePopup(messageListener?: MessageListener): Promise { if (window !== window.top) { PageElements.sbCloseButton.classList.remove("hidden"); + PageElements.sponsorBlockPopupBody.classList.add("is-embedded"); } // Hide donate button if wanted (Safari, or user choice) @@ -187,7 +189,7 @@ async function runThePopup(messageListener?: MessageListener): Promise { if (window !== window.top) { document.addEventListener("keydown", (e) => { const target = e.target as HTMLElement; - if (target.tagName === "INPUT" + if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || e.key === "ArrowUp" || e.key === "ArrowDown") { @@ -255,7 +257,7 @@ async function runThePopup(messageListener?: MessageListener): Promise { } PageElements.sponsorTimesOthersTimeSavedDisplay.innerText = getFormattedHours(minutesSaved); } - + Config.config.isVip = userInfo.vip; } }); @@ -489,7 +491,7 @@ async function runThePopup(messageListener?: MessageListener): Promise { } segmentTimeFromToNode.style.margin = "5px"; - + // for inline-styling purposes const labelContainer = document.createElement("div"); labelContainer.appendChild(categoryColorCircle); From aadc1be56cd9e3be31bc638f725ead013f6a801a Mon Sep 17 00:00:00 2001 From: Michael C Date: Mon, 22 Aug 2022 20:44:23 -0400 Subject: [PATCH 2/2] catch all html in error messages --- src/utils/genericUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/genericUtils.ts b/src/utils/genericUtils.ts index 0718d788..2d912a66 100644 --- a/src/utils/genericUtils.ts +++ b/src/utils/genericUtils.ts @@ -28,7 +28,7 @@ async function wait(condition: () => T | false, timeout = 5000, check = 100): * @returns {string} errorMessage */ function getErrorMessage(statusCode: number, responseText: string): string { - const postFix = ((responseText && !responseText.includes(`cf-wrapper`)) ? "\n\n" + responseText : ""); + const postFix = ((responseText && !(responseText.includes(`cf-wrapper`) || responseText.includes(""))) ? "\n\n" + responseText : ""); // display response body for 4xx if([400, 429, 409, 0].includes(statusCode)) { return chrome.i18n.getMessage(statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + statusCode + postFix;