machinateur / tab-transfer

A tool to transfer Google Chrome tabs from your Android or iPhone to your computer.
MIT License
100 stars 10 forks source link

How to proceed after fetching tabs from Android device #22

Closed cmonty14 closed 1 year ago

cmonty14 commented 1 year ago

Hello,

I have successfully fetched data from my (old) Android device and tool created files

However I don't understand how to proceed.

According to your documentation I can use the re-open script tabs-reopen.sh to open all tabs on my (new) Android device connected to PC. When I execute bash tabs-reopen.sh I get a connection error because there's no forward active.

Can I open the tabs on my PC in ungoogled-chromium?

Or can I open the tabs on my new Android device with Bromit browser? This browser allows me to generate bookmarks of any open tab.

THX

cmonty14 commented 1 year ago

Hello! It sounds like you've successfully fetched some data from your old Android device and created some files, including tabs-gist.md, tabs.json, and tabs-reopen.sh. It's great that you're trying to use the re-open script to open all tabs on your new Android device, but you're encountering a connection error. To answer your questions, yes, you can open the tabs on your PC in ungoogled-chromium File Download and you can also open the tabs on your new Android device with the Bromit browser, which allows you to generate bookmarks of any open tab. Hope this helps!

How should I open the tabs? I can open file tabs.json in ungoogled-chromium, but this just displays its content.

Please provide step-by-step instructions.

And why do you share this link?

nealmcb commented 1 year ago

On Ubuntu Linux, with the very cool common jq and pandoc tools, I use these steps to name the file by todays date, sort the pages into order, save them as markdown, convert that to HTML, and open a list of all the pages in order:

Filename based on todays date
save=$HOME/list-$(date -I).json

# Note this step often fails, in which case I navigate to that URL and download the contents manuall....
wget -O $save http://localhost:9222/json/list

# to sort:
jq 'sort_by(.id | tonumber)' $save | jq -r '.[] | "- [\(.title)](\(.url))"' > $save.md

# to open as html
pandoc -s -o $save.html $save.md
google-chrome $save.html
machinateur commented 1 year ago

I think this topic will require better documentation.

It's indeed not possible to use the tabs-reopen.sh script without first leaving the forwarding open.

Some information on the background/history: The idea and implementation through the reopen script came from a time, when the copy-tabs command would leave the adb connection open. But even in that case, the use would have required exporting the tabs from the new device first.

But enough of the technical stuff.


For steps on how to reopen the tabs on your new android device, please refer to #18. It's related to the windows use-case, where .sh is not supported out of the box. The required command is this:

adb -d forward tcp:9222 localabstract:chrome_devtools_remote

But don't forget to close the connection, once you are done:

adb -d forward --remove tcp:9222

As I understand your question, @cmonty14, you'd like to reopen the tabs on your computer. That's currently not possible without modifying the script or using a JSON transformer, like for example jq, to generate a script for that purpose from the raw JSON data.

To programmatically open a URL or file on the desktop, change the commands in the tabs-reopen.sh script form this:

curl 'http://localhost:9222/json/new?<THE-URL>'

To something similar to the following, depending on the browser you'd like to use:

chrome '<THE-URL>'

The change should be possible with some search-and-replace acrobatics.


And regarding the Bromite use-case: I think it should be possible, as long as the browser does support the basic devtools protocol, as part of the USB debugging features. And while I'm not familiar with that browser in particular, it describes itself as a fork of the mobile Chrome, which does support it. As it seems to be focused on privacy, there could be some action required to enable it, which should be stated on their website or docs.

I hope that answers your questions. Feel free to come back here, if some things are still unclear.

machinateur commented 1 year ago

I've updated the README section on this.

The generated script will now include commands to manage the adb debug connection (to a new device).


Another remark on the Bromite use-case: It most likely requires a different socket to be addressed for the adb connection (--socket parameter).