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}")
|
raise RuntimeError(f"Failed to start Chrome at {internal_cdp_url}")
|
||||||
|
|
||||||
# Обновляем cdp_url для Browser
|
# Обновляем 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
|
cdp_url = internal_cdp_url
|
||||||
|
logger.info(f"[{task_id}] Using new Chrome on internal port {CHROME_INTERNAL_PORT}")
|
||||||
|
|
||||||
# Инжектируем stealth-скрипты через CDP для дополнительной защиты
|
# Инжектируем stealth-скрипты через CDP для дополнительной защиты
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -565,61 +565,21 @@
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
try {
|
try {
|
||||||
const OriginalAudioContext = window.AudioContext || window.webkitAudioContext;
|
const OriginalAudioContext = window.AudioContext || window.webkitAudioContext;
|
||||||
if (OriginalAudioContext) {
|
if (OriginalAudioContext && OriginalAudioContext.prototype && OriginalAudioContext.prototype.resume) {
|
||||||
const originalResume = OriginalAudioContext.prototype.resume;
|
const originalResume = OriginalAudioContext.prototype.resume;
|
||||||
const originalConstructor = OriginalAudioContext;
|
|
||||||
|
|
||||||
// Патчим конструктор чтобы автоматически resume
|
// Патчим prototype resume
|
||||||
window.AudioContext = function(...args) {
|
OriginalAudioContext.prototype.resume = function() {
|
||||||
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
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
try {
|
try {
|
||||||
// Некоторые антифроды проверяют chrome.runtime.id — если он есть, значит расширение
|
if (this.state === 'suspended') {
|
||||||
// Мы уже определили chrome.runtime выше, но убедимся что id = undefined
|
return originalResume.call(this).catch(function() {});
|
||||||
if (window.chrome && window.chrome.runtime) {
|
|
||||||
Object.defineProperty(window.chrome.runtime, 'id', {
|
|
||||||
get: () => undefined,
|
|
||||||
configurable: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
return Promise.resolve();
|
||||||
|
} catch(e) {
|
||||||
// -------------------------------------------------------------------------
|
return Promise.resolve();
|
||||||
// 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 filteredStack.map(frame => ` at ${frame}`).join('\n');
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in new issue
Block a user