ssborbis / ContextSearch-web-ext

Search engine manager for modern browsers
337 stars 37 forks source link

Default Engine: If Search inquiry contains ".com" go to website. #673

Closed MachineThatGoesP1NG closed 5 months ago

MachineThatGoesP1NG commented 10 months ago

I'm trying to make it so that if I search "youtube" I get results in Google search for youtube but if I search "youtube.com" then it takes me to the website youtube.com.

I'm sorry i don't know how to code so I'm guessing something like:

Ifinstring, searchTerm, ".com" Website Else Google

I'm pretty much trying to replace ff address bar with your extension — too bad ff doesn't allow custom search engine bars in the toolbar.

ssborbis commented 10 months ago

Which menu are you searching from? I'm sure we can make a bookmarklet that does the job.

MachineThatGoesP1NG commented 10 months ago

Which menu are you searching from? I'm sure we can make a bookmarklet that does the job.

Oh I'm sorry I'm searching from the ?quick menu? from the icon in the toolbar.

ssborbis commented 10 months ago

You can kinda get away with it with a script like this

if ( /\.(.{2,3}$:?)/.test(searchTerms) ) {
     if ( !searchTerms.startsWith("http") ) searchTerms = "http://" + searchTerms;
     window.open(searchTerms, "_blank");
} else 
     window.open("https://www.google.com/search?q=" + searchTerms, "_blank");