bash 如何通过终端关闭 Chrome 浏览器选项卡?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20441793/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to close a chrome browser tab via terminal?
提问by luoluo
Currently I am writing a script that invokes a new instance of the chrome
browser.
目前我正在编写一个调用chrome
浏览器新实例的脚本。
I know how to call chrome to open a *.html
document in a new tab.
我知道如何调用 chrome*.html
在新选项卡中打开文档。
google-chrome *.html
Chrome will open a new tab to show that file.
Chrome 将打开一个新选项卡以显示该文件。
How can I close the tab in terminal without closing other tabs or closing the browser window?
如何在不关闭其他选项卡或关闭浏览器窗口的情况下关闭终端中的选项卡?
回答by Liam
only linux answer:
只有 linux 答案:
Perhaps wmctrl could be of some assistance. You could use the -c option that closes a window gracefully:
也许 wmctrl 可以提供一些帮助。您可以使用 -c 选项优雅地关闭窗口:
wmctrl -c "tab title"
The string chrome is matched against the window titles. Note that the window might not close if some message pops-up (e.g. when you have multiple tabs open).
字符串 chrome 与窗口标题匹配。请注意,如果弹出某些消息(例如,当您打开多个选项卡时),该窗口可能不会关闭。
回答by M3D
You can look into chrome remote debugging:
您可以查看 chrome 远程调试:
chromium --remote-debugging-port=9222
and connect to it with some kind of client ( https://github.com/cyrus-and/chrome-remote-interfaceseems good). The debug protocol is used for a number of applications, but with some work you can achieve the kind of functionality you want. Here are some docs for you to check out: https://chromedevtools.github.io/devtools-protocol/tot/Page
并使用某种客户端连接到它(https://github.com/cyrus-and/chrome-remote-interface似乎不错)。调试协议用于许多应用程序,但通过一些工作,您可以实现所需的功能类型。这里有一些文档供您查看:https: //chromedevtools.github.io/devtools-protocol/tot/Page
Or perhaps chromix-too, which is based on an extension, daemon and client architecture.
或者 chromix-too,它基于扩展、守护进程和客户端架构。
https://github.com/smblott-github/chromix-too
https://github.com/smblott-github/chromix-too
This seems to be much easier to use, and might be exactly what you want, though the extension is a bit inconvenient, and there seems to be demand for more capabilities to be supported.
这似乎更容易使用,并且可能正是您想要的,尽管扩展有点不方便,并且似乎需要支持更多功能。