I just made the necessary changes to make it work with LB (haven't even read the code throughly

How to use:
1. Bring up the image(s) you want to upload in LB
2. Tab
3. Bring up the script and hit return
4. The URL will be copied to your clipboard
Code: Select all
on open input
set thelist to {}
tell application "Finder"
-- convert file paths to posix
set imageList to {}
repeat with i from 1 to (count input)
set end of imageList to POSIX path of (item i of input as alias)
end repeat
-- no images selected
if (count imageList) is 0 then
display dialog "No image files selected" with title "Imgur uploader" buttons {"Quit"} default button "Quit"
return
--upload
else
--set dialogResponse to display dialog "You are uploading " & (count imageList) & " image(s)." & return & return & "The images will show up in separate tabs in your default browser once they are uploaded." with title "Imgur uploader" buttons {"Upload", "Cancel"} default button "Cancel"
--if button returned of dialogResponse is "Upload" then
repeat with i from 1 to (count imageList)
set apiKey to "26ff5c40cbedf50e7f81124ab473c1cc"
set curlCommand to "curl -F \"key=" & apiKey & "\" -F \"image=@" & item i of imageList & "\" http://api.imgur.com/2/upload"
set answer to do shell script curlCommand
set atid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "<imgur_page>"
set link to text item 2 of answer
set AppleScript's text item delimiters to "<"
set link to text item 1 of link
set AppleScript's text item delimiters to atid
set browser to my default_Browser()
tell application browser to open location link
set end of thelist to (link & "
") as text
end repeat
set the clipboard to thelist as text
-- end if
end if
end tell
end open
on default_Browser()
tell (system attribute "sysv") to set MacOS_version to it mod 4096 div 16
if MacOS_version is 5 then
set {a1, a2} to {1, 2}
else
set {a1, a2} to {2, 1}
end if
set pListpath to (path to preferences as Unicode text) & "com.apple.LaunchServices.plist"
tell application "System Events"
repeat with i in property list items of property list item 1 of contents of property list file pListpath
if value of property list item a2 of i is "http" then
set longName to value of property list item a1 of i
set AppleScript's text item delimiters to "."
set shortName to last text item of longName
set AppleScript's text item delimiters to ""
return shortName
end if
end repeat
return "Safari"
end tell
end default_Browser