保持 AppleScript 运行并检查 URL
我正在尝试在 macOS 应用程序中创建一个 AppleScript,该应用程序在打开的浏览器运行时运行,并将某些 URL 重定向到特定 URL。这就是它目前的样子:
if \(start) is false then
error number -128
end if
repeat until application "Safari" is not running
if application "Safari" is running then
tell application "Safari"
set myList to \(fixedSites) as list
repeat with theItem in myList
set (URL of every tab of every window where URL contains theItem) to "https://stackoverflow.com"
end repeat
end tell
end if
end repeat
我在脚本中使用布尔值以使其在用户决定后停止。尽管如此,我的示例的问题是它阻止了我的应用程序(我可以使用系统中的任何其他应用程序,但重复循环似乎过于资源密集型,因为它会提高 CPU 使用率。我尝试过使用空闲/结束也闲置,但这似乎不会触发此脚本。
I'm trying to create an AppleScript in macOS application that is running while the open browser is running and redirecting certain URLs to a specific URL. This is what it looks like at the moment:
if \(start) is false then
error number -128
end if
repeat until application "Safari" is not running
if application "Safari" is running then
tell application "Safari"
set myList to \(fixedSites) as list
repeat with theItem in myList
set (URL of every tab of every window where URL contains theItem) to "https://stackoverflow.com"
end repeat
end tell
end if
end repeat
I'm using a boolean in the script to make it stop after the user has decided. Still, the problem with my example is that it blocks my application (I can use any other in the system, but it seems that repeat loops are too resource-intensive as it cranks up the CPU usage. I've tried using idle/end idle too, but that doesn't seem to trigger this script.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论