blob: 0595a51fe9d0d05cc2be3c1b9c31f599f821a7ea (
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 delegate from 'delegate-it';
import * as pageDetect from 'github-url-detection';
import features from '.';
import looseParseInt from '../helpers/loose-parse-int';
/*
The ajaxed form that loads the new comments points to a URL like:
/_render_node/MDExOlB1bGxSZXF1ZXN0MjE2MDA0MzU5/timeline/more_items?variables%5Bafter%5D=Y3Vyc29yOnYyOpPPAAABZemjg2AAqTQyMjE5MTk1MQ%3D%3D&variables%5Bbefore%5D=Y3Vyc29yOnYyOpPPAAABaENrVHAAqTQ1Mzc3MjMzNg%3D%3D&variables%5Bfirst%5D=60&variables%5BhasFocusedReviewComment%5D=false&variables%5BhasFocusedReviewThread%5D=false
The parameter `variables[first]` controls how many additional comments are fetched. We change this number from 60 to the total number of hidden items to have it load all of them at once.
*/
function handleAltClick(event: delegate.Event<MouseEvent, HTMLButtonElement>): void {
if (!event.altKey) {
return;
}
const form = event.delegateTarget.form!;
const hiddenItemsCount = Math.min(
200, // It fails with more than this https://github.com/sindresorhus/refined-github/issues/2931#issuecomment-603818778
looseParseInt(form),
);
const url = new URL(form.action);
url.searchParams.set('variables[first]', String(hiddenItemsCount));
form.action = url.href;
}
function init(): void {
delegate(document, '.ajax-pagination-form button[type="submit"]', 'click', handleAltClick);
}
void features.add(__filebasename, {
include: [
pageDetect.isConversation,
],
init,
});
|