Greasy Fork

Greasy Fork is available in English.

Prime Video Ad Blocker [ESP]

Skip Ads in Prime Video Spain. Adapted from RawMeatEater's script for spanish Amazon site.

当前为 2022-08-01 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            Prime Video Ad Blocker [ESP]
// @namespace       http://greasyfork.icu/en/users/5102-jeau
// @version         0.1.1
// @description     Skip Ads in Prime Video Spain. Adapted from RawMeatEater's script for spanish Amazon site.
// @description:es  Bloquea los anuncios en Prime Video España. Adaptado a partir del código de RawMeatEater para la web de Amazon España.
// @author          Jeau
// @license         MIT
// @match           https://www.primevideo.com/*
// @icon            https://m.media-amazon.com/images/G/01/digital/video/DVUI/favicons/favicon-32x32.png
// @grant           none
// ==/UserScript==

(function() {
    'use strict';

    // This value when true shows that the ad has been skipped
    var adSkipped = false;

    // Every 0.2 seconds, this function runs
    setInterval(function() {

        /* Debug info */
        // console.log('Checking existing Ads...');

        // Selects the video container's child (Which is the video element)
        var video = document.getElementsByClassName("rendererContainer")[0].children[2];

        // If Time To Skip element exist
        if ( document.getElementsByClassName("atvwebplayersdk-adtimeindicator-text")[0] ){

            // Has it been skipped aready? (This is so that way you don't skip forward twice)
            if ( adSkipped == false ) {

                // Grabs the ad timer in HH:MM:SS format and splits it into an array
                var currentAdTime = document.getElementsByClassName("atvwebplayersdk-adtimeindicator-text")[0].innerHTML.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);
                }

                // It then skipped forward the video by how much ad time the timer shows
                video.currentTime = video.currentTime + adTimeInSecs;

                // Shows that the ad has been skipped
                adSkipped = true;
            }

        } else {
            // When ad timer disappers, reset the ad skip value
            adSkipped = false;
        }

    // When 200 milliseconds pass, execute script
    }, 200);

})();