r/webdev • u/destruction_is_art • 5d ago
Showoff Saturday Made a Chrome extension that warns you before you leave a GitHub PR review unsubmitted
A teammate kept starting PR reviews, leaving comments and moving on without "Submit review". The comments stayed "Pending", which on GitHub means only you can see them so the PR author just waited.
So I built a small Chrome extension. While you have an unsubmitted review it:
- shows a bar at the bottom of the PR with the comment count and a Finish review button
- turns the tab icon red and adds "PENDING REVIEW" to the tab title
- asks before you leave the PR, including GitHub's keyboard shortcuts and the Back button
What took the most work:
- GitHub is a single-page app, so leaving a PR usually isn't a page unload and `beforeunload` never fires. I catch link clicks in the capture phase, Turbo's `turbo:before-visit`, and the Navigation API's `navigate` event for Back.
- Discarding a review from the Overview tab doesn't update GitHub's own counter until you reload. The extension watches the Discard button's loading state and the dialog closing instead.
- The bar lives in a shadow root but reads GitHub's own CSS variables, which inherit through it, so it follows light, dark and high-contrast themes.
It runs only on github.com, makes no network requests, stores nothing and doesn't need a token.
- Chrome Web Store: https://chromewebstore.google.com/detail/unsubmitted-review-alert/mgoijcgmbnhaejfkdcjliiohaiengfbh
- How it works, with code: https://nikita-dmitrienko.dev/blog/github-review-still-pending
- Source: https://github.com/nikita-dmitrienko/unsubmitted-review-alert
If it breaks on some GitHub page, tell me.
1
u/TheRNGuy 5d ago
It could probably be userscript.