sfr-tv-patch / script.js
ngxson's picture
ngxson HF Staff
Create script.js
ec1f60e verified
// ==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);
}
});
})();