On Monday, January 11, 2016 at 8:21:20 AM UTC+1, Jonathan Levi wrote: > > I'm on QS 1.3.4, and on Yosemite >
After seeing your promo TED talk, I guessed you might have already learnt AppleScript and wrote it yourself overnight :D Else, here's an ugly GUI applescript, that is, it does the clicking, etc for the user, and since the GUI structure changes between versions, it might not even work for you. Access for assistive devices, or whatever is called in your system, must me enabled in System Preferences for it to function. The script itself sucks with all the nesting, etc, but it takes into account if a shortcut has been assigned to "Private Browsing…", in which case you might end up with two items, one with ellipsis, one without. It works with web searches (see comment in script) and full screen (uncomment ⌃⌘F tell block if unneeded). Tested in Safari 6. YMWV. using terms from application "Quicksilver" on process text theURLs 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) tell application "Safari" activate if running then ¬ tell application "System Events" to tell process "Safari" to ¬ tell menu bar 1 to tell menu bar item "Safari" to tell menu 1 try tell menu item "Private Browsing…" try set checkMark to value of attribute "AXMenuItemMarkChar" log checkMark -- errors when undefined on error click tell application "System Events" to tell process "Safari" to tell first window to click button "OK" end try end tell end try tell application "Safari" activate if not (exists (every window whose id ≥ 1)) then make new document repeat with theURL in theURLs as list if theURL does not start with "http" then set theURL to "http://" & theURL tell first window to make new tab with properties {URL:theURL} end repeat tell first window to set current tab to last tab end tell end tell end tell tell application "System Events" if not (value of attribute "AXFullScreen" of front window of process "Safari") then ¬ keystroke "f" using {command down, control down} 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 -- 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.
