-
Notifications
You must be signed in to change notification settings - Fork 7
Export all Chrome tabs on Android
MarkusPaul1989 edited this page Apr 12, 2020
·
16 revisions
- screenshots here
- also provided as an answer on StackExchange here
-
[2019-01-23] - Update: Thanks to Immortalin (KloudTrader) for dropping me a message telling me that this has been built upon along with a 2nd StackOverflow forum thread:
- "This can only be done manually and imported through chrome's import bookmarks in HTML API due to rate limiting."
— @immortalin- "Some URLS may have the chrome-distiller prefix. These have to be resolved manually as they are web pages that were in Reader's mode when imported as tabs. Please feel free to clean up the code, add this to the wiki or spin into a browser extension etc." source
- "This can only be done manually and imported through chrome's import bookmarks in HTML API due to rate limiting."
-
[2019-11-29] - Update: thanks to Immortalin and others (planetastro and miracle2k) for addressing further changes to this script in a GitHub issue (here), apparently Chrome withdrew support for
/deep/
, the updated script is here
-
[2019-01-23] - Update: Thanks to Immortalin (KloudTrader) for dropping me a message telling me that this has been built upon along with a 2nd StackOverflow forum thread:
- N.B.: there's a browser extension to do this on desktop (via), the Firefox version is here
- (works on a per-window basis only)
To export a list of all URLs open on Chrome for Android, firstly:
- open the
Remote devices
on Chrome devtools - set up USB debugging on your phone (under developer options, root not required)
- note that you must enable developer options, it's hidden by default to protect users
- on my phone this required tapping multiple times on the build number under 'About Device' in Settings
- once this is done, plug your USB in and allow MTP connection (probably not necessary)
- when the Chrome devtools remote device panel is open, the phone will also request to allow USB debugging
- you can opt to always trust the computer
Now the device is connected,
- open a 2nd devtools view (
Ctrl
+Shift
+J
on Windows,Ctrl
+Option
+J
on Mac) on the devtools view from which you selectedRemote 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 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.
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').attributes.href.value}))
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:
- [Degraded Planet: UN report warns of irreversible, anthropogenic species die-off, with grave consequences for humanity - The Financial Express](http://www.financialexpress.com/opinion/degraded-planet-un-report-warns-of-irreversible-anthropogenic-species-die-off-with-grave-consequences-for-humanity/1113158/lite/?__twitter_impression=true)
- [Pierre-Yves Oudeyer on Twitter: "The French #AI report by @MissionVillani in english (pdf) https://t.co/Ll3I7hkkyo @Miles_Brundage"](https://mobile.twitter.com/pyoudeyer/status/979078819498905601)
- [The Machine Learning Reproducibility Crisis – Pete Warden's blog](https://petewarden.com/2018/03/19/the-machine-learning-reproducibility-crisis/amp/?__twitter_impression=true)
- [Jennifer Doudna to advise CRISPR start-up Synthego - SynBioBeta](https://synbiobeta.com/jennifer-doudna-to-advise-crispr-start-up-synthego/)
- [How To Enable Developer Options On Galaxy S7 And Galaxy S7 Edge - RecomHub](http://recomhub.com/blog/how-to-enable-developer-options-on-galaxy-s7-and-galaxy-s7-edge/)
- [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)
...
😃
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').attributes.href.value +')\n'
} else {
console.log(tabs[i])
}
}
copy(str)
tabs = document.querySelectorAll('.subrow-box .url')
str = '';
for (i=0;i<tabs.length;i++){
console.log(tabs[i].innerHTML)
if (tabs[i].innerHTML != null){
str += tabs[i].innerHTML+'\n'
}
}
copy(str)