Open links in background

When I highlight text and then click, say, the DuckDuck Go extension, the search opens in a new tab which takes focus. Is it possible to have the new tab open in the background so I can stay in the tab in which I did the pop clip search?
Thanks!
Dave.

1 Like

Welcome @dave and thanks for the suggestion. It’s not possible right now but this would be a welcome addition. Opening links in the background is a bit tricky though and browser dependent. I’ve not attempted it as yet.

Yeah it’s a browser specific preference setting. Check them and turn off “Switch to New Tab when opening”

Does that work for tabs opened by PopClip though?

That said, I have actually started working on this in PopClip. Should get it working for Safari and Chrome, but not Firefox.

When I learned about popclip this morning I immediately installed it and hoped I could do this. After seeing that in doesn’t, I looked for a way to do it with a custom sequence of commands. The following should do it in chrome in mac os

#popclip snippet to search in new tab in background
name: Bg search
title: searchBg
Icon: search filled Bg
key combos:
- command c
- command l
- command v
- command return
- escape

The snippet copies selected text, selects address bar (command l), pastes, then opens result in new tab in the background (command return). The last command just gets rid of the drop down portion of the address bar.

EDIT: is it possible to modify the wait time between commands? The default 1/10 of a second adds up and if we could insert a wait in between each command (for e.g. 1/100), the whole sequence would seem instantaneous.

1 Like

Hi Nick… Any update for Firefox yet?

Actually, this is highly needed… I don’t want to get distracted from immediate opening of any key word search but in the background, it should open the specific search tab.

–

Dishant

Not currently, but that’s a great suggestion.

No. I still think I should be able to do it for Chrome and Safari, but it’s unlikely to be possible with Firefox. The issue is that Firefox does not support AppleScript.

Oh, Okay.

By the way, in Chromium based - Microsoft Edge, I tried, but it was not working. Is it so?

There’s no Open link in background with PopClip on any browser yet.

Gotcha, Thanks!

1 Like

You can try this:

#popclip - classic YAML snippet
name: DuckDuckGo
icon: D
applescript: |
  tell application "Google Chrome"
    activate
    set theWindow to window 1
    set theTabIndex to active tab index of theWindow
    set theBaseURL to "https://duckduckgo.com/"
    set theQuery to do shell script "python3 -c 'import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))' " & quoted form of "{popclip text}"
    set theURL to theBaseURL & "?q=" & theQuery
    make new tab at theWindow with properties {URL:theURL}
    set active tab index of theWindow to theTabIndex
  end tell
3 Likes

Hi Dear Drunlin,

I treid by Changing the Google Chrome to Firefox, but it didn’t work. Anything else, do I need to change?

I want the Google search on either Firefox or Microsoft Edge browser.

Please help me and many thanks for the Code… it will surely help me to speed up my productivity.

–

Best,

Dishant

This extension uses the AppleScript API provided by Chrome, so it is not compatible with Firefox.

For Microsoft Edge:

#popclip - classic YAML snippet
name: Google
icon: G
applescript: |
  tell application "Microsoft Edge"
    activate
    set theWindow to window 1
    set theTabIndex to active tab index of theWindow
    set theBaseURL to "https://www.google.com/search"
    set theQuery to do shell script "python3 -c 'import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))' " & quoted form of "{popclip text}"
    set theURL to theBaseURL & "?q=" & theQuery
    make new tab at theWindow with properties {URL:theURL}
    set active tab index of theWindow to theTabIndex
  end tell
1 Like

Oh, I don’t know why, but it still doesn’t work.

Moreover, every time, I select, it asks to install, why is it so? @ Nick. I think, there should be some mechanism which understands and pops-up that, this extension is already installed.

  1. Go to System Settings > Privacy & Security > Automation > PopClip, check the permission.

  2. Run the script below in the Script Editor app to test it.

tell application "Microsoft Edge"
	activate
	set theWindow to window 1
	set theTabIndex to active tab index of theWindow
	set theBaseURL to "https://www.google.com/search"
	set theQuery to do shell script "python3 -c 'import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))' " & quoted form of "test"
	set theURL to theBaseURL & "?q=" & theQuery
	make new tab at theWindow with properties {URL:theURL}
	set active tab index of theWindow to theTabIndex
end tell
1 Like

Oh, PopClip is not listed under Automation. What to do?

Maybe the extension was not installed successfully. To install an extension snippet , see [ Introducing Extension Snippets.

When the extension is installed, you should see a “G” icon in the PopClip menu. When you click the icon at the first time, the system permission prompt will show. And the PopClip app on my Mac is the website version.

image

The extension is already installed.

An update on this request. I’ve added a feature to the latest PopClip Beta (Build 4507) whereby holding Shift (⇧) when clicking the action button will open the page in a background tab.

This applies to the built in Search and Open Link actions, as well as any extension that open URLs.

It only works in some browsers, namely Safari, Chrome, Arc, and most Chromum-based browsers. (Notably it it does NOT work in Firefox, unfortunately, because Firefox does not support scripting for opening tabs.)

if you get a chance to try it, please let me know if it is working for you.