feat: Chrome 应用通过平台的安全模式动态加载扩展

pull/11211/head
Eric 1 year ago committed by Bryan
parent 7636255533
commit 49662b308d

@ -221,10 +221,6 @@ def default_chrome_driver_options():
options.add_argument('--ignore-certificate-errors-spki-list') options.add_argument('--ignore-certificate-errors-spki-list')
options.add_argument('--allow-running-insecure-content') 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") options.add_argument("--disable-dev-tools")
# 禁用 密码管理器弹窗 # 禁用 密码管理器弹窗
@ -248,6 +244,12 @@ class AppletApplication(BaseApplication):
self._chrome_options = default_chrome_driver_options() self._chrome_options = default_chrome_driver_options()
self._chrome_options.add_argument("--app={}".format(self.asset.address)) self._chrome_options.add_argument("--app={}".format(self.asset.address))
self._chrome_options.add_argument("--user-data-dir={}".format(self._tmp_user_dir.name)) 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 @wrapper_progress_bar
def run(self): def run(self):

@ -160,6 +160,7 @@ class ProtocolSetting(DictObj):
password_selector: str password_selector: str
submit_selector: str submit_selector: str
script: list[Step] script: list[Step]
safe_mode: bool
class PlatformProtocolSetting(DictObj): class PlatformProtocolSetting(DictObj):

Loading…
Cancel
Save