AppleScriptでJavaScriptを使いたい ターミナルでJavaScriptを使いたい AppleScriptでJavaScriptを使いたい applescript jsc javascriptcore 具体には、URL全体をエンコード(encodeURI)しておきたい時 下記のように、Sfafariを経由して、JavaScriptを使う事ができるが、Safariが起動してまうし、Safariが起動していてもウィンドウがゼロの時はエラーが出るので、スマートではない。 set theText to " アップルスクリプト " --JavaScript tell application "Safari" set theURL to ( do JavaScript "encodeURI(\"" & theText & "\")" in document 1) as text log "encode=" & theURL (*0=%E3%82%A2%E3%83%83%E3%83%97%E3%83%AB%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88*) set theURL to ( do JavaScript "decodeURI(\"" & theText & "\")" in document 1) as text log "decode=" & theURL (*0= アップルスクリプト *) end tell そこで、 do shell script で JavaScriptCore.framework を直接呼んで、URL全体をエンコード(encodeURI)。 ※ encodeURIとencodeURIComponentは上手くエンコードしてれない。 のでURL全体をエンコードしたい場合はリンクを参照。 BWNSUY: AppleScriptでURLエンコード しかし、Safariを通さずJava...