diff --git a/extension/background.js b/extension/background.js index d5ebe07..1b197bb 100644 --- a/extension/background.js +++ b/extension/background.js @@ -2504,6 +2504,14 @@ async function injectContentScript(tabId, { try { error.contentTarget = contentTarget; } catch { /* immutable browser error */ } throw error; } + // Name the frame the injection was aimed at. Without it every failure + // reads the same in the log and there is no way to tell a denied player + // frame from a document that navigated mid-injection. + addLog( + `Content injection failed in frame ${contentTarget.frameId}` + + `${contentTarget.frameUrl ? ` (${contentTarget.frameUrl})` : ''}: ${error?.message}`, + 'warn' + ); if (navigationRetries > 0 && isMediaTargetNavigationError(error)) { return injectContentScript(tabId, { requestHostAccess, diff --git a/extension/popup.js b/extension/popup.js index df1076e..5d81aa0 100644 --- a/extension/popup.js +++ b/extension/popup.js @@ -2797,10 +2797,28 @@ function refreshDebugInfo() { return; } + // A target that never finished activating has no content script to talk + // to. Reporting that as a communication failure hides the actual reason, + // which is the only thing that makes the problem fixable. + if (res.targetReady === false && elements.videoDebug) { + const reason = res.targetActivationError + || (res.targetActivationState === 'access_required' + ? `Website access required${res.pendingTargetHost ? ` for ${res.pendingTargetHost}` : ''}` + : null); + elements.videoDebug.textContent = reason + ? `${res.targetActivationState}: ${reason}` + : `${res.targetActivationState}…`; + return; + } + // Request direct state from the content script via background chrome.runtime.sendMessage({ type: 'GET_VIDEO_STATE', tabId: res.targetTabId }, (state) => { if (!state || (!state.found && state.error)) { - if (elements.videoDebug) elements.videoDebug.textContent = getMessage('DEBUG_COMM_FAIL'); + if (elements.videoDebug) { + elements.videoDebug.textContent = state?.error + ? `${getMessage('DEBUG_COMM_FAIL')} (${state.error})` + : getMessage('DEBUG_COMM_FAIL'); + } return; }