PornHub Hide Mouse Cursor

Hide mouse cursor (pointer) when watching videos on PornHub after 2 seconds of mouse inactivity

  1. // ==UserScript==
  2. // @name PornHub Hide Mouse Cursor
  3. // @name:ru PornHub скрывает курсор мыши
  4. // @namespace http://tampermonkey.net/
  5. // @version 1.1
  6. // @description Hide mouse cursor (pointer) when watching videos on PornHub after 2 seconds of mouse inactivity
  7. // @description:ru Скрытие курсора мыши при просмотре видео на PornHub после 2 секунд бездействия мыши
  8. // @author Paul Melekhov
  9. // @match *://*.pornhub.com/view_video.php?viewkey=*
  10. // @match *://*.youporn.com/watch/*
  11. // @grant none
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. let timeout;
  19.  
  20. const hideCursor = () => {
  21. document.body.style.cursor = 'none';
  22. };
  23.  
  24. const showCursor = () => {
  25. document.body.style.cursor = 'default';
  26. clearTimeout(timeout);
  27. timeout = setTimeout(hideCursor, 2000);
  28. };
  29.  
  30. const videoPlayer = document.querySelector('.mgp_videoWrapper');
  31.  
  32. if (videoPlayer) {
  33. const videoElement = videoPlayer.querySelector('video');
  34.  
  35. if (videoElement) {
  36. // Remove pointer-events manipulation for blocking elements
  37. videoPlayer.style.pointerEvents = 'auto';
  38. videoElement.style.pointerEvents = 'auto';
  39.  
  40. document.addEventListener('mousemove', () => {
  41. showCursor();
  42. }, true); // Use capture phase
  43.  
  44. videoPlayer.addEventListener('mouseenter', () => {
  45. showCursor();
  46. }, true); // Use capture phase
  47.  
  48. videoPlayer.addEventListener('mouseleave', () => {
  49. document.body.style.cursor = 'default';
  50. clearTimeout(timeout);
  51. }, true); // Use capture phase
  52.  
  53. videoElement.addEventListener('play', () => {
  54. showCursor();
  55. });
  56.  
  57. videoElement.addEventListener('pause', () => {
  58. document.body.style.cursor = 'default';
  59. clearTimeout(timeout);
  60. });
  61.  
  62. // Initial call to hide cursor after 2 seconds if there's no movement and video is playing
  63. if (!videoElement.paused) {
  64. console.log('initial');
  65. timeout = setTimeout(hideCursor, 2000);
  66. }
  67. }
  68. }
  69. })();