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
77 changes: 75 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,75 @@
# github-ui-mods
set of small mods for the github ui
# GitHub UI Mods

A Chrome extension that adds useful modifications to the GitHub pull request interface.

## Features

### 1. Copy PR Link Button
Adds a button next to the PR title that copies the PR title and link to your clipboard in the format: `PR Title: https://link-to-pr`

### 2. Request Copilot Review Button (Draft PRs)
When viewing a draft PR, adds a "Request Review" button next to the Copilot reviewer link (`/apps/copilot-pull-request-reviewer`) to easily request a review while the PR is still in draft status.

## Installation

### Load as Unpacked Extension (For Development/Testing)

1. Clone or download this repository:
```bash
git clone https://github.com/devm33/github-ui-mods.git
cd github-ui-mods
```

2. Open Chrome and navigate to `chrome://extensions/`

3. Enable "Developer mode" by toggling the switch in the top-right corner

4. Click "Load unpacked" button

5. Select the `github-ui-mods` directory (the one containing `manifest.json`)

6. The extension should now be installed and active!

### Verify Installation

Navigate to any GitHub pull request page. You should see:
- A "Copy PR Link" button next to the PR title
- (If it's a draft PR) A "Request Review" button next to the Copilot reviewer

## Usage

### Copy PR Link
1. Navigate to any GitHub pull request
2. Click the "Copy PR Link" button next to the PR title
3. The PR title and URL will be copied to your clipboard
4. The button will show "Copied!" briefly to confirm

### Request Copilot Review (Draft PRs)
1. Navigate to a GitHub pull request that is in draft status
2. Find the "Request Review" button next to the Copilot reviewer link
3. Click the button to request a review from Copilot
4. The button will show "Requested!" briefly to confirm

## Development

The extension consists of:
- `manifest.json` - Extension configuration
- `content.js` - Content script that modifies GitHub PR pages
- `icon*.png` - Extension icons in various sizes

To modify the extension:
1. Edit the files as needed
2. Go to `chrome://extensions/`
3. Click the refresh icon on the extension card
4. Refresh any GitHub PR pages to see your changes

## Browser Compatibility

This extension is built for Chrome (Manifest V3) but should also work in:
- Microsoft Edge
- Brave
- Other Chromium-based browsers

## License

See LICENSE file for details.
98 changes: 98 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Chrome Extension Summary

## Overview
This Chrome extension adds two useful features to GitHub pull request pages:

### Feature 1: Copy PR Link Button
- **Location**: Next to the PR title
- **Action**: Copies PR title and URL to clipboard in format: `PR Title: https://link-to-pr`
- **Feedback**: Shows "Copied!" with green checkmark on success, "Failed" with error icon on failure
- **Works on**: All PR pages (draft, open, closed, merged)

### Feature 2: Request Copilot Review Button
- **Location**: Next to the Copilot reviewer link (`/apps/copilot-pull-request-reviewer`)
- **Action**: Automates requesting a review from Copilot
- **Feedback**: Shows "Requested!" on success, or helpful message if manual action needed
- **Works on**: Only draft PRs (button only appears when PR has "Draft" status)

## Technical Implementation

### Files Created
1. **manifest.json** - Chrome Extension Manifest V3 configuration
- Permissions: `clipboardWrite`
- Content scripts: Runs on GitHub PR pages (`https://github.com/*/*/pull/*`)
- Icons: 16x16, 48x48, 128x128 PNG files

2. **content.js** - Main content script (220+ lines)
- Implements both features with proper error handling
- Uses MutationObserver to handle dynamic content loading
- Provides visual feedback for all actions
- No external dependencies

3. **Icon files** (icon16.png, icon48.png, icon128.png)
- Simple branded icons for the extension

4. **test.html** - Local test page
- Simulates GitHub PR page structure
- Allows testing without real GitHub access
- Includes automatic detection of extension features

5. **TESTING.md** - Comprehensive testing guide
- Installation instructions
- Feature testing scenarios
- Troubleshooting guide
- Debugging tips

6. **README.md** - User documentation
- Feature descriptions
- Installation steps
- Usage instructions
- Development guidelines

## Key Design Decisions

1. **Minimal Permissions**: Only requests `clipboardWrite` permission
2. **No External Dependencies**: Pure JavaScript, no libraries
3. **GitHub Theme Integration**: Uses GitHub's button classes and color scheme
4. **Robust Error Handling**: Graceful fallbacks and clear error messages
5. **Visual Feedback**: All actions provide immediate visual confirmation
6. **Dynamic Content Support**: Handles GitHub's AJAX page updates
7. **Manifest V3**: Uses latest Chrome extension standard

## Security
- ✅ CodeQL scan completed with 0 vulnerabilities
- ✅ No sensitive data access
- ✅ Scoped to GitHub PR pages only
- ✅ No network requests
- ✅ No background scripts

## Browser Compatibility
- ✅ Chrome (primary target)
- ✅ Microsoft Edge (Chromium)
- ✅ Brave (Chromium)
- ✅ Other Chromium-based browsers

## Installation Size
- Total: ~20 KB
- Code: ~15 KB (manifest.json + content.js)
- Icons: ~5 KB (3 PNG files)

## Testing Strategy
1. Local HTML test page for initial validation
2. Manual testing on actual GitHub PR pages
3. Test both draft and non-draft PRs
4. Verify clipboard functionality
5. Check visual feedback and error handling

## Future Enhancements (Optional)
- Add options page for customization
- Support for GitHub Enterprise
- Keyboard shortcuts
- More copy format options
- Additional reviewer automation features

## Notes
- The "Request Review" feature attempts to automate UI interactions
- GitHub may change their DOM structure, requiring selector updates
- Extension provides helpful messages when automation isn't possible
- Users can always fall back to manual review requests
152 changes: 152 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Testing & Verification Guide

## Extension Verification Checklist

### Installation Verification
- [ ] Extension loads without errors in Chrome
- [ ] Extension icon appears in Chrome toolbar
- [ ] No errors in Chrome DevTools console
- [ ] Extension shows as active in `chrome://extensions/`

### Feature 1: Copy PR Link Button
**Test Scenarios:**

1. **Regular PR (Open)**
- Navigate to: Any open GitHub pull request
- Expected: "Copy PR Link" button appears next to PR title
- Action: Click the button
- Expected:
- Text copied to clipboard in format: `{PR Title}: {PR URL}`
- Button shows "Copied!" with green checkmark
- Button returns to normal state after 2 seconds

2. **Draft PR**
- Navigate to: Any draft GitHub pull request
- Expected: Same behavior as regular PR for Feature 1

3. **Closed/Merged PR**
- Navigate to: A closed or merged pull request
- Expected: Same behavior - button should still work

### Feature 2: Request Copilot Review Button
**Test Scenarios:**

1. **Draft PR with Copilot Available**
- Navigate to: A draft pull request where Copilot is available
- Expected: "Request Review" button appears next to Copilot reviewer link
- Action: Click the button
- Expected:
- Attempts to open reviewer selection UI
- Button shows "Requested!" with green checkmark
- Button returns to normal state after 2 seconds

2. **Non-Draft PR**
- Navigate to: An open (non-draft) pull request
- Expected: "Request Review" button does NOT appear
- Reason: Feature only activates on draft PRs

3. **Draft PR without Copilot**
- Navigate to: A draft PR where Copilot is not listed as a reviewer option
- Expected: Button does not appear (no Copilot link to attach to)

### Cross-Browser Testing
- [ ] Chrome (primary target)
- [ ] Microsoft Edge (Chromium-based)
- [ ] Brave (Chromium-based)

### Edge Cases
- [ ] Button positioning is correct and doesn't break layout
- [ ] Buttons don't duplicate on dynamic page updates
- [ ] Extension works with GitHub's dark and light themes
- [ ] Extension works on private repositories
- [ ] Extension works on organization repositories
- [ ] Copy function works correctly with special characters in PR title
- [ ] Extension doesn't interfere with other GitHub functionality

## Manual Test Results

### Test Environment
- Browser: _____________
- Browser Version: _____________
- Date Tested: _____________
- Tester: _____________

### Feature 1 Results
| Test Case | Status | Notes |
|-----------|--------|-------|
| Button appears | ⬜ Pass / ⬜ Fail | |
| Copy to clipboard works | ⬜ Pass / ⬜ Fail | |
| Format is correct | ⬜ Pass / ⬜ Fail | |
| Visual feedback works | ⬜ Pass / ⬜ Fail | |

### Feature 2 Results
| Test Case | Status | Notes |
|-----------|--------|-------|
| Button appears on draft PR | ⬜ Pass / ⬜ Fail | |
| Button hidden on non-draft PR | ⬜ Pass / ⬜ Fail | |
| Click action works | ⬜ Pass / ⬜ Fail | |
| Visual feedback works | ⬜ Pass / ⬜ Fail | |

## Troubleshooting

### Extension not loading
1. Check that Developer mode is enabled in `chrome://extensions/`
2. Verify all files (manifest.json, content.js, icons) are present
3. Check for errors in the Extensions page
4. Try removing and re-adding the extension

### Buttons not appearing
1. Open DevTools console (F12) and check for JavaScript errors
2. Verify you're on a GitHub pull request page (URL: github.com/*/*/pull/*)
3. Refresh the page
4. Check if GitHub has changed their DOM structure (selectors might need updating)

### Copy to clipboard not working
1. Check browser permissions for clipboard access
2. Try on a different GitHub PR page
3. Check DevTools console for errors
4. Ensure the page is loaded over HTTPS

### Request Review button not working
1. Verify the PR is actually in draft status
2. Check that Copilot reviewer is available on the repository
3. Check DevTools console for errors
4. May need to manually adjust based on GitHub's current UI structure

## Debugging Tips

### View Extension Console Logs
1. Go to `chrome://extensions/`
2. Find "GitHub UI Mods"
3. Click "Inspect views: background page" or inspect the content script from DevTools

### Inspect Content Script
1. Open any GitHub PR page
2. Open DevTools (F12)
3. Go to Console tab
4. Look for messages from the extension
5. Use Sources tab to set breakpoints in content.js

### Test on Local HTML
1. Open `test.html` in your browser
2. Verify buttons appear on the simulated GitHub page
3. This tests the extension logic without needing actual GitHub access

## Known Limitations

1. **Request Review functionality**: This feature attempts to automate clicking through GitHub's UI. If GitHub changes their DOM structure, this may break and require updates to the selectors in content.js.

2. **Dynamic content**: GitHub uses dynamic content loading. The extension uses MutationObserver to handle this, but there may be edge cases where buttons don't appear immediately.

3. **Permissions**: The extension only has access to GitHub pull request pages (for security and performance).

## Reporting Issues

If you encounter issues:
1. Check the Troubleshooting section above
2. Document the issue with:
- Browser and version
- GitHub page URL (without sensitive info)
- Steps to reproduce
- Console errors (if any)
- Screenshots (if applicable)
Loading