XunLei Yunbo Better Player

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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');
}