blob: 4258350205d82e94c233100f6be5f624efc99a5d (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
import React from 'dom-chef';
import select from 'select-dom';
import elementReady from 'element-ready';
import * as pageDetect from 'github-url-detection';
import features from '../feature-manager.js';
import {getRepo} from '../github-helpers/index.js';
import getUserAvatar from '../github-helpers/get-user-avatar.js';
async function init(): Promise<void> {
// Icon for public but not template/fork/etc. repos
const icon = await elementReady('#repository-container-header .octicon-repo');
if (!icon) {
return;
}
const link = select('#repository-container-header a[rel="author"]')!.cloneNode();
const username = getRepo()!.owner;
const size = 24;
const src = getUserAvatar(username, size)!;
const avatar = (
<img
className="avatar mr-2 d-block"
src={src}
width={size}
height={size}
alt={`@${username}`}
/>
);
link.append(avatar);
icon.replaceWith(link);
if (link.dataset.hovercardType !== 'organization') {
avatar.classList.add('avatar-user');
}
}
void features.add(import.meta.url, {
include: [
pageDetect.hasRepoHeader,
],
deduplicate: 'has-rgh',
init,
});
/*
## Test URLs
- org repo: https://github.com/refined-github/refined-github
- user repo: https://github.com/fregante/GhostText
*/
|