summaryrefslogtreecommitdiff
path: root/source/features/preserve-whitespace-option-in-nav.tsx
blob: 65ecbffc69a16d87970e14aed3dc1aa31baace48 (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
import select from 'select-dom';
import features from '../libs/features';

function init(): false | void {
	if (new URLSearchParams(location.search).get('w') !== '1') {
		return false;
	}

	for (const a of select.all<HTMLAnchorElement>('[data-hotkey="p"], [data-hotkey="n"]')) {
		const linkUrl = new URLSearchParams(a.search);
		linkUrl.set('w', '1');
		a.search = String(linkUrl);
	}
}

features.add({
	id: __featureName__,
	description: 'Preserves the "ignore whitespace" setting when navigating with Next/Previous in PR review mode.',
	screenshot: false,
	include: [
		features.isRepo
	],
	load: features.onAjaxedPages,
	init
});