diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 299408a..7226f7a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,7 +15,7 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 26 cache: npm - run: npm ci diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b5babc5..3e42e3c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,13 +7,13 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 26 cache: npm - run: npm ci diff --git a/PRIVACY.md b/PRIVACY.md index 3ed611b..8176e7c 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -1,11 +1,11 @@ # Privacy Policy for Scriptmonkey -Last updated: June 23, 2026 +Last updated: November 13, 2026 -Scriptmonkey is designed as a local, lightweight user script manager. We respect your privacy and are committed to protecting it. This extension does not collect, store, or transmit any of your personal data. +Scriptmonkey is designed as a local, lightweight user script manager. We respect your privacy and are committed to protecting it. This extension does not collect or transmit any of your personal data, except feedback you explicitly choose to send. ## 1. No Data Collection or Transmission -Scriptmonkey does **not** collect, store, or transmit any personal data, browsing history, web traffic, or the contents of your user scripts to external servers. All operations run entirely locally on your device. We do not use any third-party analytics, tracking tools, cookies, or telemetry. +Apart from voluntary feedback (see section 4), Scriptmonkey does **not** collect, store, or transmit any personal data, browsing history, web traffic, or the contents of your user scripts to external servers. All operations run entirely locally on your device. We do not use any third-party analytics, tracking tools, cookies, or telemetry. ## 2. Chrome Extension Permissions & Data Use To function as a user script manager, Scriptmonkey requires the following permissions: @@ -16,8 +16,11 @@ To function as a user script manager, Scriptmonkey requires the following permis ## 3. Third-Party Network Requests (Script Updates) If a user script includes an `@updateURL` or `@downloadURL` tag, Scriptmonkey will query that URL only when you manually check for updates. This request is sent directly to the script host. Scriptmonkey does not attach any identifying telemetry, tracking parameters, or personal data to these requests. -## 4. Changes to This Policy +## 4. Voluntary Feedback +If you choose to submit the feedback form, Scriptmonkey sends your message, the extension version, and your browser's user agent to the developer email. If you choose to, the source of a selected user script is attached. No IP address, account, or other identifier is recorded by Scriptmonkey. Nothing is sent unless you explicitly submit the form. + +## 5. Changes to This Policy We may update this Privacy Policy from time to time. Any changes will be posted on this page with an updated "Last updated" date. -## 5. Contact & Support +## 6. Contact & Support If you have any questions or concerns regarding privacy, please open an issue on the [Scriptmonkey GitHub Repository](https://github.com/matwoess/Scriptmonkey/issues). diff --git a/assets/docs/dashboard.png b/assets/docs/dashboard.png index 93ba1c8..100a180 100644 Binary files a/assets/docs/dashboard.png and b/assets/docs/dashboard.png differ diff --git a/assets/docs/popup-overlay.png b/assets/docs/popup-overlay.png index 1310b9e..db11d62 100644 Binary files a/assets/docs/popup-overlay.png and b/assets/docs/popup-overlay.png differ diff --git a/assets/docs/popup.png b/assets/docs/popup.png index 0096b06..0dadbb2 100644 Binary files a/assets/docs/popup.png and b/assets/docs/popup.png differ diff --git a/assets/promo/1-dashboard.png b/assets/promo/1-dashboard.png index 1af3d5b..ff08ad4 100644 Binary files a/assets/promo/1-dashboard.png and b/assets/promo/1-dashboard.png differ diff --git a/assets/promo/2-popup.png b/assets/promo/2-popup.png index 01294ec..40cceac 100644 Binary files a/assets/promo/2-popup.png and b/assets/promo/2-popup.png differ diff --git a/assets/promo/3-popup-details.png b/assets/promo/3-popup-details.png index 1fa311e..985cc1b 100644 Binary files a/assets/promo/3-popup-details.png and b/assets/promo/3-popup-details.png differ diff --git a/assets/promo/small-promo-tile.png b/assets/promo/small-promo-tile.png index 2a53180..93e78c7 100644 Binary files a/assets/promo/small-promo-tile.png and b/assets/promo/small-promo-tile.png differ diff --git a/e2e/extension-behavior.spec.ts b/e2e/extension-behavior.spec.ts index 3daf88a..4a6c020 100644 --- a/e2e/extension-behavior.spec.ts +++ b/e2e/extension-behavior.spec.ts @@ -853,4 +853,57 @@ console.log('downgraded'); await dashboardPage.close(); }); + + test("should send feedback with an attached script from the dashboard", async ({ + page, + extensionId, + context, + }) => { + let body: Record | undefined; + await context.route("**/api/feedback", (route) => { + body = route.request().postDataJSON(); + route.fulfill({ status: 204 }); + }); + + await page.goto(`chrome-extension://${extensionId}/dashboard.html`); + await page + .locator("input[type='file']") + .setInputFiles(path.join(import.meta.dirname, "fixtures/add_button.js")); + await page.locator("#btn-feedback").click(); + await page.locator("#feedback-message").fill("Great extension"); + await page + .locator("#feedback-script") + .selectOption({ label: "Test Script - Add Button" }); + await page.locator("#feedback-submit").click(); + + await expect(page.locator("#feedback-success")).toBeVisible(); + expect(body).toMatchObject({ + message: "Great extension", + script: { filename: "add_button.js" }, + }); + }); + + test("should send feedback from popup header button", async ({ + page, + extensionId, + context, + }) => { + let body: Record | undefined; + await context.route("**/api/feedback", (route) => { + body = route.request().postDataJSON(); + route.fulfill({ status: 204 }); + }); + + await page.goto(`chrome-extension://${extensionId}/index.html`); + await page.locator("#btn-feedback").click(); + await page + .locator("#feedback-message") + .fill("Quick question about permissions"); + await page.locator("#feedback-submit").click(); + + await expect(page.locator("#feedback-success")).toBeVisible(); + expect(body).toMatchObject({ + message: "Quick question about permissions", + }); + }); }); diff --git a/feedback-api/api/feedback.ts b/feedback-api/api/feedback.ts new file mode 100644 index 0000000..1b89723 --- /dev/null +++ b/feedback-api/api/feedback.ts @@ -0,0 +1,156 @@ +import type { FeedbackPayload } from "../../src/types"; + +interface ResendEmail { + from: string; + to: string; + subject: string; + text: string; + attachments?: { filename: string; content: string }[]; +} + +const MAX_MESSAGE = 5_000; +const MAX_SCRIPT = 200_000; + +const isString = (v: unknown): v is string => typeof v === "string"; + +/** Validates an untrusted request body, returning the payload or an error message. */ +export function parseFeedback(body: unknown): FeedbackPayload | string { + if (typeof body !== "object" || body === null) return "Invalid body"; + const { message, version, userAgent, script } = body as Record< + string, + unknown + >; + if (!isString(message) || !message.trim()) return "Message is required"; + if (message.length > MAX_MESSAGE) return "Message too long"; + if (!isString(version) || version.length > 32) return "Invalid version"; + if (!isString(userAgent) || userAgent.length > 512) + return "Invalid user agent"; + + const payload: FeedbackPayload = { + message: message.trim(), + version, + userAgent, + }; + + if (script !== undefined) { + const { filename, source } = script as Record; + if (!isString(filename) || filename.length > 256 || !isString(source)) + return "Invalid script"; + if (source.length > MAX_SCRIPT) return "Script too large"; + payload.script = { filename, source }; + } + + return payload; +} + +/** Matches an origin against an allow-list; entries ending in `*` match by prefix. */ +export function isAllowedOrigin(origin: string | null, allowed: string[]) { + if (!origin) return false; + return allowed.some((entry) => + entry.endsWith("*") + ? origin.startsWith(entry.slice(0, -1)) + : entry === origin, + ); +} + +/** Builds the Resend API request body for a feedback payload. */ +export function buildEmail( + payload: FeedbackPayload, + from: string, + to: string, +): ResendEmail { + const firstLine = payload.message.split("\n")[0].slice(0, 60); + const attachments: { filename: string; content: string }[] = []; + if (payload.script) { + attachments.push({ + filename: payload.script.filename, + content: Buffer.from(payload.script.source).toString("base64"), + }); + } + return { + from, + to, + subject: `[Scriptmonkey v${payload.version}] ${firstLine}`, + text: `${payload.message}\n\n---\nVersion: ${payload.version}\nUser agent: ${payload.userAgent}`, + ...(attachments.length && { attachments }), + }; +} + +function allowedOrigins() { + return (process.env.ALLOWED_ORIGINS ?? "") + .split(",") + .map((s) => s.trim()) + .filter(Boolean); +} + +function corsHeaders(origin: string): HeadersInit { + return { + "Access-Control-Allow-Origin": origin, + "Access-Control-Allow-Methods": "POST, OPTIONS", + "Access-Control-Allow-Headers": "Content-Type", + Vary: "Origin", + }; +} + +/** Sends the validated feedback payload via the Resend API. */ +export async function sendFeedbackEmail( + payload: FeedbackPayload, + apiKey: string, + from: string, + to: string, +): Promise<{ ok: boolean; status: number; error?: string }> { + const res = await fetch("https://api.resend.com/emails", { + method: "POST", + headers: { + Authorization: `Bearer ${apiKey}`, + "Content-Type": "application/json", + }, + body: JSON.stringify(buildEmail(payload, from, to)), + }); + if (!res.ok) { + const text = await res.text(); + return { ok: false, status: res.status, error: text }; + } + return { ok: true, status: 200 }; +} + +export function OPTIONS(request: Request): Response { + const origin = request.headers.get("Origin"); + if (!origin || !isAllowedOrigin(origin, allowedOrigins())) + return new Response(null, { status: 403 }); + return new Response(null, { status: 204, headers: corsHeaders(origin) }); +} + +export async function POST(request: Request): Promise { + const origin = request.headers.get("Origin"); + if (!origin || !isAllowedOrigin(origin, allowedOrigins())) + return new Response("Forbidden", { status: 403 }); + const headers = corsHeaders(origin); + + let body: unknown; + try { + body = await request.json(); + } catch { + return new Response("Invalid JSON", { status: 400, headers }); + } + const payload = parseFeedback(body); + if (typeof payload === "string") + return new Response(payload, { status: 400, headers }); + + const { RESEND_API_KEY, FEEDBACK_FROM, FEEDBACK_TO } = process.env; + if (!RESEND_API_KEY || !FEEDBACK_FROM || !FEEDBACK_TO) + return new Response("Server not configured", { status: 500, headers }); + + const result = await sendFeedbackEmail( + payload, + RESEND_API_KEY, + FEEDBACK_FROM, + FEEDBACK_TO, + ); + + if (!result.ok) { + console.error("Resend error", result.status, result.error); + return new Response("Failed to send feedback", { status: 502, headers }); + } + return new Response(null, { status: 204, headers }); +} diff --git a/feedback-api/package.json b/feedback-api/package.json new file mode 100644 index 0000000..1f58a65 --- /dev/null +++ b/feedback-api/package.json @@ -0,0 +1,11 @@ +{ + "name": "scriptmonkey-feedback-api", + "private": true, + "type": "module", + "devDependencies": { + "@types/node": "^22.0.0" + }, + "engines": { + "node": "26.x" + } +} diff --git a/feedback-api/tests/feedback.test.ts b/feedback-api/tests/feedback.test.ts new file mode 100644 index 0000000..aa48764 --- /dev/null +++ b/feedback-api/tests/feedback.test.ts @@ -0,0 +1,107 @@ +// @vitest-environment node +import { afterEach, describe, expect, it, vi } from "vitest"; +import { + buildEmail, + isAllowedOrigin, + OPTIONS, + POST, + parseFeedback, +} from "../api/feedback"; + +const valid = { message: " Hello\nworld ", version: "1.0.0", userAgent: "UA" }; +const EXT = "chrome-extension://abc"; + +function request(body: unknown, origin = EXT) { + return new Request("https://x/api/feedback", { + method: "POST", + headers: { Origin: origin, "Content-Type": "application/json" }, + body: typeof body === "string" ? body : JSON.stringify(body), + }); +} + +describe("parseFeedback", () => { + it("accepts and trims a minimal payload", () => { + expect(parseFeedback(valid)).toEqual({ ...valid, message: "Hello\nworld" }); + }); + + it.each([ + [null, "Invalid body"], + [{ ...valid, message: " " }, "Message is required"], + [{ ...valid, message: "x".repeat(5001) }, "Message too long"], + [{ ...valid, version: 1 }, "Invalid version"], + [{ ...valid, script: { filename: "a.js" } }, "Invalid script"], + ])("rejects %j", (body, error) => { + expect(parseFeedback(body)).toBe(error); + }); +}); + +describe("isAllowedOrigin", () => { + it("matches exact entries and prefix wildcards", () => { + const allowed = ["https://site.io", "chrome-extension://*"]; + expect(isAllowedOrigin("https://site.io", allowed)).toBe(true); + expect(isAllowedOrigin(EXT, allowed)).toBe(true); + expect(isAllowedOrigin("https://evil.io", allowed)).toBe(false); + expect(isAllowedOrigin(null, allowed)).toBe(false); + }); +}); + +describe("buildEmail", () => { + it("attaches the script as base64", () => { + const email = buildEmail( + { + ...valid, + message: "Bug\ndetails", + script: { filename: "a.user.js", source: "hi" }, + }, + "from@x", + "to@x", + ); + expect(email.subject).toBe("[Scriptmonkey v1.0.0] Bug"); + expect(email.attachments).toEqual([ + { filename: "a.user.js", content: "aGk=" }, + ]); + }); +}); + +describe("handlers", () => { + afterEach(() => { + vi.unstubAllEnvs(); + vi.unstubAllGlobals(); + }); + + function configure() { + vi.stubEnv("ALLOWED_ORIGINS", EXT); + vi.stubEnv("RESEND_API_KEY", "key"); + vi.stubEnv("FEEDBACK_FROM", "from@x"); + vi.stubEnv("FEEDBACK_TO", "to@x"); + const fetchMock = vi.fn(async () => new Response("{}")); + vi.stubGlobal("fetch", fetchMock); + return fetchMock; + } + + it("sends the email via Resend", async () => { + const fetchMock = configure(); + const res = await POST(request(valid)); + expect(res.status).toBe(204); + expect(res.headers.get("Access-Control-Allow-Origin")).toBe(EXT); + expect(fetchMock).toHaveBeenCalledWith( + "https://api.resend.com/emails", + expect.objectContaining({ method: "POST" }), + ); + }); + + it("rejects foreign origins and bad bodies without sending", async () => { + const fetchMock = configure(); + expect((await POST(request(valid, "https://evil.io"))).status).toBe(403); + expect((await POST(request("{nope"))).status).toBe(400); + expect((await POST(request({}))).status).toBe(400); + expect(OPTIONS(request(valid, "https://evil.io")).status).toBe(403); + expect(fetchMock).not.toHaveBeenCalled(); + }); + + it("reports Resend failures as 502", async () => { + configure().mockResolvedValueOnce(new Response("err", { status: 500 })); + vi.spyOn(console, "error").mockImplementation(() => {}); + expect((await POST(request(valid))).status).toBe(502); + }); +}); diff --git a/feedback-api/tsconfig.json b/feedback-api/tsconfig.json new file mode 100644 index 0000000..492c2ea --- /dev/null +++ b/feedback-api/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "strict": true, + "skipLibCheck": true, + "types": ["node"] + }, + "include": ["api/**/*", "tests/**/*", "../src/types/**/*"] +} diff --git a/package.json b/package.json index e1c7ba2..38e1107 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,9 @@ "url": "https://github.com/matwoess/Scriptmonkey/issues" }, "homepage": "https://github.com/matwoess/Scriptmonkey#readme", + "engines": { + "node": "26.x" + }, "dependencies": { "@codemirror/lang-javascript": "^6.2.5", "@uiw/react-codemirror": "^4.25.10", diff --git a/src/components/FeedbackDialog.css b/src/components/FeedbackDialog.css new file mode 100644 index 0000000..f7a9a64 --- /dev/null +++ b/src/components/FeedbackDialog.css @@ -0,0 +1,70 @@ +.feedback-dialog { + margin: auto; + width: min(420px, calc(100vw - 32px)); + max-height: calc(100vh - 32px); + overflow-y: auto; + padding: 20px; + background: var(--surface-elevated); + color: var(--text); + border: 1px solid var(--border); + border-radius: var(--radius); + box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); +} + +.feedback-dialog::backdrop { + background: var(--backdrop-bg); +} + +.feedback-dialog h3 { + margin-bottom: 12px; + font-size: 14px; + color: var(--text-bold); +} + +.feedback-dialog form { + display: flex; + flex-direction: column; + gap: 10px; +} + +.feedback-dialog textarea, +.feedback-dialog select { + width: 100%; + padding: 8px 10px; + font-size: 12px; + color: var(--text-bold); + background: var(--surface); + border: 1px solid var(--border); + border-radius: 6px; +} + +.feedback-dialog textarea { + resize: vertical; +} + +.feedback-dialog textarea:focus-visible, +.feedback-dialog select:focus-visible { + border-color: var(--border-focus); + outline: none; +} + +.feedback-field { + display: flex; + gap: 8px; + align-items: center; + font-size: 11.5px; +} + +.feedback-field span { + flex-shrink: 0; +} + +.feedback-note { + font-size: 10.5px; + color: var(--muted); +} + +.feedback-error { + font-size: 11px; + color: var(--danger); +} diff --git a/src/components/FeedbackDialog.tsx b/src/components/FeedbackDialog.tsx new file mode 100644 index 0000000..2918395 --- /dev/null +++ b/src/components/FeedbackDialog.tsx @@ -0,0 +1,132 @@ +import type React from "react"; +import { useEffect, useRef, useState } from "react"; +import type { Script } from "../types"; +import { sendFeedback } from "../utils/feedback"; +import "./FeedbackDialog.css"; + +interface Props { + open: boolean; + onClose: () => void; + scripts: Script[]; +} + +type Status = "idle" | "sending" | "sent" | "error"; + +export function FeedbackDialog({ open, onClose, scripts }: Props) { + const dialogRef = useRef(null); + const [message, setMessage] = useState(""); + const [scriptId, setScriptId] = useState(""); + const [status, setStatus] = useState("idle"); + const [error, setError] = useState(""); + + useEffect(() => { + const dialog = dialogRef.current; + if (!dialog) return; + if (open && !dialog.open) dialog.showModal(); + if (!open && dialog.open) dialog.close(); + }, [open]); + + const handleClose = () => { + if (status === "sent") { + setMessage(""); + setScriptId(""); + setStatus("idle"); + } + onClose(); + }; + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setStatus("sending"); + setError(""); + const script = scripts.find((s) => s.id === scriptId); + try { + await sendFeedback({ + message, + script: script && { filename: script.filename, source: script.source }, + }); + setStatus("sent"); + } catch (err) { + setError(err instanceof Error ? err.message : String(err)); + setStatus("error"); + } + }; + + return ( + +

Send Feedback

+ {status === "sent" ? ( + <> +

Thanks! Your feedback was sent.

+
+ +
+ + ) : ( +
+