Skip to content

Add GitHub PR Approve Helper userscript - #6

Merged
MishaKav merged 11 commits into
mainfrom
claude/tampermonkey-pr-approve-ukc0w4
Aug 4, 2026
Merged

Add GitHub PR Approve Helper userscript#6
MishaKav merged 11 commits into
mainfrom
claude/tampermonkey-pr-approve-ukc0w4

Conversation

@MishaKav

@MishaKav MishaKav commented Aug 4, 2026

Copy link
Copy Markdown
Owner

What

New Tampermonkey userscript github-pr-approve-helper.user.js (v1.0.0) that speeds up approving pull requests, plus a README table entry.

When the "Finish your review" dialog opens on a PR:

  • Approve is selected automatically (AUTO_SELECT_APPROVE const to disable)
  • the review comment is auto-filled with LGTM — only when the box is empty, it never overwrites typed text
  • a compact dropdown floats in the dialog header with alternative phrases (Nice, Great job! 🎉, 🎲 Random, …) — picking one replaces the text
  • switching to Comment/Request changes removes the auto-inserted text (only if unedited)
  • a small "✅ Approve Helper active" badge flashes on page load, so it's visible the script is running

Scoped to https://github.com/linear-b/* (@match + a runtime ALLOWED_ORGS check that stays correct across GitHub's soft navigations).

How

  • Capture-phase change/click delegation on document + a MutationObserver for the on-demand dialog — survives Turbo soft navigation and React re-mounts, no polling
  • React-controlled textarea is written via the native prototype setter + bubbled input/change events, so the text lands in React state (i.e. in the submitted review, not just on screen)
  • @sandbox DOM runs the script in the extension's isolated world — github.com's Trusted-Types CSP breaks Tampermonkey's default page-context injection with a mangled SyntaxError from appendChild
  • Supports both the new React "Finish your review" dialog (name="reviewEvent") and the legacy review dropdown (pull_request_review[event])

Testing

  • Verified end-to-end with a Playwright harness: the script injected into a real Chromium isolated world (same context Tampermonkey uses for @sandbox DOM) against a React 18 replica of GitHub's review dialog — 18/18 checks pass (auto-select, default fill, no-overwrite, clear-on-switch-away, click fallback, dropdown replace/reset/re-inject, org scoping)
  • Verified manually on a real linear-b PR in Chrome

🤖 Generated with Claude Code

https://claude.ai/code/session_01JL2YxajmCPuDRWyejSpCJM


Generated by Claude Code

claude added 9 commits August 4, 2026 11:21
Auto-fills the review comment with a random LGTM-style text when
selecting Approve in the GitHub pull request review dialog. Supports
both the new react review dialog and the legacy review dropdown.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JL2YxajmCPuDRWyejSpCJM
- narrow @match to https://github.com/linear-b/*
- expand the list of approve comments
- inject a dropdown above the review textarea to pick a specific
  comment (or a random one) on demand
- bump version 1.2.0

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JL2YxajmCPuDRWyejSpCJM
- fill the comment when the review dialog opens with approve already
  selected (no change event fires in that case)
- add a capture-phase click fallback for clicks on the label or on an
  already-selected approve radio
- resolve event targets through composedPath for shadow dom safety
- more console diagnostics, bump version 1.3.0

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JL2YxajmCPuDRWyejSpCJM
Shows a small self-removing badge on PR pages, so it's visible the
script is injected and running without opening devtools.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JL2YxajmCPuDRWyejSpCJM
GitHub's trusted-types CSP breaks tampermonkey's page-context (MAIN
world) injection with a mangled SyntaxError from appendChild. The
script only needs DOM access, so run it in the extension's isolated
world instead, which bypasses the page CSP entirely.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JL2YxajmCPuDRWyejSpCJM
Logs every radio change/click with full attribute details and dumps
the radios/textareas of each dialog once, so real github markup can
be compared against the selectors. DEBUG const to silence later.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JL2YxajmCPuDRWyejSpCJM
- automatically select the approve option when the review dialog opens
  (AUTO_SELECT_APPROVE const to disable)
- auto-fill always inserts the deterministic DEFAULT_COMMENT ('LGTM');
  the dropdown replaces it with an alternative on demand
- restyle the dropdown as a compact pill floating in the dialog header
  next to the close button, instead of squeezing into the editor

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JL2YxajmCPuDRWyejSpCJM

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Tampermonkey userscript to streamline approving GitHub PRs within linear-b/* by auto-selecting “Approve”, auto-filling the review comment, and providing quick comment presets, plus registers the script in the repository README.

Changes:

  • Add github-pr-approve-helper.user.js v1.0.0 to auto-select Approve, auto-fill/clear review text, and inject a preset dropdown + “active” badge.
  • Add README table entry and wiki/raw links for the new userscript.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
README.md Adds the new userscript to the install table and link references.
github-pr-approve-helper.user.js Implements the approve-helper behavior (dialog detection, autofill, dropdown, scoping, and badge).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread github-pr-approve-helper.user.js
Comment thread github-pr-approve-helper.user.js
claude added 2 commits August 4, 2026 12:23
- fall back to a plain value assignment when the native prototype
  setter is unavailable
- coalesce mutation bursts into one scan per animation frame
- re-show the active badge once per soft navigation

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JL2YxajmCPuDRWyejSpCJM
@MishaKav
MishaKav merged commit 4631439 into main Aug 4, 2026
@MishaKav
MishaKav deleted the claude/tampermonkey-pr-approve-ukc0w4 branch August 4, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants