CLICK TO PAUSE/PLAY

Userscript that enables pause/play on click for kick.com

当前为 2024-01-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name CLICK TO PAUSE/PLAY
  3. // @description Userscript that enables pause/play on click for kick.com
  4. // @version 5.0
  5. // @grant none
  6. // @author Trilla_G
  7. // @match *://kick.com/*
  8. // @namespace https://greasyfork.org/en/users/1200587-trilla-g
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. document.addEventListener("click", clickHandler, false);
  14.  
  15. function clickHandler(e) {
  16. // Check if the click is on the video element
  17. let player = getPlayer();
  18. if (!player || e.target !== player) {
  19. return;
  20. }
  21.  
  22. // Prevent default action
  23. e.preventDefault();
  24.  
  25. // Toggle play/pause
  26. if (player.paused) {
  27. // Video is paused, click on the big play button
  28. let playButton = getPlayButton();
  29. if (playButton) {
  30. playButton.click();
  31. }
  32. } else {
  33. // Video is playing, pause the video
  34. player.pause();
  35. }
  36. }
  37.  
  38. function getPlayer() {
  39. var possibleVideo = document.querySelector('.vjs-tech');
  40. if (!possibleVideo || possibleVideo.nodeName !== "VIDEO") {
  41. return null;
  42. }
  43. return possibleVideo;
  44. }
  45.  
  46. function getPlayButton() {
  47. var playButton = document.querySelector('.vjs-big-play-button');
  48. return playButton;
  49. }
  50. })();
  51.