Files
Tommy D. Rossi 6224a0f374 fix: render ghost cursor as inline SVG instead of a data URL background
The ghost cursor painted its arrow with
`background-image: url("data:image/svg+xml;base64,…")`. Pages with a
strict `img-src` CSP refuse to load that URL, so on Hacker News every
navigation logged a CSP violation and the cursor rendered as an empty
box.

Changes:

- `setInnerSvg()` parses the markup with `DOMParser`, validates the root
  is a real SVG element, imports it into the document, and appends it to
  the cursor. No image URL is involved, so no `img-src` rule applies.
- The generated cursor module now exports raw SVG markup
  (`pointer-macos-tahoe-svg.ts`) instead of a base64 data URL
  (`pointer-macos-tahoe-data-url.ts`). `encode-screenstudio-cursor.ts`
  writes the markup with `JSON.stringify`.
- `applyRuntimeVisualOptions()` clears previous children and resets
  `background-image` on every style switch, so toggling between
  `screenstudio`, `minimal`, and `dot` never stacks two arrows.

The always-on cursor test now asserts the injected element contains a
literal `<svg>` and no `data:image/svg` reference.

Session: ses_fe45ea8e3ffepbcZz6OQQ9sFSH
2026-08-20 16:23:03 +02:00

22 lines
851 B
TypeScript

/**
* Encodes the extracted Screen Studio cursor SVG as an inline markup TS module.
*/
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const sourcePath = path.resolve(__dirname, '../src/assets/cursors/screen-studio/pointer-macos-tahoe.svg')
const outputPath = path.resolve(__dirname, '../src/assets/cursors/screen-studio/pointer-macos-tahoe-svg.ts')
function main() {
const svg = fs.readFileSync(sourcePath, 'utf-8').trim()
const output = `/**\n * Generated from pointer-macos-tahoe.svg via scripts/encode-screenstudio-cursor.ts.\n */\n\nexport const SCREENSTUDIO_POINTER_MACOS_TAHOE_SVG = ${JSON.stringify(svg)}\n`
fs.writeFileSync(outputPath, output)
console.log(`Wrote ${outputPath}`)
}
main()