Last active
August 29, 2015 14:06
-
-
Save mityukov/a1eef45f3b5b0a02054b to your computer and use it in GitHub Desktop.
VK/YandexMusic remote control
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is AppleScript to play/pause player in VK.com or in Music.Yandex.ru | |
# Make it a Service (via Automator) and assign shortkey to call it. | |
# | |
# Look here: https://www.evernote.com/shard/s40/sh/a77fd23b-47f0-4b8d-a18f-6cea2c6dd4c4/389e1fe1622daff105433f75158bdd0d | |
# | |
# TODO: find a way to assign use <Play/Pause> key on keyboard to this shortcut | |
# + even better, if it would also listen to <Play/Pause> on my headphones cord (like iTunes) | |
# | |
# (c) Vladimir Mityukov, 2014 | |
set matchVK to "vk.com" | |
set matchYM to "music.yandex.ru" | |
tell application "Google Chrome" | |
set window_list to every window | |
repeat with the_window in window_list | |
set tab_list to every tab in the_window | |
repeat with the_tab in tab_list | |
set the_url to the URL of the_tab | |
if the_url contains matchVK then | |
tell the_tab | |
execute javascript "document.getElementById('gp_play').click();" | |
end tell | |
end if | |
if the_url contains matchYM then | |
tell the_tab | |
execute javascript "document.getElementsByClassName('player-controls__btn_play')[0].click();" | |
end tell | |
end if | |
end repeat | |
end repeat | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Эх, не понимаю я Objective C. Т.е., ни VK туда не впилить, ни себе перенять метод перехвата Media keys. :-(