Custom SharePoint Caption

Fixed font size and with background captions in SharePoint video player (No Flicker)

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Custom SharePoint Caption
// @namespace    http://tampermonkey.net/
// @version      1.7
// @description  Fixed font size and with background captions in SharePoint video player (No Flicker)
// @match        https://v6v10-my.sharepoint.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const FONT_SIZE = '30px';
    const BG_COLOR = 'rgba(0, 0, 0, 0.75)';
    const BORDER_RADIUS = '8px';
    const PADDING = '10px 15px';

    const cssStyles = `
        .captions {
            --oneplayer-caption-text-size: ${FONT_SIZE} !important;
            font-size: ${FONT_SIZE} !important;
            background-color: ${BG_COLOR} !important;
            border-radius: ${BORDER_RADIUS} !important;
            padding: ${PADDING} !important;
            display: inline-block !important;
            white-space: normal !important;
            margin: 0 !important;
            border: none !important;
            transition: background-color 0.1s, padding 0.1s;
        }

        .captions.hide-bg {
            background-color: transparent !important;
            padding: 0 !important;
        }

        .captions-section {
            bottom: 30px !important;
            top: auto !important;
            text-align: center !important;
        }

        .video-player-container .captions-region {
            position: absolute !important;
            bottom: 0px !important;
            left: 0px !important;
            right: 0px !important;
            width: 100% !important;
            height: 100% !important;
            background-color: transparent !important;
        }
    `;

    const styleElement = document.createElement('style');
    styleElement.type = 'text/css';
    styleElement.appendChild(document.createTextNode(cssStyles));
    document.head.appendChild(styleElement);

    const observer = new MutationObserver(() => {
        const captions = document.querySelectorAll('.captions');
        captions.forEach(caption => {
            if (caption.textContent.trim() === '') {
                caption.classList.add('hide-bg');
            } else {
                caption.classList.remove('hide-bg');
            }
        });
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true,
        characterData: true
    });

})();