XunLei Yunbo Better Player

改进迅雷云播的播放器页面

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        XunLei Yunbo Better Player
// @namespace   qixinglu.com
// @description 改进迅雷云播的播放器页面
// @grant       none
// @include     http://vod.xunlei.com/iplay.html?*
// @include     http://vod.xunlei.com/nplay.html?*
// @version 0.0.1.20140517140352
// ==/UserScript==

var addStyle = function(cssText) {
    var head = document.querySelector('head');
    var style = document.createElement('style');
    style.setAttribute('type', 'text/css');
    style.textContent = cssText;
    head.appendChild(style);
};

var changePlayerArea = function() {
    var wrapNode = document.querySelector('.wrap');
    wrapNode.style.width = 'auto';
    wrapNode.style.padding = '0 20px';
    var height = window.innerHeight - 100; // 100 像素大约是顶部标题的高度
    var width = Math.ceil(height * 16 / 9); // 按 16:9 比例算出对应的宽度
    var playerArea = document.querySelector('#XL_CLOUD_VOD_PLAYER');
    playerArea.style.width = width + 'px';
    playerArea.style.height =  height + 'px';
};

var changeDownloadArea = function() {
    var lixian = 'http://lixian.vip.xunlei.com/lixian_login.html?furl='
    var originalNode = document.querySelector('#original_url');
    originalNode.textContent = originalNode.title;
    var downLink = document.createElement('a');
    downLink.href = lixian + originalNode.title;
    downLink.textContent = '离线下载';
    downLink.target = '_blank';
    downLink.style.display = 'block';
    downLink.style.color = '#808080';
    downLink.style.padding = '6px';
    downLink.style.margin = '0 0 0 32px';
    var copyBtn = document.querySelector('#mycopyer');
    copyBtn.replaceChild(downLink, document.querySelector('#copyer'));
};

var isOldVersion = location.pathname == '/iplay.html';
if (isOldVersion) {
    addStyle('body { width: auto !important;');
    changePlayerArea();
    window.addEventListener('resize', changePlayerArea);
    setTimeout(changeDownloadArea, 2000);
} else {
    location.href = location.href.replace('/nplay.html', '/iplay.html');
}