XunLei Yunbo Better Player

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

当前为 2014-05-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name XunLei Yunbo Better Player
  3. // @namespace qixinglu.com
  4. // @description 改进迅雷云播的播放器页面
  5. // @grant none
  6. // @include http://vod.xunlei.com/iplay.html?*
  7. // @include http://vod.xunlei.com/nplay.html?*
  8. // @version 0.0.1.20140517140352
  9. // ==/UserScript==
  10.  
  11. var addStyle = function(cssText) {
  12. var head = document.querySelector('head');
  13. var style = document.createElement('style');
  14. style.setAttribute('type', 'text/css');
  15. style.textContent = cssText;
  16. head.appendChild(style);
  17. };
  18.  
  19. var changePlayerArea = function() {
  20. var wrapNode = document.querySelector('.wrap');
  21. wrapNode.style.width = 'auto';
  22. wrapNode.style.padding = '0 20px';
  23. var height = window.innerHeight - 100; // 100 像素大约是顶部标题的高度
  24. var width = Math.ceil(height * 16 / 9); // 按 16:9 比例算出对应的宽度
  25. var playerArea = document.querySelector('#XL_CLOUD_VOD_PLAYER');
  26. playerArea.style.width = width + 'px';
  27. playerArea.style.height = height + 'px';
  28. };
  29.  
  30. var changeDownloadArea = function() {
  31. var lixian = 'http://lixian.vip.xunlei.com/lixian_login.html?furl='
  32. var originalNode = document.querySelector('#original_url');
  33. originalNode.textContent = originalNode.title;
  34. var downLink = document.createElement('a');
  35. downLink.href = lixian + originalNode.title;
  36. downLink.textContent = '离线下载';
  37. downLink.target = '_blank';
  38. downLink.style.display = 'block';
  39. downLink.style.color = '#808080';
  40. downLink.style.padding = '6px';
  41. downLink.style.margin = '0 0 0 32px';
  42. var copyBtn = document.querySelector('#mycopyer');
  43. copyBtn.replaceChild(downLink, document.querySelector('#copyer'));
  44. };
  45.  
  46. var isOldVersion = location.pathname == '/iplay.html';
  47. if (isOldVersion) {
  48. addStyle('body { width: auto !important;');
  49. changePlayerArea();
  50. window.addEventListener('resize', changePlayerArea);
  51. setTimeout(changeDownloadArea, 2000);
  52. } else {
  53. location.href = location.href.replace('/nplay.html', '/iplay.html');
  54. }