Completes the two-tier cache contract from step 9 / docs/CACHE_CONTRACT.md
on the extension side. The Python side shipped in the Python repo at
33c495a.
Host (rcjav-host.py):
- fetch_rules_info() memoizes per-script-path calls to
`rc-jav.py --print-rules-info` so handle_cache_status doesn't pay
the Python startup cost on every poll.
- _cache_freshness_fields(data, rules_info) computes the new
cache_schema / id_rules / id_rules_signature trio + their three
*_match booleans + cache_state ('fresh' / 'stale_by_rules' /
'schema_mismatch' / 'missing'). Legacy version:3 caches still on
disk report as stale_by_rules with cache_schema_match=True (we'll
migrate them at next load_cache).
- New handle_reextract_ids() action forwards to
`rc-jav.py --reextract --format json` with a 5-minute timeout.
background.js:
- New `reextract-ids` message forwards to host with a 300s timeout.
options-cache.js + options-library-issues.js:
- renderCacheContractBanner() paints a three-state banner above the
per-remote list: green ✓ fresh / amber ! stale-by-rules (with
"Re-extract IDs (fast, no rescan)" chip button) / red ✗ schema
mismatch. Includes a snippet of the cache signature for diagnostics.
- Delegated click handler in options-library-issues.js catches
.cache-reextract, sends the message, shows transient
"Re-extracting…" state, and replaces the button with a per-summary
line ("Re-extracted N IDs · X changed · Y unchanged · Z dropped").
- rules_info_error from the host surfaces as its own amber line above
the banner.
node --check passes on background.js, options-cache.js,
options-library-issues.js individually and on the concatenation of all
four script files. python -m py_compile passes on rcjav-host.py.
Behavioral verification requires reloading the unpacked extension and
running through:
- Check Cache → banner shows "stale by rules" amber (legacy v3 cache)
- Click "Re-extract IDs" → fast path runs, summary appears
- Check Cache again → banner now shows "Cache up to date" green
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
rclone-jav
Brave extension that extracts JAV IDs from the active page and checks them against your local rc-jav library via a native-messaging Python host.
Setup: see
INSTALL.md. This file documents how it works once installed.
Architecture
Brave tab title (e.g. "MILK-257")
─► content/background script extracts ID
─► chrome.runtime.connectNative("com.rcjav.host")
─► rcjav-host.bat → rcjav-host.py
─► python rc-jav.py --search MILK-257 --basic --no-color
─► result back through the port
─► popup / notification / badge
Long-lived port: Brave keeps the host process alive while the connection is open, so subsequent lookups don't pay Python startup cost.
Triggers (all available, enable any combination in Options)
| Trigger | Behavior |
|---|---|
| Auto-check every page load | Fires chrome.tabs.onUpdated. Badge shows hit count or ? when no JAV ID detected. Noisy. |
| Auto-check on known JAV sites | Same as above but gated by host patterns (e.g. *.javdb.com). |
| Toolbar icon popup | Click the icon → popup can run a check on the active tab. The Scan Behavior toggle gates popup auto-check. |
| Right-click context menu | "rclone-jav: check this page". Shows a desktop notification. |
| Keyboard shortcut (Alt+J) | Rebind at brave://extensions/shortcuts. |
Enable them all to compare — they don't conflict.
ID extraction
Uses site adapters, URL text, and the page title plus ID normalizers. Common title forms include:
MILK-257→MILK-257MILK257→MILK-257Some site - MILK-257 [4K]→MILK-257
Search behavior
By default the extension passes --quick to rc-jav (single-ID live rclone lsjson --include, ~1–2s, fresh data, no cache). Uncheck Use --quick mode in options to use the cache (faster on warm cache, may be stale).
Files
manifest.json MV3 manifest
background.js service worker, native-messaging port, triggers
content.js page extraction, element picker, and in-page overlays
popup.html / .css / .js click-the-icon UI
options.html / .js trigger toggles + known-site patterns
icons/ extension icons
host/
rcjav-host.py native messaging host (length-prefixed JSON)
rcjav-host.bat shim so the manifest path is stable
install-host.ps1 writes the manifest into Brave's NM dir
register-host.bat prompts for ID, calls install-host.ps1
com.rcjav.host.json generated by install-host.ps1 (UTF-8 no BOM)
logs/ host logs and delete audit log
state/ scan progress state
docs/
INSTALL.md setup guide
README.md this file
EXTENSION_ID.md extension ID stability notes
Security
- The host manifest's
allowed_originsis pinned to your extension ID. Only that extension can connect. - No network ports opened.
- Host only spawns
python rc-jav.py …; no shell, no arbitrary code execution.
Troubleshooting
Quick reference — full troubleshooting in INSTALL.md.
- Badge
?→ no JAV ID in title. - Badge
!→ host error. Readhost\logs\rcjav-host-stderr.log. - "host unreachable" → re-run
install-host.ps1, fully restart Brave.