Copy Script Tag
A VS Code / Cursor extension. Right-click a .js/.mjs/.css file in a
workspace and it starts a local static server (if not already running) and
copies a ready-to-paste <script>/<link> tag pointing at that file —
handy for injecting local, in-progress JS/CSS into a live page (Webflow
custom code, a CodePen, a client's <head>, a local test page) without
deploying anything first.
How it works
src/server.ts — a minimal static file server (Node's built-in http/
https modules, no framework). Serves files under the workspace root,
guards against path traversal, sets permissive CORS headers.
src/certs.ts — checks for / generates a local HTTPS certificate via
mkcert, so the server can run over HTTPS when needed (see below).
src/extension.ts — the VS Code extension entry point: registers
commands, manages the server's lifecycle, builds the tag text, and
writes it to the clipboard.
package.json — extension manifest: commands, context-menu entries,
and the settings schema.
Run it in dev mode (Extension Development Host)
npm install
- Open this folder in VS Code or Cursor
- Press
F5 (or Run → Start Debugging) — this compiles the TypeScript
and launches a second "Extension Development Host" window with the
extension loaded
- In that new window, open any folder, right-click a
.js/.mjs/.css
file in the Explorer, choose Copy as Script Tag
- The server starts automatically and the tag is copied to your clipboard
If F5 isn't available in your setup (e.g. no visible Run menu), use the
manual package/install flow below instead — it's slower per iteration but
needs nothing but the terminal.
Manual build & install (no F5 needed — e.g. plain terminal in Cursor)
npm install
npm run compile
npx vsce package
cursor --install-extension copy-script-tag-0.0.1.vsix
(vsce package may warn about a missing repository field — safe to
continue past that for local use.)
If cursor isn't recognized as a command, either use the full path —
/Applications/Cursor.app/Contents/Resources/app/bin/cursor (macOS) — or
set it up once globally:
sudo ln -sf "/Applications/Cursor.app/Contents/Resources/app/bin/cursor" /usr/local/bin/cursor
After reinstalling, fully quit and reopen Cursor (a window reload isn't
always enough to pick up a reinstalled extension).
Settings
copyScriptTag.port — default 5510
copyScriptTag.host — default localhost. Set to your LAN IP to test
against a page open on another device.
copyScriptTag.scriptAttributes — extra attributes on <script> tags,
e.g. defer or type="module"
copyScriptTag.useHttps — serve over HTTPS via a local mkcert
certificate, so tags can be pasted into HTTPS pages (e.g. Webflow)
without getting blocked as mixed content. Off by default.
Note: the server only reads config values at startup. If you change a
setting while the server is already running, stop it first (click the
status bar item) so the next request picks up the new value.
Using HTTPS (for pasting into Webflow or other HTTPS pages)
One-time setup, outside the extension:
brew install mkcert # macOS; see mkcert docs for other OSes
mkcert -install # installs a local CA into your system/browser trust store
Then enable copyScriptTag.useHttps in Settings. The next time the server
starts, the extension generates a localhost/127.0.0.1 cert automatically
(cached in the extension's global storage) and switches to https:// —
tags come out as https://localhost:5510/....
If mkcert isn't installed, you'll get a clear error message with the
install command rather than a silent failure.
Known limitations
- Single-root workspaces only
- No bundling — points directly at the file as it exists on disk, so raw
.ts/.jsx files won't resolve without a build step first
- No live-reload yet
- HTTPS mode only covers
localhost/127.0.0.1 — using a LAN IP as
copyScriptTag.host with HTTPS enabled isn't supported yet
- Config changes while the server is running require a manual restart
(stop via the status bar item, then trigger the command again)
- CORS is wide open (
Access-Control-Allow-Origin: *) and every HTTP
method is treated like GET — both fine for a local dev tool, not meant
for anything beyond that
Development
See CONTRIBUTING.md for the workflow on making
changes, testing them, and submitting a fix or feature.