Tabs are out of order
garyking opened this issue · comments
At the moment, tabs in CloudyTabs appear in the order in the CloudTabs.db
database, but this is not the correct order that actually appears in Safari on iPhone, and in Safari on Mac.
Safari on Mac is able to display the tabs in the correct order, so the information exists somewhere, likely in the position
column, which is unfortunately in binary format.
It looks like the position
column is just zlib-compressed JSON. Here are a couple existing sorting implementations:
icloudtabs2md.js:
https://gist.github.com/mems/2c96233708c6b5b44ed1a26cb0ec5a0e/61235619601467603270a6ba0048804436437ddd#file-icloudtabs2md-js-L46
Thanks. I hadn't come around to this until just now. I wrote my own solution in Ruby, so I'll post it here as another option:
require 'json'
require 'sqlite3'
require 'zlib'
db_file_path = '/CloudTabs.db'
db = SQLite3::Database.new(db_file_path)
query = 'SELECT title, position FROM cloud_tabs'
rows = []
db.execute query do |row|
title = row[0]
position = row[1]
parsed = JSON.parse(Zlib::Inflate.inflate(position))
rows.push(
title: title,
position: parsed['sortValues'][0]['sortValue']
)
end
puts rows.sort_by { |row| row[:position] }
Hey everyone, I've just released Version 2.0 which persists the position of tabs across devices – thanks so much for all the information here!
Please let me know if you have feedback on the feature 😄