minimax-start
This commit is contained in:
1 parent
fc889c46a8
commit
5522dc5d1d
2 files changed
+16
-49
No files matched your search
@@ -465,7 +465,14 @@ async def run_browser_task(task_id: str, task: str, max_steps: int, model: str):
|
||||
raise RuntimeError(f"Failed to start Chrome at {internal_cdp_url}")
|
||||
|
||||
# Обновляем cdp_url для Browser
|
||||
# Если Chrome уже был запущен - используем external port (через socat)
|
||||
# Если Chrome был запущен нами - используем internal port
|
||||
if chrome_already_running:
|
||||
cdp_url = f"http://127.0.0.1:{REMOTE_DEBUGGING_PORT}"
|
||||
logger.info(f"[{task_id}] Using existing Chrome on external port {REMOTE_DEBUGGING_PORT}")
|
||||
else:
|
||||
cdp_url = internal_cdp_url
|
||||
logger.info(f"[{task_id}] Using new Chrome on internal port {CHROME_INTERNAL_PORT}")
|
||||
|
||||
# Инжектируем stealth-скрипты через CDP для дополнительной защиты
|
||||
try:
|
||||
|
||||
@@ -565,61 +565,21 @@
|
||||
// -------------------------------------------------------------------------
|
||||
try {
|
||||
const OriginalAudioContext = window.AudioContext || window.webkitAudioContext;
|
||||
if (OriginalAudioContext) {
|
||||
if (OriginalAudioContext && OriginalAudioContext.prototype && OriginalAudioContext.prototype.resume) {
|
||||
const originalResume = OriginalAudioContext.prototype.resume;
|
||||
const originalConstructor = OriginalAudioContext;
|
||||
|
||||
// Патчим конструктор чтобы автоматически resume
|
||||
window.AudioContext = function(...args) {
|
||||
const ctx = new originalConstructor(...args);
|
||||
// Автоматически resume если suspended
|
||||
if (ctx.state === 'suspended') {
|
||||
try { ctx.resume(); } catch(e) {}
|
||||
}
|
||||
return ctx;
|
||||
};
|
||||
window.AudioContext.prototype = originalConstructor.prototype;
|
||||
|
||||
if (window.webkitAudioContext) {
|
||||
window.webkitAudioContext = window.AudioContext;
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// 27. Скрываем факт использования расширений от content scripts detection
|
||||
// -------------------------------------------------------------------------
|
||||
// Патчим prototype resume
|
||||
OriginalAudioContext.prototype.resume = function() {
|
||||
try {
|
||||
// Некоторые антифроды проверяют chrome.runtime.id — если он есть, значит расширение
|
||||
// Мы уже определили chrome.runtime выше, но убедимся что id = undefined
|
||||
if (window.chrome && window.chrome.runtime) {
|
||||
Object.defineProperty(window.chrome.runtime, 'id', {
|
||||
get: () => undefined,
|
||||
configurable: true,
|
||||
});
|
||||
if (this.state === 'suspended') {
|
||||
return originalResume.call(this).catch(function() {});
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// 28. Скрываем sourceURL в стеке вызовов (anti-extension detection)
|
||||
// -------------------------------------------------------------------------
|
||||
try {
|
||||
const originalError = Error;
|
||||
const originalPrepareStackTrace = Error.prepareStackTrace;
|
||||
|
||||
Error.prepareStackTrace = function(error, stack) {
|
||||
// Фильтруем фреймы, содержащие chrome-extension://
|
||||
const filteredStack = stack.filter(frame => {
|
||||
const fileName = frame.getFileName();
|
||||
return !fileName || !fileName.startsWith('chrome-extension://');
|
||||
});
|
||||
|
||||
if (originalPrepareStackTrace) {
|
||||
return originalPrepareStackTrace(error, filteredStack);
|
||||
return Promise.resolve();
|
||||
} catch(e) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return filteredStack.map(frame => ` at ${frame}`).join('\n');
|
||||
};
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user