This commit is contained in:
HuangHai
2026-01-16 21:29:49 +08:00
parent 3f3eb5ee05
commit aea318ce80
9 changed files with 23 additions and 35 deletions

View File

@@ -57,13 +57,21 @@ async def check_and_close_ad(d):
if ad_type == "rabbit":
logger.info(">>> 检测到兔子广告。尝试使用图片识别关闭...")
try:
# 使用用户验证有效的图片点击方法
template_path = os.path.join(BASE_DIR, "Template", "X.jpg")
if d.image.click(template_path, timeout=3.0):
logger.info(">>> 成功通过图片识别关闭兔子广告。")
await asyncio.sleep(1.5)
template_path_1 = os.path.join(BASE_DIR, "Template", "X1.jpg")
template_path_2 = os.path.join(BASE_DIR, "Template", "X2.jpg")
clicked = False
if d.image.click(template_path_1, timeout=3.0):
logger.info(">>> 成功通过图片识别关闭兔子广告 (X1 模板)。")
clicked = True
else:
logger.warning(">>> 图片识别未找到兔子广告关闭按钮,跳过。")
logger.warning(">>> X1 模板未找到兔子广告关闭按钮,尝试 X2 模板。")
if d.image.click(template_path_2, timeout=3.0):
logger.info(">>> 成功通过图片识别关闭兔子广告 (X2 模板)。")
clicked = True
else:
logger.warning(">>> X2 模板也未找到兔子广告关闭按钮。")
if clicked:
await asyncio.sleep(1.5)
except Exception as ex:
logger.error(f">>> 图片识别关闭兔子广告异常: {ex}")