YouTube Detailed Timecode

Displays a time in seconds to 3 decimal places when paused.

Stan na 02-09-2018. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         YouTube Detailed Timecode
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Displays a time in seconds to 3 decimal places when paused.
// @author       Charlie Laabs
// @match        https://*.youtube.com/*
// @match        http://*.youtube.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    console.log('Running YTDT');
    var ytPlayer;
    var ytPlayerUnwrapped;
    var detailedTime = document.createElement('span');
    var playerInitialized = false;

    function getElements() {
        ytPlayer = document.getElementById("movie_player") || document.getElementsByClassName("html5-video-player")[0];
        ytPlayerUnwrapped = ytPlayer.wrappedJSObject;
        if (ytPlayer)
        {
            detailedTime.innerHTML = "";
            ytPlayer.addEventListener("onStateChange", playerChanged, true );
            document.addEventListener("keyup", keyUp, true );
        }
    }

    function playerStarted()
    {
        var timeDisp = ytPlayer.getElementsByClassName("ytp-time-display")[0];
        detailedTime.className = 'us-detailed-time';
        detailedTime.style.paddingLeft = '5px';
        timeDisp.appendChild(detailedTime);
        playerInitialized = true;

    }

    function playerChanged(state)
    {
        //console.log("stateChanged: ", state);
        if (state != -1 && !playerInitialized ) {
            playerStarted();
        }
        if (state == 2) {
            detailedTime.innerHTML = '| ' + ytPlayerUnwrapped.getCurrentTime().toFixed(3);
        }

    }

    function keyUp(e)
    {
        //console.log('keyUp:', e);
        if (e.keyCode == 188 || e.keyCode == 190) {
            detailedTime.innerHTML = '| ' + ytPlayerUnwrapped.getCurrentTime().toFixed(3);
        }
    }
    getElements(); //for embedded videos
    document.addEventListener("yt-navigate-finish", getElements, true ); //for YouTube


})();