blob: 1916abf8bc35cf042b08a4e6b54bac2cfd51f5c5 (
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
|
import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';
import {wrap} from '../helpers/dom-utils.js';
import features from '../feature-manager.js';
import observe from '../helpers/selector-observer.js';
function linkifyLabel(label: Element): void {
const activity = label.closest('div:not([class])')!;
const isPR = select.exists('.octicon-git-pull-request', activity);
const repository = select('a[data-hovercard-type="repository"]', activity)!;
const url = new URL(`${repository.href}/${isPR ? 'pulls' : 'issues'}`);
const labelName = label.textContent.trim();
url.searchParams.set('q', `is:${isPR ? 'pr' : 'issue'} is:open sort:updated-desc label:"${labelName}"`);
wrap(label, <a href={url.href}/>);
}
function init(signal: AbortSignal): void {
observe('.news :not(a) > .IssueLabel', linkifyLabel, {signal});
}
void features.add(import.meta.url, {
include: [
pageDetect.isDashboard,
],
init,
});
|