property allowed_URL_chars : (characters of "$-_.+!*'(),1234567890abcdefghijklmnopqrstuvwxyz") property hex_list : (characters of "0123456789ABCDEF") tell application "TextEdit" activate try set ChrissisURLsString to the text of the front document -- just testing whether there's an open document; we're not actually using the value on error make new document end try end tell tell me to activate display dialog "Please enter a few URLs in a TextEdit Document. Hit the button right below this message when you're done. I'll wait here..." if button returned of result = "OK" then tell application "TextEdit" activate set ChrissisURLsString to the text of the front document end tell set theTextItemDelimitersBackup to AppleScript's text item delimiters set AppleScript's text item delimiters to {" "} set ChrissisURLsList to text items of ChrissisURLsString --get ChrissisURLsList set AppleScript's text item delimiters to theTextItemDelimitersBackup repeat with i from 1 to number of items in ChrissisURLsList set aRawURL to item i of ChrissisURLsList if length of aRawURL > 0 then set anEncodedURL to encode_URL_string(aRawURL) set aTubeSockURL to "tubesock://" & anEncodedURL open location aTubeSockURL tell application "TubeSock1.0.1" to activate tell application "System Events" tell process "TubeSock" click button "Save" of window 1 delay 3 repeat until (exists button "Save" in window 1) delay 1 end repeat end tell end tell end if end repeat end if -- encoding functionality by Paul Westbrook -- on encode_URL_string(this_item) set character_list to (characters of this_item) repeat with i from 1 to number of items in character_list set this_char to item i of character_list if this_char is not in allowed_URL_chars then set item i of character_list to my encode_URL_char(this_char) end repeat return character_list as string end encode_URL_string on encode_URL_char(this_char) set ASCII_num to (ASCII number this_char) return ("%" & (item ((ASCII_num div 16) + 1) of hex_list) & (item ((ASCII_num mod 16) + 1) of hex_list)) as string end encode_URL_char