StreamCloud Enhancer

Prepares video for playback and enables download.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        StreamCloud Enhancer
// @namespace   schwarztee
// @description Prepares video for playback and enables download.
// @include     *streamcloud.eu/*
// @copyright   2015, schwarztee
// @license     MIT
// @version     0.1.1
// @grant       none
// ==/UserScript==


// jQuery ist auf streamcloud.eu verfügbar und kann genutzt werden
(function($){
    
    // Warteseite?
    if ( document.getElementById( 'login' ) )
    {
        var submitForm = function submitForm()
        {
            // Event-Handler entfernen, der Absenden des Formulars verhindert
            $(document).off( 'submit', 'form.proform' );
            
            // Formular absenden
            $( 'form.proform' ).submit();
        };
        
        // 11 Sekunden warten (unvermeidbar, wird serverseitig kontrolliert)
        setTimeout( submitForm, 11000 );
    }
    
    // Videoseite?
    if ( typeof jwplayer != 'undefined' )
    {
        // Referenz auf Player zurechtlegen
        var player = jwplayer( 'mediaplayer' );
        
        // Button-Reihe in Titelleiste anvisieren
        var buttonList = $( '#page .header ul' );
        
        // neuen Download-Link erzeugen
        var link = $( '<a>' )
        .attr( 'href', player.config.file )
        .html( "Download" )
        .attr( 'title', "Direktlink zum Video" );
        
        // Link in Listenelement einpacken
        var element = $( '<li>' )
        .html( link )
        .addClass( 'active' );
        
        // falschen Download-Button entfernen und neuen Button hinzufügen
        buttonList.find( 'li:last-child' ).remove();
        buttonList.append( element );
        
        // erstmaliges Anhalten?
        var initialPause = true;
        
        // Wiedergabe anhalten, sobald bereit zum Abspielen
        player.onPlay( function pauseOnce()
        {
            // pausieren
            initialPause && player.pause(true);
            
            // fertig
            initialPause = false;
        });
        
        // Laden des Videos starten
        player.play();
    }

})(jQuery);