Created
May 22, 2023 10:15
-
-
Save ruaanvds/127279bc626250c38e6ab41e4f24e571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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