blob: c99a8aaae512f1a48c1d1ccff2bffe8452751394 (
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 select from 'select-dom';
import delegate from 'delegate-it';
import * as pageDetect from 'github-url-detection';
import features from '.';
function jumpToFirstNonViewed(): void {
const firstNonViewedFile = select('.file:not([data-file-user-viewed])')!;
if (firstNonViewedFile) {
// Scroll to file without pushing to history
location.replace('#' + firstNonViewedFile.id);
} else {
// The file hasn't loaded yet, so make GitHub load it by scrolling to the bottom
window.scrollTo(window.scrollX, document.body.scrollHeight);
}
}
function init(): void {
delegate(document, '.diffbar-item progress-bar', 'click', jumpToFirstNonViewed);
select('.diffbar-item progress-bar')!.style.cursor = 'pointer';
}
void features.add(__filebasename, {
include: [
pageDetect.isPRFiles
],
exclude: [
pageDetect.isPRFile404
],
init
});
|