summaryrefslogtreecommitdiff
path: root/source/helpers/open-tabs.ts
blob: 78619cdfb226f4dccd5164352d17708040694c2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import showToast from '../github-helpers/toast.js';
import pluralize from '../helpers/pluralize.js';

export default async function openTabs(urls: string[]): Promise<boolean> {
	if (urls.length >= 10 && !confirm(`This will open ${urls.length} new tabs. Continue?`)) {
		return false;
	}

	const response = browser.runtime.sendMessage({
		openUrls: urls,
	});

	await showToast(response, {
		message: 'Opening…',
		doneMessage: pluralize(urls.length, '$$ tab') + ' opened',
	});

	return true;
}