summaryrefslogtreecommitdiff
path: root/source/features/preserve-whitespace-option-in-nav.tsx
blob: 4a5eab2b74b4b133fbc74cdcbbdda0a25c78d036 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';

import features from '.';

function init(): void {
	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);
	}
}

void features.add(__filebasename, {
	include: [
		pageDetect.isRepo
	],
	exclude: [
		() => new URLSearchParams(location.search).get('w') !== '1'
	],
	init
});