Prime Video Ad Blocker [ESP]

Skip Ads and self Promotionals in Prime Video.

目前為 2025-06-05 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name            Prime Video Ad Blocker [ESP]
// @name:es         Prime Video Ad Blocker [ESP]
// @namespace       https://greasyfork.org/en/users/5102-jeau
// @version         0.3.2
// @description     Skip Ads and self Promotionals in Prime Video.
// @description:es  Bloquea los anuncios y promociones en Prime Video.
// @author          Jeau
// @license         MIT
// @match           https://*.amazon.co.jp/Amazon-Video/*
// @match           https://*.amazon.co.uk/Amazon-Video/*
// @match           https://*.amazon.com/Amazon-Video/*
// @match           https://*.amazon.de/Amazon-Video/*
// @match           https://*.amazon.com/*instant-video*
// @match           https://*.primevideo.com/*
// @icon            https://m.media-amazon.com/images/G/01/digital/video/DVUI/favicons/favicon-32x32.png
// @grant           none
// ==/UserScript==

/*
-----------------------------------------------------------------------------------
  Adapted for Amazon Prime Video Spain site. It might also work in other countries.
  Based on RawMeatEater's script:
  https://greasyfork.org/es/scripts/446723-amazon-video-ad-blocker
-----------------------------------------------------------------------------------
*/

(function() {
    'use strict';
    // This value when true shows that the Ad has been skipped
    var adSkipped = false;
    // Time pattern
    var adTimeRegExp = /(\d?\d:){0,2}\d?\d/;

    setInterval(function() {
        var video;
        var adTime;
        // In case of multiple video elements look for the one which is currently playing
        var renderers = document.getElementsByClassName("atvwebplayersdk-video-surface");
        if (renderers.length) {
            for (let i = renderers.length - 1; i >= 0; i--) {
                video = renderers[i].querySelector('video');
                if (video && video.currentTime) break;
            }
        }
        var promoTimeElement = document.getElementsByClassName("atvwebplayersdk-adtimeindicator-text")[0];
        var adTimeElement = document.getElementsByClassName("atvwebplayersdk-ad-timer-remaining-time")[0];
        // When detected stores the ad time in adTime
        if (adTimeElement && adTimeRegExp.test(adTimeElement.innerHTML)) adTime = adTimeElement;
        if (promoTimeElement && adTimeRegExp.test(promoTimeElement.innerHTML)) adTime = promoTimeElement;
        // If video started playing and a 'Time to Skip' element is detected
        if (video && video.currentTime && adTime) {
            // Has it been skipped aready? (To be sure that you don't skip forward twice)
            if (adSkipped == false) {
                // Grab the Ad timer in HH:MM:SS format and split it into an array as soon as it is detected
                var currentAdTime = adTime.innerHTML.match(adTimeRegExp)[0].split(':');
                // Calculate the Ad time in seconds
                var adTimeInSecs = 0;
                for (let i = 0; i < currentAdTime.length; i++) {
                    adTimeInSecs += parseInt(currentAdTime[i]) * Math.pow(60, currentAdTime.length - 1 - i);
                }
                // Forward the video by how much Ad time the timer shows
                video.currentTime += adTimeInSecs;
                // Mark the Ad as skipped
                adSkipped = true;
                // DEBUG
                console.log('==========================');
                console.log('PRIME VIDEO AD SKIPPED !!!');
                console.log('==========================');
            }
        } else {
            // When Ad timer disappers, reset the Ad skip value
            adSkipped = false;
        }
    }, 200);
})();