UrlChecker icon indicating copy to clipboard operation
UrlChecker copied to clipboard

allow searching with search engine

Open KorigamiK opened this issue 1 year ago • 7 comments

Describe a related problem (optional)

When sharing a search query that's not a url the app doesn't allow any actions. Screenshot_2024-09-04-02-59-55-12_21561dfd7cdb810023cdb17e8b11e256

Describe your suggested feature

An ability to use the input as a search query to open in the browser which searches on Google et al. as a popover (not persisting this tab) would be great.

Describe alternatives you've considered for your suggested feature

No response

Other details

No response

Acknowledgements

  • [X] I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
  • [X] I have written a short but informative title.
  • [X] I will fill out all of the requested information in this form.

KorigamiK avatar Sep 03 '24 21:09 KorigamiK

Several things here:

When sharing a search query that's not a url the app doesn't allow any actions.

The open button is disabled since there is no app that can open that url (because it's not a url). However the share option is still available. Some apps like Firefox allow you to 'send' them text and they will automatically perform a search (but I know is not as 'simple' as opening a url)

An ability to use the input as a search query to open in the browser which searches on Google et al.

Another alternative is to use a pattern to convert any text to a url of the search itself. This one for example for google:

  "Search on google": {
    "encode": true,
    "regex": ".*",
    "replacement": "https:\/\/www.google.com\/search?q=$0"
  }

as a popover (not persisting this tab) would be great.

That is achieved by using the custom tabs button (the one at the left of the open module, in your screenshot opening as custom tab is already enabled) image

I'll keep this issue open because maybe a separate module to choose to search with different search providers may be useful, in case it is implemented in the future.

TrianguloY avatar Sep 04 '24 18:09 TrianguloY

Screenshot_2024-09-05-00-24-15-47_6f8f7a6a69f2aa2976412416ecb84f7a.jpg

Great! Do you know if there is a way to add a urlChecker to this popup context menu on any selected text (I'm not sure of the name)

KorigamiK avatar Sep 04 '24 18:09 KorigamiK

Not currently, there is https://github.com/TrianguloY/UrlChecker/issues/191 to implement it.

Maybe there is an app that you can use to add arbitrary shortcuts to that menu?

You will always have the share->URLCheck option though...

TrianguloY avatar Sep 04 '24 19:09 TrianguloY

That is achieved by using the custom tabs button (the one at the left of the open module, in your screenshot opening as custom tab is already enabled)

Although sharing to firefox works, this doesn't solve my problem. Firefox still opens a new tab to search this query. The share button doesn't respect the custom tabs button.

I also wasn't able to figure out how the regex replacement works and how I can use in the app.

KorigamiK avatar Sep 04 '24 20:09 KorigamiK

Although sharing to firefox works, this doesn't solve my problem. Firefox still opens a new tab to search this query. The share button doesn't respect the custom tabs button.

Arg, you are right, the custom tabs are only for opening.

I also wasn't able to figure out how the regex replacement works and how I can use in the app.

You should:

  1. open the app > modules > pattern checker > advanced editor
  2. scroll to the bottom, then paste the snippet above before the last close bracket "}" and also add a comma before it.

Assuming you have the default patterns, you sould have at the end this:

...
  "Youtube ➔ Invidious": {
    "regex": "^https?:\/\/(?:[a-z0-9-]+\\.)*?youtube.com\/(.*)",
    "replacement": [
      "https:\/\/yewtu.be\/$1",
      "https:\/\/farside.link\/invidious\/$1"
    ],
    "enabled": "false"
  }
}

And after pasting as explained you should have this instead (remember the extra comma!)

...
  "Youtube ➔ Invidious": {
    "regex": "^https?:\/\/(?:[a-z0-9-]+\\.)*?youtube.com\/(.*)",
    "replacement": [
      "https:\/\/yewtu.be\/$1",
      "https:\/\/farside.link\/invidious\/$1"
    ],
    "enabled": "false"
  },
  "Search on google": {
    "encode": true,
    "regex": ".*",
    "replacement": "https:\/\/www.google.com\/search?q=$0"
  }
}

If pasted correctly pressing save will close the dialog. Then make sure the module is enabled, and next time you open the app you will find an "apply - search on google" button.

Using other searches should be easy, but if you are having issues just say which page you want and I'll create it for you.

Btw: you can check other patterns here: https://github.com/TrianguloY/UrlChecker/wiki/Custom-patterns

TrianguloY avatar Sep 04 '24 21:09 TrianguloY

Another alternative is to use a pattern to convert any text to a url of the search itself. This one for example for google:

"Search on google": { "encode": true, "regex": ".*", "replacement": "https://www.google.com/search?q=$0" }

The regex here and in the wiki seems to be wrong. When applying it on a word test, I'm getting https://www.google.com/search?q=testhttps://www.google.com/search?q=. Tested on 2 devices, both were on the latest version of the app.

To fix it, use ^(.*)$ as the regex and $1 instead of $0 in the replacement (maybe $0 works too?).

"Search on google": {
    "encode": true,
    "regex": "^(.*)$",
    "replacement": "https:\/\/www.google.com\/search?q=$1"
  }

Also, for DuckDuckGo:

"Search on DuckDuckGo": {
    "encode": true,
    "regex": "^(.*)$",
    "replacement": "https:\/\/duckduckgo.com?q=$1"
  }

Notice also that it should be Search on DuckDuckGo instead of Search on google in the wiki for DDG. Also, shouldn't there be a (escaped) slash "/" \/ before ?q=$1? It currently works, but not sure which one is the correct way.

@TrianguloY please update the wiki page. I couldn't find an edit button there so searched for an issue about "search on Google" and found this.

Bakr-Ali avatar Jan 17 '25 17:01 Bakr-Ali

Updated, thank you!

It's strange that it doesn't work, I may need to review the replacement code, but your suggestion is also a good one so I just changed it.

As for the escaped slash, it's just a matter of preference. Urls can end on a slash or not, and most pages will accept both (google and ddg included). Only some very special servers may behave differently between example.com and example.com/, but that's very unusual.

Ah, and for the edit permissions, originally it was open for anyone, but it was vandalized and I had to restrict to collaborators only, sorry :(

TrianguloY avatar Jan 17 '25 18:01 TrianguloY