On Wednesday, December 30, 2015 at 4:25:27 AM UTC+1, Jonathan Levi wrote:
>
> I am often testing web pages to see what a not-logged-in user would see. I 
> find that the fastest way to do this is to open a new Private window in 
> Safari (or incognito window in Chrome) and paste the URL there. 
> It would be so much faster if we could either add an action "Open in 
> Private Window" or "Open With..." (tab) "Safari Private Window"
> Then, from there, I could pretty easily make a custom trigger so that it 
> took my clipboard contents and automatically opened in a private url. 
> Something like Option + Command + Control + N.
>

This is a short applescript that you can put in ~/Library/Application 
Support/Quicksilver/Actions/.

using terms from application "Quicksilver"
 on process text theURL
 tell application "Google Chrome"
 make new window with properties {mode:"incognito"}
 activate
 set URL of active tab of first window to theURL
 end tell
 end process text
 on get direct types
 return {"NSStringPboardType", "Apple URL pasteboard type"}
 end get direct types
end using terms from


This is a longer applescript that also let's you open multiple URLs 
separated by commas, use web search strings (see comment in script), close 
the default window when launching Chrome and switch to either full screen 
or presentation mode.

using terms from application "Quicksilver"
 
 on process text theURLs
 
 if not running of application "Google Chrome" then ¬
 tell application "Google Chrome" to close front window
 
 if theURLs contains "," then ¬
 set theURLs to theURLsToCSV(theURLs)
 if (count of theURLs) is 2 and item 1 of theURLs contains "***" then ¬
 set theURLs to theURLsToWebSearch(theURLs)
 
 repeat with theURL in theURLs as list
 if theURL does not start with "http" then set theURL to "http://"; & theURL
 tell application "Google Chrome"
 activate
 if not ((some window whose mode is "incognito") exists) then
 make new window with properties {mode:"incognito"}
 set URL of active tab of first window to theURL
 else
 make new tab at (front window whose mode is "incognito") with properties {
URL:theURL}
 end if
 end tell
 end repeat
 
 -- Full Screen Mode
 tell application "System Events"
 if not (value of attribute "AXFullScreen" of front window of process "Google 
Chrome") then ¬
 keystroke "f" using {command down, control down}
 end tell
 -- Presentation Mode
 (** tell application "Google Chrome" to tell front window
 if not presenting then enter presentation mode
 end tell **)
 
 end process text
 
 on get direct types
 return {"NSStringPboardType", "Apple URL pasteboard type"}
 end get direct types
 
end using terms from


on theURLsToCSV(theURLs)
 -- for multiple values use comma-separated text
 -- comma trick doesn't work with text nor URLs #1727
 set ASTID to AppleScript's text item delimiters
 set AppleScript's text item delimiters to ","
 set theCSURLs to text items of theURLs
 set AppleScript's text item delimiters to ASTID
 return theCSURLs
end theURLsToCSV


on theURLsToWebSearch(theURLsAsWebSearch)
 -- usage: select QS Web Search, change to text mode, add search terms 
after a comma
 -- example: http://www.google.com/search?hl=en&q=***,søren kierkegaard
 set theSearchTerms to urlEncode(item 2 of theURLsAsWebSearch)
 set QSWebSearchURL to item 1 of theURLsAsWebSearch
 set theWebSearchURL to findReplace("***", theSearchTerms, QSWebSearchURL)
 return theWebSearchURL
end theURLsToWebSearch


on urlEncode(theSearchTerms)
 return do shell script "php -r 'echo urlencode(\"" & theSearchTerms & 
"\");'"
end urlEncode


on findReplace(findText, replaceText, sourceText)
 set ASTID to AppleScript's text item delimiters
 set AppleScript's text item delimiters to findText
 set sourceText to text items of sourceText
 set AppleScript's text item delimiters to replaceText
 set sourceText to sourceText as text
 set AppleScript's text item delimiters to ASTID
 return sourceText
end findReplace

I tested with most cases (full screen, presentation, normal, incognito, 1+ 
tabs) at the same time. Let me know how it works.

-- 
You received this message because you are subscribed to the Google Groups 
"Quicksilver" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/blacktree-quicksilver.
For more options, visit https://groups.google.com/d/optout.

Reply via email to