Skip to content

Instantly share code, notes, and snippets.

@ruaanvds
Created May 22, 2023 10:15
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 ruaanvds/127279bc626250c38e6ab41e4f24e571 to your computer and use it in GitHub Desktop.
Save ruaanvds/127279bc626250c38e6ab41e4f24e571 to your computer and use it in GitHub Desktop.
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment