39

Chrome's sync feature isn't picking up all of the tabs open on my Android phone.

Are the tabs stored in a file somewhere that I can access?

My intention is to export the list of tabs so that I could run a factory reset on the device.

Running Android 4.3

  • I wish there was an add-on for that purpose. – neverMind9 Dec 21 '18 at 3:09
34

You can use the Remote Devices feature in the Chrome debugger to connect to Chrome on the device and access the tabs. Just expand the list of tabs visible to get the full list and then highlight & copy everything shown (including the URLs) to the clipboard: https://developers.google.com/web/tools/chrome-devtools/remote-debugging/

I just managed to export ~400 tabs this way.

  • 1
    wanted to mention that the chrome debugger list will shorten the urls if they are too long, so instead of copy-pasting, you can get the url's directly using the method in Louis Maddox's answer – woojoo666 Sep 18 '18 at 3:29
  • @woojoo666: It looks like things in Chrome have changed and now Louis's answer also truncates the end of many URLs. Looks like any URL over 100 characters -- which in my case it about 50% of all my open tabs -- will be missing its ending. – peterflynn Sep 25 '18 at 7:05
  • @peterflynn still works for me. Just exported a url that was 432 characters long. Just to make sure, you're opening the dev tools in a pop-out window, going to the "remote devices" pane, then using ctrl-shift-J to open a second dev-tools window, and then using the script provided here, correct? – woojoo666 Sep 26 '18 at 9:30
  • What is the minimum required Android version to do this? – neverMind9 Dec 22 '18 at 13:01
20

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 SettingsDeveloper 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 SettingsAbout Device
  • 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 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

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)
  • Chrome changed, 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('.devtools-link')._href})) will work now – dlamotte Jun 13 '18 at 3:15
  • Note that using this technique, any URL over 100 characters long will have its ending cut off. – peterflynn Sep 25 '18 at 7:09
  • @peterflynn still works for me. I just exported a url that was 432 chars. Make sure you're using the script that diamotte provided – woojoo666 Sep 26 '18 at 21:56
  • Can this be used to get a previous tabs state? – Melab Oct 3 '18 at 7:02
  • What is the minimum required Android version? – neverMind9 Dec 22 '18 at 13:01
13

I came across this solution when I was looking to recover tabs that had been permanently closed after my browser crashed one day. In order to access the information you require, your device needs to be rooted so you can run a file explorer app with access to the root files installed on your device. ES File Explorer or Root Explorer are my recommendations.

  1. Navigate to the root folder of your device (the protected system partition) → select DATA → select com.android.chrome.

  2. There are several places where you may find information about your current tabs.

    1. The first folder to check is app_tabs, then 0. In this folder there should be a file called tab_state which contains a list of all your current tabs.
    2. There are also other files in this folder called tab3, tab4, etc. that contain info about current tabs.
    3. IMO, you need a special "text editor / sql editor" to read the content of some of these files as the encoding is different.
  3. Next place to look is /data/com.android.chrome/app_chrome/Default/. In this folder you'll find a file called History. Depending on your situation, you may find a good list of recent site visits here.

  4. Finally, navigate to the Sync Data folder. In here, you will find the information that's being synced to Google (and this should include all the tabs you currently have synced on other devices).

    • In the file SyncData.sqlite3, you'll also find a history of all your Google searches (which I sometimes find to be an interesting read).
    • You'll need an Sqlite3 data browser program on your PC in order to read this file. The app should be able to export to a highly usable .CSV or .XLS file that you can open in MS Excel.

This could be helpful to someone I assume.

4

If you have the Android command line tools installed on a development machine, and have enabled USB debugging on your Android device, then you can do the following:

  • Execute adb forward tcp:9222 localabstract:chrome_devtools_remote on your development machine.

    Chrome instances expose access to a debugging protocol via a unix domain socket with the abstract address "chrome_devtools_remote" – the above adb command forwards requests to port 9222, on to that socket. (You can get a list of all the unix domain sockets on the Android device by typing adb shell cat /proc/net/unix.)

  • The debugging protocol exposes JSON data about the chrome instance over HTTP. A JSON file listing the open tabs can be got by executing wget -O tabs.json http://localhost:9222/json/list.

    (Other endpoints of the API can be found at https://github.com/buggerjs/bugger-daemon/blob/master/README.md#api.)

See here for more details on enabling USB debugging, and here for an overview of how it works.

2

This workaround will give you a text file with individual URLs for all tabs you have open in Chrome for Android.

  1. As mentioned in this answer by Michael, you have to grab the file that contains the current tabs. Using a root explorer on the device, grab this file and move it to your choice of folder in windows: /data/data/com.android.chrome/app_tabs/0/tab_state

  2. Install GNU Tools for Windows

  3. Sometimes there's a weird arrow-character in the file that screws up the script. If you run the script and it truncates part of the file, look at the last character and it'll probably be that weird arrow character. Find/replace it in the original file. Once it's gone, the script will run fine. It looks like this: -->

  4. Go to command line prompt (go to "Run" or Win+R, and type cmd) and navigate to the folder which contains sed.exe (wherever you installed it in step 2.)

  5. You'll probably want to move the original file (tab_state) to the same folder containing sed.exe. It'll make everything easier. Once you've done that, run this script:

    sed -i "s/.\{6\}http/\r\n\r\nhttp/g" tab_state
    
  6. This will modify the file with all of the URLs formatted correctly. Open the file as a text file and then copy and paste the contents into a Word document or some other location. For some reason, if you don't copy and paste the data out, when you save the file it erases all of the line breaks/carriage returns. If things screw up, just start over and do it again. When it's all said and done, you should have a file that contains a list of links to all the tabs you had open before.

1

Michael identified the tab_state file, it remains to decode it. The following script worked for me (in kitkat KSH_VERSION='@(#)MIRBSD KSH R43 2013/02/19' or xenial BASH_VERSION='4.3.46(1)-release' on a tab_state file from Chrome 49.0.2623.105), it prints out the last URL first, between the URLs it removes any unprintable byte and all following bytes, and more if needed so at least 2 bytes are removed. Following each URL it prints a space, then the removed contiguous printable bytes if any, then a comma, then the number of other bytes removed (&said bytes within parentheses). To print the URLs only use the commented echo command instead.

tab_state=/data/data/com.android.chrome/app_tabs/0/tab_state
[[ $KSH_VERSION ]]||shopt -s extglob       #set if bash
(cat $tab_state;echo)|while read -r r;do b=
   while
      q=${r%http?(s)://*}          #chip off a URL
      [[ $q = *url= ]]&&{
         p=${r%http?(s)://*url=*}  #special case URL within URL
         [[ $p = "$r" ]]||q=$p;}
      h=${r:${#q}}                 #the chip
      h=${h%%[! -~]*}              #remove unprintable&following bytes
      u=$((${#r}-${#q}-${#h}))     #no of said bytes removed
      p=$((u<b?b-u:0))             #no of more bytes to remove
      [[ $h ]];do
         echo "${h::${#h}-p} ${h:${#h}-p},$u(${r:${#r}-u})"
      #  echo "${h::${#h}-p}"
         r=$q b=2
   done
done
1

You need to be root or Chrome to read /data/data/com.android.chrome/app_tabs/0/tab_state0

You can use this dirtycow exploit on vulnerable devices to become Chrome and get tab_state0 from an attached device:

make root
adb shell
run-as com.android.chrome
chmod 711 /data/data/com.android.chrome/app_tabs/0
chmod 644 /data/data/com.android.chrome/app_tabs/0/tab_state0
exit
cp /data/data/com.android.chrome/app_tabs/0/tab_state0 /sdcard/
exit
adb pull /sdcard/tab_state0

Once you have access to tab_state0, extract the URLs:

LC_ALL=C grep -a -o 'http[[:print:]]*' tab_state0
0

In windows, to extract tab_state0 from a TitaniumBackup archive (that works over rooted phones)

7z e TitaniumB\com.android.chrome-20180918-001302.tar.gz -so | 7z e -si -ttar tab_state0 -r

To get the list of tabs from tab_state0

sed -b "s/^.\{20\}//g" tab_state0 | sed -b "s/.\{6\}http/\nhttp/g" > my-tabs.md

On windows I would install https://scoop.sh/ then scoop install busybox 7zip

-1

This is not the answer you're looking for, but:

  1. Create dummy account on Google

  2. Login on Android device and enable syncing

  3. Login on desktop and enable syncing

  4. Install Session Buddy extension on desktop

  5. Export tabs

  • 5
    As the OP stated in his question: Chrome's sync feature isn't picking up all of the tabs open on my Android phone. – how should that help? Your suggested solution exports after the incomplete sync, so it won't export all tabs as requested by the OP. – Izzy Oct 24 '14 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.