0
我想找到的Safari标签,并注重这个标签的AppleScript:Safari的搜索标签,打开标签
这是不工作的,但标签被发现没事,我只是不能打开此选项卡。
tell application "Safari"
repeat with t in tabs of windows
tell t
if name starts with "facebook" then open tab
end tell
end repeat
end tell
我还想知道是否可以从另一个选项卡中找到一些文本而不关注此选项卡?
to getInputByClass75(theClass, num)
tell application "Safari"
set input to do JavaScript "
document.getElementsByClassName('" & theClass & "')[" & num & "].innerHTML;" in document 1
end tell
return input
end getInputByClass75
getInputByClass75("Order", 0)
set theText to Unicode text
set theSource to getInputByClass75("Order", 0)
property leftEdge75 : "<a class=\"columns\" href=\"/Web"
property rightEdge75 : "\">Display</a>"
set saveTID to text item delimiters
set text item delimiters to leftEdge75
set classValue to text item 2 of theSource
set text item delimiters to rightEdge75
set OrderLink to text item 1 of classValue
set text item delimiters to saveTID
OrderLink
谢谢你,那太棒了。第一个脚本(查找标签)工作正常,但始终有一个错误“Safari得到一个错误:无法获得每个窗口的项目2的每个选项卡。” –
这可能是一个僵尸窗口。我已经更新了答案。 – user309603
只是一件小事,你会如何将标签号保存为变量?我尝试了如果t的名称包含“谷歌”,然后将tabNumber设置为t,但结果看起来像“应用程序的每个窗口的项目1的每个选项卡的项目5”Safari“” –