Spotify hotkeys

Allows hotkeys and media keys to control the Spotify web player from any tab

< 腳本Spotify hotkeys的回應

提問/評論

§
發表於:2020-03-21

Fixed script

Script wasn't working on latest Greasemonkey version due to API changes. Here's the fixed version:

// ==UserScript== // @name Spotify hotkeys // @version 1.3 // @description Allows hotkeys and media keys to control the Spotify web player from any tab // @author CennoxX // @contact [email protected] // @homepage https://twitter.com/CennoxX // @namespace https://gf.qytechs.cn/users/21515 // @include * // @grant GM.getValue // @grant GM.setValue // ==/UserScript== document.addEventListener('keydown', async function (e) { if (e.ctrlKey && e.altKey && e.key == "p" || e.key == "MediaPlayPause") await GM.setValue("ctrl", "[class*='spoticon-play-'],[class*='spoticon-pause-']"); if (e.ctrlKey && e.altKey && e.key == "s" || e.key == "MediaStop") await GM.setValue("ctrl", "[class*='spoticon-pause-']"); if (e.ctrlKey && e.altKey && e.key == "," || e.key == "MediaTrackPrevious") await GM.setValue("ctrl", "[class*='spoticon-skip-back-']"); if (e.ctrlKey && e.altKey && e.key == "." || e.key == "MediaTrackNext") await GM.setValue("ctrl", "[class*='spoticon-skip-forward-']"); }, false); if (document.domain == "open.spotify.com") { setInterval(async function () { var ctrl = await GM.getValue("ctrl"); if (ctrl) { document.querySelector(ctrl).click(); await GM.setValue("ctrl", ""); } }, 100); }

發表回覆

登入以回復

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址