Greasy Fork

Greasy Fork is available in English.

Prime Video Sólo Contenido Prime [ESP]

Oculta las secciones de compra o alquiler en la portada de Amazon Prime Video España.

当前为 2024-11-04 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name          Prime Video Sólo Contenido Prime [ESP]
// @namespace     http://tampermonkey.net/
// @version       0.3.1
// @description   Oculta las secciones de compra o alquiler en la portada de Amazon Prime Video España.
// @author        Jeau
// @license       MIT
// @match         https://*.primevideo.com/*
// @icon          https://m.media-amazon.com/images/G/01/digital/video/DVUI/favicons/favicon-32x32.png
// @require       https://code.jquery.com/jquery-latest.min.js
// @grant         none
// @run-at        document-end
// ==/UserScript==

(function() {
    'use strict';

    // Hide every carousel with payment requirements
    function checkCarousels() {
        // Script won't work on 'store' pages
        if (location.href.includes('/addons')) return;
        if (location.href.includes('/livetv')) return;
        if (location.href.includes('/collection/homepremiere')) return;

        // Hide subscription carousels
        $('section[data-testid*="carousel"]').each(function() {
            if ($(this).find('div[data-testid="card-overlay"]').find('svg').length) {
                let carousel = this;

                // Avoid hiding "Keep watching" carousel
                if ($(carousel).find('span[data-testid="carousel-title"]').length) {
                    let carouselTitle = $(carousel).find('span[data-testid="carousel-title"]')[0].firstElementChild.innerText.toUpperCase();
                    // Case: "Keep Watching" carousel only
                    if (carouselTitle.includes('SEGUIR VIENDO')) {
                        $(carousel).find('article[data-testid="card"]').each(function() {
                            // Hide the card with purchase requirements only
                            if ($(this).find('div[data-testid="card-overlay"]').find('svg').length) {
                                $(this).css('display', 'none');
                            }
                        });
                    } else {
                        $(carousel).parent().css('display', 'none');
                        return true;
                    }
                } else {
                    $(carousel).parent().css('display', 'none');
                    return true;
                }
            }
        });
    }

    // Dinamically check any new node added to the webpage
    function checkNewNode(n) {
        // // Script won't work on 'store' pages
        if (location.href.includes('/addons')) return;
        if (location.href.includes('/livetv')) return;
        if (location.href.includes('/collection/homepremiere')) return;

        // Hide subscription carousels
        if ($(n).find('section[data-testid*="carousel"]').length) {
            $(n).find('section[data-testid*="carousel"]').each(function() {
                try {
                    if ($(this).find('div[data-testid="card-overlay"]').find('svg').length) {
                        let carousel = this;

                        // Avoid hiding "Keep watching" carousel
                        if ($(carousel).find('span[data-testid="carousel-title"]').length) {
                            let carouselTitle = $(carousel).find('span[data-testid="carousel-title"]')[0].firstElementChild.innerText.toUpperCase();
                            // Case: "Keep Watching" carousel only
                            if (carouselTitle.includes('SEGUIR VIENDO')) {
                                $(carousel).find('article[data-testid="card"]').each(function() {
                                    // Hide the card with purchase requirements only
                                    if ($(this).find('div[data-testid="card-overlay"]').find('svg').length) {
                                        $(this).css('display', 'none');
                                    }
                                });
                            } else {
                                $(carousel).parent().css('display', 'none');
                                return true;
                            }
                        } else {
                            $(carousel).parent().css('display', 'none');
                            return true;
                        }
                    }
                } catch(e) {
                    console.log('\n\n\n');
                    console.log('Error userscript "Mostrar Sólo Prime" (MutationObserver) !!!!');
                    console.log('Estructura no reconocida en el siguiente elemento:');
                    console.log(n);
                    console.log('\n\n\n');
                }
            });
        }
    }

    // Check carousels on windows load
    checkCarousels();

    // Declaration of Mutation observer
    let observer = new MutationObserver((mutations) => {
        for (const { addedNodes } of mutations) {
            for (const n of addedNodes) {
                if (n.tagName) {
                    checkNewNode(n);
                }
            }
        }
    });

    observer.observe(document, {
        subtree: true,
        childList: true,
        characterData: false
    });

})();