groups

Link to this snippet:


Download to Code Collector

language: AppleScript
licence: Other

Google_Search

options: send to code collectorview all seydoggy's snippets
(*
Remeber when searching Google didn't have any strings attached, and assumed lanuages, any device detection, any referal data attached?

Get back to the roots of a good old Google query string with this AppleScript.

by Adam Merrifield <http://www.seydoggy.com>

r4 10-29-09 09:43
	added ability to recognize urls and open them automatically

r3 10-13-09 12:06
*)

-- optional: to set the application running the script to the forground
-- uncomment and change "FastScripts" to the script running app of your choice
-- tell application "System Events" to set frontmost of process "FastScripts" to true

set userQuery to text returned of (display dialog "Google search:" default answer "" buttons {"Cancel", "OK"} default button 2)

set httpArray to {"http://", "www.", ".com", ".ca", ".net", ".org", ".info", ".us"}

set httpBool to false
repeat with httpAny in httpArray
	if userQuery contains httpAny then
		set httpBool to true
		exit repeat
	end if
end repeat

if httpBool then
	tell application "Safari" to open location userQuery
else
	tell application "Safari" to open location "http://www.google.com/search?q=" & userQuery
end if
tell application "Safari" to activate