Radio.net space for toggle play/pause

Makes it so spacebar toggles pause/play instead of scrolling down the page.

  1. // ==UserScript==
  2. // @name Radio.net space for toggle play/pause
  3. // @namespace https://github.com/Alistair1231/my-userscripts/
  4. // @version 0.1.4
  5. // @description Makes it so spacebar toggles pause/play instead of scrolling down the page.
  6. // @author Alistair1231
  7. // @match https://www.radio.net/s/*
  8. // @icon https://icons.duckduckgo.com/ip2/radio.net.ico
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function togglePlayingState(e){
  16. if(e.keyCode==32){
  17. e.preventDefault();
  18. let playButton = document.querySelector(".player__button.player__button--stopped.icon-play-circle")
  19. let stopButton = document.querySelector(".player__button.player__button--playing.icon-play-circle")
  20.  
  21. let currentlyPlaying= playButton.style["display"]=='none' // play button hidden
  22.  
  23. if(currentlyPlaying){
  24. console.log("stop")
  25. stopButton.click()
  26. }
  27. else{
  28. console.log("start")
  29. playButton.click()
  30. }
  31. }
  32. }
  33.  
  34. document.addEventListener('keydown', togglePlayingState, false);
  35.  
  36.  
  37. })();

QingJ © 2025

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