Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###########################################################
- -->> ABOUT
- ###########################################################
- (*
- Phil Stokes -- 2017
- applehelpwriter.com
- sqwarq.com
- *)
- ###########################################################
- -->> DESCRIPTION
- ###########################################################
- (*
- See a history of your downloads that were quarantined
- *)
- ###########################################################
- -->> USAGE
- ###########################################################
- (*
- Click to run. If you're playing in Sierra, you can change the default font size in Notes preferences. If you're on an earlier version of macOS, you might want to cut and paste the text out of notes and into a text editor if it's too small.
- *)
- ###########################################################
- -->> IMPORT STATEMENTS
- ###########################################################
- use AppleScript version "2.4" -- Yosemite (10.10) or later
- use scripting additions
- use framework "Foundation"
- ###########################################################
- -->> VARIABLES
- ###########################################################
- set d to current date
- set fileName to "Quarantine Report (app -- download url -- website url -- date)"
- property NSString : a reference to current application's NSString
- ###########################################################
- -->> HANDLERS
- ###########################################################
- on replaceString:oldChar withString:newChar inString:source_string
- set s_String to NSString's stringWithString:source_string
- set old_string to NSString's stringWithString:oldChar
- set replace_string to NSString's stringWithString:newChar
- return s_String's stringByReplacingOccurrencesOfString:old_string withString:replace_string
- end replaceString:withString:inString:
- ###########################################################
- -->> COMMANDS
- ###########################################################
- set saveTID to AppleScript's text item delimiters
- set AppleScript's text item delimiters to {"\r"}
- set quarantined_items to text items of (do shell script "sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineAgentName, LSQuarantineDataURLString, LSQuarantineOriginURLString, date(LSQuarantineTimeStamp + 978307200, \"unixepoch\") as downloadedDate from LSQuarantineEvent order by LSQuarantineTimeStamp' | sort ")
- set AppleScript's text item delimiters to saveTID
- set theString to ""
- repeat with i from 1 to count of quarantined_items
- set this_item to item i of quarantined_items
- set this_item to this_item & "<br></br>"
- set theString to theString & this_item
- end repeat
- set theString to (my replaceString:"|" withString:" - " inString:theString) as text
- tell application "Notes"
- activate
- tell account "iCloud"
- tell folder "Notes"
- make new note with properties {name:fileName, body:theString}
- end tell
- end tell
- end tell
- ###########################################################
- #EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement