Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's a little known fact that you can easily make these kind of keyboard shortcuts globally by making a Service. Here's how to make a global service that reloads the browser:

  1. Open Automator
  2. Select Service
  3. Search for run Applescript
  4. Copy and paste one of the following Applescripts
  5. Change the Service receives selected drop down list to "No input" 
  6. Save the service  (Automator will ask you what to name it)
You can then find the service under "Services" inside the Application's Menu.

You can also assign it to a global shortcut by:

  1. Open the Keyboard section in System Preferences
  2. Find your service under the Services list
  3. Click the service to reveal the Add Shortcut button
  4. Type the shortcut (Like Command+Ctrl+R)
Applescript for Safari:

    on run
      tell application "Safari"
        do JavaScript "window.location.reload()" in current tab of window 1
        activate
      end tell
    end run
Applescript for Chrome:

    on run
      tell application "Google Chrome" to tell the active tab of its first window
        reload
      end tell
      tell application "Google Chrome" to activate
    end run


Can anyone explain why these scripts that do the exact same thing for different browsers are so different? How could one learn to write these things?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: