tell application "Safari" set imageURL to the URL of the front document set AppleScript's text item delimiters to "/" set the imageName to the last text item of imageURL set AppleScript's text item delimiters to "" set desktopPath to (POSIX path of ((path to desktop folder))) set savedImage to desktopPath & imageName save the front document in savedImage end tell tell application "iPhoto" select album "Random" import from savedImage to album "Random" end tell set tempFile to savedImage as POSIX file as alias tell application "Finder" delete tempFile end tell