[email protected]

Add next button for 115 HTML5 player

目前為 2019-01-10 提交的版本,檢視 最新版本

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();