Posted By

iloveitaly on 12/22/10


Tagged

browser refresh reload


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

jlbfalcao
loranger
macrane9


Custom TextMate Refresh Browsers Script


 / Published in: Bash
 

refreshes Chrome + Safari without bringing them into focus. If Chrome is hidden, then no refresh occurs.

  1. osascript >/dev/null <<EOL
  2. tell application "Safari"
  3. do JavaScript "if(window.location.hostname.indexOf('.local') != -1 || window.location.hostname.indexOf('.dev') || window.location.href.indexOf('file://') != -1) { window.location.reload(); }" in first document
  4. end tell
  5. EOL
  6.  
  7. osascript > /dev/null <<'APPLESCRIPT'
  8. tell application "System Events"
  9. set isVisible to visible of process "Google Chrome"
  10. end tell
  11.  
  12. tell application "Google Chrome"
  13. if isVisible then
  14. tell active tab of first window
  15. execute javascript "window.location.reload()"
  16. end tell
  17. end if
  18. end tell
  19. APPLESCRIPT
  20.  
  21. exit 0

Report this snippet  

You need to login to post a comment.