Tirkx Popup Video Player

Popup Video Player for tirkx.com

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Tirkx Popup Video Player
// @namespace    http://your.homepage/
// @version      0.10
// @description  Popup Video Player for tirkx.com
// @author       Soginal
// @match        http://*.tirkx.com/main/showthread.php?*
// @grant        none
// @local        en
// ==/UserScript==
var process = function(){
    $('head').append('<script src="https://releases.flowplayer.org/6.0.3/flowplayer.min.js"></script>');
    $('head').append('<link rel="stylesheet" type="text/css" href="https://releases.flowplayer.org/6.0.3/skin/minimalist.css">');
    $(document.body).on('click', '.dl_chapter a',function(e){
        if (e.ctrlKey || e.altKey || e.shiftKey) return;
        closeVideo();
        var videoPath = $(this).attr('href');
        var videoType = videoPath.substr(videoPath.lastIndexOf('.') + 1).toLowerCase();
        var html = '<div style="z-index:1000000;position:fixed;left:0px; top:0px;width:800px;background-color:black;padding-left:10px;padding-right:10px;padding-bottom:35px;boxing-size:border-box;">' +
            '<div style="position:relative;font-size:20px;color:white;padding:3px;height:20px;"><span style="font-size:12px;display:inline-block;margin-top:4px;">' + $(this).text() + '</span>' +
            '<div style="position:absolute;right:6px;top:1px;cursor:pointer;font-weight:bolder;" onclick="closeVideo()">X</div> </div>' +
            '<div id="videoplayer" class="flowplayer fixed-controls" data-ratio="0.4167"></div>' +
            '</div>';
        var div = $(html);
        window.videoElement = div;
        div.css({
            left: $(document).width()/2-div.width()/2,
            top: 50
        });
        $(document.body).append(div);
        
        switch(videoType){
            case 'mkv': videoType = 'video/webm';break;
            default: videoType = 'video/' + videoType;break;
        }
        window.player = flowplayer("#videoplayer", {
            autoplay: true,
            //ratio: 5/12,
            mouseoutTimeout: 2000,
            clip: {
                sources: [
                    { type: videoType,  src: videoPath  }
                ]
            },
            embed: {
                skin: "https://releases.flowplayer.org/6.0.3/skin/minimalist.css"
            }
        });
        div.find('a[href=http\\:\\/\\/flowplayer\\.org]').hide();
        div.find('.fp-embed').hide();
        div.find('.fp-fullscreen').css({top:-26, right:30, height:20});
        return false;
    });
};


window.closeVideo = function(){
    if (window.player){
        player.stop();
        player.shutdown();
    }
    if (window.videoElement) {
        videoElement.hide();
        var video = videoElement.find('video').attr('src', '');
        if (video.length)
            video[0].load();
        videoElement.remove();
    }
    window.videoElement = null;
    window.player = null;
};

$(document).ready(process);