Script you can run on your computer in the background, to export your Safari history every hour and upload it to a D1 database. The goal with this is to be able to have browsing history as additional context for your AI.
Other related repos I made:
- https://github.com/janwilmake/ip-camera-to-s3-macos
- https://github.com/janwilmake/yaptabber
- https://github.com/janwilmake/efficient-recorder
-
Ensure you have
nodeandbun -
install pm2 with
npm install -g pm2To look at the data locally: -
Go to privacy & security -> Full Disk Access, and allow full disk access to
Terminal -
Run
sudo bun run export-history-formatted.ts(or other scripts); (need administrator access to export browsing history)
To run this in the background and upload it every hour:
- run
npm run createto create your db and copy the result inwrangler.toml - run
npx wrangler deployand put the domain in.envasDOMAIN=Your Domain Here - run
pm2 start job.js --name "safari-history-tracker" - run
pm2 saveto ensure it reruns at restart - run
pm2 logs safari-history-trackerto view if it worked
- Try scraping every page stored and augment the with its markdown and raw text (e.g. with https://github.com/janwilmake/llmtext.reader)
- Analyse each url+text into a summary of a sentence (with your desired LLM API)
- Create an endpoint that shows domains visited most, average page duration, total duration, duration percentage, etc.
- Create an endpoint to get context between two times (?from=...&until=...) that allows us to gather the context for cros-processing this with another context (e.g. audio or video)
- Analyse URL structure of domains visited (uncover patterns) using LLMs
- Run workerd locally (https://github.com/cloudflare/workerd) so this doesn't need to be hosted on cloudflare (Full privacy)