如何使Chrome始终使用remote-debugging-port标志启动

时间:2018-07-27 18:02:38

标签: google-chrome chrome-remote-debugging

我知道我可以通过以下方式启动chrome,以在9222端口处打开远程调试端口-

prev

但是我要设置Chrome,以便每当由其他任何应用程序启动Chrome时,它始终在启用了远程调试选项的情况下打开。自定义个人资料可以使用吗?

我想实现这一点,因为那里有一个桌面应用程序,单击该按钮即可启动chrome。我想控制那个chrome会话。

4 个答案:

答案 0 :(得分:4)

我想出了一种解决我的问题陈述的方法。我将其发布为答案,因为它可能会帮助具有类似问题陈述的其他人。

如果您使用的是Windows,请转到注册表编辑器并搜索此命令

Computer\HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command

使用以下命令修改密钥-

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 -- "%1"

如果您想使用Chrome浏览器,请始终在隐身模式下启动Chrome时输入--incognito。

警告:请先备份注册表,然后再使用它。

答案 1 :(得分:4)

我还不能添加评论,但是David Mann的答案对于MacOS已经过时了。

非常感谢,只需要进行一点更改;将bash shebang添加到Chrome调试器脚本中。

#!/bin/bash
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222&

此Mac用户的更新位于: Enable remote debugging on Chrome by default on mac?

Nat Khun还遇到了制作.dmg以允许mac用户使用“正常”安装过程的麻烦。他的回购可以在这里找到: https://github.com/natkuhn/Chrome-debug/

一定要给他一颗星星。我做到了!

答案 2 :(得分:2)

您无需编辑注册表,只需在Chrome图标上右键单击并添加...,即可直接在程序属性中直接添加标志。

--remote-debugging-port=9222 -- "%1" 

...到目标字段的末尾。

enter image description here

答案 3 :(得分:1)

对于Mac,我做了一个简单的应用程序,它为我启动了带有--remote-debugging-port的chrome。 Mathias Bynens有一个wonderful post on how to do this(这是我的主意)。他甚至还包括一个(分叉的)script,可以为您完成大部分工作,但是基础非常简单。

  1. 在应用程序文件夹中使用以下<new app name>/Contents/MacOS结构创建目录:

    mkdir /Applications/Chrome\ Debugger.app/Contents/MacOS
    
  2. 创建脚本文件并使其可执行(其名称必须与顶级文件夹名称匹配):

    cd /Applications/Chrome\ Debugger.app/Contents/MacOS
    touch Chrome\ Debugger
    sudo chmod +x Chrome\ Debugger
    
  3. 使用您选择的编辑器编辑新文件(您的chrome路径可能不同)

    #!/usr/bin/env bash
    /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222&
    

就是这样。如果要使其更易于查找,可以添加自定义图标(复制新图标>右键单击新应用>获取信息>单击左上角的当前图标>将新图标粘贴到当前图标上),但是没有它,应用程序就可以正常工作。