Spotify hotkeys

Adds hotkeys to control the Spotify webplayer from any tab

Fra og med 02.07.2019. Se den nyeste version.

// ==UserScript==
// @name        Spotify hotkeys
// @version     1.2
// @description Adds hotkeys to control the Spotify webplayer from any tab
// @author      CennoxX
// @contact     [email protected]
// @homepage    https://twitter.com/CennoxX
// @namespace   https://greasyfork.org/users/21515
// @include     *
// @grant       GM_getValue
// @grant       GM_setValue
// ==/UserScript==
document.addEventListener('keydown', function (e) {
  if (e.ctrlKey && e.altKey && e.keyCode == 80) // ctrl+alt+p
  GM_setValue('ctrl', '.spoticon-play-32,.spoticon-pause-32,.spoticon-play-16,.spoticon-pause-16');
  if (e.ctrlKey && e.altKey && e.keyCode == 83) // ctrl+alt+s
  GM_setValue('ctrl', '.spoticon-pause-32,.spoticon-pause-16');
  if (e.ctrlKey && e.altKey && e.keyCode == 188) // ctrl+alt+,
  GM_setValue('ctrl', '.spoticon-skip-back-24,.spoticon-skip-back-16');
  if (e.ctrlKey && e.altKey && e.keyCode == 190) // ctrl+alt+.
  GM_setValue('ctrl', '.spoticon-skip-forward-24,.spoticon-skip-forward-16');
}, false);
if (document.domain == 'open.spotify.com') {
  setInterval(function () {
    var ctrl = GM_getValue('ctrl');
    if (ctrl) {
      document.querySelector(ctrl).click();
      GM_setValue('ctrl', '');
    }
  }, 100);
}