├── .circleci └── config.yml ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── conventionalCommit.xml ├── inspectionProfiles │ └── Project_Default.xml ├── misc.xml ├── modules.xml ├── quickreview-for-github.iml └── vcs.xml ├── .npmrc ├── README.md ├── babel.config.js ├── license ├── media ├── feature screens │ ├── screen 01 view.png │ ├── screen 01 view.psd │ ├── screen 02 approve.png │ ├── screen 02 approve.psd │ ├── screen 03 merge.png │ └── screen 03 merge.psd └── promo │ ├── large promo tile.psd │ ├── large-promo-tile.png │ ├── marquee promo tile.psd │ ├── marquee-promo-tile.png │ ├── small promo tile.psd │ └── small-promo-tile.png ├── package.json ├── renovate.json ├── src ├── background │ ├── background.ts │ ├── circle-api.ts │ ├── gh-api.ts │ └── helpers │ │ └── open-tab.ts ├── features │ └── pull-requests │ │ ├── press-a-approve-m-merge.tsx │ │ └── press-v-to-view.ts ├── icons │ ├── 128.png │ ├── 16.png │ ├── 256.png │ ├── 48.png │ └── icon.psd ├── index.test.ts ├── index.tsx ├── manifest.json ├── options.html ├── options.ts └── types.ts ├── tsconfig.json ├── wallaby.config.js ├── webpack.config.js └── yarn.lock /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | orbs: 4 | node: circleci/node@1.1.6 5 | 6 | commands: 7 | install_deps: 8 | steps: 9 | - node/with-cache: 10 | cache-version: v1-all 11 | cache-key: package.json 12 | dir: ~/repo/node_modules 13 | use-strict-cache: true 14 | steps: 15 | - run: yarn install --pure-lockfile --no-progress 16 | 17 | jobs: 18 | build: 19 | executor: 20 | name: node/default 21 | tag: '12' 22 | steps: 23 | - checkout 24 | - install_deps 25 | - run: yarn test 26 | - run: yarn type-check 27 | - run: yarn lint:ci 28 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | insert_final_newline = true 8 | indent_style = space 9 | indent_size = 2 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | lib/ 3 | renovate.json 4 | tsconfig.json 5 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "@shelf/eslint-config/typescript" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.js text eol=lf 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ['https://send.monobank.ua/2A11P2NhMq'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | .serverless/ 3 | coverage/ 4 | lib/ 5 | node_modules/ 6 | 7 | *.log 8 | junit.xml 9 | draft.js 10 | *.draft.js 11 | 12 | .env 13 | .DS_Store 14 | 15 | # User-specific stuff 16 | .idea/**/workspace.xml 17 | .idea/**/tasks.xml 18 | .idea/**/usage.statistics.xml 19 | .idea/**/shelf 20 | 21 | # File-based project format 22 | *.iws 23 | 24 | .idea/$CACHE_FILE$ 25 | .idea/$PRODUCT_WORKSPACE_FILE$ 26 | .idea/.gitignore 27 | 28 | artifact.zip 29 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 11 | 12 | 14 | 15 | 17 | 18 | 29 | 30 | 31 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/conventionalCommit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/quickreview-for-github.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QuickReview for GitHub 2 | 3 | > Reviewing 50+ Pull Requests a day is no fun. Automate it with keyboard shortcuts 4 | 5 | One day I noticed how quickly one of my friends approves GitHub Pull Requests. He created a browser bookmarklet which executes some JavaScript on click to approve PR via API. 6 | 7 | I thought this is a cool idea and will boost my productivity as I review dozens of PRs everyday. 8 | 9 | 🤔 Problem: too much time spent fiddling with a cursor to hide viewed files, approve or merge PRs. 10 | 11 | 💡 Solution: Automate manual clicks with keyboard shortcuts. 12 | 13 | ![](media/promo/large%20promo%20tile.png) 14 | 15 | # Features 16 | 17 | ## Press `V` to mark files as viewed 18 | 19 | ![](media/feature%20screens/screen%2001%20view.png) 20 | 21 | ## Press `A` to approve PRs 22 | 23 | ![](media/feature%20screens/screen%2002%20approve.png) 24 | 25 | ## Press `M` to merge PRs 26 | 27 | ![](media/feature%20screens/screen%2003%20merge.png) 28 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@babel/preset-typescript', 4 | [ 5 | '@babel/preset-env', 6 | { 7 | targets: { 8 | browsers: ['last 4 chrome versions'] 9 | } 10 | } 11 | ] 12 | ], 13 | plugins: [['@babel/plugin-transform-react-jsx']] 14 | }; 15 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Gemshelf Inc. (shelf.io) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /media/feature screens/screen 01 view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/feature screens/screen 01 view.png -------------------------------------------------------------------------------- /media/feature screens/screen 01 view.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/feature screens/screen 01 view.psd -------------------------------------------------------------------------------- /media/feature screens/screen 02 approve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/feature screens/screen 02 approve.png -------------------------------------------------------------------------------- /media/feature screens/screen 02 approve.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/feature screens/screen 02 approve.psd -------------------------------------------------------------------------------- /media/feature screens/screen 03 merge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/feature screens/screen 03 merge.png -------------------------------------------------------------------------------- /media/feature screens/screen 03 merge.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/feature screens/screen 03 merge.psd -------------------------------------------------------------------------------- /media/promo/large promo tile.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/promo/large promo tile.psd -------------------------------------------------------------------------------- /media/promo/large-promo-tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/promo/large-promo-tile.png -------------------------------------------------------------------------------- /media/promo/marquee promo tile.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/promo/marquee promo tile.psd -------------------------------------------------------------------------------- /media/promo/marquee-promo-tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/promo/marquee-promo-tile.png -------------------------------------------------------------------------------- /media/promo/small promo tile.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/promo/small promo tile.psd -------------------------------------------------------------------------------- /media/promo/small-promo-tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/media/promo/small-promo-tile.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@shelf/xxxxxx", 3 | "version": "0.0.0", 4 | "description": "xxxxxx", 5 | "license": "MIT", 6 | "author": { 7 | "name": "Vlad Holubiev", 8 | "email": "vlad@shelf.io", 9 | "url": "https://shelf.io" 10 | }, 11 | "main": "lib", 12 | "types": "lib/index.d.ts", 13 | "files": [ 14 | "lib" 15 | ], 16 | "scripts": { 17 | "build": "rm -rf lib/ && yarn build:code && yarn build:artifact", 18 | "build:artifact": "[ ! -e artifact.zip ] || rm artifact.zip && (cd lib && zip -r --exclude=*.DS_Store* --exclude=*.js.map ../artifact.zip .)", 19 | "build:code": "NODE_ENV=production webpack", 20 | "coverage": "jest --coverage", 21 | "dev": "NODE_ENV=development webpack --mode=development --watch", 22 | "lint": "eslint . --ext .js,.ts,.json --fix", 23 | "lint:ci": "eslint . --ext .js,.ts,.json", 24 | "test": "jest src", 25 | "type-check": "tsc --noEmit", 26 | "type-check:watch": "npm run type-check -- --watch" 27 | }, 28 | "husky": { 29 | "hooks": { 30 | "pre-commit": "lint-staged" 31 | } 32 | }, 33 | "lint-staged": { 34 | "*.{html,md,yml}": [ 35 | "prettier --write", 36 | "git add" 37 | ], 38 | "*.{js,json,ts,tsx}": [ 39 | "eslint --fix", 40 | "git add" 41 | ] 42 | }, 43 | "prettier": "@shelf/prettier-config", 44 | "jest": { 45 | "testEnvironment": "node" 46 | }, 47 | "dependencies": { 48 | "delegate-it": "1.1.0", 49 | "dom-chef": "3.6.3", 50 | "dom-loaded": "2.0.0", 51 | "element-ready": "4.1.1", 52 | "select-dom": "6.0.2", 53 | "webext-options-sync": "1.2.3" 54 | }, 55 | "devDependencies": { 56 | "@babel/core": "7.10.2", 57 | "@babel/plugin-transform-react-jsx": "7.10.1", 58 | "@babel/preset-env": "7.10.2", 59 | "@babel/preset-typescript": "7.10.1", 60 | "@shelf/eslint-config": "0.16.0", 61 | "@shelf/prettier-config": "0.0.7", 62 | "@types/chrome": "0.0.115", 63 | "@types/copy-webpack-plugin": "5.0.0", 64 | "@types/jest": "26.0.0", 65 | "@types/node": "14.0.13", 66 | "@types/webpack": "4.41.17", 67 | "babel-jest": "26.0.1", 68 | "babel-loader": "8.1.0", 69 | "copy-webpack-plugin": "5.1.1", 70 | "eslint": "7.2.0", 71 | "husky": "4.2.5", 72 | "jest": "26.0.1", 73 | "lint-staged": "10.2.10", 74 | "prettier": "2.0.5", 75 | "typescript": "3.9.5", 76 | "webpack": "4.43.0", 77 | "webpack-bundle-analyzer": "3.8.0", 78 | "webpack-cli": "3.3.11", 79 | "webpack-extension-reloader": "1.1.4" 80 | }, 81 | "publishConfig": { 82 | "access": "public" 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /src/background/background.ts: -------------------------------------------------------------------------------- 1 | import {AnyAction} from '../types'; 2 | import {approvePR, mergePR} from './gh-api'; 3 | import {rerunJob} from './circle-api'; 4 | 5 | chrome.contextMenus.removeAll(); 6 | chrome.contextMenus.create({ 7 | title: 'Rerun Job', 8 | contexts: ['all'], 9 | onclick: async function (info) { 10 | const [workflowId, jobNumber] = info.linkUrl.split('/workflows/')[1].split('/jobs/'); 11 | console.log({workflowId, jobNumber}); 12 | 13 | await rerunJob(workflowId, Number(jobNumber)); 14 | } 15 | }); 16 | 17 | chrome.runtime.onMessage.addListener((message: AnyAction, sender, sendResponse) => { 18 | messageHandler(message, sender, sendResponse); 19 | 20 | return true; 21 | }); 22 | 23 | async function messageHandler( 24 | message: AnyAction, 25 | sender: chrome.runtime.MessageSender, 26 | sendResponse: (response?: any) => void 27 | ) { 28 | console.log('got background message', message); 29 | 30 | if (message.action === 'approve-pr') { 31 | try { 32 | const resp = await approvePR(message.params); 33 | console.log('approve response', resp); 34 | } catch (error) { 35 | console.log('approve error', error); 36 | 37 | return sendResponse({error: `❌ ${error.message}`}); 38 | } 39 | 40 | return sendResponse({}); 41 | } 42 | 43 | if (message.action === 'merge-pr') { 44 | try { 45 | const resp = await mergePR(message.params); 46 | console.log('merge response', resp); 47 | } catch (error) { 48 | console.error('merge error', error); 49 | 50 | return sendResponse({error: `❌ ${error.message}`}); 51 | } 52 | 53 | return sendResponse({}); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/background/circle-api.ts: -------------------------------------------------------------------------------- 1 | import OptionsSync from 'webext-options-sync'; 2 | import {Options} from '../types'; 3 | 4 | export async function rerunJob(workflowId: string, jobNumber: number): Promise { 5 | const jobId = await getJobIdByJobNumber(workflowId, jobNumber); 6 | console.log(`Found job id by job number`, {jobId}); 7 | 8 | await rerunWorkflow(workflowId, jobId); 9 | console.log(`Triggered workflow rerun`); 10 | } 11 | 12 | async function getJobIdByJobNumber(workflowId: string, jobNumber: number): Promise { 13 | const circleToken = await getCircleTokenFromOptions(); 14 | const resp = await fetch(`https://circleci.com/api/v2/workflow/${workflowId}/job`, { 15 | method: 'GET', 16 | headers: { 17 | 'circle-token': circleToken 18 | } 19 | }); 20 | 21 | if (!resp.ok) { 22 | const {message} = await resp.json(); 23 | throw new Error(message); 24 | } 25 | 26 | const json = await resp.json(); 27 | 28 | return json.items.find(i => i.job_number === jobNumber).id; 29 | } 30 | 31 | async function rerunWorkflow(workflowId: string, jobId: string): Promise { 32 | const circleToken = await getCircleTokenFromOptions(); 33 | const resp = await fetch(`https://circleci.com/api/v2/workflow/${workflowId}/rerun`, { 34 | method: 'POST', 35 | headers: { 36 | 'circle-token': circleToken, 37 | 'content-type': 'application/json' 38 | }, 39 | body: JSON.stringify({ 40 | jobs: [jobId] 41 | }) 42 | }); 43 | 44 | if (!resp.ok) { 45 | const {message} = await resp.json(); 46 | throw new Error(message); 47 | } 48 | 49 | return resp.json(); 50 | } 51 | 52 | async function getCircleTokenFromOptions(): Promise { 53 | const optionsStorage = new OptionsSync(); 54 | const {circleToken} = await optionsStorage.getAll(); 55 | 56 | return circleToken; 57 | } 58 | -------------------------------------------------------------------------------- /src/background/gh-api.ts: -------------------------------------------------------------------------------- 1 | import OptionsSync from 'webext-options-sync'; 2 | import {Options} from '../types'; 3 | import {openNewTab} from './helpers/open-tab'; 4 | 5 | export async function approvePR({ 6 | org, 7 | repo, 8 | prNumber, 9 | username 10 | }: { 11 | org: string; 12 | repo: string; 13 | prNumber: string; 14 | username: string; 15 | }): Promise { 16 | const authHeader = await getAuthHeader(username); 17 | 18 | const resp = await fetch( 19 | `https://api.github.com/repos/${org}/${repo}/pulls/${prNumber}/reviews`, 20 | { 21 | method: 'POST', 22 | headers: { 23 | Authorization: authHeader 24 | }, 25 | body: JSON.stringify({ 26 | event: 'APPROVE' 27 | }) 28 | } 29 | ); 30 | 31 | if (!resp.ok) { 32 | const {message} = await resp.json(); 33 | throw new Error(message); 34 | } 35 | 36 | return resp.json(); 37 | } 38 | 39 | export async function mergePR({ 40 | org, 41 | repo, 42 | prNumber, 43 | username 44 | }: { 45 | org: string; 46 | repo: string; 47 | prNumber: string; 48 | username: string; 49 | }): Promise { 50 | const authHeader = await getAuthHeader(username); 51 | 52 | const resp = await fetch(`https://api.github.com/repos/${org}/${repo}/pulls/${prNumber}/merge`, { 53 | method: 'PUT', 54 | headers: { 55 | Authorization: authHeader 56 | } 57 | }); 58 | 59 | if (!resp.ok) { 60 | const {message} = await resp.json(); 61 | throw new Error(message); 62 | } 63 | 64 | return resp.json(); 65 | } 66 | 67 | async function getAuthHeader(username: string): Promise { 68 | const ghToken = await getGitHubTokenFromOptions(); 69 | 70 | if (!ghToken) { 71 | alert('Please set Personal token first!'); 72 | 73 | openNewTab(`chrome://extensions/?options=${chrome.runtime.id}`); 74 | } 75 | 76 | return `Basic ${btoa(`${username}:${ghToken}`)}`; 77 | } 78 | 79 | async function getGitHubTokenFromOptions(): Promise { 80 | const optionsStorage = new OptionsSync(); 81 | const {ghToken} = await optionsStorage.getAll(); 82 | 83 | return ghToken; 84 | } 85 | -------------------------------------------------------------------------------- /src/background/helpers/open-tab.ts: -------------------------------------------------------------------------------- 1 | export function openNewTab(url): void { 2 | chrome.tabs.create({ 3 | url, 4 | active: true 5 | }); 6 | } 7 | -------------------------------------------------------------------------------- /src/features/pull-requests/press-a-approve-m-merge.tsx: -------------------------------------------------------------------------------- 1 | import delegate from 'delegate-it'; 2 | import select from 'select-dom'; 3 | import React from 'dom-chef'; 4 | import domLoaded from 'dom-loaded'; 5 | import {ApprovePRAction, MergePRAction} from '../../types'; 6 | 7 | export async function enableApproveMergeShortcuts(): Promise { 8 | const [org, repo, _, prNumber] = window.location.href 9 | .replace(window.location.search, '') 10 | .split('/') 11 | .slice(3); 12 | await domLoaded; 13 | const username = select('meta[name="user-login"]').getAttribute('content'); 14 | 15 | delegate('html', 'keypress', async event => { 16 | if (isAKeyPressedInBody(event)) { 17 | const wantApprove = confirm('Approve this PR?'); 18 | 19 | if (wantApprove) { 20 | chrome.runtime.sendMessage( 21 | { 22 | action: 'approve-pr', 23 | params: { 24 | org, 25 | repo, 26 | prNumber, 27 | username 28 | } 29 | } as ApprovePRAction, 30 | function (response) { 31 | if (response?.error) { 32 | return insertNotificationBanner(response?.error); 33 | } 34 | 35 | insertNotificationBanner('Your review was submitted successfully.'); 36 | } 37 | ); 38 | } 39 | } 40 | 41 | if (isMKeyPressedInBody(event)) { 42 | const wantMerge = confirm('Merge this PR?'); 43 | 44 | if (wantMerge) { 45 | chrome.runtime.sendMessage( 46 | { 47 | action: 'merge-pr', 48 | params: { 49 | org, 50 | repo, 51 | prNumber, 52 | username 53 | } 54 | } as MergePRAction, 55 | function (response) { 56 | if (response?.error) { 57 | return insertNotificationBanner(response?.error); 58 | } 59 | 60 | insertNotificationBanner('Successfully merged PR'); 61 | } 62 | ); 63 | } 64 | } 65 | }); 66 | } 67 | 68 | function insertNotificationBanner(text: string): void { 69 | select('#js-flash-container').append( 70 |
71 |
72 | 87 | {text} 88 |
89 |
90 | ); 91 | } 92 | 93 | function isAKeyPressedInBody(event: KeyboardEvent): boolean { 94 | const isKeypressInBody = event.target['tagName'] === 'BODY'; 95 | const isKeypressA = event.code === 'KeyA'; 96 | 97 | console.debug({isKeypressInBody, isKeypressA}); 98 | 99 | return isKeypressA && isKeypressInBody; 100 | } 101 | 102 | function isMKeyPressedInBody(event: KeyboardEvent): boolean { 103 | const isKeypressInBody = event.target['tagName'] === 'BODY'; 104 | const isKeypressM = event.code === 'KeyM'; 105 | 106 | console.debug({isKeypressInBody, isKeypressM}); 107 | 108 | return isKeypressM && isKeypressInBody; 109 | } 110 | -------------------------------------------------------------------------------- /src/features/pull-requests/press-v-to-view.ts: -------------------------------------------------------------------------------- 1 | import delegate from 'delegate-it'; 2 | import elementReady from 'element-ready'; 3 | 4 | let currentViewFileCheckbox: HTMLDivElement = null; 5 | 6 | export async function enableViewingFilesOnVPress(): Promise { 7 | delegate('html', 'keypress', event => { 8 | if (!isVKeyPressedInBody(event)) { 9 | return; 10 | } 11 | 12 | currentViewFileCheckbox?.click(); 13 | }); 14 | 15 | delegate('#files', 'mouseover', setCurrentViewFileCheckbox); 16 | 17 | await elementReady('[data-hotkey="v"]'); 18 | 19 | const vHotKeyEl = document.querySelector('[data-hotkey="v"]'); 20 | 21 | if (vHotKeyEl) { 22 | vHotKeyEl.removeAttribute('data-hotkey'); 23 | console.debug('Removed V key binding from "Review Changes" box'); 24 | } 25 | } 26 | 27 | function isVKeyPressedInBody(event: KeyboardEvent): boolean { 28 | const isKeypressInBody = event.target['tagName'] === 'BODY'; 29 | const isKeypressV = event.code === 'KeyV'; 30 | 31 | console.debug({isKeypressInBody, isKeypressV}); 32 | 33 | return isKeypressV && isKeypressInBody; 34 | } 35 | 36 | function setCurrentViewFileCheckbox(event: MouseEvent): void { 37 | const viewFileForm = (event.target as HTMLDivElement) 38 | .closest('.file') 39 | ?.querySelector('form.js-toggle-user-reviewed-file-form'); 40 | 41 | currentViewFileCheckbox = viewFileForm?.querySelector('input[type=checkbox]'); 42 | console.debug('currentViewFileCheckbox', currentViewFileCheckbox); 43 | } 44 | -------------------------------------------------------------------------------- /src/icons/128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/src/icons/128.png -------------------------------------------------------------------------------- /src/icons/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/src/icons/16.png -------------------------------------------------------------------------------- /src/icons/256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/src/icons/256.png -------------------------------------------------------------------------------- /src/icons/48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/src/icons/48.png -------------------------------------------------------------------------------- /src/icons/icon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vladholubiev/quickreview-for-github/0decfd24bab27e1f7034deccbd2c21cf5fd33918/src/icons/icon.psd -------------------------------------------------------------------------------- /src/index.test.ts: -------------------------------------------------------------------------------- 1 | import {getFoo} from './index'; 2 | 3 | it('should return bar', () => { 4 | expect(getFoo()).toEqual('bar'); 5 | }); 6 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import {enableViewingFilesOnVPress} from './features/pull-requests/press-v-to-view'; 2 | import {enableApproveMergeShortcuts} from './features/pull-requests/press-a-approve-m-merge'; 3 | 4 | async function init() { 5 | const {host} = window.location; 6 | 7 | if (host.includes('github.com')) { 8 | enableViewingFilesOnVPress(); 9 | enableApproveMergeShortcuts(); 10 | } 11 | } 12 | 13 | init(); 14 | -------------------------------------------------------------------------------- /src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Quick Review for GitHub", 3 | "description": "Hotkeys for faster code review of Pull Requests on GitHub", 4 | "version": "0.3.2", 5 | "manifest_version": 2, 6 | "permissions": [ 7 | "tabs", 8 | "storage", 9 | "contextMenus", 10 | "https://circleci.com/api/*" 11 | ], 12 | "background": { 13 | "scripts": [ 14 | "background.js" 15 | ] 16 | }, 17 | "icons": { 18 | "16": "icons/16.png", 19 | "48": "icons/48.png", 20 | "128": "icons/128.png", 21 | "256": "icons/256.png" 22 | }, 23 | "options_ui": { 24 | "chrome_style": true, 25 | "page": "options.html" 26 | }, 27 | "content_scripts": [ 28 | { 29 | "run_at": "document_start", 30 | "matches": [ 31 | "https://github.com/*/*/pull/*/files", 32 | "https://app.circleci.com/pipelines/*" 33 | ], 34 | "js": [ 35 | "content-script.js" 36 | ] 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /src/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 |
13 |

GitHub Personal Token

14 |

15 | Click here to create one 20 |

21 |

22 |

23 | Click here to create one 26 |

27 |

28 |

CircleCI Personal Token

29 |
30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/options.ts: -------------------------------------------------------------------------------- 1 | import OptionsSync from 'webext-options-sync'; 2 | 3 | function init() { 4 | const optionsStorage = new OptionsSync(); 5 | optionsStorage.syncForm(document.querySelector('form')); 6 | } 7 | 8 | init(); 9 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | export interface Options { 2 | ghToken?: string; 3 | circleToken?: string; 4 | [key: string]: string | number | boolean; 5 | } 6 | 7 | export type AnyAction = ApprovePRAction | MergePRAction; 8 | 9 | export interface ApprovePRAction { 10 | action: 'approve-pr'; 11 | params: { 12 | org: string; 13 | repo: string; 14 | prNumber: string; 15 | username: string; 16 | }; 17 | } 18 | 19 | export interface MergePRAction { 20 | action: 'merge-pr'; 21 | params: { 22 | org: string; 23 | repo: string; 24 | prNumber: string; 25 | username: string; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "esModuleInterop": true, 5 | "module": "commonjs", 6 | "skipLibCheck": true, 7 | "sourceMap": false, 8 | "target": "esnext", 9 | "jsx": "react" 10 | }, 11 | "exclude": ["node_modules"], 12 | "include": ["src"] 13 | } 14 | -------------------------------------------------------------------------------- /wallaby.config.js: -------------------------------------------------------------------------------- 1 | module.exports = () => { 2 | return { 3 | autoDetect: true, 4 | files: ['package.json', 'src/**/*.ts', '!src/**/*.test.ts'], 5 | tests: ['src/**/*.test.ts'], 6 | env: { 7 | params: { 8 | env: 'TZ=UTC' 9 | } 10 | } 11 | }; 12 | }; 13 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const CopyWebpackPlugin = require('copy-webpack-plugin'); 3 | const ExtensionReloader = require('webpack-extension-reloader'); 4 | 5 | module.exports = { 6 | mode: 'production', 7 | entry: { 8 | 'content-script': './src/index.tsx', 9 | options: './src/options.ts', 10 | background: './src/background/background.ts' 11 | }, 12 | output: { 13 | filename: '[name].js', 14 | path: path.resolve(__dirname, 'lib') 15 | }, 16 | optimization: { 17 | minimize: false 18 | }, 19 | devtool: 'cheap-module-source-map', 20 | module: { 21 | rules: [ 22 | { 23 | test: /\.(ts|js)x?$/, 24 | use: { 25 | loader: 'babel-loader', 26 | options: { 27 | cacheDirectory: true 28 | } 29 | } 30 | } 31 | ] 32 | }, 33 | plugins: [ 34 | process.env.NODE_ENV === 'development' && 35 | new ExtensionReloader({ 36 | manifest: path.resolve(__dirname, 'src/manifest.json') 37 | }), 38 | new CopyWebpackPlugin([{from: 'src/manifest.json'}]), 39 | new CopyWebpackPlugin([{from: 'src/options.html'}]), 40 | new CopyWebpackPlugin([{from: 'src/icons/*.png', to: 'icons/[name].[ext]'}]) 41 | ].filter(e => e), 42 | resolve: { 43 | modules: [path.resolve(__dirname, 'node_modules')], 44 | extensions: ['.ts', '.tsx', '.json', '.js'] 45 | } 46 | }; 47 | --------------------------------------------------------------------------------