Applescript to reload a web page in DevonThink Pro via Harvard's EZ-Proxy

filed under: computing, mac

Whipped this up this morning.

The Error -128 exception is from one of DT’s own scripts, so I’m not sure what that error is, precisely.

Feel free to comment as I’m a novice at AppleScript.

tell application id "com.devon-technologies.thinkpro2"
        if not (exists think window 1) then error "No window is open."
        set old_URL to the URL of think window 1
        set pat to "'s@(https*://[^/]+)@\'"
        set new_URL to do shell script "echo " & quoted form of old_URL & " | perl -pe " & pat
        set the URL of think window 1 to new_URL
on error error_message number error_number
        if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
    end try
end tell