Greasy Fork

Greasy Fork is available in English.

粉笔课堂显示暂停遮罩

暂停时显示遮罩,可点击的图标在鼠标悬停时变为手形

当前为 2020-07-23 提交的版本,查看 最新版本

// ==UserScript==
// @name         粉笔课堂显示暂停遮罩
// @namespace    http://tampermonkey.net/
// @version      0.4.4
// @description  暂停时显示遮罩,可点击的图标在鼠标悬停时变为手形
// @author       AN drew
// @match        https://pc.fenbi.com/webclass/class/*
// @require      http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @require      http://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    if($.cookie("maskon")==undefined)
        $.cookie('maskon', "1", { expires: 365, path: "/", domain: "fenbi.com" });

    var maskon = $.cookie("maskon")

    $("<style></style>").text(".switcher {"+
						"	width:160px;"+
            " position:absolute;"+
            " left:880px;"+
            " user-select:none;"+
						"}"+
						".btn_fath {"+
						"	margin-top:12px;"+
						"	position:relative;"+
						"	border-radius:16px;"+
            " margin-top:15px;"+
						"	float:left;"+
						"}"+
						".tip{"+
						"	float:left;"+
            " font-size:14px;"+
						"	line-height: 50px;"+
						"}"+
						".btn1 {"+
						"	float:left;"+
						"}"+
						".btn2 {"+
						"	float:right;"+
						"}"+
						".btnSwitch {"+
						"	height:20px;"+
						"	width:25px;"+
						"	border:none;"+
						"	color:#fff;"+
						"	line-height:20px;"+
						"	font-size:12px;"+
						"	text-align:center;"+
						"	z-index:1;"+
						"}"+
						".move {"+
						"	z-index:100;"+
						"	width:18px;"+
						"	border-radius:18px;"+
						"	height:18px;"+
						"	position:absolute;"+
						"	cursor:pointer;"+
						"	border:1px solid #828282;"+
						"	background-color:#f1eff0;"+
						"	box-shadow:1px 2px 2px 1px #fff inset,0 0 5px 1px #999;"+
						"}"+
						".on .move {"+
						"	left:30px;"+
						"}"+
						".on.btn_fath {"+
						"	background-color:#44b549;"+
						"	height:20px"+
						"}"+
						".off.btn_fath {"+
						"	background-color:#828282;"+
						"	height:20px"+
						"}").appendTo($("head"));


    var $switcher = $('<div class="switcher">'+
                    '    <span class="tip">显示暂停遮罩&nbsp;</span>'+
                    '    <div class="btn_fath on">'+
                    '        <div class="move" data-state="on"></div>'+
                    '        <div class="btnSwitch btn1">开</div>'+
                    '        <div class="btnSwitch btn2">关</div>'+
                    '    </div>'+
                    '</div>')

    $switcher.css({"cursor":"pointer"})

    if($.cookie("maskon")=="0")
    {
       $switcher.find(".btn_fath").removeClass("on").addClass("off");
       $switcher.find(".move").attr("data-state", "off");
    }

    $switcher.click(function(){
        var ele = $(this).find(".move");
        var fath = $(this).find(".btn_fath");
        if (ele.attr("data-state") == "on") {
            ele.animate({
                left: "0"
            }, 100, function() {
                ele.attr("data-state", "off");
            });
            fath.removeClass("on").addClass("off");
            $.cookie('maskon', "0", { expires: 365, path: "/", domain: "fenbi.com" });
        } else if (ele.attr("data-state") == "off") {
            ele.animate({
                left: '30px'
            }, 100, function() {
                ele.attr("data-state", "on");
            });
            fath.removeClass("off").addClass("on");
            $.cookie('maskon', "1", { expires: 365, path: "/", domain: "fenbi.com" });
        }
    })

    $(".jubao").before($switcher)

    $(".progress-bg").css({"z-index":"5000"})
    $("#breviary").css({"z-index":"5000"})
    $(".wrap.push").css({"z-index":"5000"})
    $(".wrap.pull").css({"z-index":"5000"})

    $(".breviary-bottom-panel").css({"height": "17px","margin-top": "-4px"})

    $(".toolbtn-big").css({"cursor":"pointer"})
    $(".keynote-btn").css({"cursor":"pointer"})
    $(".toolbtn").css({"cursor":"pointer"})
    $(".pull").css({"cursor":"pointer"})
    $(".push").css({"cursor":"pointer"})
    $(".nav-link").css({"cursor":"pointer"})
    $("#playBtn").css({"cursor":"pointer"})

    $(".progress-bg").click(function(){
        $(".toolbtn-big").removeClass("play")
    })

    $(".canvas_container").click(function(){
        $(".toolbtn-big").get(0).click()
    })
    $(".mask").click(function(){
        $(".toolbtn-big").get(0).click()
    })
    $(".toolbtn-big").click(function(){
        if($(".toolbtn-big").hasClass("play") && $.cookie("maskon")=="1")
            $("#playWrap").show()
        else
            $("#playWrap").hide()
    })

    $(".toolbtn.fullScreen").click(function(e){
        var el = e.srcElement || e.target; //target兼容Firefox
        var isFullscreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
        if (!isFullscreen) { //进入全屏,多重短路表达式
            (el.requestFullscreen && el.requestFullscreen()) ||
                (el.mozRequestFullScreen && el.mozRequestFullScreen()) ||
                (el.webkitRequestFullscreen && el.webkitRequestFullscreen()) || (el.msRequestFullscreen && el.msRequestFullscreen());

        } else { //退出全屏,三目运算符
            document.exitFullscreen ? document.exitFullscreen() :
            document.mozCancelFullScreen ? document.mozCancelFullScreen() :
            document.webkitExitFullscreen ? document.webkitExitFullscreen() : '';
        }
    })

    $(".header-wrapper").find("h3").css({"color":"black"});

    setInterval(function(){
        $("p.ng-star-inserted").css({"color":"black"});
        $(".clock.ng-star-inserted").css({"color":"black"});

        if($(".nav-item:nth-of-type(1)").find(".nav-link").hasClass("active"))
            $(".nav-item:nth-of-type(1)").find("span").css({"color":"black"})
        else
            $(".nav-item:nth-of-type(1)").find("span").css({"color":"#999"})

        if($(".toolbtn-big").hasClass("play") && $.cookie("maskon")=="1")
            $("#playWrap").show()
        else
            $("#playWrap").hide()


        $(".pull").click();
        $(".like").css({"cursor":"pointer","background": "url(https://nodestatic.fbstatic.cn/weblts_spa_online/webclass/static/star.00c51cc376f8088c8f23.svg)","width":"20px","height":"20px"})
        $(".unlike").css({"cursor":"pointer","background": "url(https://gitee.com/AN_drew/picBed/raw/master/img/empty-star.svg)"})
        $(".icon-close").css({"cursor":"pointer"})
        $(".toolbtn.volume").parent().css({"z-index":"6000"})
        $(".toolbtn.speed").parent().css({"z-index":"6000"})
    },100)


    // Your code here...
})();