CDA.pl Enhancer

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

当前为 2021-02-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name CDA.pl Enhancer
  3. // @name:pl Ulepszenia dla odtwarzania filmów na stronie CDA.pl
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.1
  6. // @description Script contains features like auto best quality choose and some hotkeys for CDA.pl website.
  7. // @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
  8. // @author DaveIT
  9. // @match https://www.cda.pl/video/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. /*jshint esversion: 6 */
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. let config = {
  19. bestQualityEnable: true,
  20. hotkeysEnable: true,
  21. hotkeys: {
  22. fullscreen: 'f',
  23. mute: 'm'
  24. }
  25. }
  26.  
  27. if(config.bestQualityEnable) {
  28. let buttons = document.querySelectorAll('.quality-btn');
  29.  
  30. if(buttons.length > 0) {
  31. let lastButton = buttons[buttons.length - 1];
  32.  
  33. if(lastButton.text == 'Premium') {
  34. lastButton = buttons[buttons.length - 2];
  35. }
  36.  
  37. if(!lastButton.className.includes('quality-btn-active')) {
  38. lastButton.click();
  39. }
  40. }
  41. }
  42.  
  43. if(config.hotkeysEnable) {
  44. document.onkeypress = (e) => {
  45. switch(e.key) {
  46. case config.hotkeys.fullscreen:
  47. document.querySelector('.pb-fullscreen').click();
  48. break;
  49.  
  50. case config.hotkeys.mute:
  51. document.querySelector('.pb-volume-mute').click();
  52. break;
  53. }
  54. }
  55. }
  56.  
  57. })();