import './patch-diff-links.css'; import React from 'dom-chef'; import select from 'select-dom'; import features from '../libs/features'; import {isPRCommit} from '../libs/page-detect'; function init(): void { let commitUrl = location.pathname.replace(/\/$/, ''); if (isPRCommit()) { commitUrl = commitUrl.replace(/\/pull\/\d+\/commits/, '/commit'); } select('.commit-meta > :last-child')!.append( patch { ' ' /* Workaround for: JSX eats whitespace between elements */ } diff ); } features.add({ id: __featureName__, description: 'Adds links to `.patch` and `.diff` files in commits.', screenshot: 'https://cloud.githubusercontent.com/assets/737065/13605562/22faa79e-e516-11e5-80db-2da6aa7965ac.png', include: [ features.isCommit ], load: features.onAjaxedPages, init });