Last active
March 26, 2024 05:45
-
-
Save kphrx/2d7c91067c42453ec88a65e2202c2144 to your computer and use it in GitHub Desktop.
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 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