Новичок ie в Applescript здесь. Я пытаюсь создать скрипт, который сканирует текст в текстовом редакторе онлайн и заменяет слова другими словами.
В моем конкретном случае c он заменяет несколько фрагментов html пустыми "" - т.е. удаляя их.
Мой текущий скрипт получает следующее сообщение об ошибке… «Brave Browser получил ошибку: окно 1 не понимает сообщение« execute ».» число -1708 из окна 1
Вот скрипт ниже. Проблемная строка c, кажется, где-то появляется переменная EditorField .
Есть какие-нибудь указатели или идеи, чтобы заставить это работать? Спасибо.
tell application "Brave Browser"
activate
my replaceWordWithStringInBodyText(" ", "")
my replaceWordWithStringInBodyText("<span class=\"Apple-converted-space\">", "")
my replaceWordWithStringInBodyText("<b>", "<strong>")
end tell
on replaceWordWithStringInBodyText(searchWord, replacementString)
tell application "Brave Browser"
activate
tell window 1
set EditorField to (execute javascript "document.getElementById('\"wp-content-editor-container\"')")
tell EditorField
-- start at the end and go to the beginning
repeat with i from the (count of paragraphs) to 1 by -1
tell paragraph i
repeat
try
if exists searchWord then
set (last word where it is searchWord) to replacementString
else
exit repeat
end if
on error errorMessage
exit repeat
end try
end repeat
end tell
end repeat
end tell
end tell
return true
end tell
end replaceWordWithStringInBodyText