LoginSignup
0
1

More than 1 year has passed since last update.

Safari で YouTube の自動再生をトグルする AppleScript

Last updated at Posted at 2023-02-22

Safari で YouTube の自動再生をトグルする

YouTube、たくさんショートカットキーが用意されているのに、自動再生をトグルするショートカットキーは存在しないんですよね… なんでなんでしょうね…

と思ったので AppleScript を書きました。

AppleScript

以下の通りです。シアターモードとデフォルト表示でのみ動作します(全画面時とミニプレーヤーには非対応)。設定言語に関わらず動くはずですが、拡張機能などの有無によって動かない可能性はあります(動かなかったらコメントください)。

AppleScript
tell application "System Events" to tell process "Safari" to tell first window
	tell group 1 of (first group whose subrole is not "AXEmptyGroup") of group -3 of UI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1
		
		if button 1 of group -1 of group 1 exists then
			click button 1 of group -1 of group 1
		else if button 1 of group -1 exists then
			click button 1 of group -1
		end if
		
	end tell
end tell

この AppleScript を Apple 純正「ショートカット」アプリでショートカットキーに割り当てれば完璧ですね(割り当て方はこの記事を参照)。

簡略的な解説

この AppleScript は「YouTube の自動再生ボタンをクリック」しているだけです。

質問があればコメントにどうぞ。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1