Make Plain Text

Ok, so I just realized that you can’t save files from Safari into plain text format. So, I fired up script editor and this is what I came up with. Just copy the text you want to the clipboard and then run this. It will launch textedit, paste in the text, convert it to plain text, and give you a save dialog. This is my first script so let me know what you think and maybe how I could have made it more efficient. Thanks and enjoy!

OS version: OS X

on do_menu(app_name, menu_name, menu_item)
	try
		-- bring the target application to the front
		tell application app_name
			activate
		end tell
		tell application "System Events"
			tell process app_name
				tell menu bar 1
					tell menu bar item menu_name
						tell menu menu_name
							click menu item menu_item
						end tell
					end tell
				end tell
			end tell
		end tell
		return true
	on error error_message
		return false
	end try
end do_menu

do_menu("Textedit", "Edit", "Paste")
do_menu("Textedit", "Format", "Make Plain Text")

tell application "System Events"
	tell process "textedit"
		tell window "untitled"
			if exists sheet 1 then
				tell sheet 1
					click button "ok"
				end tell
			end if
		end tell
	end tell
end tell

do_menu("Textedit", "File", "Save")