Created
August 5, 2019 09:11
-
-
Save MaxXx1313/06f5851a26e000864dd2d9c954e670ae to your computer and use it in GitHub Desktop.
Enable global media keys in vk.com (tampermonkey)
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
// ==UserScript== | |
// @name Enable global media keys in vk.com | |
// @namespace http://github.com/MaxXx1313 | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://vk.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
navigator.mediaSession.setActionHandler('previoustrack', function() { | |
document.querySelector('[accesskey="j"]').click(); | |
}); | |
navigator.mediaSession.setActionHandler('nexttrack', function() { | |
document.querySelector('[accesskey="l"]').click(); | |
}); | |
navigator.mediaSession.setActionHandler('playpause', function() { | |
document.querySelector('[accesskey="k"]').click(); | |
}); | |
navigator.mediaSession.setActionHandler('play', function() { | |
document.querySelector('[accesskey="k"]').click(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment