Greasy Fork

Greasy Fork is available in English.

Prime Video Sólo Contenido Gratuito [ESP]

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

当前为 2023-07-09 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          Prime Video Sólo Contenido Gratuito [ESP]
// @namespace     http://tampermonkey.net/
// @version       0.2.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/
// @match         https://*.primevideo.com/storefront/*
// @match         https://*.primevideo.com/genre/*
// @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
// ==/UserScript==

(function() {
    'use strict';

    // Script won't work on 'store' pages
    if (location.href.includes('contentId=store')) {
        return;
    }

    var regularClass;
    var subscriptionClass;

    // Find the name of the regular Carousel Titles Class
    $('span[data-automation-id="carousel-title"]').each(function() {
        let classes = $(this).attr('class');
        if (classes != "" && classes.split(' ').length == 1) {
            regularClass = $(this).attr('class');
            return false;
        }
    });

    // Find the name of subscription Carousel Titles Class
    $('span[data-automation-id="carousel-title"]').each(function() {
        let classes = $(this).attr('class');
        if (classes != "" && classes.split(' ').length == 2 && classes.includes(regularClass)) {
            let classesArr = classes.split(' ');
            for (let i = 0; i <= classesArr.length; i++) {
                if (classesArr[i] != regularClass && !subscriptionClass) {
                    subscriptionClass = classesArr[i];
                }
            }
            return false;
        }
    });

    // Look for Subscription Classes and hide every carousel with it
    if (subscriptionClass) {
        $('span[data-automation-id="carousel-title"].' + subscriptionClass).each(function() {
            let carousel = this.closest('section').closest('div[class]');
            $(carousel).parent().remove();
        });
    }

    // Dinamically check any new node added to the webpage
    function checkNewNode(n) {
        // Hide subscription carousels
        if (n.tagName == 'DIV') {
            if ($(n).find('span[data-automation-id="carousel-title"].' + subscriptionClass).length) {
                $(n).find('span[data-automation-id="carousel-title"].' + subscriptionClass).each(function() {
                    let carousel = this.closest('section').closest('div[class]');
                    $(carousel).parent().remove();
                });
            }
        }

        // Hide subscription cards from "New on shopping" section
        if (n.tagName == 'SECTION') {
            if ($(n).find('span[data-testid="unentitled-icon"]').length) {
                let subIcon = $(n).find('span[data-testid="unentitled-icon"]')[0];
                if ($(subIcon).closest('section[data-testid="cover-container"]').length) {
                    $(subIcon).closest('section[data-testid="cover-container"]').remove();
                }
            }
        }
    }

    // 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
    });

})();