SmartBlock

code

Chrome and Brave extension for page-aware website time blocking with local Ollama classification

Overview

SmartBlock is a Chrome and Brave extension for time blocking mixed-use websites. Instead of treating an entire domain as distracting, it can classify the specific page being viewed with a local Ollama model and only count pages that look like entertainment.

Modes

SmartBlock supports two tracking modes:

  • Smart: classifies the current page and only counts distracting time.
  • Strict: counts all active time on the configured domain.

This makes it useful for sites like YouTube, where some pages may be productive and others are purely distracting.

Features

  • Tracks only domains explicitly added in the popup.
  • Counts one active tab per browser window while ignoring background tabs.
  • Handles multiple browser windows without double-counting duplicate active pages on the same domain.
  • Uses manual overrides and cached classifications before making a new model call.
  • Redirects over-limit domains to a block page.
  • Shows an Activity view with counted pages, ignored pages, classification sources, manual overrides, and cache clearing.

Classification Flow

For domains using Smart mode, classification happens in this order:

  1. Manual override from the Activity tab.
  2. Cached classification.
  3. Ollama classification.
  4. Fail-open fallback to productive if Ollama is unavailable or no model is selected.

SmartBlock sends Ollama the page URL, title, and a compact content snippet built from high-signal page text such as metadata, headings, and visible main content. It avoids sending full-page dumps because they are slower, noisier, and often include comments, navigation, recommendations, and other boilerplate.

Technology

  • Extension platform: Chrome/Brave extension APIs
  • Classification: local Ollama model selected by the user
  • Runtime: JavaScript service worker, popup UI, content scripts, and block page
  • Release flow: GitHub Actions validates, packages, and attaches extension zips to GitHub Releases

Repository

The extension source is organized under extension/ with separate modules for background timing, classification, rules, storage, popup UI, content extraction, and block-page behavior.