Omniweb applescripting...

Troy Brandt troyb at omnigroup.com
Fri Jan 27 11:49:57 PST 2006


On Jan 27, 2006, at 9:16 AM, Phillip Deackes wrote:

> What about this one? It's just a script to take the current url,  
> run it through tinyurl.com which generates a short url, and then  
> passes it on to Apple Mail.
>
> It was written for Safari and I changed Safari with OmniWeb but it  
> still doesn't work. I get this error:
>
> The script 'TinyURL' could not complete.
> AppleScript reported the following error:
> OmniWeb got an error: Can't make «class url » of document 1 into  
> type reference.
>
> Any ideas?

Hi Phillip,

You'll want to change:

set bigURL to the URL of document 1

to:

set bigURL to address of front browser

So the script should look like this:

-- ####################
-- #  -- eMail tinyURL.scpt --
-- #  script to automagically get
-- #  and paste a tinyURL from-- #  the active Safari window-- #   
into Mail.app.            -- #  --  by nekvas 2005
-- ####################

-- get the url
tell application "OmniWeb"
	set bigURL to the address of front browser
end tell

-- build the command for curl...quoting the url
set curlCMD to ¬
	"curl --stderr /dev/null \"http://tinyurl.com/create.php?url=" &  
bigURL & "\""

-- grep for tinyurl value
set grepCMD to "| grep 'tinyurl value='"

-- use awk to pull the url out of the retuned page, using " as a  
delimiter
set awkCMD to "| awk -F'\"' '{ print $2 }'"

-- build the command
set shellCMD to curlCMD & grepCMD & awkCMD

-- run the script and get the result
do shell script shellCMD
set tinyURL to the result

-- pass the value to Mail and put it in the body
tell application "Mail"
	activate
	set this_message to make new outgoing message with properties ¬
		{visible:true, subject:"check out this page", content:("<" &  
tinyURL & ">")}
end tell




More information about the OmniWeb-l mailing list