This AppleScript opens a page in Chrome (where you presumably have a logged-in session if required), opens the passed-in URL, runs the passed-in JavaScript and returns the JS return value.
Waits for 1 second for the page to load before executing the JS. Optionally, pass in a third argument with the number of seconds to wait.
Examples:
osascript js_in_chrome.scpt "http://google.com" "document.title"
# When logged in.
osascript js_in_chrome.scpt "http://search.ancestry.com/Browse/view.aspx?dbid=1670&path=1930.Spring.160V.1" "szImageURL"
# Custom wait.
osascript js_in_chrome.scpt "http://google.com" "document.title" 10