Greasy Fork

Greasy Fork is available in English.

chinahrt继续教育

全新2.0版本,进入视频自动开始并静音,并增加播放速度控制。增加配置面板,可以自由调节。

当前为 2022-05-13 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         chinahrt继续教育
// @include      http://web.chinahrt.com
// @include      https://web.chinahrt.com
// @version      2.2
// @description  全新2.0版本,进入视频自动开始并静音,并增加播放速度控制。增加配置面板,可以自由调节。
// @author       yikuaibaiban(https://github.com/yikuaibaiban)
// @match        http://videoadmin.chinahrt.com.cn/videoPlay/play*
// @match        http://videoadmin.chinahrt.com/videoPlay/play*
// @match        https://videoadmin.chinahrt.com.cn/videoPlay/play*
// @match        https://videoadmin.chinahrt.com/videoPlay/play*
// @grant        none
// @license      MIT
// @namespace https://github.com/yikuaibaiban/chinahrt
// ==/UserScript==
$(document).ready(function() {
    // (function () {
    // 'use strict';

    // 从localstorage中获取设置
    var autoplay = (localStorage.getItem('autoplay') || 'true') === 'true';
    var mute = (localStorage.getItem('mute') || 'true') === 'true';
    var speed = parseInt(localStorage.getItem('speed') || '1');

    // ==================页面设计开始==========================
    // 增加页面配置
    var configDiv = document.createElement("div");
    configDiv.style.cssText = "position:fixed;right:0;top:0;width:250px;height:300px;background-color:#FFF;z-index:9999;border: 1px solid #ccc;";

    // 标题
    var configTitle = document.createElement("div");
    configTitle.style.cssText = "border-bottom:1px solid #ccc ;padding: 5px;font-weight: bold;";
    configTitle.innerHTML = "视频控制配置";
    configDiv.appendChild(configTitle);

    // 外部包裹
    var configWrapper = document.createElement("div");
    configWrapper.style.cssText = "padding: 5px;padding-bottom: 5px;font-size: 12px;line-height: 150%;";

    // 是否自动播放
    var configAutoPlay = document.createElement("div");
    configAutoPlay.style.cssText = "border-bottom: 1px dotted #ccc ;padding-bottom: 5px;";
    var p = document.createElement("p");
    p.innerHTML = "是否自动播放:";
    configAutoPlay.appendChild(p);
    var inputAutoPlay = document.createElement("input");
    inputAutoPlay.type = "radio";
    inputAutoPlay.name = "autoPlay";
    inputAutoPlay.value = "true";
    inputAutoPlay.checked = autoplay;
    inputAutoPlay.onclick = function() {
        localStorage.setItem('autoplay', 'true');
    }
    configAutoPlay.appendChild(inputAutoPlay);
    var labelAutoPlay = document.createElement("label");
    labelAutoPlay.innerHTML = "是";
    configAutoPlay.appendChild(labelAutoPlay);
    var inputAutoPlay2 = document.createElement("input");
    inputAutoPlay2.type = "radio";
    inputAutoPlay2.name = "autoPlay";
    inputAutoPlay2.value = "false";
    inputAutoPlay2.checked = !autoplay;
    inputAutoPlay2.onclick = function() {
        localStorage.setItem('autoplay', 'false');
    }
    configAutoPlay.appendChild(inputAutoPlay2);
    var labelAutoPlay2 = document.createElement("label");
    labelAutoPlay2.innerHTML = "否";
    configAutoPlay.appendChild(labelAutoPlay2);
    configWrapper.appendChild(configAutoPlay);

    // 是否静音
    var configMute = document.createElement("div");
    configMute.style.cssText = "border-bottom: 1px dotted #ccc ;padding-bottom: 5px;";
    var p = document.createElement("p");
    p.innerHTML = "是否静音:";
    configMute.appendChild(p);
    var inputMute = document.createElement("input");
    inputMute.type = "radio";
    inputMute.name = "mute";
    inputMute.value = "true";
    inputMute.checked = mute;
    inputMute.onclick = function() {
        localStorage.setItem('mute', 'true');
        player.videoMute();
    }
    configMute.appendChild(inputMute);
    var labelMute = document.createElement("label");
    labelMute.innerHTML = "是";
    configMute.appendChild(labelMute);
    var inputMute2 = document.createElement("input");
    inputMute2.type = "radio";
    inputMute2.name = "mute";
    inputMute2.value = "false";
    inputMute2.checked = !mute;
    inputMute2.onclick = function() {
        localStorage.setItem('mute', 'false');
        player.videoEscMute();
    }
    configMute.appendChild(inputMute2);
    var labelMute2 = document.createElement("label");
    labelMute2.innerHTML = "否";
    configMute.appendChild(labelMute2);
    var muteTip = document.createElement("p");
    muteTip.style.cssText = "font-size:13px;font-weight:bold;";
    muteTip.innerHTML = "注意:不静音,视频可能会出现不会自动播放";
    configMute.appendChild(muteTip);

    configWrapper.appendChild(configMute);

    // 播放速度调整
    var configSpeed = document.createElement("div");
    configSpeed.style.cssText = "border-bottom: 1px dotted #ccc ;padding-bottom: 5px;";
    var p = document.createElement("p");
    p.innerHTML = "播放速度调整(慎用,不知后台是否检测):";
    configSpeed.appendChild(p);
    var inputSpeed = document.createElement("input");
    inputSpeed.type = "radio";
    inputSpeed.name = "speed";
    inputSpeed.value = "0";
    inputSpeed.checked = speed === 0;
    inputSpeed.onclick = function() {
        localStorage.setItem('speed', '0');
        player.changePlaybackRate(0);
    }
    configSpeed.appendChild(inputSpeed);
    var labelSpeed = document.createElement("label");
    labelSpeed.innerHTML = "低速";
    configSpeed.appendChild(labelSpeed);
    var inputSpeed2 = document.createElement("input");
    inputSpeed2.type = "radio";
    inputSpeed2.name = "speed";
    inputSpeed2.value = "1";
    inputSpeed2.checked = speed === 1;
    inputSpeed2.onclick = function() {
        localStorage.setItem('speed', '1');
        player.changePlaybackRate(1);
    }
    configSpeed.appendChild(inputSpeed2);
    var labelSpeed2 = document.createElement("label");
    labelSpeed2.innerHTML = "正常";
    configSpeed.appendChild(labelSpeed2);
    var inputSpeed3 = document.createElement("input");
    inputSpeed3.type = "radio";
    inputSpeed3.name = "speed";
    inputSpeed3.value = "2";
    inputSpeed3.checked = speed === 2;
    inputSpeed3.onclick = function() {
        localStorage.setItem('speed', '2');
        player.changePlaybackRate(2);
    }
    configSpeed.appendChild(inputSpeed3);
    var labelSpeed3 = document.createElement("label");
    labelSpeed3.innerHTML = "高速";
    configSpeed.appendChild(labelSpeed3);
    var inputSpeed4 = document.createElement("input");
    inputSpeed4.type = "radio";
    inputSpeed4.name = "speed";
    inputSpeed4.value = "3";
    inputSpeed4.checked = speed === 3;
    inputSpeed4.onclick = function() {
        localStorage.setItem('speed', '3');
        player.changePlaybackRate(3);
    }
    configSpeed.appendChild(inputSpeed4);
    var labelSpeed4 = document.createElement("label");
    labelSpeed4.innerHTML = "超高速";
    configSpeed.appendChild(labelSpeed4);
    var speedTip = document.createElement("div");
    speedTip.style.cssText = "font-size:13px;font-weight:bold;";
    speedTip.innerHTML = "提示:基于播放器本身的速度挡位实现,目测最高大概是2倍速。";
    configSpeed.appendChild(speedTip);
    configWrapper.appendChild(configSpeed);

    configDiv.appendChild(configWrapper);

    // 联系方式
    var contactDiv = document.createElement("div");
    contactDiv.style.cssText = "margin-top:10px;font-size:12px;font-weight:bold;line-height: 150%;";
    // 博客园地址
    var blogDiv = document.createElement("div");
    var blog = document.createElement("a");
    blog.href = "https://www.cnblogs.com/ykbb/";
    blog.target = "_blank";
    blog.innerHTML = "博客园地址";
    blogDiv.appendChild(blog);
    contactDiv.appendChild(blogDiv);

    // 意见反馈
    var feedbackDiv = document.createElement("div");
    var feedback = document.createElement("a");
    feedback.href = "https://msg.cnblogs.com/send/ykbb";
    feedback.target = "_blank";
    feedback.innerHTML = "点此意见反馈";
    feedbackDiv.appendChild(feedback);
    contactDiv.appendChild(feedbackDiv);

    configDiv.appendChild(contactDiv);

    document.body.appendChild(configDiv);
    // ==================页面设计结束==========================

    $("video").prop("muted", "muted");

    // 移除讨厌的事件
    window.onfocus = function() {};
    window.onblur = function() {};

    var tmp = setInterval(function() {
        if (player && player.loaded) {
            player.addListener('loadedmetadata', function() {
                // 总是显示播放进度
                player.changeControlBarShow(true);

                if (mute) {
                    player.videoMute();
                } else {
                    player.videoEscMute();
                }

                player.changePlaybackRate(speed);

                if (autoplay) {
                    player.videoPlay();
                }
                clearInterval(tmp);
            });
        }
    }, 500);
});