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

Re-opening tabs on Windows #18

Closed HeyItsJono closed 1 year ago

HeyItsJono commented 1 year ago

I just wanted to flag that it's possible to repurpose the generated tabs-reopen.sh script for use on Windows without WSL. The only prerequisite is that the user has access to curl via the Windows commandline, this can be installed quite easily with Scoop, which is sort of like a package manager for Windows.

With curl installed, the steps to convert tabs-reopen.sh to work on Windows are as follows:

  1. Rename tabs-reopen.sh to tabs-reopen.cmd
  2. Open tabs.reopen.cmd in Notepad
  3. Go to Edit -> Replace (or alternatively press Ctrl+H to bring it up)
  4. Replace # with :: and click Replace All (converts bash comments to batch comments)
  5. Replace % with %% and click Replace All (batch files require all % to be escaped with another %)
  6. Replace ' with " and click Replace All (all URLs must be double-quoted to work with curl, and double-quotes also escape other batch characters)
  7. Save then run tabs-reopen.cmd with Chrome open on your phone and connected via USB (may need to re-forward with adb -d forward tcp:9222 localabstract:chrome_devtools_remote first).

If there's an error within the URL (e.g. something isn't escaped properly), it'll manifest as opening an about:blank page. For this purpose you may find it useful to redirect all output from tabs-reopen to a logfile so you can Ctrl+F through and ensure this hasn't happened. This can be done with tabs-reopen.cmd > reopen.log 2>&1 from the commandline.

If you want each page to load a bit before opening the next tab so that you get the titles displayed in the open tabs view, then you can put a sleep command between each curl line. I'm using powershell -nop -c "& {sleep 5}" to wait 5secs between each tab open.

Thanks to this and your tool I managed to get my cripplingly large tab collection back on my new phone (>1100 tabs lmao help).

machinateur commented 1 year ago

Thanks for the description of how to achive this. I didn't really bother with making a Powershell compatible script, when I made this tool.

As this description should be helpful to most others, who use the script on windows, I will link to it in the readme.

I know the struggle large amounts of tabs can be, yet I haven't tried pulling >300 tabs. Good to know it can handle more than 1k just fine, and I'm happy the tool could be of use to you.

Best regards machinateur