Skip to content

Instantly share code, notes, and snippets.

@wizzie2
Last active June 6, 2020 12:01
Show Gist options
  • Save wizzie2/0895128f5fe96d376e4d4864aedebfc7 to your computer and use it in GitHub Desktop.
Save wizzie2/0895128f5fe96d376e4d4864aedebfc7 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Amazon Prime Video Mouse Fix
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Fix mouse cursor while watching fullscreen video
// @author Me
// @match https://*.primevideo.com/*
// @match http://*.primevideo.com/*
// @grant none
// ==/UserScript==
(function() {
"use strict";
var mouseVisible = true;
var timerHandle, playerElement;
var mouseMove = () => {
if (mouseVisible) {
playerElement.style.cursor = "auto";
clearTimeout( timerHandle );
timerHandle = setTimeout( () => {
playerElement.style.cursor = "none";
mouseVisible = false;
setTimeout( () => { mouseVisible = true; }, 200);
}, 1500);
}
}
document.addEventListener( "fullscreenchange", () => {
try {
var fullscreenElement = document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement;
if (fullscreenElement) {
playerElement = fullscreenElement
.childNodes[1]
.childNodes[0]
.childNodes[0]
.childNodes[0]
.childNodes[1]
.childNodes[0]
.childNodes[2];
document.addEventListener( "mousemove", mouseMove );
mouseMove();
} else {
document.removeEventListener( "mousemove", mouseMove );
clearTimeout( timerHandle );
playerElement.style.cursor = "auto";
}
} catch(e) { return; }
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment