CanisLupus / swift-selection-search

Swift Selection Search (SSS) is a simple Firefox add-on that lets you quickly search for some text in a page using your favorite search engines.
https://addons.mozilla.org/firefox/addon/swift-selection-search/
MIT License
213 stars 27 forks source link

Search for a phrase ("Problem report") instead of all results that include the words (Problem+report) #211

Closed gitupdown closed 3 years ago

gitupdown commented 3 years ago

I want to set certain search engines to search for phrases and not simply word combinations. For instance,

  1. On a Github problem report page, you see the phrase, "Issue: Problem report" and want to Google it.

  2. You use your mouse to select the phrase, "Issue: Problem report". If you go to Google.com and use quotation marks around the phrase at issue, you'll get fewer than 40,000 results. (On my browser address bar, the url for this results page reads google.com/search?q="Issue%3A+Problem+report” ; when I copy the address and paste it here, it comes out as google.com/search?q=%22Issue%3A+Problem+report%22 )

  3. But just using ={searchTerms}, you get more than 2 million results containing any approximate combination of the three words issue, problem, and report (i.e, the url google.com/search?q=Issue%3A+Problem+report)

I see that you can use slashes to replace, perhaps, a space (" ") with a plus sign ("+"). But I can't figure out how set the search url to put quotation marks around a string of words in order to search for a phrase.

System info:

Any advice or enhancements would be greatly appreciated. Anyway, thanks so much for your work on this.

EX.1: Search as phrase = under 40,000 results SSS Search phrase 39k results - Copy

EX.2: Current Default-Find all 2 million+ pages that include words contained in the phrase SSS Search no phrase 2m results chrome - Copy

ZIEXED commented 3 years ago

If you want to search for "Issue: Problem report" instead of Issue: Problem report just put "{searchTerms}" instead of {searchTerms} if you want to replace space with + then use {searchTerms{ |+}} (put it between quotation marks if you want both) "{searchTerms{ |+}}"

CanisLupus commented 3 years ago

Hey @gitupdown, could you tell us if what ZIEXED said solves the problem for you?

An additional possibility is using quotes ONLY if the selected text contains a space between some characters. You could do this with a regex like in {searchTerms{re/(.+ .+)/|"$1"}}.

gitupdown commented 3 years ago

@ZIEXED Thanks so much. Works perfectly. @CanisLupus sorry for the delay, and thanks for advising me to report back. It didn't occur to me that I should do so.

CanisLupus commented 3 years ago

No problem, thanks for reporting back! ;) I'll close this issue now.