【发布时间】:2022-01-11 17:27:38
【问题描述】:
PreNote:我对任何信息、建议、提示等都很开放并渴望。
大家好!
我正在尝试使用 applescript 创建自动化。这是我的第一个个人 applescript 任务,但我有一些有价值的问题。基本上我正在尝试从网站捕获实时通知并将它们显示在 mac os 通知中。
我正在尝试构建过程几天,但我不想给你带来混乱:)所以我在下面大致解释了我的过程。
(* Variables used in whole process
set $webToCheck > This is Safari webpage which I want to run my script on it. It won't be front window, script should be run with its name or other property.
set $theClass > This is class name of DOM element to check if it is exist or not. This class is not always exist on DOM of $webpage. It comes with notifications so when use it in "do Javascript" I got error "variable is not defined"
set $num > number of class to use in "do Javascript"
set $input > variable to assign HTML text
set $modifiedInput > Text of input seperated from HTML tags
*)
-- Step 1
tell application "Safari"
work on $webToCheck
-- Step 2
repeat until $input is not empty
set input do Javascript
document.getElementsByClassName > $theClass, $num of $webToCheck
end repeat
-- Step 3
modify text of $input to seperate from RAW HTML -- For example: <a class="" value=""> TEXT to be seperated </a>
Display notification $modifiedInput
-- Step 4
Go back to step 1 or 2 to check and display notification again
【问题讨论】:
标签: macos applescript automator javascript-automation