title: Getting values from inner functions of current webpage in Chrome via (JXA / AppleScript)
body: <p>I can't get values from inner functions of current webpage in Chrome. Why it's happened?</p>
  
  <p>for examples in JXA:</p>
  
  <pre class="lang-js prettyprint-override"><code>function getTime() {
      const chrome = Application('Google Chrome')
      const currentTab = chrome.windows[0].activeTab()
      return currentTab.execute({javascript: 'jwplayer().getPosition()'})
  }
  getTime()
  </code></pre>
  
  <p>Chrome returns reference error:</p>
  
  <pre><code> Uncaught ReferenceError: jwplayer is not defined
  </code></pre>
  
  <p>in AppleScript the same: </p>
  
  <pre><code>tell application "Google Chrome"
      return execute front window's active tab javascript "jwplayer().getPosition()"
  end tell
  </code></pre>
  
  <p>Settings in Chrome is checked: "Allow Javascript from Apple Events"</p>