Custom SharePoint Caption

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

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==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
    });

})();