Automatic karma recording workflow.

I made my first useful Automator/Applescript workflow yesterday and thought I’d share it here.
I wanted to make a daily record of my karma on Reddit, but the workflow can be customized to record any info on any webpage you want.

  1. Get Specified URLs
  2. Get Text from Webpage
  3. Set Value of Variable (FullText)
  4. Filter Paragraphs (contain link karma)
  5. Set Value of Variable (LinkKarma)
  6. Get Value of Variable (FullText)
  7. Filter Paragraphs (contain comment karma)
  8. Get Value of Variable (LinkKarma)
  9. Run AppleScript
on run {input, parameters}
	set text item delimiters to space
	set LinkKarma to (text item 1 of (item 2 of input))
	set CommentKarma to (text item 1 of (item 1 of input))
	set output to ((current date) as string) & tab & LinkKarma & tab & CommentKarma
	set LogPath to (path to desktop as string) & "Karma History.txt" as string
	set LogRef to open for access LogPath with write permission
	write output & return to LogRef starting at eof
	close access LogRef
end run

That’s it. There has to be a “Karma History.txt” file on the desktop obviously. I saved this workflow as an iCal alarm recurring daily, so now the log is writing itself. The format of the text file is tab separated values which makes it easy to open up in Numbers.

The biggest revelation I had while writing this, was the ability to “stack” multiple Automator variables before passing them to an AppleScript. If a “Get Value of Variable” comes after another “Get Value” or “Set Value”, the last result will contain a list of them all.