Share via Facebook Menu Item

Description

This script addresses a shortcoming in Safari, and possibly the rest of the system, which causes a custom keystroke assignment to launch a Facebook history item, if it exists rather than File > Share > Facebook menu item. That is, if you assign a keystroke to the 'Facebook' sub-item of the 'Share' menu item, and you have Facebook URL's in your history list, the keystroke will launch the first matching item in your history rather than the menu item you actually assigned.

The Code

(*
◸ Veritrope.com
Share via Facebook Menu Item
VERSION 1.0
June 16, 2014
)

(* Share via Facebook Menu Item <---<< Share > Facebook menu item.
 *
 * That is, if you assign a keystroke to the 'Facebook' sub-item of the 'Share' menu item,
 * and you have Facebook URL's in your history list, the keystroke will launch the first
 * matching item in your history rather than the menu item you actually assigned.
 *
 *                                           ...cb
 *)

tell application "Safari" to activate
tell application "System Events"
    tell process "Safari"
        click menu item "Facebook" of menu 1 of menu item "Share" of menu 1 of menu bar item "File" of menu bar 1
    end tell
end tell