Skip to content

Instantly share code, notes, and snippets.

@kphrx
Last active March 26, 2024 05:45
Show Gist options
  • Save kphrx/2d7c91067c42453ec88a65e2202c2144 to your computer and use it in GitHub Desktop.
Save kphrx/2d7c91067c42453ec88a65e2202c2144 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Amazon Prime Video auto hide the next up card
// @namespace http://tampermonkey.net/
// @version 1.3.4
// @author kPherox
// @match https://www.amazon.co.jp/gp/video/*
// @match https://www.amazon.co.jp/Amazon-Video/*
// @updateURL https://gist.github.com/kphrx/2d7c91067c42453ec88a65e2202c2144/raw/primevideo-autohide-nextupcard.user.js
// @downloadURL https://gist.github.com/kphrx/2d7c91067c42453ec88a65e2202c2144/raw/primevideo-autohide-nextupcard.user.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
const NextUpCard = {
autohide () {
return this.querySelector('.atvwebplayersdk-nextupcardhide-button')?.click();
},
autohideObserve (config = {childList: true, subtree: true}) {
return new MutationObserver(() => {this.autohide()}).observe(this, config);
},
};
Element.prototype.autohideObserve = Element.prototype.autohideObserve || NextUpCard.autohideObserve;
Element.prototype.autohide = Element.prototype.autohide || NextUpCard.autohide;
const nextUpCard = () => {
return document.querySelector('.atvwebplayersdk-nextupcard-wrapper');
};
if (nextUpCard()?.autohideObserve()) {
nextUpCard().autohide();
return;
}
new MutationObserver((_, observer) => {
if (nextUpCard()?.autohideObserve()) {
observer.disconnect();
nextUpCard().autohide();
return;
}
}).observe(document, {childList: true, subtree: true});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment