[email protected]

Add next button for 115 HTML5 player

当前为 2019-01-10 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         [email protected]
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add next button for 115 HTML5 player
// @author       zaypen
// @match        http*://*/*
// @require      https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js
// @grant        none
// ==/UserScript==

/*jslint browser:true*/
/*global _ */
(function() {
    'use strict';

    function main() {
        var items = Array.apply(null, document.querySelectorAll('.video-playlist .vpl-container .item-list li'));
        var remainingItems = _.dropWhile(items, function (item) {
            return item.className !== 'hover';
        });
        var nextItem = _.head(_.tail(remainingItems));
        var playNext = function(e) {
            window.location.href = nextItem.querySelector('a').href;
        };
        var nextButton = document.createElement('a');
        nextButton.href = 'javascript:;';
        nextButton.innerHTML = '<i class="icon-operate iop-playing" style="background-size: 400% 200%;"></i>';
        nextButton.className = 'btn-switch';
        nextButton.onclick = playNext;

        var playButton = document.querySelector('.operate-bar a[btn="play"]');
        if (playButton && nextItem) {
            playButton.insertAdjacentElement('afterend', nextButton);
            document.body.addEventListener('keyup', function(e) {
                if (e.key === "PageDown") {
                    playNext();
                }
            });
            return true;
        }
    }

    function retry(fn, interval, times) {
        var ret = fn();
        if (!ret && times) {
            setTimeout(function () {
                retry(fn, interval, times--);
            }, interval);
        }
    }

    retry(main, 500, 10);
})();