Created
May 14, 2010 12:06
-
-
Save zarigani/401071 to your computer and use it in GitHub Desktop.
AppleScript_URL_by_JavaScript.scpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "AppleScript Editor" | |
activate | |
set myString to contents of document 1 | |
set beforeList to {"%", ASCII character (9), ASCII character (13), ASCII character (13), ASCII character (32), ASCII character (34), "&", "<", ">", "\\", "\""} | |
set afterList to {"%25", "%09", "%0a", "%0a", "%20", "%22", "%26", "%3c", "%3e", "\\\\", "\\\""} | |
set html1 to "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n</head>\n<body>\n\n<script language=\"JavaScript\">\n<!--\nlocation.href=\"" | |
set html2 to "\"\nsetTimeout('window.close();', 1000);\n//-->\n</script>\n\n</body>\n</html>\n" | |
set oldDel to text item delimiters of AppleScript | |
set i to 1 | |
repeat with x in beforeList | |
set text item delimiters of AppleScript to x | |
set mylist to every text item of myString | |
set text item delimiters of AppleScript to item i of afterList | |
set myString to mylist as string | |
set i to i + 1 | |
end repeat | |
set text item delimiters of AppleScript to oldDel | |
set myString to html1 & "applescript://com.apple.scripteditor?action=new&script=" & myString & html2 | |
set the clipboard to myString | |
end tell | |
my message("クリップボード", "AppleScriptをURLに変換して、セットしました。") | |
on message(title, msg) | |
try | |
do shell script "/usr/local/bin/growlnotify " & title & " -m " & quoted form of msg | |
on error | |
activate | |
display alert msg giving up after 1 | |
end try | |
end message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment