Skip to content

Instantly share code, notes, and snippets.

@chergik
Last active December 1, 2023 10:52
Show Gist options
  • Save chergik/74c3fa0a96114eb7b2b5e0ea3eb4d5cc to your computer and use it in GitHub Desktop.
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.
// ==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);
})();
@monish-1234
Copy link

image

Not Working :(

@chergik
Copy link
Author

chergik commented Jun 14, 2020

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.

@monish-1234
Copy link

Working ! Thanks <3

@wduandy
Copy link

wduandy commented Jan 20, 2022

Can you make a script to auto skip that ad before the video starts?

@Sprunkmiester
Copy link

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