Skip to content

Instantly share code, notes, and snippets.

@jsumners
Created October 24, 2021 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsumners/2d016f0248693f90e4c277198d1fb15b to your computer and use it in GitHub Desktop.
Save jsumners/2d016f0248693f90e4c277198d1fb15b to your computer and use it in GitHub Desktop.
Retrieve tabs from iOS Safari backup
  1. From a backup of the iOS device, extract /HomeDomain/Library/Safari/BrowserState.db to a local directory
  2. Place index.js and package.json in the same local directory
  3. npm install
  4. node index.js > lost_ios_safari_tabs.csv

Note: these instructions were created using an iMazing backup.

'use strict'
const path = require('path')
const Database = require('better-sqlite3')
const {Parser: CsvParser} = require('json2csv')
const db = new Database(path.resolve(path.join(__dirname, 'BrowserState.db')))
const statement = db.prepare('select * from tabs')
const rows = statement.all()
db.close()
const csvParser = new CsvParser({
fields: ['browser_window_id', 'order_index', 'title', 'url', 'private_browsing']
})
const csv = csvParser.parse(rows)
console.log(csv)
{
"dependencies": {
"better-sqlite3": "^7.4.3",
"json2csv": "^5.0.6"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment