summaryrefslogtreecommitdiff
path: root/source/features/linkify-commit-sha.tsx
blob: 99928822476d83c62c9d1bcd4abbcb91cd0245a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import React from 'dom-chef';
import select from 'select-dom';
import {wrap} from '../libs/dom-utils';
import features from '../libs/features';
import * as pageDetect from '../libs/page-detect';

function init(): void {
	const element = select('.sha.user-select-contain');
	if (element) {
		wrap(element, <a href={location.pathname.replace(/pull\/\d+\/commits/, 'commit')}/>);
	}
}

features.add({
	id: __filebasename,
	description: 'Adds link to non-PR commit when visiting a PR commit.',
	screenshot: 'https://user-images.githubusercontent.com/101152/42968387-606b23f2-8ba3-11e8-8a4b-667bddc8d33c.png'
}, {
	include: [
		pageDetect.isPRCommit
	],
	init
});