From 90cd402a126bb7a2c04385d4119a005452e17927 Mon Sep 17 00:00:00 2001 From: ramen <1205925392@qq.com> Date: Sun, 20 Oct 2024 08:51:18 +0800 Subject: [PATCH 1/5] =?UTF-8?q?chromium=E8=BF=90=E8=A1=8C=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=BAheadless=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/dynamicwechat/__init__.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/plugins/dynamicwechat/__init__.py b/plugins/dynamicwechat/__init__.py index bf8e0de..7fb076c 100644 --- a/plugins/dynamicwechat/__init__.py +++ b/plugins/dynamicwechat/__init__.py @@ -18,7 +18,7 @@ from app.helper.cookiecloud import CookieCloudHelper from app.log import logger from app.plugins import _PluginBase from app.plugins.dynamicwechat.update_help import PyCookieCloud -from app.schemas.types import EventType, NotificationType +from app.schemas.types import EventType class DynamicWeChat(_PluginBase): @@ -29,7 +29,7 @@ class DynamicWeChat(_PluginBase): # 插件图标 plugin_icon = "Wecom_A.png" # 插件版本 - plugin_version = "1.1.4" + plugin_version = "1.1.5" # 插件作者 plugin_author = "RamenRa" # 作者主页 @@ -199,7 +199,7 @@ class DynamicWeChat(_PluginBase): for url in retry_urls: ip_address = self.get_ip_from_url(url) if ip_address != "获取IP失败" and ip_address: - logger.info(f"IP获取成功: {url}:{ip_address}") + logger.info(f"IP获取成功: {url}: {ip_address}") break # 如果所有 URL 请求失败 @@ -447,7 +447,7 @@ class DynamicWeChat(_PluginBase): def refresh_cookie(self): # 保活 try: with sync_playwright() as p: - browser = p.chromium.launch(headless=False, args=['--lang=zh-CN']) + browser = p.chromium.launch(headless=True, args=['--lang=zh-CN']) context = browser.new_context() cookie = self.get_cookie() if cookie: @@ -493,7 +493,7 @@ class DynamicWeChat(_PluginBase): confirm_button.click() # 点击确认 time.sleep(3) # 等待处理 # 等待登录成功的元素出现 - success_element = page.wait_for_selector('#check_corp_info', timeout=10000) + success_element = page.wait_for_selector('#check_corp_info', timeout=5000) if success_element: logger.info("验证码登录成功!") return True @@ -503,7 +503,7 @@ class DynamicWeChat(_PluginBase): except Exception as e: logger.debug(str(e)) # try: # 没有登录成功,也没有短信验证码。 查找二维码是否还存在 - if self.find_qrc(page) and not task != 'refresh_cookie': # 延长任务找到的二维码不会被发送,所以不算用户没有扫码 + if self.find_qrc(page) and not task == 'refresh_cookie': # 延长任务找到的二维码不会被发送,所以不算用户没有扫码 logger.error(f"用户没有扫描二维码") return False @@ -513,15 +513,16 @@ class DynamicWeChat(_PluginBase): buttons = [ # ("//span[@class='frame_nav_item_title' and text()='应用管理']", "应用管理"), # ("//div[@class='app_index_item_title ' and contains(text(), 'MoviePilot')]", "MoviePilot"), - ("//div[contains(@class, 'js_show_ipConfig_dialog')]//a[contains(@class, '_mod_card_operationLink') and text()='配置']", - "配置") + ( + "//div[contains(@class, 'js_show_ipConfig_dialog')]//a[contains(@class, '_mod_card_operationLink') and text()='配置']", + "配置") ] if self._input_id_list: id_list = self._input_id_list.split(",") app_urls = [f"{bash_url}{app_id.strip()}" for app_id in id_list] for app_url in app_urls: page.goto(app_url) # 打开应用详情页 - # logger.info(f"已打开{app_url}") + app_id = app_url.split("/")[-1] time.sleep(2) # 依次点击每个按钮 for xpath, name in buttons: @@ -535,7 +536,7 @@ class DynamicWeChat(_PluginBase): input_area = page.locator('textarea.js_ipConfig_textarea') confirm = page.locator('.js_ipConfig_confirmBtn') input_area.fill(self._current_ip_address) # 填充 IP 地址 - logger.info("已输入公网IP:" + self._current_ip_address) + logger.info(f"应用ID: {app_id} 已输入公网IP:" + self._current_ip_address) confirm.click() # 点击确认按钮 time.sleep(3) # 等待处理 self._ip_changed = True @@ -964,11 +965,3 @@ class DynamicWeChat(_PluginBase): except Exception as e: logger.error(str(e)) - - - - - - - - From a9c96d40eaf2fd10380af56e68a7921a7365a129 Mon Sep 17 00:00:00 2001 From: ramen <1205925392@qq.com> Date: Sun, 20 Oct 2024 08:58:42 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=B01.1.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 66f7bb3..3e0169a 100644 --- a/package.json +++ b/package.json @@ -858,7 +858,7 @@ "name": "修改企业微信可信IP", "description": "优先使用cookie,当填写两个第三方token时手机微信可以更新cookie。验证码以?结尾发给企业微信应用。如:110301?", "labels": "消息通知", - "version": "1.1.4", + "version": "1.1.5", "icon": "Wecom_A.png", "author": "RamenRa", "level": 2, From 6e175d2986104d6f7329c18fb7e11f9b1ed6ade3 Mon Sep 17 00:00:00 2001 From: RamenRa <53000259+RamenRa@users.noreply.github.com> Date: Sun, 20 Oct 2024 09:00:12 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=B01.1.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 66f7bb3..3e0169a 100644 --- a/package.json +++ b/package.json @@ -858,7 +858,7 @@ "name": "修改企业微信可信IP", "description": "优先使用cookie,当填写两个第三方token时手机微信可以更新cookie。验证码以?结尾发给企业微信应用。如:110301?", "labels": "消息通知", - "version": "1.1.4", + "version": "1.1.5", "icon": "Wecom_A.png", "author": "RamenRa", "level": 2, From 0465e27179d9790a400420643a686dbd113ad381 Mon Sep 17 00:00:00 2001 From: ramen <1205925392@qq.com> Date: Sun, 20 Oct 2024 09:01:10 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=B01.1.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 3e0169a..db664bf 100644 --- a/package.json +++ b/package.json @@ -863,6 +863,7 @@ "author": "RamenRa", "level": 2, "history": { + "v1.1.5": "chromium运行设置为headless模式", "v1.1.4": "放弃self.post_message()的消息推送,还原成send_pushplus_message()", "v1.1.3": "关闭cookie输入框,延长cookie任务成功时不输出日志,使用设定中的CookieCloud设置" } From 514091d359cdbf5b49debc5ad818502abf81e6c1 Mon Sep 17 00:00:00 2001 From: ramen <1205925392@qq.com> Date: Sun, 20 Oct 2024 09:03:42 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=B01.1.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index db664bf..cc8d895 100644 --- a/package.json +++ b/package.json @@ -863,7 +863,7 @@ "author": "RamenRa", "level": 2, "history": { - "v1.1.5": "chromium运行设置为headless模式", + "v1.1.5": "将chromium运行设置为headless模式", "v1.1.4": "放弃self.post_message()的消息推送,还原成send_pushplus_message()", "v1.1.3": "关闭cookie输入框,延长cookie任务成功时不输出日志,使用设定中的CookieCloud设置" }