10 Sep 2025
Update: 02 Apr 2026

Add subtitles to video automatically on Breakdance

Example of *.vtt file (subtitles)
WEBVTT line have to be there.

WEBVTT

1
00:00:01.000 –> 00:00:02.000
First line

2
00:00:03.000 –> 00:00:04.000
Second line

Add javascript:

// Auto-add VTT subtitles for Breakdance videos (works even in new tab)
(function() {
    'use strict';

    const CONFIG = {
        videoSelectors: [
            'video',
            '.bde-video video',
            '.breakdance-video video',
            '.ee-video video'
        ]
    };

    let processedVideos = new Set();

    function initAutoSubtitles() {
        const videos = findAllVideos();

        // Fallback: ak stránka obsahuje len jedno video priamo
        if (videos.length === 0 && document.querySelector('video')) {
            videos.push(document.querySelector('video'));
        }

        videos.forEach((video, index) => {
            const videoId = video.src || video.currentSrc || video.outerHTML.substring(0, 100);
            if (!processedVideos.has(videoId)) {
                processedVideos.add(videoId);
                addVttSubtitle(video, index + 1);
            }
        });
    }

    function findAllVideos() {
        const videos = [];
        CONFIG.videoSelectors.forEach(selector => {
            document.querySelectorAll(selector).forEach(video => {
                if (!videos.includes(video)) videos.push(video);
            });
        });
        return videos;
    }

    function addVttSubtitle(video, videoNumber, attempt = 0) {
        const src = video.src || video.currentSrc;
        if (!src) {
            // Retry if src isn't ready yet
            if (attempt < 5) {
                setTimeout(() => addVttSubtitle(video, videoNumber, attempt + 1), 500);
            }
            return;
        }

        // Extract folder path and file name
        const urlParts = src.split('/');
        const fileName = urlParts.pop().split('.')[0]; // remove extension
        const folderPath = urlParts.join('/') + '/';

        const subtitleUrl = folderPath + fileName + '.vtt';

        // Check if track already exists
        if (video.querySelector('track[kind="subtitles"]')) return;

        const track = document.createElement('track');
        track.kind = 'subtitles';
        track.src = subtitleUrl;
        track.srclang = 'en';
        track.label = 'English';
        track.default = true;

        video.appendChild(track);
        video.load();

        video.addEventListener('loadedmetadata', () => {
            if (video.textTracks && video.textTracks.length > 0) {
                video.textTracks[0].mode = 'showing';
                console.log(`✅ Video ${videoNumber}: Subtitles enabled`);
            }
        });
    }

    // Observe dynamically added videos
    const observer = new MutationObserver(mutations => {
        let newVideo = false;
        mutations.forEach(m => {
            m.addedNodes.forEach(node => {
                if (node.nodeType === 1 && (node.tagName === 'VIDEO' || node.querySelector('video'))) {
                    newVideo = true;
                }
            });
        });
        if (newVideo) setTimeout(initAutoSubtitles, 500);
    });
    observer.observe(document.body, { childList: true, subtree: true });

    // Run on page load
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', initAutoSubtitles);
    } else {
        initAutoSubtitles();
    }

    // Fallback: ensure subtitles load even after full window load
    window.addEventListener('load', () => setTimeout(initAutoSubtitles, 1000));

    console.log('🚀 Breakdance auto-VTT subtitles loaded (works in new tab too)');
})();
Matúš Trgiňa
- Founder of Shapeusto

Get it done.

Pause or cancel any time

If you don't need our services, there's no reason to pay. Just pause your subscription.

48 hour average delivery

We work incredibly fast. We can create most tasks within 48 hours.

Unlimited requests

Simply enter the number of tasks you need to solve, and we'll take care of all of them.

Unlimited users

An unlimited number of team members can add tasks to us.
Pause or cancel anytime

Pause or cancel anytime

If you don't need our services, there's no reason to pay. Just pause your subscription.
48 hour average delivery

48 hour average delivery

We work incredibly fast. We can create most tasks within 48 hours.
Unlimited users

Unlimited users

An unlimited number of team members can add tasks to us.
Unlimited requests

Unlimited requests

Simply enter the number of tasks you need to solve, and we'll take care of all of them.
Shapeusto - footer logo
Headquartered in European Union, Slovak Republic
© 2026 Shapeusto. All rights reserved