DEV Community

When you never close tabs on your mobile Chrome browser

Marcin Piczkowski on March 07, 2019

Whenever I browse on my mobile I often open an interesting pages in Chrome and leave it for later. Usually the later never comes so I ended up with...
Collapse
 
nowellmorrisla profile image
Nowell Morris

Also, a simple tr helps and removes "

curl http://localhost:9222/json/list | jq .[].url | tr -d '"' > mobile.tabs.txt

Collapse
 
aletedini profile image
Alete - ฿ 📈 • Edited

For those of you who have more than one instance of chrome running on your Android and ./adb forward tcp:9222 localabstract:chrome_devtools_remote shows you the wrong one, you may need to find the process of the other instance like this:
First I disabled the undesired chrome app (the one of my work profile, in my case), then,
adb shell "cat /proc/net/unix" (I wasn't able to grep that, because it's binary or something like that, I had to copy the output into a text editor and find "chrome_devtools_remote") in order to find the instance that was named: localabstract:chrome_devtools_remote_31723 in my case.
then:
./adb forward tcp:9222 localabstract:chrome_devtools_remote_31723 worked like a charm.

Thanks for this awesome trick!

Collapse
 
piczmar_0 profile image
Marcin Piczkowski

Awsome! Thanks for the tip, I will update the post with it.

Collapse
 
christophocles profile image
christophocles

THANK YOU!! I have wanted to clean this up for a long time, but as you are well aware, when one ends up in this situation, there are no easy options to clean it up. In my case, it got so bad that I could not even open the tab navigation anymore because it would cause Chrome to freeze and eventually crash. I could use the browser just fine (with some delay to initially open the browser), it was just difficult to switch tabs. I could only swipe left or right on the address bar to move to the adjacent tab, being careful not to swipe down because this would open the tab browser and crash. I had no idea how many tabs were open, and I also had no way to close tabs (!) because this can only be done from within the tab browser (or the Chrome Remote API, as I just learned today). As it turns out, I had about 7700 tabs open! Now the URLs are safely stored in an Excel sheet where I can sort/organize/bookmark/etc.

I am actually kind of amazed how well Chrome for Android was able to cope with this situation even as it got so ridiculously out of control. I was afraid one day the tab set would get completely corrupted and everything would be wiped out. This never happened.

In contrast, my secondary (work) phone is an iPhone 7 and it was in a similar situation but far less severe (maybe 200 tabs open). When Chrome crashed there, upon re-opening Chrome after the crash, it displayed a message for about 3 seconds that said "Chrome had a problem. Restore tabs?". If you did not click that restore button within those 3 seconds, the tabs were unrecoverably lost. I'm sure that even if I wanted to, I would not have been able to do a trick like this on the iPhone to back up my tabs. It was a completely hopeless situation, and that experience reinforces my preference to never voluntarily use an Apple product.

Next on the todo list is to adjust my habits so I don't end up in this situation again. This was an incredibly helpful first step on the road to recovery :)

Collapse
 
zapdash profile image
ZapDash

Yeah, once my accidentally vertical swipes turned into minutes of relaunching Chrome I started using Incognito tabs and bookmarking religiously. But I thought 732 tabs was a lot, and here you and the topic creator are pushing the multiple THOUSANDS! Color me impressed. And grateful to have found this guide!

Funnily enough, the much despised grid view Chrome pushed out actually helped me close more tabs in the past few months, since I could group them and then have subtabs with an accessible X button. And viewing the clustered groups actually worked better and didn't crash the app (as often).

But I concur, better browsing habits are a must for us digital hoarders.

Collapse
 
pierre profile image
Pierre-Henry Soria ✨

Thanks for this great step-by-step tutorial Marcin! I had sometimes about 70~90 tabs opened and, yes indeed, this can definitely be useful for cleaning them up (if you are sure you will read those URLs later). I now try to save interesting URLs to Pocket and read them offline when I have time, but still your trick can be helpful when we are in this kind of situation (especially with ~2500 opened tabs!).

Collapse
 
piczmar_0 profile image
Marcin Piczkowski

Glad that I could help. I'm curious why Chrome developers excluded the "Bookmark All Tabs" feature from mobile version, it would be useful so much.

Collapse
 
dkodr profile image
Dariusz Kuśnierek • Edited

Thanks a lot! This really helped me :-) I just made a small modification:

To parse the JSON and save it to a Markdown file (with titles and urls):

curl http://localhost:9222/json/list | jq -r ".[] | \"[\" + .title + \"](\" + .url + \")\"" > mobile.tabs.md
Enter fullscreen mode Exit fullscreen mode
Collapse
 
kangarooo profile image
kangarooo • Edited

How to make it URL clickable with a href and title to html file so i can import or click them?
what is wrong here?
curl localhost:9222/json/list | jq -r ".[] | \"(<a href="" + .url + \")">[\" + .title + \"]\"" > mobile.tabs.html

Collapse
 
benhadad profile image
benhadad

As a dev I understand the go-to method of writing code to solve a problem. The only issue here is that Chrome has a built-in way to do the same thing. This way does have 1 drawback, and that is it will open all the tabs on your computer first before you can bookmark them.

  1. Open a new chrome window (ctrl-N if you are in chrome)
  2. Go to history (ctrl-h)
  3. Select Tabs from other devices
  4. Find your other device
  5. Click on the action button (three vertical dots) and select open tabs
  6. Allow tabs to start to open, then select bookmark all open tabs (ctrl-Shift-D).

No code option.

Collapse
 
christophocles profile image
christophocles

This only works with recently-accessed tabs. It will not actually get ALL of the tabs that are currently open on the device, only maybe the last 50. So this "no code" option is not adequate. There is NO built-in way to do this properly; dev tools are the only way, and this is still true 1.5 years after you wrote this comment.

Collapse
 
piczmar_0 profile image
Marcin Piczkowski

Thanks. This is a good option too as long as you have your mobile Chrome tabs synchronized with Google account. Also, not sure how Chrome desktop browser would handle over 2000 open tabs.

Collapse
 
kangarooo profile image
kangarooo

Theres only 5 tabs. I have million open. You didnt help.

Collapse
 
sdkb profile image
sdkb

I'm glad there's some way to do this, but it's insane that it has to be this hard. It's a common issue — why can't the Chrome developers add an option for it?

Collapse
 
piczmar_0 profile image
Marcin Piczkowski

I'd like to know it as well.

Collapse
 
zapdash profile image
ZapDash

As someone who has never been adventurous enough to use Linux I still lament the shift away from user control and customizable options that the smartphone revolution has brought us. I swear there are about a dozen features in each major app that exist as total headscratchers or have been ignored (or worse, removed) over the years.

Collapse
 
imikari profile image
Will Wang

Marcin, THANK YOU!! This is so handy and solve my issue :)
Besides, I found that I have to add quotation marks for jq to make it work, FYI !

curl http://localhost:9222/json/list | jq '.[].url'
Enter fullscreen mode Exit fullscreen mode
Collapse
 
jewelwildmoon profile image
Jewel Wildmoon

Would this work on a phone that wouldn't turn on? I'm currently getting an error "Your phone couldn't start normally. Some configuration data may be corrupt" so I'm trying to access all the tabs and groups I had open on Chrome. I believe I already had Developer's Mode on before this happened but I don't know if it was turned off when the phone updated to Android 11.
Phone is a Samsung A20 in case that's relevant.

Collapse
 
piczmar_0 profile image
Marcin Piczkowski

I have no idea, but maybe if you manage to boot in safe mode.

Collapse
 
jewelwildmoon profile image
Jewel Wildmoon

Yeah I got it to boot into Safe Mode today through the "Erase App Data" option for the error, but it ended up losing all the tabs.

Collapse
 
ranchercz profile image
ranchercz

It's best! but I have two spaces in my xiaomi phone and if I debugging first space all were done, but if I'm in second space, desktop chrome writes me error - webpage is not available and something like server is busy...in this second space I like to debugging because I have approximately 20000 tabs opened.. and what I have to do? Maybe I haven't enought buffer? Help!!

Collapse
 
piczmar_0 profile image
Marcin Piczkowski

Have you tried the trick with disabling one application (one space)? I've just added some more screens to the description.

Collapse
 
ranchercz profile image
ranchercz

Thanks so much

Collapse
 
kangarooo profile image
kangarooo • Edited

So when i got mobile-tabs.json
superuser.com/a/1469296/64599
then i in excel removed other json collums.
Then in convertcsv.com/html-links-to-csv.htm
made step4 custom {f1}{br} and button click
Then exporting
Importing as bookmarks in chrome.
But easyer would be if this could be helped to fix dev.to/kangarooo/comment/1m776

Collapse
 
andrizmitnick profile image
andrizmitnick

somehow i always get :(

parse error: Invalid numeric literal at line 3, column 11
Enter fullscreen mode Exit fullscreen mode
Collapse
 
piczmar_0 profile image
Marcin Piczkowski

Can you check in browser on PC when you mapped port using adb command from the post: localhost:9222/json/list ?
Looks like you did not get the JSON from this address.

Collapse
 
andrizmitnick profile image
andrizmitnick

Hey, thanks for the reply.
it looks like my issue was related to powershell. i need to add Select Content -Expand Content which ended up like this

curl 'http://localhost:9222/json/list' | Select Content -Expand Content | jq .[].url > mobile.tabs.txt
Thread Thread
 
kangarooo profile image
kangarooo

platform-tools>curl 'localhost:9222/json/list' | Select Content -Expand Content | jq.exe .[].url > mobile.tabs.txt
'Select' is not recognized as an internal or external command,
operable program or batch file.

Collapse
 
petruskiendys profile image
Petrus Kiendys

Dzieki Marcin!
Just what I needed to move my open tabs from my phone to the desktop!

Collapse
 
piczmar_0 profile image
Marcin Piczkowski

You welcome :)

Collapse
 
zapdash profile image
ZapDash

I put off clearing my tabs for the last five years. I only had 732 open, but that is because, like others said, trying to look at them crashed Chrome. So I would use Incognito mode to avoid dealing with that.

Thank you so much for having these instructions up! My phone (Galaxy S7) finally bit the dust, and I can only have it powered on for minutes at a time. I never got around to backups, so I've been frantically copying all I can while the short windows of up time (which last longer when the phone is colder, go figure) permit me to do so.

I'm sorry to say that despite having a CS degree, I have zero skill with cmd anymore, and your instructions, while surely obvious to somebody with an ounce of awareness, took me about 5 hours to implement. (It didn't help that I misunderstood your instructions regarding bash and installed Ubuntu on my Windows in a shell, ugh.)

But once I learned how to use the command line all over again, I was able to pull that json list up just long enough to copy it!

I hope more people find this page, and more importantly I hope the Chrome devs get a clue and allow us to bookmark all our mobile tabs in a future update. Doubtful, as a day's worth of googling plus years of prior attempts have proven, but I know on PC I do the bookmark and move on thing far more often. Or so I say as I have 2 Chrome accounts open with 100 combined tabs, lol. Most of my bookmark folders are some variant of "Open September 1 2021" ha ha. (That's another feature Chrome on mobile needs, the ability to bookmark something multiple times so it can be in several folders at once!)

Again, thanks a ton for this guide and providing the only realistic solution to the tab hoarder's dilemma. Now to figure out how to regex my json list into an importable bookmarks file. Wish me and my rusty skills good luck!

Collapse
 
666alice999 profile image
Alice Morrison • Edited

Hello. This is what I was looking for. Thanks. But I have Chrome installed on my Android phone and Brave browser (?id=com.brave.browser) which is also based on Chrome. I applied your instructions step by step but it exported Brave browser's tabs. not Chrome's. How can I export chrome tabs?

Collapse
 
piczmar_0 profile image
Marcin Piczkowski

Hmmm.. Not sure what is happening. Can you also try these steps: developers.google.com/web/tools/ch...

Or you could try force shutting down Brave and see if that halped.

Collapse
 
poopooracoocoo profile image
Poopooracoocoo

By the way, there's an issue on the Chromium issue tracker bugs.chromium.org/p/chromium/issue... 😊

Collapse
 
piczmar_0 profile image
Marcin Piczkowski

Cool, assigned to sb. on 13 March. Looking forward tot have it.

Collapse
 
poopooracoocoo profile image
Poopooracoocoo

Any ideas on where I can share the issue?

des... is more likely to implement it with more stars! :) btw sb hasn't been on Chromium Bugs in over a year. They probably stopped working there.

Collapse
 
etacarinae profile image
Christopher Dobson • Edited

edit 1: disregard, it still works!
edit 2: here was the bugtracker ticket I was thinking of bugs.chromium.org/p/chromium/issue...
Is this still possible? Running adb shell "cat /proc/net/unix" shows no output with localabstract:chrome_devtools_remote anymore. From memory, I believe someone brought this up on the Chromium bugtracker and this has been deprecated post v100 versions of Chrome but I can't find it on the tracker.

Collapse
 
ferret profile image
barpbrap

I have no idea how to do this. where do i even need to type these commands? I am on windows 10

Collapse
 
shaglock profile image
Ilya Shaplyko

Thank you for this article, very useful.
Also I found jq map({title, url}) much better to fit my purposes :)

Collapse
 
kangarooo profile image
kangarooo

platform-tools>curl localhost:9222/json/list | jq map({title, url}) > 12.html
% Total % Received % Xferd Average Speed Tjq: error: syntax error, unexpected $end (Windows cmd shell quoting issues?) at , line 1:
map({title,
ijq: 1 compile error
me Time Time Current
Dload Upload Total Spent Left Speed
40 244k 40 99k 0 0 99k 0 0:00:02 --:--:-- 0:00:02 278k
curl: (23) Failed writing body (0 != 16384)

Collapse
 
peeyu5h profile image
Peeyush Singh

Thanks! Pretty useful. :D

Collapse
 
crossbowg profile image
CrossbowG • Edited

Thank you Marcin, using your method modified to work on a Windows PC was able to get the result.
Only Will Wang's syntax below worked for me to get the list at the end :-)
curl localhost:9222/json/list | jq '.[].url' > mobiletabs.txt
Found I had 4887 tabs open!

Collapse
 
okazakikirito profile image
okazakikirito

Hi thanks man this helped lot

Collapse
 
kangarooo profile image
kangarooo

C:\Users\User\platform-tools>adb forward tcp:9222 localabstract:chrome_devtools_remote
It give back info
9222

Localhost still not working localhost:9222/
Android 7.0

Collapse
 
roronoajohnny profile image
Johnny Bone

Where can I see how many tabs are opened on my android device? I want to check it before I try this method.

Collapse
 
zapdash profile image
ZapDash

chrome.google.com/sync

At the bottom should be a section tallying the stored (but inaccessible via any reasonable means) tabs.

"Open tabs
Tabs that are currently open in Chrome on one of your devices."

Collapse
 
qrueyuihejksadhkhd profile image
qrueyuihejksadhkhd

Will this tip works with Opera (on Android)?

What modification of commands needs?

Collapse
 
b3k4 profile image
bakanisan

How does one "install" JQ? I downloaded it, ran it but nothing happens. Do I need to add it to PATH? Sorry for asking, I just have no experience with these thing.