home / skills / samhvw8 / dotfiles / browser-history

browser-history skill

/dot_ccp/hub/skills/browser-history

This skill helps you locate and analyze your browser history across Firefox and Chromium to recall visited pages and browsing patterns.

npx playbooks add skill samhvw8/dotfiles --skill browser-history

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
4.5 KB
---
name: browser-history
description: Search local browser history. Use when user asks about visited pages, forgotten URLs, or time spent on sites.
---

# Browser History Search

Search the user's browser history to find visited pages, analyze browsing patterns, and retrieve forgotten information.

## When to use

- User asks about pages they visited ("what github repos did I look at last week?")
- User wants to find a forgotten page ("find that article about LLMs I read")
- User asks about browsing habits ("how much time did I spend on Twitter?")
- User wants browsing statistics ("show my most visited sites")

## Requirements

- `sqlite3` CLI

## Setup

First, detect available browsers by running:

```bash
./find-browser.sh
```

- Output: PATH,TYPE,BROWSER,LAST_MODIFIED
- **TYPE**: `firefox` or `chromium` (determines SQL syntax)
- Use the first result (most recently used browser) by default
- If multiple browsers were used recently (within last 24h), ask the user which one to search

## Querying the database

Use `?immutable=1` in the SQLite URI to read the database even when the browser is open:

```bash
sqlite3 "file:///path/to/history.db?immutable=1" "SELECT ..."
```

### Firefox databases (places.sqlite)

**Search by keyword:**
```sql
SELECT
    title,
    url,
    datetime(last_visit_date/1000000, 'unixepoch', 'localtime') as visit_date
FROM moz_places
WHERE url LIKE '%keyword%' OR title LIKE '%keyword%'
ORDER BY last_visit_date DESC
LIMIT 50;
```

**Search by date range:**
```sql
SELECT url, title, datetime(last_visit_date/1000000, 'unixepoch', 'localtime') as visit_date
FROM moz_places
WHERE last_visit_date > strftime('%s', '2025-01-01') * 1000000
  AND last_visit_date < strftime('%s', '2025-01-31') * 1000000
ORDER BY last_visit_date DESC;
```

**Time spent analysis** (uses moz_places_metadata):
```sql
SELECT
    SUM(m.total_view_time) / 1000 / 60 as minutes,
    COUNT(*) as sessions
FROM moz_places_metadata m
JOIN moz_places p ON m.place_id = p.id
WHERE p.url LIKE '%example.com%'
  AND m.created_at > strftime('%s', '2025-01-01') * 1000;
```

Note: `created_at` is in milliseconds, `last_visit_date` is in microseconds.

**Most visited sites:**
```sql
SELECT
    SUBSTR(url, INSTR(url, '://') + 3,
           INSTR(SUBSTR(url, INSTR(url, '://') + 3), '/') - 1) as domain,
    SUM(visit_count) as visits
FROM moz_places
WHERE url LIKE 'http%'
GROUP BY domain
ORDER BY visits DESC
LIMIT 20;
```

### Chromium databases (History)

**Important:** Chromium timestamps are microseconds since January 1, 1601 (Windows epoch).

Conversion: `(timestamp/1000000) - 11644473600` gives Unix epoch.

**Search by keyword:**
```sql
SELECT
    title,
    url,
    datetime((last_visit_time/1000000)-11644473600, 'unixepoch', 'localtime') as visit_date
FROM urls
WHERE url LIKE '%keyword%' OR title LIKE '%keyword%'
ORDER BY last_visit_time DESC
LIMIT 50;
```

**Search by date range:**
```sql
SELECT url, title, datetime((last_visit_time/1000000)-11644473600, 'unixepoch', 'localtime') as visit_date
FROM urls
WHERE last_visit_time > (strftime('%s', '2025-01-01') + 11644473600) * 1000000
  AND last_visit_time < (strftime('%s', '2025-01-31') + 11644473600) * 1000000
ORDER BY last_visit_time DESC;
```

## Database schema

### Firefox (moz_places)

| Column | Description |
|--------|-------------|
| `url` | Full URL |
| `title` | Page title |
| `last_visit_date` | Microseconds since Unix epoch |
| `visit_count` | Number of visits |
| `frecency` | Frequency + recency score |

### Firefox (moz_places_metadata)

| Column | Description |
|--------|-------------|
| `place_id` | Foreign key to moz_places |
| `total_view_time` | Milliseconds spent on page |
| `created_at` | Milliseconds since Unix epoch |
| `scrolling_time` | Time spent scrolling |
| `key_presses` | Number of key presses |

### Chromium (urls)

| Column | Description |
|--------|-------------|
| `url` | Full URL |
| `title` | Page title |
| `last_visit_time` | Microseconds since 1601-01-01 |
| `visit_count` | Number of visits |

## Output guidelines

- Present results in a readable format, grouped by domain when relevant
- For time analysis, show hours/minutes, not raw milliseconds
- When showing history, include the date and a clickable link
- If results are numerous, summarize by domain or time period
- You might include a small ASCII/Unicode chart (daily breakdown, histogram) if relevant

See @README.md for output examples.

Overview

This skill searches a local browser history database to find visited pages, recover forgotten URLs, and analyze browsing patterns like time spent and most visited sites. It supports both Firefox and Chromium history formats and uses SQLite queries to extract results. Results are formatted for readability, grouped by domain when helpful, and include visit dates and durations.

How this skill works

The skill discovers available browser history files and selects the most recently used browser by default (or asks if multiple were active recently). It opens the appropriate SQLite file in read-only/immutable mode and runs tailored SQL queries for Firefox or Chromium schemas. Queries return titles, URLs, visit timestamps, visit counts, and metadata used to compute time spent and summaries.

When to use it

  • You need to find a page you visited but can’t recall the URL or title.
  • You want a list of pages visited during a specific date or date range.
  • You want browsing statistics: most visited domains, session counts, or time spent on sites.
  • You want to reconstruct activity (e.g., what GitHub repos you viewed last week).
  • You need a domain-level summary or daily histogram of visits for analysis.

Best practices

  • Run the browser-detection step first and default to the most recently used history file.
  • Open the SQLite file with an immutable/read-only URI to avoid conflicts while the browser is open.
  • Use keyword and date-range filters to limit result size and improve relevance.
  • Aggregate by domain for long result sets; show top N domains with totals and an option to expand.
  • Convert raw timestamps and millisecond durations to human-friendly formats (local date, hours/minutes).

Example use cases

  • Find the article about large language models you read two weeks ago by searching titles and URLs.
  • Show the top 20 most visited domains for last month and total time spent per domain.
  • List every visited GitHub URL during a specified week to recreate what repositories were inspected.
  • Compute total minutes spent on a given site using the browser’s metadata tables (when available).
  • Produce a daily histogram of visit counts for the past 30 days to spot browsing spikes.

FAQ

Which browsers are supported?

Firefox (places.sqlite) and Chromium-based browsers (History) are supported; the skill adapts SQL to each schema.

Can I query history while the browser is open?

Yes — open the SQLite database using an immutable/read-only URI to avoid locking issues and read safely.

How are timestamps converted?

Firefox timestamps are microseconds since Unix epoch; Chromium timestamps are microseconds since 1601-01-01 and are converted to Unix epoch before formatting.