Skip to content

Instantly share code, notes, and snippets.

Created March 8, 2018 05:04
Show Gist options
  • Save anonymous/0d3bcab295707ad8a4c3ecbf2823213c to your computer and use it in GitHub Desktop.
Save anonymous/0d3bcab295707ad8a4c3ecbf2823213c to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<root>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_86-space</name>
<url type="shell">
osascript -e '
tell application "System Events"
set activeApp to (get name of first process where it is frontmost)
end tell
if activeApp is "Safari" then
tell application "Safari"
set wURL to get URL of document 1
end tell
delay 0.03
if wURL contains "/watch" then
tell application "System Events"
key code 44
delay 0.03
key code 51
delay 0.03
repeat 6 times
delay 0.03
key code 48
end repeat
key code 40
end tell
else
tell application "System Events"
key code 49
end tell
end if
end if
if activeApp is "Google Chrome" or activeApp is "Opera" then
tell application "System Events"
tell application process activeApp
set wURL to (get value of text field 1 of toolbar 1 of window 1)
end tell
end tell
delay 0.03
if wURL contains "/watch" then
tell application "System Events"
key code 44
delay 0.03
key code 51
delay 0.03
repeat 6 times
delay 0.03
key code 48
end repeat
key code 40
end tell
else
tell application "System Events"
key code 49
end tell
end if
end if
'
</url>
</vkopenurldef>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_86-leftarrow</name>
<url type="shell">
osascript -e '
set myRepeat to 1 -- 1 = 5 secs, 2 = 10 secs, 3 = 15 secs
tell application "System Events"
set activeApp to (get name of first process where it is frontmost)
end tell
if activeApp is "Google Chrome" or activeApp is "Opera" then
tell application "System Events"
tell application process activeApp
set wURL to (get value of text field 1 of toolbar 1 of window 1)
end tell
end tell
delay 0.03
if wURL contains "/watch" then
tell application "System Events"
key code 44
delay 0.03
key code 51
delay 0.03
repeat 6 times
delay 0.03
key code 48
end repeat
repeat myRepeat times
key code 123
end repeat
end tell
else
tell application "System Events"
key code 123
end tell
end if
end if
if activeApp is "Safari" then
tell application "Safari"
set wURL to get URL of document 1
end tell
delay 0.03
if wURL contains "/watch" then
tell application "System Events"
key code 44
delay 0.03
key code 51
delay 0.03
repeat 6 times
delay 0.03
key code 48
end repeat
repeat myRepeat times
key code 123
end repeat
end tell
else
tell application "System Events"
key code 123
end tell
end if
end if
'
</url>
</vkopenurldef>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_86-rightarrow</name>
<url type="shell">
osascript -e '
set myRepeat to 1 -- 1 = 5 secs, 2 = 10 secs, 3 = 15 secs
tell application "System Events"
set activeApp to (get name of first process where it is frontmost)
end tell
if activeApp is "Google Chrome" or activeApp is "Opera" then
tell application "System Events"
tell application process activeApp
set wURL to (get value of text field 1 of toolbar 1 of window 1)
end tell
end tell
delay 0.03
if wURL contains "/watch" then
tell application "System Events"
key code 44
delay 0.03
key code 51
delay 0.03
repeat 6 times
delay 0.03
key code 48
end repeat
repeat myRepeat times
key code 124
end repeat
end tell
else
tell application "System Events"
key code 124
end tell
end if
end if
if activeApp is "Safari" then
tell application "Safari"
set wURL to get URL of document 1
end tell
delay 0.03
if wURL contains "/watch" then
tell application "System Events"
key code 44
delay 0.03
key code 51
delay 0.03
repeat 6 times
delay 0.03
key code 48
end repeat
repeat myRepeat times
key code 124
end repeat
end tell
else
tell application "System Events"
key code 124
end tell
end if
end if
'
</url>
</vkopenurldef>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_86-uparrow</name>
<url type="shell">
osascript -e '
tell application "System Events"
set activeApp to (get name of first process where it is frontmost)
end tell
if activeApp is "Google Chrome" or activeApp is "Opera" then
tell application "System Events"
tell application process activeApp
set wURL to (get value of text field 1 of toolbar 1 of window 1)
end tell
end tell
delay 0.03
if wURL contains "/watch" then
tell application "System Events"
key code 44
delay 0.03
key code 51
delay 0.03
repeat 9 times
delay 0.03
key code 48
end repeat
key code 126
end tell
else
tell application "System Events"
key code 126
end tell
end if
end if
if activeApp is "Safari" then
tell application "Safari"
set wURL to get URL of document 1
end tell
delay 0.03
if wURL contains "/watch" then
tell application "System Events"
key code 44
delay 0.03
key code 51
delay 0.03
repeat 9 times
delay 0.03
key code 48
end repeat
key code 126
end tell
else
tell application "System Events"
key code 126
end tell
end if
end if
'
</url>
</vkopenurldef>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_86-downarrow</name>
<url type="shell">
osascript -e '
tell application "System Events"
set activeApp to (get name of first process where it is frontmost)
end tell
if activeApp is "Google Chrome" or activeApp is "Opera" then
tell application "System Events"
tell application process activeApp
set wURL to (get value of text field 1 of toolbar 1 of window 1)
end tell
end tell
delay 0.03
if wURL contains "/watch" then
tell application "System Events"
key code 44
delay 0.03
key code 51
delay 0.03
repeat 9 times
delay 0.03
key code 48
end repeat
key code 125
end tell
else
tell application "System Events"
key code 125
end tell
end if
end if
if activeApp is "Safari" then
tell application "Safari"
set wURL to get URL of document 1
end tell
delay 0.03
if wURL contains "/watch" then
tell application "System Events"
key code 44
delay 0.03
key code 51
delay 0.03
repeat 9 times
delay 0.03
key code 48
end repeat
key code 125
end tell
else
tell application "System Events"
key code 125
end tell
end if
end if
'
</url>
</vkopenurldef>
<windownamedef>
<name>YouTube</name>
<regex> - YouTube 🔊$</regex>
<regex> - YouTube$</regex>
</windownamedef>
<item>
<name>My Key 86.3: Make YouTube Keyboard Shortcuts Work When Video is not in Focus</name>
<!-- my key 86.3 for Opera,Chrome,Safari -->
<item>
<name>Spacebar</name>
<identifier>My Key 86.1-spacebar</identifier>
<windowname_only>YouTube</windowname_only>
<uielementrole_not>AXTextField, AXTextArea</uielementrole_not>
<autogen>
--KeyToKey--
KeyCode::SPACE, ModifierFlag::NONE,
KeyCode::VK_OPEN_URL_86-space,
</autogen>
</item>
<item>
<name>Up-arrow</name>
<identifier>My Key 86-Up-arrow</identifier>
<windowname_only>YouTube</windowname_only>
<uielementrole_not>AXTextField, AXTextArea</uielementrole_not>
<autogen>
--KeyToKey--
KeyCode::CURSOR_UP, ModifierFlag::NONE,
KeyCode::VK_OPEN_URL_86-uparrow,
</autogen>
</item>
<item>
<name>Down-arrow</name>
<identifier>My Key 86-Down-arrow</identifier>
<windowname_only>YouTube</windowname_only>
<uielementrole_not>AXTextField, AXTextArea</uielementrole_not>
<autogen>
--KeyToKey--
KeyCode::CURSOR_DOWN, ModifierFlag::NONE,
KeyCode::VK_OPEN_URL_86-downarrow,
</autogen>
</item>
<item>
<name>Left-arrow</name>
<identifier>My Key 86-Left-arrow</identifier>
<windowname_only>YouTube</windowname_only>
<uielementrole_not>AXTextField, AXTextArea</uielementrole_not>
<autogen>
--KeyToKey--
KeyCode::CURSOR_LEFT, ModifierFlag::NONE,
KeyCode::VK_OPEN_URL_86-leftarrow,
</autogen>
</item>
<item>
<name>Right-arrow</name>
<identifier>My Key 86-Right-arrow</identifier>
<windowname_only>YouTube</windowname_only>
<uielementrole_not>AXTextField, AXTextArea</uielementrole_not>
<autogen>
--KeyToKey--
KeyCode::CURSOR_RIGHT, ModifierFlag::NONE,
KeyCode::VK_OPEN_URL_86-rightarrow,
</autogen>
</item>
</item>
</root>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment