<commit_before>import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';

import features from '.';
import {getCleanPathname} from '../github-helpers';

function buildUrl(queryField: string): URL {
	const url = new URL('/search', location.href);
	url.searchParams.set('o', 'desc');
	url.searchParams.set('q', `user:${getCleanPathname()}`);
	url.searchParams.set('s', queryField);
	url.searchParams.set('type', 'Repositories');
	return url;
}

function init(): void {
	// Showcase title
	select('.js-pinned-items-reorder-container .text-normal')!.firstChild!.after(
		' / ',
		<a href={String(buildUrl('stars'))}>Top repositories</a>
	);
}

void features.add(__filebasename, {
	include: [
		pageDetect.isUserProfileMainTab
	],
	init
});<commit_msg>Simplify `show-user-top-repositories` (#4235)<commit_after>import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';

import features from '.';

function buildUrl(): URL {
	const url = new URL(location.pathname, location.href);
	url.searchParams.set('tab', 'repositories');
	url.searchParams.set('sort', 'stargazers');
	return url;
}

function init(): void {
	// Showcase title
	select('.js-pinned-items-reorder-container .text-normal')!.firstChild!.after(
		' / ',
		<a href={String(buildUrl())}>Top repositories</a>
	);
}

void features.add(__filebasename, {
	include: [
		pageDetect.isUserProfileMainTab
	],
	init
});
{'fraction_non_alphanumeric': 0.17555705604321403, 'fraction_numerical': 0.0027008777852802163, 'mean_word_length': 5.253164556962025, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1452057', 'n_tokens_mistral': 519, 'n_tokens_neox': 494, 'n_words': 101}