Opening a URL in Chrome's Incognito mode

Sharing and discussing custom search templates for LaunchBar
joebeone
Posts: 5
Joined: Tue Sep 07, 2010 9:37 pm

Opening a URL in Chrome's Incognito mode

Postby joebeone » Fri Feb 13, 2015 4:45 pm

Heya, I regularly want to open a copied URL in Chrome's Incognito mode... I realize this isn't a search template as it's not just a formatted URL passed to a browser application. I've found a rather kludgy way of doing this with a bash script, but I wonder if there isn't a better way?

Here is the post where I outline my hack in another part of this forum.

I'll include a bit of it below:

You have to enable Unix Directories in the Index and then put a simple bash script (that is executable) in a place like /usr/bin... e.g.,

Code: Select all

#!/bin/bash
for url in "$@" ; do
    dummy=`/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --incognito ${url}`
done


This is a bash script that accepts a string as input (the url) and then passes that off to a command-line launch of Chrome in incognito mode. I don't think you need the loop and I'll probably remove it when I clean this up for a blog post. Copy this and put into a text file named something like "google-chrome-incognito". Make it executable by doing "chmod gou+x google-chrome-incognito". You should be able to type "./google-chrome-incognito http://www.example.com/" and it should open that url in Chrome in incognito mode.

When you've checked that that works, put this somewhere like /usr/bin/. Open Launchbar's Index and activate "Unix Directories".

Now comes the kludgy part... as an aside, I use this to open URLs that I suspect to be full of tracking elements like cookies and such (e.g., unsubscribe URLs from many, many emails I get). Here is how you use it with Launchbar...

  • Hit command-space (or your Launchbar shortcut) and type "inco"...
  • You should see your script "google-chrome-incognito" in the list, likely not first.
  • Select it and hit spacebar to pass a string to it... type something like http://www.example.com/ and hit Option-Return (which instead of launching a terminal instance, launches the command in the background).
  • Verify that this does indeed launch the url in Chrome in Incognito mode with the URL you entered.

now, this pretty much works. However, if you pass a complicated URL with special characters for the command-line like question marks or apersands, the full URL won't make it through to the script. :/ In that case, after hitting the space bar, you'll need to type a single quote ('), then paste your url, and end with a single quote ('). This will ensure that anything in the URL will not be interpreted by the command-line to be a command-line operator or delimiter.

There must be a less kludgy way of doing this!

logicfault
Posts: 6
Joined: Thu May 14, 2015 3:22 pm

Re: Opening a URL in Chrome's Incognito mode

Postby logicfault » Thu May 14, 2015 3:37 pm

My solution to opening a URL in Chrome's incognito mode is to save the following Applescript to ~/Library/Application Support/LaunchBar/Actions:

Code: Select all

on handle_string(theUrl)
    if theUrl does not start with "http" then
        set theUrl to "http://" & theUrl
    end if

    tell application "Google Chrome"
        tell (make new window with properties {mode:"incognito"})
            set URL of active tab to theUrl
        end tell
        activate
    end tell
end handle_string


This script has room for improvement, but hopefully it is a little less kludgy than the shell script.

joebeone
Posts: 5
Joined: Tue Sep 07, 2010 9:37 pm

Re: Opening a URL in Chrome's Incognito mode

Postby joebeone » Thu May 14, 2015 10:05 pm

Nice! I will give it a try... and yes, that shell script is hella kludgy. :/

logicfault
Posts: 6
Joined: Thu May 14, 2015 3:22 pm

Re: Opening a URL in Chrome's Incognito mode

Postby logicfault » Mon May 18, 2015 7:47 am

Updated the script and created a Launchbar extension. See viewtopic.php?f=24&t=9822

prenagha
Rank 3
Rank 3
Posts: 87
Joined: Mon Nov 05, 2012 4:10 pm

Re: Opening a URL in Chrome's Incognito mode

Postby prenagha » Wed Sep 09, 2015 5:56 am


Olinelooo
Posts: 1
Joined: Sat Apr 23, 2016 12:16 pm

Re: Opening a URL in Chrome's Incognito mode

Postby Olinelooo » Sat Apr 23, 2016 12:25 pm

I use this to open URLs that I suspect to be full of tracking elements like cookies and such (e.g., unsubscribe URLs from many, many emails I get). Here is how you use it with Launchbar...????



== http://www.solitairechamp.info/ ==


Return to “LaunchBar Search Templates”

Who is online

Users browsing this forum: No registered users and 2 guests