From a128babde044f87278c7394ec17cce7e49f7db7d Mon Sep 17 00:00:00 2001 From: robot Date: Wed, 12 Aug 2026 11:11:06 +0000 Subject: [PATCH] fix: run deep probe and scraper in MAIN world for access to page globals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The root cause of repeated 'does not detect any videos' failures was that m3u8DeepProbeFn and scrapeFn were injected via chrome.scripting.executeScript in the isolated world (default). From the isolated world: - window.__goon_plugin_data (set by main-world interceptors) — NOT visible - window.Hls / Hls.cast (page's hls.js) — NOT visible - Player globals (PHPlayer, flowplayer, etc.) — NOT visible - Config globals (__NEXT_DATA__, appData, etc.) — NOT visible Only DOM properties like video._goon_hls_manifest cross the boundary, making the detection pipeline mostly blind on real HLS sites. Fix: set world: 'MAIN' on both executeScript calls so all 6 deep probe strategies and all 5 scrape priorities actually work. Chrome MV3 supports this since Chrome 108; our build targets chrome110. --- src/viewer/index.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/viewer/index.js b/src/viewer/index.js index 6ff493f..3b2b4ae 100644 --- a/src/viewer/index.js +++ b/src/viewer/index.js @@ -323,13 +323,21 @@ function filterValidTabs(tabs) { /** * Probe all frames in a tab for HLS manifests. + * Runs in the MAIN world so strategies that depend on page globals work: + * - window.__goon_plugin_data.manifests (set by main-world interceptors) + * - window.Hls / Hls.cast (page's hls.js global) + * - player globals (PHPlayer, flowplayer, etc.) + * - config globals (__NEXT_DATA__, appData, etc.) + * + * The default isolated world cannot see these — only DOM properties like + * video._goon_hls_manifest cross the boundary. * @param {number} tabId * @returns {Promise} array of { url, player } or empty on error */ async function probeHlsManifests(tabId) { try { const results = await chrome.scripting.executeScript({ - target: { tabId, allFrames: true }, + target: { tabId, allFrames: true, world: 'MAIN' }, func: m3u8DeepProbeFn, }); return results.flatMap(r => r.result || []); @@ -384,6 +392,13 @@ async function queryContentScript(tabId) { * Scrape video elements from ALL frames in a tab. * On sites like Pornhub, the video player lives inside an iframe — main-frame-only * scraping sees zero