Last active
April 18, 2025 06:08
-
-
Save kphrx/2d7c91067c42453ec88a65e2202c2144 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 auto hide the next up card | |
// @namespace https://kpherox.dev/ | |
// @version 1.4.0 | |
// @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 getNextUpCard = () => { | |
return document.querySelector('.atvwebplayersdk-nextupcard-wrapper'); | |
}; | |
const detectNextUpCard = () => { | |
const nextUpCard = getNextUpCard(); | |
if (nextUpCard != null) { | |
nextUpCard.autohideObserve(); | |
nextUpCard.autohide(); | |
return true; | |
} | |
return false; | |
} | |
if (detectNextUpCard()) { | |
return; | |
} | |
new MutationObserver((_, observer) => { | |
if (detectNextUpCard()) { | |
observer.disconnect(); | |
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