blob: 66ca120a7ae2606f04d1ea7bfe9b22e7f6e0a5a6 (
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
24
25
26
27
28
29
30
31
|
import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';
import {wrap} from '../helpers/dom-utils';
import features from '.';
import {buildRepoURL, getRepo} from '../github-helpers';
function init(): void {
const references = getRepo()!
.path
.replace('compare/', '')
.split('...')
.reverse();
// Compares against the "base" branch if the URL only has one reference
if (references.length === 1) {
references.unshift(select('.branch span')!.textContent!);
}
const icon = select('.octicon-arrow-left')!;
icon.parentElement!.attributes['aria-label'].value += '.\nClick to swap.';
wrap(icon, <a href={buildRepoURL('compare/' + references.join('...'))}/>);
}
void features.add(__filebasename, {
include: [
pageDetect.isCompare
],
init
});
|