release: v1.0.50 playwright stealth gemini
All checks were successful
技能自动化发布 / release (push) Successful in 34s
All checks were successful
技能自动化发布 / release (push) Successful in 34s
This commit is contained in:
@@ -168,6 +168,13 @@ def _run_login_browser_session(
|
||||
if verbose_ui:
|
||||
print(f"正在为账号 [{target['name']}] 打开 {browser_name} …")
|
||||
print(f"访问地址:{url}")
|
||||
if platform == "gemini":
|
||||
print(
|
||||
"Gemini / Google 登录:若提示「浏览器不安全」或「无法登录」,请关闭本窗口后,"
|
||||
"用普通 Chrome 启动参数 --user-data-dir= 指向下面 profile 目录,在普通浏览器里完成"
|
||||
" Google 登录后完全退出 Chrome,再执行本 login;详见 llm-manager Gemini 引擎说明。"
|
||||
)
|
||||
print(f" (本账号 profile 目录){profile_dir}")
|
||||
print(
|
||||
"请在窗口内完成登录。系统根据页面是否仍出现「登录」等未登录控件判断;"
|
||||
"成功后自动关闭窗口并写入状态(无需手动关浏览器)。"
|
||||
|
||||
@@ -16,6 +16,12 @@ _scripts_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
if _scripts_dir not in sys.path:
|
||||
sys.path.insert(0, _scripts_dir)
|
||||
|
||||
from util.playwright_stealth import (
|
||||
STEALTH_INIT_SCRIPT,
|
||||
persistent_context_launch_parts,
|
||||
stealth_enabled,
|
||||
)
|
||||
|
||||
|
||||
def _is_context_closed_error(ex: BaseException) -> bool:
|
||||
s = str(ex).lower()
|
||||
@@ -224,13 +230,19 @@ def _run_login_child(c: dict) -> None:
|
||||
|
||||
with sync_playwright() as p:
|
||||
try:
|
||||
ctx = p.chromium.launch_persistent_context(
|
||||
args, ignore_automation = persistent_context_launch_parts()
|
||||
lc_kw = dict(
|
||||
user_data_dir=profile_dir,
|
||||
headless=False,
|
||||
channel=c["channel"],
|
||||
no_viewport=True,
|
||||
args=["--start-maximized"],
|
||||
args=args,
|
||||
)
|
||||
if ignore_automation is not None:
|
||||
lc_kw["ignore_default_args"] = ignore_automation
|
||||
ctx = p.chromium.launch_persistent_context(**lc_kw)
|
||||
if stealth_enabled():
|
||||
ctx.add_init_script(STEALTH_INIT_SCRIPT)
|
||||
except Exception as e:
|
||||
if _is_context_closed_error(e):
|
||||
end_reason = "user_closed"
|
||||
|
||||
@@ -4,18 +4,30 @@ import sys
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
from util.playwright_stealth import (
|
||||
STEALTH_INIT_SCRIPT,
|
||||
persistent_context_launch_parts,
|
||||
stealth_enabled,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
with open(sys.argv[1], encoding="utf-8") as f:
|
||||
c = json.load(f)
|
||||
with sync_playwright() as p:
|
||||
ctx = p.chromium.launch_persistent_context(
|
||||
args, ignore_automation = persistent_context_launch_parts()
|
||||
lc_kw = dict(
|
||||
user_data_dir=c["profile_dir"],
|
||||
headless=False,
|
||||
channel=c["channel"],
|
||||
no_viewport=True,
|
||||
args=["--start-maximized"],
|
||||
args=args,
|
||||
)
|
||||
if ignore_automation is not None:
|
||||
lc_kw["ignore_default_args"] = ignore_automation
|
||||
ctx = p.chromium.launch_persistent_context(**lc_kw)
|
||||
if stealth_enabled():
|
||||
ctx.add_init_script(STEALTH_INIT_SCRIPT)
|
||||
try:
|
||||
page = ctx.pages[0] if ctx.pages else ctx.new_page()
|
||||
page.goto(c["url"], wait_until="domcontentloaded", timeout=60000)
|
||||
|
||||
Reference in New Issue
Block a user