如何在访问某个网站时发出声音(Mac)?
How to make a sound when visiting a certain website (Mac)?
我正在想一个创造性的方法来打破我对 Youtube 的依赖。
访问 youtoube.com 时如何发出恼人的声音?我试图用 Applescript 做到这一点,但我一无所获,所以我看看互联网是否可以提供帮助。我主要只需要一些方法来不断检查我当前的网站(Safari and/or Chrome)并在我访问 Youtube 时触发一个事件。我知道如何播放我的声音,但不知道现场检查部分。最好我可以在 Automator 上制作。
我知道改掉习惯有更好的方法,但我真的很想这样做。我真的希望有人能提供帮助。提前致谢!
如果 Chrome 或 Safari 的前端标签位于包含 "youtube".
字样的 URL 上,这将产生恼人的噪音
** 编辑 ** 以使其在 automator 中工作:
单击 Automator window 左上角的操作,然后单击库中的 select 实用程序。
选择'Run AppleScript'
- 将代码粘贴到代码编辑框中
(替换输入框中的全部代码)
on run
set check to "youtube"
repeat
try
tell application "Safari"
set theURLs to URL of current tab of window 1
end tell
end try
try
tell application "Google Chrome"
set theURLc to URL of active tab of front window
end tell
end try
if check is in theURLs then
tell application "System Events"
beep
end tell
end if
if check is in theURLc then
tell application "System Events"
beep
end tell
end if
end repeat
end run
我敢断言,这不能完成。我的意思是,AppleScript 中没有任何方法或实现可以高效、安全、明智地或以任何实用、有用或可用的方式来完成此类事情。
这包括:
任何涉及无限重复循环的脚本,尤其是没有允许用户跳出它的代码的脚本;
任何使用 polling;
的实现
尤其是任何脚本,其轮询速度比被轮询的事物发生状态变化所需的时间更快。
我正在想一个创造性的方法来打破我对 Youtube 的依赖。
访问 youtoube.com 时如何发出恼人的声音?我试图用 Applescript 做到这一点,但我一无所获,所以我看看互联网是否可以提供帮助。我主要只需要一些方法来不断检查我当前的网站(Safari and/or Chrome)并在我访问 Youtube 时触发一个事件。我知道如何播放我的声音,但不知道现场检查部分。最好我可以在 Automator 上制作。
我知道改掉习惯有更好的方法,但我真的很想这样做。我真的希望有人能提供帮助。提前致谢!
如果 Chrome 或 Safari 的前端标签位于包含 "youtube".
字样的 URL 上,这将产生恼人的噪音** 编辑 ** 以使其在 automator 中工作:
单击 Automator window 左上角的操作,然后单击库中的 select 实用程序。
选择'Run AppleScript'
- 将代码粘贴到代码编辑框中
(替换输入框中的全部代码)
on run
set check to "youtube"
repeat
try
tell application "Safari"
set theURLs to URL of current tab of window 1
end tell
end try
try
tell application "Google Chrome"
set theURLc to URL of active tab of front window
end tell
end try
if check is in theURLs then
tell application "System Events"
beep
end tell
end if
if check is in theURLc then
tell application "System Events"
beep
end tell
end if
end repeat
end run
我敢断言,这不能完成。我的意思是,AppleScript 中没有任何方法或实现可以高效、安全、明智地或以任何实用、有用或可用的方式来完成此类事情。
这包括:
任何涉及无限重复循环的脚本,尤其是没有允许用户跳出它的代码的脚本;
任何使用 polling;
的实现
尤其是任何脚本,其轮询速度比被轮询的事物发生状态变化所需的时间更快。