Last active
December 1, 2023 10:52
-
-
Save chergik/74c3fa0a96114eb7b2b5e0ea3eb4d5cc to your computer and use it in GitHub Desktop.
Tampermonkey script to hide annoying cursor when video is playing on Amazon Prime.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Amazon-Prime-Video-hide-hand | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Remove annoying cursor hand while watching the video. | |
// @author Andrey Chergik | |
// @include /^https://www\.(amazon|primevideo)\.com/.*$/ | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var loggingPrefix = "Amazon-Prime-Video-hide-hand"; | |
var logging = false; // CHANGE TO TRUE TO ENABLE LOGGING INTO THE BROWSER CONSOLE (access it via Option+Command+i). | |
var isUndefOrNull = function (o) { | |
return (typeof o === 'undefined' || o === null); | |
}; | |
var isEmpty = function(a) { | |
return a.length === 0; | |
}; | |
var getDeepNode = function (root, indices) { | |
if (isUndefOrNull(root) || isUndefOrNull(indices) || isEmpty(indices)) return null; | |
for (var i = 0; i < indices.length; ++i) { | |
if (isUndefOrNull(root) || isUndefOrNull(root.childNodes) || indices[i] >= root.childNodes.length) return null; | |
root = root.childNodes[indices[i]]; | |
} | |
return root; | |
}; | |
var log = function(msg) { | |
if (isUndefOrNull(msg)) return; | |
if (!logging) return; | |
console.log(loggingPrefix + ": " + msg); | |
}; | |
var interval = setInterval(function() { | |
log("START"); | |
var webPlayerUiContainer = document.querySelectorAll(".webPlayerUIContainer")[0]; | |
log("CONT: " + webPlayerUiContainer); | |
if (isUndefOrNull(webPlayerUiContainer)) return; | |
log("CONT is not null"); | |
var movieScreen = getDeepNode(webPlayerUiContainer, [0,0,1,0,2]); | |
log("MOVIE SCREEN:" + movieScreen); | |
if (isUndefOrNull(movieScreen)) return; | |
log("MOVIE SCREEN.style.cursor: " + movieScreen.style.cursor) | |
var cursor = window.getComputedStyle(movieScreen).getPropertyValue('cursor'); | |
log("CURSOR style: " + cursor); | |
if (cursor !== "pointer") return; | |
movieScreen.style.cursor = 'none'; | |
var controls = movieScreen.childNodes[0]; | |
if (isUndefOrNull(controls)) return; | |
log("CONTROLS: " + controls); | |
controls.style.cursor = 'auto'; | |
clearInterval(interval); | |
}, 2000); | |
})(); |
webPlayerUIContainer is renamed now? Never mind it appears on some OS amazon has it setup with webPlayerContainer carry on
webPlayerUIContainer is renamed now? Never mind it appears on some OS amazon has it setup with webPlayerContainer carry on
If you think it is the case, then I'd love to merge your changes to adapt that other container name to this script.
It was not working because the it was meant for the amazon.com and not the primevideo.com. I added the latter to the regular expression and now it should work.
Working ! Thanks <3
Can you make a script to auto skip that ad before the video starts?
Logged into to say: Thank you kindly for sharing this with the world.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
amazon-prime-video-hide-cursor
Tampermonkey script to hide annoying cursor when a video is playing.