我希望我给你这段代码不会违反 StackOverflow 的一些不成文规则,但你可以试试这个 AppleScript 代码,看看它是如何工作的(假设整个浏览器窗口只是聊天框,根据需要更改它):
repeat
tell application "Safari" --or whatever browser you use
set the message to ""
repeat until the message contains "something" --replace 'something' with the string you want to search for
set the message to (the text of document 1) as string --all text on the page
end repeat
end tell
tell application "System Events"
tell process "Safari"
select text box 1 of document 1 --assuming the chat box is the only text box on the page; if not, determine which number the chat box is.
--Text boxes are numbered starting at 1 and ending at the last text box. The 'search' goes from left to right, once the right edge of the window is reached, the search goes down until it reaches the next box.
--Once you determine the text box's number, change the 'text box 1' to 'text box [number]', where [number] is the text box's number.
keystroke "response" --replace 'respose' with the reply you want to send back
end tell
end tell
delay 2 --wait 2 seconds so the script doesn't spam the chat box
end repeat
如果由于某种原因这不起作用和/或您有任何问题,请询问。:)