From 49662b308d11930f2b6a40a6e9954e17ea871c2d Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 4 Aug 2023 16:53:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Chrome=20=E5=BA=94=E7=94=A8=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E5=B9=B3=E5=8F=B0=E7=9A=84=E5=AE=89=E5=85=A8=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E5=8A=A8=E6=80=81=E5=8A=A0=E8=BD=BD=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/applets/chrome/app.py | 10 ++++++---- apps/terminal/applets/chrome/common.py | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/terminal/applets/chrome/app.py b/apps/terminal/applets/chrome/app.py index b19e219d1..14654386e 100644 --- a/apps/terminal/applets/chrome/app.py +++ b/apps/terminal/applets/chrome/app.py @@ -221,10 +221,6 @@ def default_chrome_driver_options(): options.add_argument('--ignore-certificate-errors-spki-list') options.add_argument('--allow-running-insecure-content') - # 加载 extensions - extension_paths = load_extensions() - for extension_path in extension_paths: - options.add_argument('--load-extension={}'.format(extension_path)) # 禁用开发者工具 options.add_argument("--disable-dev-tools") # 禁用 密码管理器弹窗 @@ -248,6 +244,12 @@ class AppletApplication(BaseApplication): self._chrome_options = default_chrome_driver_options() self._chrome_options.add_argument("--app={}".format(self.asset.address)) self._chrome_options.add_argument("--user-data-dir={}".format(self._tmp_user_dir.name)) + protocol_setting = self.platform.get_protocol_setting(self.protocol) + if protocol_setting and protocol_setting.safe_mode: + # 加载 extensions + extension_paths = load_extensions() + for extension_path in extension_paths: + self._chrome_options.add_argument('--load-extension={}'.format(extension_path)) @wrapper_progress_bar def run(self): diff --git a/apps/terminal/applets/chrome/common.py b/apps/terminal/applets/chrome/common.py index 06d23f9fd..161150a0d 100644 --- a/apps/terminal/applets/chrome/common.py +++ b/apps/terminal/applets/chrome/common.py @@ -160,6 +160,7 @@ class ProtocolSetting(DictObj): password_selector: str submit_selector: str script: list[Step] + safe_mode: bool class PlatformProtocolSetting(DictObj):