CLICK TO PAUSE/PLAY

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

当前为 2023-11-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name CLICK TO PAUSE/PLAY
  3. // @description Userscript that enables pause/play on click for kick.com
  4. // @version 1
  5. // @grant none
  6. // @author Trilla_G
  7. // @include https://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 and toggle play/pause
  23. e.preventDefault();
  24. if (player.paused) {
  25. player.play();
  26. } else {
  27. player.pause();
  28. }
  29. }
  30.  
  31. function getPlayer() {
  32. var possibleVideo = document.querySelector('.vjs-tech');
  33. if (!possibleVideo || possibleVideo.nodeName !== "VIDEO") {
  34. return null;
  35. }
  36. return possibleVideo;
  37. }
  38. })();