CLICK TO PAUSE/PLAY

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

当前为 2023-12-21 提交的版本,查看 最新版本

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