- 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 Command+Option+J(MAC)
Ctrl
+Shift
+J
(WINDOWS) will just close the first devtools panel.
- 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
tabslet bookmarkList = Array.from(document.querySelectorAll('div'.widget>.vbox'))
/deep/ div.map(e /deep/=> dive.shadowRoot)
/deep/ div.map(e /deep/=> dive /deep/&& e.querySelector('.device-page-listlist'))
.vbox'find(e => e),;
let sbookmarks =>= Array.from({name: sbookmarkList.querySelectorquerySelectorAll('.device-page-title'vbox'))
.textContent,map(e url:=> s`[${e.querySelector('.device-page-url title').devtoolsinnerHTML}](${e.querySelector('x-link').hrefinnerHTML})`);
str = '';
for copy(i=0;i<tabsbookmarks.length;i++){
str += '['+tabs[i]['name']+']join('+tabs[i]['url']+''\n')\n'
}
copy(str);
[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)