Greasy Fork

Prime Video - 仅显示 Prime 内容

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

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

// ==UserScript==
// @name                Prime Video Sólo Contenido Prime [ESP]
// @name:en             Prime Video - Show Prime Content Only
// @name:pt             Prime Video - Mostrar apenas conteúdo Prime
// @name:fr             Prime Video - Afficher uniquement le contenu Prime
// @name:it             Prime Video - Mostra solo contenuti Prime
// @name:de             Prime Video - Nur Prime-Inhalte anzeigen
// @name:nl             Prime Video - Alleen Prime-content weergeven
// @name:da             Prime Video - Vis kun Prime-indhold
// @name:ro             Prime Video - Afișează doar conținutul Prime
// @name:fi             Prime Video - Näytä vain Prime-sisältö
// @name:pl             Prime Video - Pokaż tylko treści Prime
// @name:nn             Prime Video – Vis berre Prime-innhald
// @name:hu             Prime Video - Csak Prime-tartalmat jelenítsen meg
// @name:ms             Prime Video - Paparkan Kandungan Prime Sahaja
// @name:id             Prime Video - Tampilkan Konten Prime Saja
// @name:sv             Prime Video - Visa endast Prime-innehåll
// @name:tr             Prime Video - Sadece Prime içeriğini göster
// @name:fil            Prime Video - Ipakita lamang ang Prime na Nilalaman
// @name:cs             Prime Video - Zobrazit pouze obsah Prime
// @name:el             Prime Video - Εμφάνιση μόνο περιεχομένου Prime
// @name:ru             Prime Video - Показывать только контент Prime
// @name:ar             برايم فيديو - عرض محتوى برايم فقط
// @name:hi             प्राइम वीडियो - केवल प्राइम सामग्री दिखाएं
// @name:ta             பிரைம் வீடியோ - பிரைம் உள்ளடக்கத்தை மட்டும் காட்டு
// @name:te             ప్రైమ్ వీడియో - కేవలం ప్రైమ్ కంటెంట్ మాత్రమే చూపించు
// @name:th             Prime Video - แสดงเฉพาะเนื้อหา Prime เท่านั้น
// @name:ja             Prime Video - プライムコンテンツのみ表示
// @name:zh-CN          Prime Video - 仅显示 Prime 内容
// @name:zh-TW          Prime Video - 僅顯示 Prime 內容
// @name:ko             Prime Video - 프라임 콘텐츠만 표시
// @namespace           http://tampermonkey.net/
// @version             0.3.6
// @description         Oculta las secciones de compra o alquiler en la portada de Amazon Prime Video.
// @description:en      Hide the purchase or rental sections on the Amazon Prime Video homepage.
// @author              Jeau
// @license             MIT
// @match               https://*.amazon.co.jp/*
// @match               https://*.amazon.com/*
// @match               https://*.amazon.ae/*
// @match               https://*.amazon.co.uk/*
// @match               https://*.amazon.it/*
// @match               https://*.amazon.in/*
// @match               https://*.amazon.eg/*
// @match               https://*.amazon.com.au/*
// @match               https://*.amazon.nl/*
// @match               https://*.amazon.ca/*
// @match               https://*.amazon.sa/*
// @match               https://*.amazon.sg/*
// @match               https://*.amazon.se/*
// @match               https://*.amazon.es/*
// @match               https://*.amazon.de/*
// @match               https://*.amazon.com.tr/*
// @match               https://*.amazon.com.br/*
// @match               https://*.amazon.fr/*
// @match               https://*.amazon.com.be/*
// @match               https://*.amazon.pl/*
// @match               https://*.amazon.com.mx/*
// @match               https://*.amazon.cn/*
// @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
// @description:pt      Oculta as secções de compra ou aluguer no Amazon Prime Video
// @description:fr      Masque les sections d'achat ou de location sur Amazon Prime Video
// @description:it      Nasconde le sezioni di acquisto o noleggio su Amazon Prime Video
// @description:de      Blendet die Kauf- oder Mietbereiche auf Amazon Prime Video aus
// @description:nl      Verbergt de koop- of huursecties op Amazon Prime Video
// @description:da      Skjuler købs- eller lejefelterne på Amazon Prime Video
// @description:ro      Ascunde secțiunile de cumpărare sau închiriere de pe Amazon Prime Video
// @description:fi      Piilottaa osto- tai vuokrausosiot Amazon Prime Videossa
// @description:pl      Ukrywa sekcje zakupu lub wypożyczenia na Amazon Prime Video
// @description:nn      Gøymer kjøps- eller leigedelar på framsida til Amazon Prime Video
// @description:hu      Elrejti a vásárlási vagy bérlési szekciókat az Amazon Prime Videón
// @description:ms      Menyembunyikan bahagian pembelian atau sewaan pada Amazon Prime Video
// @description:id      Menyembunyikan bagian pembelian atau penyewaan di Amazon Prime Video
// @description:sv      Döljer köp- eller uthyrningssektionerna på Amazon Prime Video
// @description:tr      Amazon Prime Video'daki satın alma veya kiralama bölümlerini gizler
// @description:fil     Itinatago ang mga seksyon ng pagbili o pag-upa sa Amazon Prime Video
// @description:cs      Skrývá sekce nákupu nebo pronájmu na Amazon Prime Video
// @description:el      Αποκρύπτει τα τμήματα αγοράς ή ενοικίασης στο Amazon Prime Video
// @description:ru      Скрывает разделы покупки или аренды на Amazon Prime Video
// @description:ar      يخفي أقسام الشراء أو الاستئجار على أمازون برايم فيديو
// @description:hi      अमेज़न प्राइम वीडियो पर खरीद या किराए के अनुभाग छिपाता है
// @description:ta      அமேசான் பிரைம் வீடியோவில் கொள்முதல் அல்லது வாடகைப் பிரிவுகளை மறைக்கிறது
// @description:te      అమెజాన్ ప్రైమ్ వీడియోలో కొనుగోలు లేదా అద్దె విభాగాలను దాస్తుంది
// @description:th      ซ่อนส่วนการซื้อหรือเช่าใน Amazon Prime Video
// @description:ja      Amazon Prime Videoの購入またはレンタルセクションを隠します
// @description:zh-cn   隐藏 Amazon Prime Video 上的购买或租赁部分
// @description:zh-tw   隱藏 Amazon Prime Video 上的購買或租賃部分
// @description:ko      Amazon Prime Video에서 구매 또는 대여 섹션을 숨깁니다
// ==/UserScript==

/*
  ***********************************************************************************************************
   This script has only been tested on Prime Video Spain site, but it might work in other countries as well.
   If you know how to make it work in your country, please let me know in the comments so I can fix it.
  ***********************************************************************************************************
*/

(function() {
    'use strict';

    var CONTINUE_WATCHING_STR = localizedContinueWatchingString();

    // Check node added to the webpage
    function checkNodes(n) {
        // Script won't work on 'store' and personal account pages
        if (location.href.includes('/search')) return;
        if (location.href.includes('/detail')) return;
        if (location.href.includes('/settings')) return;
        if (location.href.includes('/mystuff')) return;
        if (location.href.includes('/addons')) return;
        if (location.href.includes('/subscription')) return;
        if (location.href.includes('/livetv')) return;
        if (location.href.includes('/collection/homepremiere')) return;

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

                        // Check every carousel
                        let carouselTitleEl = $(carousel).find('span[data-testid="carousel-title"]');
                        if (carouselTitleEl.length) {
                            let carouselTitle = carouselTitleEl[0].firstElementChild.innerText.toUpperCase();
                            // Case: "Continue Watching" carousel only
                            if (carouselTitle.includes(CONTINUE_WATCHING_STR)) {
                                $(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 window load
    checkNodes(document.body);

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

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


    // Get the localized string for 'Continue Watching' section using Amazon site language
    function localizedContinueWatchingString() {
        var str;
        try {
            let userButtonStr = document.querySelector('button[data-testid="pv-nav-account-dropdown-trigger"]').getAttribute('aria-label');
            // English
            if (userButtonStr.includes('Profile, Settings, and Account')) {
                str = 'Continue watching';
            // Spanish - Español
            } else if (userButtonStr.includes('Perfil, Configuración y Cuenta')) {
                str = 'Seguir viendo';
            // Portuguese (Brazil) - Portugués (Brasil)
            } else if (userButtonStr.includes('Perfil, configurações e conta')) {
                str = 'Continuar assistindo';
            // Portuguese (Portugal) - Português (Portugal)
            } else if (userButtonStr.includes('Perfil, Definições e Conta')) {
                str = 'Continuar a ver';
            // French - Français
            } else if (userButtonStr.includes('Profil, paramètres et compte')) {
                str = 'Continuez à regarder';
            // Italian - Italiano
            } else if (userButtonStr.includes('Profilo, impostazioni e account')) {
                str = 'Continua a guardare';
            // German - Deutsch
            } else if (userButtonStr.includes('Profil, Einstellungen und Konto')) {
                str = 'Fortsetzen';
            // Dutch - Nederlands
            } else if (userButtonStr.includes('Profiel, instellingen en account')) {
                str = 'Kijk Verder';
            // Danish - Dansk
            } else if (userButtonStr.includes('Profil, indstillinger og konto')) {
                str = 'Fortsæt med at se';
            // Romanian - Română
            } else if (userButtonStr.includes('Profil, Setări și Cont')) {
                str = 'Continuă să vizionezi';
            // Finnish - Suomi
            } else if (userButtonStr.includes('Profiili, asetukset ja tili')) {
                str = 'Jatka katsomista';
            // Polish - Polski
            } else if (userButtonStr.includes('Profil, ustawienia i konto')) {
                str = 'Kontynuuj oglądanie';
            // Norwegian - Norsk
            } else if (userButtonStr.includes('Profil, innstillinger og konto')) {
                str = 'Fortsett å se';
            // Hungarian - Magyar
            } else if (userButtonStr.includes('Profil, Beállítások és Fiók')) {
                str = 'Megtekintés folytatása';
            // Malay - Bahasa Melayu
            } else if (userButtonStr.includes('Profil, Tetapan dan Akaun')) {
                str = 'Teruskan menonton';
            // Indonesian - Bahasa Indonesia
            } else if (userButtonStr.includes('Profil, Pengaturan, dan Akun')) {
                str = 'Lanjutkan Menonton';
            // Swedish - Svenska
            } else if (userButtonStr.includes('Profil, inställningar och konto')) {
                str = 'Fortsätt se';
            // Turkish - Türkçe
            } else if (userButtonStr.includes('Profil, Ayarlar ve Hesap')) {
                str = 'İzlemeye Devam Et';
            // Filipino - Wikang Filipino
            } else if (userButtonStr.includes('Profile, Mga Setting, at Account')) {
                str = 'Magpatuloy sa panonood';
            // Czech - Čeština
            } else if (userButtonStr.includes('Profil, nastavení a účet')) {
                str = 'Pokračovat ve sledování';
            // Greek - Ελληνικά
            } else if (userButtonStr.includes('Προφίλ, Ρυθμίσεις και Λογαριασμός')) {
                str = 'Συνεχίστε να παρακολουθείτε';
            // Russian - Русский
            } else if (userButtonStr.includes('Профиль, настройки и аккаунт')) {
                str = 'Продолжить просмотр';
            // Arabic - العربية
            } else if (userButtonStr.includes('الملف الشخصي والإعدادات والحساب')) {
                str = 'متابعة المشاهدة';
            // Hindi - हिन्दी
            } else if (userButtonStr.includes('प्रोफ़ाइल, सेटिंग्स और अकाउंट')) {
                str = 'देखना जारी रखें';
            // Tamil - தமிழ்
            } else if (userButtonStr.includes('சுயவிவரம், அமைப்புகள் மற்றும் கணக்கு')) {
                str = 'தொடர்ந்து காண்க';
            // Telugu - తెలుగు
            } else if (userButtonStr.includes('ప్రొఫైల్, సెట్టింగ్‌లు మరియు ఖాతా')) {
                str = 'చూడటాన్ని కొనసాగించండి';
            // Thai - ไทย
            } else if (userButtonStr.includes('โปรไฟล์ การตั้งค่า และบัญชี')) {
                str = 'ดูต่อ';
            // Japanese - 日本語
            } else if (userButtonStr.includes('プロフィール、設定、アカウント')) {
                str = '続けて観る';
            // Simplified Chinese - 简体中文
            } else if (userButtonStr.includes('个人资料、设置和账户')) {
                str = '继续播放';
            // Traditional Chinese - 繁體中文
            } else if (userButtonStr.includes('個人檔案、設定和帳戶')) {
                str = '繼續觀看';
            // Korean - 한국어
            } else if (userButtonStr.includes('프로필, 설정, 계정')) {
                str = '계속 시청하기';
            }
            if (str) str = str.toUpperCase();

        // If checking actual Amazon site language fails then browser language is used
        } catch(e) {
            str = localizedStringFromBrowser();
        }
        if (!str) str = localizedStringFromBrowser();
        return str;
    }

    // Get the localized string for 'Continue Watching' section using browser language
    function localizedStringFromBrowser() {
        var str = 'CONTINUE WATCHING';
        let locale = navigator.language.tolowerCase();
        let lang = locale.split(/-|_/)[0];

        // English
        if (lang === 'en') {
            str = 'Continue watching';
        // Spanish
        } else if (lang === 'es') {
            str = 'Seguir viendo';
        // Portuguese (Brazil)
        } else if (locale === 'pt-br') {
            str = 'Continuar assistindo';
        // Portuguese (Portugal)
        } else if (lang === 'pt') {
            str = 'Continuar a ver';
        // French
        } else if (lang === 'fr') {
            str = 'Continuez à regarder';
        // Italian
        } else if (lang === 'it') {
            str = 'Continua a guardare';
        // German
        } else if (lang === 'de') {
            str = 'Fortsetzen';
        // Dutch
        } else if (lang === 'nl') {
            str = 'Kijk Verder';
        // Danish
        } else if (lang === 'da') {
            str = 'Fortsæt med at se';
        // Romanian
        } else if (lang === 'ro') {
            str = 'Continuă să vizionezi';
        // Finnish
        } else if (lang === 'fi') {
            str = 'Jatka katsomista';
        // Polish
        } else if (lang === 'pl') {
            str = 'Kontynuuj oglądanie';
        // Norwegian
        } else if (lang === 'no') {
            str = 'Fortsett å se';
        // Norwegian (Nynorsk)
        } else if (lang === 'nn') {
            str = 'Fortsett å se';
        // Hungarian
        } else if (lang === 'hu') {
            str = 'Megtekintés folytatása';
        // Malay
        } else if (lang === 'ms') {
            str = 'Teruskan menonton';
        // Indonesian
        } else if (lang === 'id') {
            str = 'Lanjutkan Menonton';
        // Swedish
        } else if (lang === 'sv') {
            str = 'Fortsätt se';
        // Turkish
        } else if (lang === 'tr') {
            str = 'İzlemeye Devam Et';
        // Filipino
        } else if (lang === 'fil') {
            str = 'Magpatuloy sa panonood';
        // Czech
        } else if (lang === 'cs') {
            str = 'Pokračovat ve sledování';
        // Greek
        } else if (lang === 'el') {
            str = 'Συνεχίστε να παρακολουθείτε';
        // Russian
        } else if (lang === 'ru') {
            str = 'Продолжить просмотр';
        // Arabic
        } else if (lang === 'ar') {
            str = 'متابعة المشاهدة';
        // Hindi
        } else if (lang === 'hi') {
            str = 'देखना जारी रखें';
        // Tamil
        } else if (lang === 'ta') {
            str = 'தொடர்ந்து காண்க';
        // Telugu
        } else if (lang === 'te') {
            str = 'చూడటాన్ని కొనసాగించండి';
        // Thai
        } else if (lang === 'th') {
            str = 'ดูต่อ';
        // Japanese
        } else if (lang === 'ja') {
            str = '続けて観る';
        // Simplified Chinese
        } else if (locale === 'zh-CN') {
            str = '继续播放';
        // Traditional Chinese
        } else if (locale === 'zh-TW') {
            str = '繼續觀看';
        // Korean
        } else if (lang === 'ko') {
            str = '계속 시청하기';
        }

        if (str) str = str.toUpperCase();
        return str;
    }
})();