Greasy Fork

CDA No Ads

Easy way to skip ads on cda.pl

当前为 2024-08-09 提交的版本,查看 最新版本

// ==UserScript==
// @name         CDA No Ads
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Easy way to skip ads on cda.pl
// @author       lxst-one
// @match        http*://www.cda.pl/video/*
// @icon         https://scdn2.cda.pl/img/icon/fav/favicon-16x16.png
// @grant        none
// @run-at       document-idle
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function skipAdPlayer() {
        const adPlayer = document.querySelector('video.pb-ad-video-player');

        if(adPlayer === null || adPlayer.currentTime === 0) {
            return;
        }

        adPlayer.currentTime = adPlayer.duration || 0;
    }

    async function startAdsWatcher() {
        while(true) {
            console.log('watching');
            skipAdPlayer();
            await new Promise(r => setTimeout(r, 300));
        }
    }

    startAdsWatcher();
})();