blob: 07f4641bfc96cc223e4fc0a707ad13abda69334b (
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
|
import select from 'select-dom';
import features from '../libs/features';
function init(): void {
const tabs = select.all('.tabnav-pr .tabnav-tab');
const selectedIndex = tabs.indexOf(select('.tabnav-pr .selected')!);
const lastTab = tabs.length - 1;
for (const [index, tab] of tabs.entries()) {
const keys = [`g ${index + 1}`];
if (index === selectedIndex - 1 || (selectedIndex === 0 && index === lastTab)) {
keys.push('g ArrowLeft');
} else if (index === selectedIndex + 1 || (selectedIndex === lastTab && index === 0)) {
keys.push('g ArrowRight');
}
tab.dataset.hotkey = String(keys);
}
}
features.add({
id: __featureName__,
description: 'Adds keyboard shortcuts to cycle through PR tabs: `g` `←` and `g` `→`, or `g` `1`, `g` `2`, `g` `3` and `g` `4`',
screenshot: false,
include: [
features.isPR
],
load: features.onAjaxedPages,
shortcuts: {
'g 1': 'Go to Conversation',
'g 2': 'Go to Commits',
'g 3': 'Go to Checks',
'g 4': 'Go to Files changed'
},
init
});
|