115 Player Enhancer

115播放器增强

目前为 2021-12-18 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 115 Player Enhancer
  3. // @namespace https://gf.qytechs.cn/scripts/376536-115-player-enhancer
  4. // @version 0.6
  5. // @description 115播放器增强
  6. // @author zaypen
  7. // @license MIT
  8. // @match http*://115.com/*
  9. // @match http*://anxia.com/*
  10. // @match http*://*.anxia.com/*
  11. // @require https://openuserjs.org/src/libs/sizzle/GM_config.min.js
  12. // @require https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js
  13. // @require https://cdn.staticfile.org/lodash.js/4.17.21/lodash.min.js
  14. // @grant GM_getValue
  15. // @grant GM_setValue
  16. // ==/UserScript==
  17.  
  18. /*jslint browser:true*/
  19. /*global GM_config, _, $ */
  20.  
  21. var defaultOpeningDuration = 125;
  22.  
  23. var fieldDefs = {
  24. 'OpeningDuration': {
  25. 'label': 'OP 时长',
  26. 'type': 'unsigned int',
  27. 'default': defaultOpeningDuration
  28. }
  29. };
  30.  
  31. GM_config.init({
  32. id: 'GM_config',
  33. title: '115 Player Enhancer',
  34. fields: fieldDefs
  35. });
  36.  
  37. function appendElement(current, next) {
  38. console.log('add ', next);
  39. return current.insertAdjacentElement('afterend', next);
  40. }
  41.  
  42. function registerHotkey(key, fn) {
  43. document.body.addEventListener('keyup', function(e) {
  44. if (e.key === key) {
  45. fn();
  46. }
  47. });
  48. }
  49.  
  50. function retry(fn, interval, times) {
  51. var ret = fn();
  52. if (!ret && times) {
  53. setTimeout(function () {
  54. retry(fn, interval, times--);
  55. }, interval);
  56. }
  57. }
  58.  
  59. function createButton(onclick, alt) {
  60. var button = document.createElement('a');
  61. button.href = 'javascript:;';
  62. button.className = 'btn-switch';
  63. button.alt = alt;
  64. button.onclick = onclick;
  65. return button;
  66. }
  67.  
  68. function getPlayer() {
  69. return $('#js-video')[0];
  70. }
  71.  
  72. function getNextItem() {
  73. var items = Array.apply(null, document.querySelectorAll('.video-playlist .vpl-container .item-list li'));
  74. var remainingItems = _.dropWhile(items, function (item) {
  75. return item.className !== 'hover';
  76. });
  77. return _.head(_.tail(remainingItems));
  78. }
  79.  
  80. (function() {
  81. 'use strict';
  82.  
  83. function main() {
  84. var video = getPlayer();
  85. var configration = function() {
  86. GM_config.open();
  87. };
  88.  
  89. var playButton = document.querySelector('.operate-bar a[btn="play"]');
  90. var currentButton = playButton;
  91.  
  92. var skipOp = function() {
  93. video.currentTime += GM_config.get('OpeningDuration');
  94. };
  95. var skipOpButton = createButton(skipOp, '跳过OP (快捷键END)');
  96. skipOpButton.innerHTML = '<i class="icon-operate iop-playing" style="background-size: 240px 40px;"></i><div class="tooltip">点击跳过OP</div>';
  97. currentButton = appendElement(currentButton, skipOpButton);
  98. registerHotkey('End', skipOp);
  99.  
  100. var configButton = createButton(configration, '设置');
  101. configButton.innerHTML = '<i class="icon-operate iop-setting"></i>';
  102. currentButton = appendElement(currentButton, configButton);
  103.  
  104. var nextButton = document.querySelector('.operate-bar a[btn="next"]');
  105. nextButton.innerHTML += '<div class="tooltip">下一集(快捷键PageDown)</div>';
  106. registerHotkey('PageDown', function() {
  107. nextButton.click();
  108. });
  109.  
  110. var jump = function(e) {
  111. if (e.key === '0') {
  112. var endTime = video.buffered.end(video.buffered.length - 1);
  113. var target = endTime - 5;
  114. if (video.currentTime < target) {
  115. video.currentTime = target;
  116. }
  117. }
  118. };
  119. document.addEventListener('keyup', jump, false);
  120. console.info('115 Enhancer loaded');
  121. return true;
  122. }
  123.  
  124. function inject() {
  125. var video = getPlayer();
  126. if (video) {
  127. video.addEventListener('playing', main, { once: true });
  128. return true;
  129. }
  130. }
  131.  
  132. retry(inject, 500, 10);
  133. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址