File size: 2,371 Bytes
ec1f60e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// ==UserScript==
// @name         Nui SFR TV
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Nui SFR TV
// @author       ngxson
// @match        https://*.sfr.fr/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=sfr.fr
// @updateURL    https://ngxson-sfr-tv-patch.static.hf.space/script.js
// @downloadURL  https://ngxson-sfr-tv-patch.static.hf.space/script.js
// @grant        none
// ==/UserScript==

const customCss = `
    nav[aria-label="Menu transverse"], nav[aria-label="Menu principal"] {
        display: none !important;
    }
    div.scrim, .info.ng-star-inserted {
        display: none !important;
    }
    web-seek-bar {
        opacity: 0.5;
    }
`;

(function() {
    'use strict';

    var head = document.head || document.getElementsByTagName('head')[0];
    if (head) {
        var style = document.createElement('style');
        style.id = 'nui_custom_css';
        style.type = 'text/css';
        style.appendChild(document.createTextNode(customCss));
        head.appendChild(style);
    }

    setInterval(function () {
        return; // disabled
        const fullScreenBtn = document.querySelector('.svg-icon-fullscreen');
        if (fullScreenBtn) {
            fullScreenBtn.parentElement.click();
        }
    }, 500);

    function changeChannel(deltaIdx) {
        try {
            const channels = document.querySelector('cdk-virtual-scroll-viewport').children[0].children;
            for (let i = 0; i < channels.length; i++) {
                const channel = channels[i];
                const isActive = channel.classList.contains('active');
                const nextChannel = channels[i + deltaIdx];
                if (isActive && nextChannel) {
                    nextChannel.querySelector('.thumbnail').click();
                    return nextChannel;
                }
            }
        } catch (err) {
            console.error(err);
        }
    }

    document.addEventListener('keydown', function(event) {
        if (event.key === 'ArrowLeft') {
            // Left arrow key pressed
            console.log('Left arrow key pressed');
            changeChannel(-1);
        } else if (event.key === 'ArrowRight') {
            // Right arrow key pressed
            console.log('Right arrow key pressed');
            changeChannel(1);
        }
    });

})();