This commit is contained in:
parent
99d6953f03
commit
0729e4f84d
3 changed files with 40 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name M3U8 HLS Downloader
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 1.0.2
|
||||
// @version 1.0.3
|
||||
// @description 자동 탐지 및 다운로드: HLS(m3u8) 스트림의 세그먼트를 병합하여 단일 파일로 저장
|
||||
// @author kyush
|
||||
// @match *://*/*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "m3u8-monkey-script",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
38
src/index.ts
38
src/index.ts
|
|
@ -295,6 +295,44 @@ function onStreamDetected(url: string, headers?: Record<string, string>): void {
|
|||
if (typeof window === 'undefined') {
|
||||
log.error('Script not running in a browser context');
|
||||
} else {
|
||||
// Anti-devtool: debugger statement 차단
|
||||
(function() {
|
||||
const originalEval = window.eval;
|
||||
window.eval = function(code: any) {
|
||||
if (typeof code === 'string' && code.includes('debugger')) {
|
||||
code = code.replace(/debugger/g, '');
|
||||
}
|
||||
return originalEval.call(window, code);
|
||||
};
|
||||
|
||||
const originalFunction = Function;
|
||||
(window as any).Function = function(...args: any[]) {
|
||||
if (args.length > 0) {
|
||||
args[args.length - 1] = args[args.length - 1].replace(/debugger/g, '');
|
||||
}
|
||||
return originalFunction.apply(this, args);
|
||||
};
|
||||
(window as any).Function.prototype = originalFunction.prototype;
|
||||
|
||||
const originalLocation = Object.getOwnPropertyDescriptor(window, 'location');
|
||||
let locationBlocked = false;
|
||||
|
||||
window.addEventListener('beforeunload', function(e) {
|
||||
if (locationBlocked) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(window, 'location', {
|
||||
get: function() { return originalLocation!.get!.call(window); },
|
||||
set: function(val) {
|
||||
locationBlocked = true;
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
})();
|
||||
|
||||
log.info(`Script initialized in ${isTopFrame() ? 'top frame' : `iframe (${location.origin})`}`);
|
||||
|
||||
interceptXHR(onStreamDetected);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue