reduce changes compare to old files

This commit is contained in:
katiue
2025-01-10 02:57:45 +07:00
parent 540729ec27
commit 48fa8c37e4

View File

@@ -3,33 +3,27 @@
# @Author : wenshao
# @Email : wenshaoguo1026@gmail.com
# @Project : browser-use-webui
# @FileName: merged_context.py
# @FileName: context.py
import asyncio
import base64
import json
import logging
import os
from typing import TYPE_CHECKING
from playwright.async_api import Browser as PlaywrightBrowser, Page, BrowserContext as PlaywrightContext
from browser_use.browser.browser import Browser
from browser_use.browser.context import BrowserContext, BrowserContextConfig
if TYPE_CHECKING:
from .custom_browser import CustomBrowser
logger = logging.getLogger(__name__)
class CustomBrowserContext(BrowserContext):
def __init__(
self,
browser: "Browser", # Forward declaration for CustomBrowser
browser: "Browser",
config: BrowserContextConfig = BrowserContextConfig(),
context: BrowserContext = None
context: BrowserContext = None,
):
super(CustomBrowserContext, self).__init__(browser=browser, config=config)
self.context = context # Rename to avoid confusion
self.context = context
self._page = None
@property
@@ -37,7 +31,7 @@ class CustomBrowserContext(BrowserContext):
"""Returns the underlying Playwright context implementation"""
return self.context
async def _create_context(self, browser: PlaywrightBrowser = None):
async def _create_context(self, browser: PlaywrightBrowser):
"""Creates a new browser context with anti-detection measures and loads cookies if available."""
if self.context:
return self.context