iframe-fetch 으로 m3u8 탐지 안하도록 변경
All checks were successful
Build / build (push) Successful in 23s

This commit is contained in:
Kyush 2026-06-06 23:20:45 +09:00
commit 81c9cc1b8a
4 changed files with 9 additions and 4 deletions

View file

@ -1,7 +1,7 @@
// ==UserScript==
// @name M3U8 HLS Downloader
// @namespace http://tampermonkey.net/
// @version 1.0.0
// @version 1.0.2
// @description 자동 탐지 및 다운로드: HLS(m3u8) 스트림의 세그먼트를 병합하여 단일 파일로 저장
// @author kyush
// @match *://*/*

View file

@ -1,6 +1,6 @@
{
"name": "m3u8-monkey-script",
"version": "1.0.0",
"version": "1.0.2",
"description": "",
"main": "index.js",
"scripts": {

View file

@ -101,9 +101,11 @@ function processIframe(
log.info(`iframe fetch: found VTT ${url}`);
onDetected(url, headers);
}
// Skip m3u8 URLs from iframe-fetch — the iframe's own XHR intercept will detect them
// with the correct referer from the iframe context. iframe-fetch only has access to
// the top frame's origin as referer, which causes 403 errors from Cloudflare.
for (const url of m3u8) {
log.info(`iframe fetch: found M3U8 ${url}`);
onDetected(url, headers);
log.info(`iframe fetch: found M3U8 ${url}, skipping (iframe XHR intercept will handle)`);
}
} else {
log.warn(`iframe fetch: HTTP ${response.status} for ${iframeUrl}`);

View file

@ -279,6 +279,8 @@ function onStreamDetected(url: string, headers?: Record<string, string>): void {
}).catch(e => {
log.error(`onStreamDetected: pre-parse failed for ${url}: ${e}`);
});
} else if (!isTopFrame() && type === 'm3u8') {
log.info(`onStreamDetected: iframe detected ${url}, skipping parse (top frame will handle)`);
}
}
@ -301,6 +303,7 @@ if (typeof window === 'undefined') {
const headers: Record<string, string> = {};
if (referer) headers['Referer'] = referer;
if (origin) headers['Origin'] = origin;
log.info(`postMessage received: url=${e.data.url} referer=${referer} origin=${origin}`);
onStreamDetected(e.data.url as string, Object.keys(headers).length ? headers : undefined);
}
});