Add switch option to open search box result in same tab #476

This makes it easier to search when homer is set as the default for a new
tab.

Co-authored-by: Momcilo Bajalovic <momcilobajalovic@Momcilos-Air.lan>
This commit is contained in:
Momcilo42
2022-10-21 21:58:35 +02:00
committed by GitHub
parent e028fe29bb
commit fdecf24905
5 changed files with 72 additions and 3 deletions

View File

@@ -153,20 +153,22 @@ export default function SearchBar(props: any) {
}}
onSubmit={form.onSubmit((values) => {
const query = values.query.trim();
const open_in = config.settings.searchNewTab ? '_blank' : '_self';
setTimeout(() => {
form.setValues({ query: '' });
switch (query.substring(0, 3)) {
case '!yt':
window.open(`https://www.youtube.com/results?search_query=${query.substring(3)}`);
window.open(`https://www.youtube.com/results?search_query=${query.substring(3)}`, open_in);
break;
case '!t ':
window.open(`https://www.torrentdownloads.me/search/?search=${query.substring(3)}`);
window.open(`https://www.torrentdownloads.me/search/?search=${query.substring(3)}`, open_in);
break;
case '!os':
break;
default:
window.open(
`${queryUrl.includes('%s') ? queryUrl.replace('%s', query) : `${queryUrl}${query}`}`
`${queryUrl.includes('%s') ? queryUrl.replace('%s', query) : `${queryUrl}${query}`}`,
open_in
);
break;
}