Ultrawide Fix for Kick

Adjust video player to fit full width, accounting for sidebars on ultrawide monitors

目前為 2024-09-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Ultrawide Fix for Kick
// @namespace   https://greasyfork.org/en/users/1200587-trilla-g
// @version      1.0
// @description  Adjust video player to fit full width, accounting for sidebars on ultrawide monitors
// @match        *://kick.com/*
// @grant        none
// @license      MIT
// @author      Trilla_G
// ==/UserScript==


(function() {
    'use strict';

    // Function to adjust the video element considering sidebars and center it
    let adjustVideoElement = () => {
        // Select the <video> element
        let videoElement = document.querySelector("video");

        if (videoElement) {
            // Calculate the available width considering sidebars
            let sidebarWidth = 256;  // Width of one sidebar
            let totalSidebarWidth = 2 * sidebarWidth;  // Total width of both sidebars
            let viewportWidth = window.innerWidth;  // Full viewport width
            let availableWidth = viewportWidth - totalSidebarWidth;

            // Set the video width and height
            videoElement.style.width = `${availableWidth}px`;
            videoElement.style.height = 'auto';  // Maintain aspect ratio
            videoElement.style.maxWidth = 'none'; // Remove any max-width constraints
            videoElement.style.maxHeight = '100vh'; // Fit to viewport height
            videoElement.style.objectFit = 'cover';  // Fill the screen, cropping if needed

            // Center the video element horizontally
            videoElement.style.position = 'fixed'; // Use fixed positioning
            videoElement.style.left = `${sidebarWidth}px`;  // Offset for the left sidebar
            videoElement.style.top = '0';  // Align with the top of the viewport
        }
    };

    // Run the adjustment periodically, in case the video is loaded dynamically
    let interval = setInterval(() => {
        adjustVideoElement();
    }, 500);

    // Stop the interval after 5 seconds (adjust as necessary)
    setTimeout(() => {
        clearInterval(interval);
    }, 5000);
})();