Chrome can't execute javascript:why?

Hi,

here is a snippet of AppleScript code that does not work on my Chrome browser which has in its settings allow all sites to run javascript:

 tell application "Google Chrome"
      tell active tab of front window
           execute javascript "document.getElementsByClassName('ytp-fullscreen-button ytp-button')[0].click();"
      end tell
 end tell

why does AppleScript return me this?:
Error in Google Chrome: Execution of JavaScript via AppleScript is disabled. To enable it, from the menu bar, navigate to View > Developer > Allow JavaScript in AppleScript Events. F

thanks

Two reasons.

(1)Google Chrome and other scriptable web browsers disable the execution of JavaScript with the AppleScript command “execute javascript” by default.

You have to operate Google Chrome as it returns…

To enable it, from the menu bar, navigate to View > Developer > Allow JavaScript in AppleScript Events.

(2) I run the script and found it works only during playing some Youtube movie.

“ytp-button” is used only in YouTube movies. You have to play some Youtube movie with Google Chrome.

Which application should be made:
To enable it, from the menu bar, navigate to View > Developer > Allow JavaScript in AppleScript Events.

Google Chrome or ScriptEditor?

this menu is in Chrome

1 Like