fix: background-script fetch (CSP/mixed-content), prefer-Spotify links, toolbar icon (task/fix-extension-and-linkui)
The extension linked nothing and the resolver saw no requests: the content script fetched http://localhost:8787 directly from the HTTPS reddit page, which reddit's CSP / mixed-content blocks. Move the network call to a background script (extension origin, exempt) and add stage logging so failures are visible. - extension/background.js (new): does the resolver fetch on message; sets the toolbar badge. - extension/content.js: talks to background via runtime messaging (no page-context fetch); [rsl] console logs at boot/root/candidates/resolve/scan; single primary link. - extension/manifest.json: background.scripts + browser_action (icon.svg, title). - extension/{styles.css,icon.svg}: platform-coloured link (green=spotify, teal=bandcamp) + toolbar icon. - service/lib.js: primaryOf()/isSearchUrl() — link Spotify when the artist is on Spotify, else Bandcamp, else Spotify search; spotifyResult/mbResult attach `primary` (unit-tested). - README: link behaviour, toolbar, Troubleshooting. Verified: scripts/check.sh green (10 tests); resolver returns `primary` end-to-end. The in-browser fix is logic-verified only (no headless Firefox here) — reload the temp add-on and watch the page console `[rsl]` logs to confirm. Source: project human-feedback 2026-06-16 (notes 01KV8VC58QMYBDY6VVVJHR8YNY + 01KV91AMJCN2C4GFCKMKQRGNXE). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -26,10 +26,12 @@ service/ tiny Node.js resolver (one file, zero npm deps)
|
||||
resolver.js
|
||||
package.json
|
||||
.env.example
|
||||
extension/ Firefox MV2 extension (content script only)
|
||||
extension/ Firefox MV2 extension
|
||||
manifest.json
|
||||
background.js (does the resolver fetch; talks to the content script)
|
||||
content.js
|
||||
styles.css
|
||||
icon.svg
|
||||
```
|
||||
|
||||
## 1. Run the resolver service
|
||||
@@ -91,9 +93,26 @@ with `xpinstall.signatures.required = false`.)
|
||||
|
||||
1. Make sure the resolver service is running.
|
||||
2. Open any Reddit comments thread (a URL with `/comments/` in it).
|
||||
3. Artist names in the comments become links: the name links to **Spotify**, with
|
||||
a small superscript **`bc`** link to **Bandcamp** beside it. New comments loaded
|
||||
as you scroll are linked automatically.
|
||||
3. Artist names become a single link — to **Spotify** if the artist is on Spotify,
|
||||
otherwise to **Bandcamp** — colour-coded (green = Spotify, teal = Bandcamp). New
|
||||
comments loaded as you scroll are linked automatically.
|
||||
4. The toolbar icon shows the extension is active; its badge shows how many links were
|
||||
added on the current page.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If nothing gets linked:
|
||||
|
||||
1. Confirm the resolver is running — `curl localhost:8787/health` should return
|
||||
`{"ok":true,...}`.
|
||||
2. On the reddit thread, open the browser console (F12) and look for `[rsl]` logs: they
|
||||
report the root element, candidate count, and resolver responses on each scan. A
|
||||
`resolve failed` line means the background script can't reach the resolver (is it on
|
||||
`:8787`?); `candidates found: 0` means the comment text wasn't matched (please report
|
||||
the thread).
|
||||
3. The content script reaches the resolver **through the extension's background script**
|
||||
— a page-context fetch to `http://localhost` is blocked by reddit's CSP — so make sure
|
||||
the add-on loaded without errors in `about:debugging`.
|
||||
|
||||
## Configuration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user