Allows hotkeys and media keys to control the Spotify web player from any tab
< 腳本Spotify hotkeys的回應
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或关注我们的公众号极客氢云获取最新地址
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); }