summaryrefslogtreecommitdiff
path: root/source/features/trending-menu-item.tsx
blob: 02b18a425b2b7cdc5f902d15f19a1b814f3c0d7a (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
import React from 'dom-chef';
import onetime from 'onetime';
import elementReady from 'element-ready';
import * as pageDetect from 'github-url-detection';

import features from '.';

async function init(): Promise<false | void> {
	const exploreLink = await elementReady('.Header-link[href="/explore"]');
	if (!exploreLink) {
		return false;
	}

	exploreLink.before(
		<a href="/trending" className={exploreLink.className} data-hotkey="g t">Trending</a>
	);
}

void features.add({
	id: __filebasename,
	description: 'Adds a `Trending` link to the global navbar and a keyboard shortcut: `g` ` t`',
	screenshot: false,
	shortcuts: {
		'g t': 'Go to Trending'
	}
}, {
	exclude: [
		pageDetect.isGist
	],
	waitForDomReady: false,
	init: onetime(init)
});