CDA.pl Enhancer

Script contains features like auto best quality choose and some hotkeys for CDA.pl website.

Från och med 2021-02-05. Se den senaste versionen.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name            CDA.pl Enhancer
// @name:pl         Ulepszenia dla odtwarzania filmów na stronie CDA.pl
// @namespace       http://tampermonkey.net/
// @version         0.1
// @description     Script contains features like auto best quality choose and some hotkeys for CDA.pl website.
// @description:pl  Skrypt zawiera właściwości takie jak wybór najlepszej jakości filmu oraz kilka skrótów klawiszowych dla strony CDA.pl
// @author          DaveIT
// @match           https://www.cda.pl/video/*
// @grant           none
// ==/UserScript==

/*jshint esversion: 6 */

(function() {
    'use strict';

    let config = {
        bestQualityEnable: true,
        hotkeysEnable: true,
        hotkeys: {
            fullscreen: 'f',
            mute: 'm'
        }
    }

    if(config.bestQualityEnable) {
        let buttons = document.querySelectorAll('.quality-btn');

        if(buttons.length > 0) {
            let lastButton = buttons[buttons.length - 1];

            if(lastButton.text == 'Premium') {
                lastButton = buttons[buttons.length - 2];
            }

            if(!lastButton.className.includes('quality-btn-active')) {
                lastButton.click();
            }
        }
    }

    if(config.hotkeysEnable) {
        document.onkeypress = (e) => {
            switch(e.key) {
                case config.hotkeys.fullscreen:
                    document.querySelector('.pb-fullscreen').click();
                    break;

                case config.hotkeys.mute:
                    document.querySelector('.pb-volume-mute').click();
                    break;
            }
        }
    }

})();