Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 22
node-version: 26
cache: npm

- run: npm ci
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions PRIVACY.md
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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).
Binary file modified assets/docs/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/docs/popup-overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/docs/popup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/promo/1-dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/promo/2-popup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/promo/3-popup-details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/promo/small-promo-tile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions e2e/extension-behavior.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown> | 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<string, unknown> | 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",
});
});
});
156 changes: 156 additions & 0 deletions feedback-api/api/feedback.ts
Original file line number Diff line number Diff line change
@@ -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<string, unknown>;
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<Response> {
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 });
}
11 changes: 11 additions & 0 deletions feedback-api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "scriptmonkey-feedback-api",
"private": true,
"type": "module",
"devDependencies": {
"@types/node": "^22.0.0"
},
"engines": {
"node": "26.x"
}
}
107 changes: 107 additions & 0 deletions feedback-api/tests/feedback.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
Loading
Loading