Opening custom extension's URL with a non-default web browser

I’m using some basic extension snippets, which has name, icon, and URL.

And I’m wondering if it is possible for a custom extension to open its custom URL with a browser that is not system-default.

1 Like

You can always make Choosy your default browser. It’s a really powerful way to use different browsers for different sites, or under different circumstances, etc.

1 Like

You can indeed:

#popclip
name: URL app example
javascript: |
  popclip.openUrl('https://xkcd.com', {app: 'com.brave.Browser'})
1 Like

Thanks! But I see an error message when I try to import it. The error message is: "JS: SyntaxError: Invalid character '\u2018` (line 1)
Do you have an idea of what causes the error in the following script?

#popclip
name: [name]
icon: square filled [name]
javascript: |
  popclip.openUrl('https://[website's name].org/v2/search?queryString=***&clusterResults=on&stickyFacetsChecked=on&baseScope=sz%3A36213', {app: ‘Google Chrome’})

Oddly enough that snippet is actally crashing my PopClip! Ooof…

/u2018 is unicode for a left quotation mark … perhaps you have smart quotes turned on in your editor? It has to be a plain old vertical single quote.

And of course your placeholder text website's name has a ' in it which is terminating the string eartly.

Otherwise looks fine except you need to specify the app as a bundle id e.g. com.google.Chrome.
(For finding bundle ID see also here)

Nick, you were right! It was smart quotes. And I also updated the bundle id. Now it is successfully imported and works, but the problem is that custom keyword *** does not reflect the selected portion of texts.
So no matter what text I choose, the search keyword is ***.

Do you have any idea?

Ah yes, I should have caught that. The *** shorthand only works in a url: field of the extension. In javascript you will have to manually build the string.

For example:

popclip.openUrl(`https://xyz.org/?q=${encodeURIComponent(popclip.input.text)}`)

Notes:

Thanks, Nick.
Then, what portion of that code needs to replace ***?

This part: ${encodeURIComponent(popclip.input.text)}

If you want to post an example you are trying to get working (not with placeholders), I can correct it.

Thanks Nick,

Since I can’t make it work, please correct these two extensions:

# popclip
name: GCTS Library
icon: square filled GC
javascript: |
  const term = encodeURIComponent(popclip.input.text)
  const url = `https://gordonconwell.on.worldcat.org/v2/search?queryString=${term}&clusterResults=on&stickyFacetsChecked=on&baseScope=sz%3A36213`
  popclip.openUrl(url, {app: 'com.google.Chrome'})

# popclip
name: TIU Library
icon: square filled TIU
javascript: |
  const term = encodeURIComponent(popclip.input.text)
  const url = `https://i-share-tiu.primo.exlibrisgroup.com/discovery/search?institution=01CARLI_TIU&vid=01CARLI_TIU:CARLI_TIU&tab=LibraryCatalog&search_scope=MyInstitution&mode=Basic&displayMode=full&bulkSize=10&highlight=true&dum=true&query=any,contains,${term}&displayField=all&scopeSelecter=LibraryCatalog&pcAvailabiltyMode=`
  popclip.openUrl(url, {app: 'com.google.Chrome'})

Edited in the post, enjoy!

1 Like