Get URL of currently active chromium or chrome tab from external process

1.6k views Asked by At

How can I get the current chromium tab URL from an external process in linux programmatically?

There are many similar questions to this one, but I haven't found any with the following requirements

  • Solution should work from outside of the chrome process, i.e. not within javascript or a chrome extension.
  • Solution should not be based on autohotkey, xdotool, wmctrl or similar tools for simulating keyboard or mouse input
  • No OSX or Windows-specific solutions

In firefox, there is mozrepl, which exposes browser internals through an interactive repl over a TCP port. I am looking for something similar in chromium or chrome, even if it means installing a chrome extension.

1

There are 1 answers

0
ealfonso On

I implemented @Asesh suggestion in https://github.com/erjoalgo/chrome-current-url, it is a chrome extension that exposes the currently active tab's URL through a local http server.

pip install chromeurl
sudo chromeurl --install-manifest native

Then install the extension from the webstore

Finally, query the current chrome url:

$ curl http://localhost:19615/tabs/current/url
https://developer.chrome.com/extensions/activeTab