Just joined this StackExchange to show some appreciation for Jeremy's answer above, and also add the few lines of JS I used to export the tabs list (since copying with the cursor isn't ideal!)
As Jeremy said, select Remote devices
under More tools
on Chrome devtools ⋮
icon (top right of the panel):
- set up USB debugging on your phone (under
Settings
⇒Developer options
, root not required)- note that you must enable the
Developer options
menu, it's hidden by default to protect users - on my phone this required tapping multiple times on the build number under
Settings
⇒About Device
- note that you must enable the
- once this is done, plug your USB in and allow MTP connection
- when the Chrome devtools remote device panel is open, the phone will then request to allow USB debugging
- you can opt to always trust the computer
Now the device is connected,
- open a 2nd devtools view on the devtools view from which you selected
Remote devices
to be able to retrieve the list of tabs using JavaScript- note that you must have devtools in pop-out mode (use the vertical ellipsis symbol in the top right of the panel) to be able to get this up, otherwise
Ctrl
+J
will just close the first devtools panel.
- note that you must have devtools in pop-out mode (use the vertical ellipsis symbol in the top right of the panel) to be able to get this up, otherwise
- expand the list from the first few items to all tabs by clicking 'Show more'
- to script against the list, use the following few lines of code [entered in the console of the 2nd devtools window]
- N.B.
/deep/
is the CSS selector to enter#shadow-root
DOM elements
- N.B.
To export a list of all URLs open on Chrome for Android, I chose to just make the list into a markdown formatted text string and copy it to the clipboard
tabs = Array.from(document.querySelectorAll('div /deep/ div /deep/ div /deep/ div /deep/ div /deep/ .device-page-list .vbox'), s => ({name: s.querySelector('.device-page-title').textContent, url: s.querySelector('.device-page-url .devtools-link').href}))
str = '';
for (i=0;i<tabs.length;i++){
str += '['+tabs[i]['name']+']('+tabs[i]['url']+')\n'
}
copy(str)
You will then have a list on your clipboard looking like this:
[How can I export the list of open Chrome tabs? - Android Enthusiasts Stack Exchange](https://android.stackexchange.com/questions/56635/how-can-i-export-the-list-of-open-chrome-tabs)
[Get Started with Remote Debugging Android Devices | Tools for Web Developers | Google Developers](https://developers.google.com/web/tools/chrome-devtools/remote-debugging/)
[How To Enable USB Debugging On Your Android Phone](https://www.groovypost.com/howto/mobile/how-to-enable-usb-debugging-android-phone/)
[Configure On-Device Developer Options | Android Studio](https://developer.android.com/studio/debug/dev-options.html)
...
Update
For some reason I'm getting an error some of the time, saying it failed to get the href
attribute of a null
item (when I inspect it it's an invisible node, who knows). To step around this, use this version instead:
tabs = document.querySelectorAll('div /deep/ div /deep/ div /deep/ div /deep/ div /deep/ .device-page-list .vbox')
str = '';
for (i=0;i<tabs.length;i++){
if (tabs[i].querySelector('.device-page-url .devtools-link') != null){
str += '- ['+tabs[i].querySelector('.device-page-title').textContent + '](' + tabs[i].querySelector('.device-page-url .devtools-link').getAttribute('href') +')\n'
} else {
console.log(tabs[i])
}
}
copy(str)