본문 바로가기

Tips/Mac

[Applescript] How to detect page loading status using applescript and chrome

This is far from rocket science but I haven’t seen it posted so I’m going to put it here for posterity. This is how you can detect if a page is loaded in chrome with applescript. This is a subroutine, so you can put it at the end of your program and call it with this line 


checkForLoading()

Ok, here’s the subroutine.

on CheckForLoading()

# checks chrome to see if the frontmost tab is loaded

tell application "Google Chrome" to set chromeLoading to loading of active tab of window 1

repeat while chromeLoading = true

delay 1

tell application "Google Chrome" to set chromeLoading to loading of active of window 1

end repeat

end checkForLoading

If I recall correctly, wordpress messes up quotes. If this doesn’t compile then replace the quotes and try again.