Custom TextMate Refresh Browsers Script


/ Published in: Bash
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.