ブラウザのヘルパーアプリ for Mac X 10.5
http://d.hatena.ne.jp/bootblack/20090208/p1に悔い改められました
ブラウザのヘルパーアプリなんてまだ有ったんですね(苦笑)
これは実戦である
結局開けてみないと判らない訳ですよ(苦笑)
クイックルック?で遊んでる余裕などある訳ないじゃないですか
これは実戦である
- for Mac X 10.5, for Firefoxです。使用するアプリ名をスクリプト中で指定しているので指定有りです?
- ディスクに保存したいだけのファイルをウィルススキャンする
- 以下の安全なファイル(ほんとかよ!?(苦笑))を「普通」に開き、ウィルススキャンも行う。
- 開くためのアプリはPreview.app, DiskImageMounter.app, StuffIt Expander.appでウィルスチェックはclamav, clamav-wrapper.appで行う
- safariの模倣です?
と、clamav-wrapper.appはAppleScriptから切断されたことだし、ここらでホンマモンのAppleScript Studio Dropletっていう芸当を披露しておきますね(苦笑)。Studio用です。
info.plistはシステム系は当然?ノータッチ、後述のAppleScript Studio Dropletは「Application is agent (UIElement)」です。StuffIt Expanderはパスワード付きZIPの入力ウィンドゥ等も出るのでノータッチで普通、後述のAppleScript Studio Droplet実行時は通常、ドックアイコンに丸がついて跳ねるだけなのでウザくないと思います(苦笑)。
また、スクリプト中で表示するようにしているダイアログが閉じられるまで常に表示されるように、IBで以下のチェックを入れる必要があります。内容はログにも出します
- Application.applescript(上記IB設定も必要)
- DMGはだまされていないかの確認とマウントがメインイベントです、マウントされた実体のウィルスチェックはここではやっていません。ここではマウントしたあとにDMGファイルのウィルスチェックを行います
- アーカイブ系は解凍後のもののみウィルスチェックを行います
- PDFは開いてからウィルスチェクです
- 処理したものにはラベルで色付けします、ダウンロード先に無色のファイルが単体でころがっていたらアクロバティックな芸当が失敗した等、何らかの激ヤバ!?です。血眼になってサクっと手動でチェックします(苦笑)
- ウィルスチェックの結果はclamav-wrapper.appで表示します
- ダウンロード先の内容の表示更新がとどこおっているときは
tell application "Finder"
tell application "System Events" to set downloadsFolderPath to path of (downloads folder)
open downloadsFolderPath
activate
set current view of Finder window 1 to column view
set current view of Finder window 1 to list view
end tell
とか手動で?するといいです
property endFlag : true property alertON : 0 on activateBrowerApp() tell application "/Applications/Firefox.app" ignoring application responses activate end ignoring end tell end activateBrowerApp on setLabel(aFileObj) tell application "Finder" ignoring application responses set label index of aFileObj to 7 end ignoring end tell end setLabel on doScan(aObj) tell application "/opt/local/etc/clamav-wrapper.app" ignoring application responses open aObj end ignoring end tell end doScan on MountDMG(aObj) tell application "DiskImageMounter" ignoring application responses open aObj end ignoring end tell end MountDMG on openPDF(aObj) tell application "Preview" ignoring application responses open aObj end ignoring end tell end openPDF on quitExpander() if application "/Applications/StuffIt/StuffIt Expander.app" is running then tell application "/Applications/StuffIt/StuffIt Expander.app" quit end tell end if end quitExpander on doExpend(aList) tell application "/Applications/StuffIt/StuffIt Expander.app" expand aList set dest to the result as alias end tell return dest end doExpend on open names set endFlag to false hide me activateBrowerApp() repeat with tgFile in names tell application "System Events" to set theKind to kind of tgFile if ((theKind as string) contains "archive") or ((theKind as string) contains "アーカイブ") then try set dest to doExpend(tgFile as list) tell application "System Events" to set theKind to kind of dest if theKind as string is "ディスクイメージ" then MountDMG(dest) end if doScan(dest) setLabel(tgFile) on error the error_message number the error_number set alertON to alertON + 1 activate me set logMes to "Error " & (error_number as string) & ": " & error_message & " '" & (POSIX path of file (tgFile as string)) & "'" log logMes set Mes to "error_number: " & (error_number as string) & return & error_message & return & return & (POSIX path of file (tgFile as string)) & return & return & "の解凍をキャンセルせざるを得ませんので、" & return & "あとで確認お願います。" tell me to display alert "エラー" as warning message Mes set alertON to alertON - 1 end try activateBrowerApp() else if (theKind as string is "ディスクイメージ") then MountDMG(tgFile) doScan(tgFile) setLabel(tgFile) activateBrowerApp() else if (theKind as string) contains "PDF" then openPDF(tgFile) doScan(tgFile) setLabel(tgFile) tell application "Preview" to activate else doScan(tgFile) setLabel(tgFile) activateBrowerApp() end if end repeat quitExpander() end open on idle theObject if endFlag is true then quit else set endFlag to true end if return 10 end idle on resigned active theObject if alertON is not 0 then activate me end if end resigned active