set account to "ethank"
set tag to "@read_later"
to split(someText)
set AppleScript's text item delimiters to space
set someText to someText's text items
set AppleScript's text item delimiters to {""} --> restore delimiters
return someText
end split
tell application "Safari"
set myURL to URL of document 1
set myTitle to do JavaScript "document.title" in document 1
set myReferrer to do JavaScript "document.referrer" in document 1
set mySelection to do JavaScript "window.getSelection() + ''" in document 1
set rawTags to do JavaScript "prompt('Enter tags:')" in document 1
end tell
set myTags to split(rawTags)
property destination_group_location : "/url/delicious/"
tell application "DEVONthink Pro"
if item 1 of myTags is "@readlater" then
set destination_group_location to destination_group_location & item 2 of myTags
if not (exists record at destination_group_location) then
set destination_group to create location destination_group_location
else
set destination_group to get record at destination_group_location in current database
end if
create record with {name:myTitle, type:link, URL:myURL} in destination_group
end if
end tell
tell application "Pukka"
set post url to myURL
set post title to myTitle
set post tags to myTags
if (length of mySelection is not 0) and (length of myReferrer is not 0) then
set post description to mySelection & " (linked via " & myReferrer & ")"
else if (length of myReferrer is not 0) then
set post description to "linked via " & myReferrer
else if (length of mySelection is not 0) then
set post description to mySelection
end if
set selected account to account
add link
end tell