Applescript if class else - PullRequest
       32

Applescript if class else

0 голосов
/ 20 июня 2020

У меня есть applescript, который я использую некоторое время, и он отлично работает:

set js to "document.getElementsByClassName('The_Class')[0].click();"

tell application "Google Chrome" to tell ¬
    the front window to tell ¬
    the active tab to ¬
    set jsResult to execute javascript js

Теперь я хочу добавить к нему if и else . Вот так, но я не могу найти способ решить:

if the class ('The_Class') exist then

  set js to "document.getElementsByClassName('The_Class')[0].click();"

     tell application "Google Chrome" to tell ¬
       the front window to tell ¬
       the active tab to ¬
       set jsResult to execute javascript js

else

   tell application "Google Chrome" to activate

      tell application "System Events"
         keystroke "r" using {command down}
      end tell

end if
...