osascript 语法错误 "Expected expression but found end of line. (-2741)"

osascript syntax error "Expected expression but found end of line. (-2741)"

我正在编写一个 bash 脚本,该脚本利用禁用麦克风和摄像头的 AppleScript,然后单击 google 会议网页上的“立即加入”按钮。禁用麦克风和摄像头的部分工作得很好,但我 运行 遇到了脚本中用于单击加入按钮的部分的问题。这是脚本:

#!/bin/bash

osascript <<EOF

tell application "System Events"

    delay 4

    key code 14 using command down 
    delay 1 

    key code 2 using command down
    delay 1 

end tell

EOF

#the following is not working- 

osascript <<EOF

tell application "brave" 
  tell active tab of window 1 to - 
  execute JavaScript "document.getElementById('Join now')[0].click();" 
end tell 

EOF

当脚本的第二部分尝试执行时,出现此错误:

62:63: syntax error: Expected expression but found end of line. (-2741)

如何修复此错误并使脚本正确执行(单击按钮)?

您在 to:

之后没有正确的 续行符
tell active tab of window 1 to -

使用:¬,例如:

tell active tab of window 1 to ¬

可以通过在 [=25] 中输入 optionL 来创建 line continuation character =]脚本编辑器.

如果仍然报错,则将其全部放在一行中,例如:

tell active tab of window 1 to execute JavaScript "document.getElementById('Join now')[0].click();"