Open chrome-history in Script Kit

import "@johnlindquist/kit"
// Menu: Chrome History
// Description: Open a url from your history
// Author: John Lindquist
// Twitter: @johnlindquist
let historyFilePath = home(
"Library/Application Support/Google/Chrome/Default/History"
)
// ~/.kenv/tmp/chrome-history/History
let tmpHistoryPath = tmpPath("History")
// We make copy of the db each time or you run into a SQL_BUSY if Chrome is open
await copyFile(historyFilePath, tmpHistoryPath)
let sqlite3 = await npm("sqlite3")
let db = new sqlite3.Database(tmpHistoryPath)
let limit = 1000
let sql = `SELECT url, title, last_visit_time FROM urls ORDER BY last_visit_time DESC LIMIT ${limit}`
let callback = async (err, rows) => {
let url = await arg(
"Chrome History",
rows.map(({ url, title }) => {
return {
name: title,
description: url,
value: url,
}
})
)
open(url)
}
db.all(sql, callback)
db.close()