blob: 4c907cd77cac0a6540d20bd6cfc76d20d613e475 (
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
32
33
34
35
36
37
|
import React from 'dom-chef';
import select from 'select-dom';
import FileIcon from 'octicon/file.svg';
import * as pageDetect from 'github-url-detection';
import features from '.';
import GitHubURL from '../github-helpers/github-url';
import {groupSiblings} from '../github-helpers/group-buttons';
function init(): void | false {
const {filePath} = new GitHubURL(location.href);
if (!filePath) {
return false;
}
for (const rootLink of select.all<HTMLAnchorElement>('[aria-label="Browse the repository at this point in the history"]')) {
// `rootLink.pathname` points to /tree/ but GitHub automatically redirects to /blob/ when the path is of a file
rootLink.before(
<a
href={rootLink.pathname + '/' + filePath}
className="btn btn-outline tooltipped tooltipped-sw"
aria-label="See object at this point in the history"
>
<FileIcon/>
</a>
);
groupSiblings(rootLink);
}
}
void features.add(__filebasename, {
include: [
pageDetect.isRepoCommitList
],
init
});
|