Greasy Fork is available in English.

富聊审核后台优化脚本

try to make bteeer the fuliao!

Version vom 11.12.2018. Aktuellste Version

// ==UserScript==
// @name         富聊审核后台优化脚本
// @namespace    http://tampermonkey.net/
// @version      2.9.0
// @description  try to make bteeer the fuliao!
// @author       yinchengnuo
// @match        http://*/*
// @grant        none
// ==/UserScript==
/* jshint -W097 */
(function($) {
    //创建自动刷新器及其相关事件函数
    const $refresherInsert = (bool) => {
        $('<div class="refresh" title="鼠标右键查看帮助" style="width: 70px; height: 17px; overflow: hidden; position: fixed; right: 0px; top: 0px; border: 1px solid black; border-radius: 8px; opacity: 0.5; font-size: 12px;"><button class="refresherLeft" style="font-size: 10px; box-sizing: border-box; width: 24px; height: 17px; padding: 0px; float: left; cursor: pointer;">ON</button><input class="refresherCenter" maxlength="3" placeholder = "秒" type="text" style="box-sizing: border-box; width: 22px; height: 17px; text-align: center; float: left; font-size: 10px;"></input><button class="refresherRight" style="font-size: 10px; box-sizing: border-box; width: 24px; height: 17px; padding: 0px; float: left; cursor: pointer;">OFF</button></div>').appendTo("body");
        const showTime = $(".refresherCenter");
        let timer = null;
        //定义自动刷新器点击事件
        $(".refresh").on("click", "button", function() {
            //自动刷新器手动启动
            if (this.className === "refresherLeft") {
                clearInterval(timer);
                const time = parseInt(showTime.val());
                if (time && time >= 10) {
                    document.cookie = `time=${time};`;
                    let value = time;
                    timer = setInterval(() => {
                        value--;
                        showTime.val(value);
                        if (value === 0) {
                            location.reload();
                        }
                    }, 1000);
                } else {
                    alert("请输入大于等于10的纯数字");
                    showTime.val("20");
                }
                //自动刷新器手动结束
            } else if (this.className === "refresherRight") {
                clearInterval(timer);
                showTime.val("");
                document.cookie = "time=0;";
            }
        });
        $(".refresh").on("contextmenu", () => {
            alert("    1 当前自动刷新器可在富聊后台审核系统的部分页面上使用,设定一个不小于10的数字作为自动刷新间隔。不建议过大。设定时间之后点击ON按钮,开始进入自动刷新模式。自动刷新器上面显示的数字就是距离下次页面刷新的时间。点击OFF按钮终止自动刷新。如果当前浏览器打开了多个页面都在使用当前自动刷新器,则对一个页面的刷新间隔修改会影响所有正在使用当前定时刷新器的刷新间隔。(既如果点击了某一个正在运行自的自动刷新器的OFF按钮,则所有正在使用当前定时刷新器的页面会在当前时间间隔结束时退出自动刷新模式。)\n    2 当前自动刷新器的存在主要是为了配合在常规和文字类部分模块审核时增加的进审提醒功能。当设定了固定的自动刷新时间,页面刷新后,如果有新的内容进审则当前选项卡的title会一直闪烁显示进审,提示当前页面有新内容进审。同时自动刷新不会停止。当点击了正在闪烁提醒的选项卡时,自动刷新自动停止,只有当当前进审内容提交之后,自动刷新模式才会重新开启,时间为之前设置的时间间隔。设置了进审提醒的模块有所有常规, 封面审核,私聊广告消息,敏感词报警处理。\n    3 在使用进审提醒时,一些有下级的模块(如头像审核中有“已认证”和“其他”两个下级模块), 应当将这些下级模块都在浏览器的新选项卡打开,(视频介绍和敏感词报警的各四个下级模块也不例外),否则会影响提醒效果!");
            return false;
        });
        //自动刷新器自动启动
        if (document.cookie.match(/time=\d+/g)) {
            const time = parseInt(document.cookie.match(/time=\d+/g)[0].match(/\d+/g)[0]);
            if (time) {
                let value = time;
                showTime.val(value);
                timer = setInterval(() => {
                    value--;
                    showTime.val(value);
                    if (value === 0) {
                        location.reload();
                    }
                }, 1000);
            }
        }
        //进审提醒功能
        if (bool) {
            const title = $("title").html();
            let i = 0;
            setInterval(function() {
                if (i % 2 == 0) {
                    $("title").html(title);
                } else {
                    $("title").html("进审");
                }
                i++;
                if (document.hidden === false) {
                    clearInterval(timer);
                }
            }, 500);
        }
    };
    //图片尺寸设置函数
    const setSize = (width) => {
        var bite = 1.8;
        $("img").filter(function(i, e) {
            if (e.width > 100) {
                e.style.width = width + "px";
                e.style.height = width * bite + "px";
            } else {
                e.style.float = "right";
                e.style.width = "10x";
            }
        });
    }
    //设置按钮样式
    const setButtonSize = (size) => {
        $("table input:visible").css({
            "width": size / 3 + "px",
            "padding": "0",
            "margin": "0",
            "float": "left"
        }).filter(function(i, e) {
            if (e.value == "荐" || e.value == "拉黑" || e.value == "取荐") {
                e.style.display = "none";
            } else if (e.value == "推流" || e.value == "禁播") {
                e.style.width = size / 3 + "px";
                e.style.float = "right";
            }
        });
    }
    //设置用户名宽度,添加title属性显示用户名
    const setTitleSize = (size) => {
        $("tbody tr:nth-child(2) td a").css({
            "display": "inline-block",
            "width": size / 3 - 6 + "px",
            "height": "12px",
            "line-height": "12px",
            "overflow": "hidden"
        }).each(function(i, e) {
            $(e).parent().parent().parent().attr("title", $(e).html());
        });
    }
    //设置回车提交
    const enterLogin = (btn) => {
        $(document).one('keydown', function(e) {
            if (e.key === "Enter") {
                btn.click();
            }
        });
    }
    if (location.href.match(/userHeadPicAction!userHeadCheckWomanRenzhen/g) || location.href.match(/userHeadPicAction!userHeadCheckAll/g) || location.href.match(/auditUserAciton!photoNoneblogindex/g) || location.href.match(/groupChatPicAction!listUntreated/g) || location.href.match(/groupAction!auditindex/g) || location.href.match(/videoFile!videoFileAuditList/g) || location.href.match(/userFilterwordAction!index/g) || location.href.match(/videoLivePic!liveAutoReviewList/g)) {
        //头像,随拍,群聊,群,敏感词报警,自动处罚复审进审提示
        enterLogin($('a[title="提交"]').first().length ? $('a[title="提交"]').first() : $('a[title="操 作"]').first());
        $("img").length > 2 ? $refresherInsert(true) : $refresherInsert();
    } else if (location.href.match(/videoLivePic!getHotLiveVideoList/g)) {
        //封面进审提示
        enterLogin($('button:contains("提交")').first());
        $("img").length > 0 ? $refresherInsert(true) : $refresherInsert();
    } else if (location.href.match(/smallVideoAudit!getAuditList/g)) {
        //小视频进审提示
        enterLogin($('a[title="提交"]').first());
        $(".box").length > 0 ? $refresherInsert(true) : $refresherInsert();
    } else if (location.href.match(/imMsgAction!toAuditList/g)) {
        //私聊广告消息进审提示
        setTimeout(() => {
            if ($(".pag")[0].offsetHeight > 51 || $(".pag")[1].offsetHeight > 51 || $(".pag")[2].offsetHeight > 51) {
                $refresherInsert(true);
                $(".content_div input:button").click(() => {
                    setTimeout(() => {
                        location.reload();
                    }, 500);
                });
            } else {
                $refresherInsert();
            }
        }, 500);
    } else if (location.href.match(/picture.audit/g)) {
        //公共图片进审提醒及相关键盘事件改变
        $refresherInsert();
        $(".btn.border").first().click();
        $("img").length > 2 ? $refresherInsert(true) : $refresherInsert();
        const refresh = () => {
            $(".layui-layer").find('a:contains("确定")').click(function() {
                location.reload();
            });
            $(document).on('keydown', function(e) {
                if (e.code === 'Space') {
                    $(".layui-layer").find('a:contains("确定")').click();
                }
            })
        }
        $("#submitBut").click(function() {
            refresh();
        });
        $(document).on('keydown', function(e) {
            if (e.code === "Enter" || e.code === "NumpadEnter") {
                refresh();
            }
        });
    } else if (location.href.match(/userFilterwordAction!getnewfilterSecKillList/g)) {
        //敏感词秒杀模块
        $('<div class="t-b" style=" cursor: pointer;width: 50px;height:50px; position: fixed; bottom: 50px; right:0;border-radius: 8px; border: 1px solid black; overflow: hidden;"><button class="toTop" style="color: red; background: #fff;width: 50px; height:25px; padding: 0px; font-size: 14px;">去顶部</button><button class="toBottom" style="color: red; background: #fff;width: 50px; height:25px; padding: 0px; font-size: 14px;">去底部</button></div>').appendTo("body");
        $('.toTop').add('.toBottom').hover(function() {
            $(this).css({
                'background-color': '#ccc'
            });
        }, function() {
            $(this).css({
                'background-color': '#fff'
            });
        });
        $('.t-b').on('click', 'button', function() {
            if (this.className === 'toTop') {
                window.scrollTo(0, 0);
            } else {
                if ($('.marked').length) {
                    let l = $('#chatdiv .marked').length ? $('#chatdiv .marked').first()[0].offsetTop : $('#chatdiv>div').last()[0].offsetTop;
                    let c = $('#groupdiv .marked').length ? $('#groupdiv .marked').first()[0].offsetTop : $('#groupdiv>div').last()[0].offsetTop;
                    let r = $('#livediv .marked').length ? $('#livediv .marked').first()[0].offsetTop : $('#livediv>div').last()[0].offsetTop;
                    window.scrollTo(0, [l, c, r].sort((a, b) => b - a)[0] - 666);
                } else {
                    window.scrollTo(0, 999999999);
                }
            }
        });
        document.oncontextmenu = function() {
            return false;
        };
        const rander = ele => {
            $(ele).parent().find(".marked").removeClass("marked").css("background-color", "#f3f3f3");
            $(ele).addClass("marked").css("background-color", "#ddd").nextAll().addClass("marked").css("background-color", "#ddd");
        }
        $("#chatdiv").add("#groupdiv").add("#livediv").on("mousedown", "div", function(e) {
            if (e.button == 2) {
                rander(this);
            }
        });
    } else if (location.href.match(/videoLiveAuditAction!videoliveScreenAuditList/g)) {
        //截屏审核
        //文档加载完毕后开始优化
        document.onreadystatechange = () => {
            if (document.readyState == "complete") {
                //直播截屏审核
                //脚本控制面板写入
                $('<div class="mytool"style="float:right; margin: 8px 0px;font-size: 12px;"><span class="how" style="font-size: 8px; color: blue; cursor: pointer; ">如何使用?</span><span style="color:red;">快捷键:Q警告(取消) W下榜(取消) E禁播(取消) R推流 T换一批 </span><span style="font-weight:bold;"> 当前页面停留时间:</span><span class="keepTime" style="color:red; display:inline-block;font-weight:bold;text-align:right;">0</span><span> 秒 </span><label for="autInput" style="font-weight:bold; cursor: pointer; ">图片尺寸:</label><input id="autInput" type="input" style="width:22px; height:16px; font-size: 12px; cursor: pointer; "><span>(px)</span><label for="hdButton" style="font-weight:bold; cursor: pointer; "> 隐藏按钮:</label><input id="hdButton" type="checkbox" style="vertical-align: middle; cursor: pointer; width: 12px; height: 12px;">&nbsp&nbsp<label for="dbClick" style="font-weight:bold; cursor: pointer; ">双击页面换一批:</label><input id="dbClick" type="checkbox" style="vertical-align: middle; cursor: pointer; width: 12px; height: 12px;"></div>').appendTo(".toolbar:last");
                ////页面计时开始
                let keepTime = 0;
                setInterval(() => {
                    $(".keepTime").html(keepTime);
                    keepTime++;
                }, 1000);
                enterLogin($(".btn_blue").first());
                //检测cookie
                if (document.cookie.match(/size=\d+/g) && document.cookie.match(/db=\d/g) && document.cookie.match(/hd=\d/g)) {
                    var size = parseInt(document.cookie.match(/size=\d+;/g)[0].match(/\d+/g)[0]);
                    var db = parseInt(document.cookie.match(/db=\d;/g)[0].match(/\d/g)[0]);
                    var hd = parseInt(document.cookie.match(/hd=\d;/g)[0].match(/\d/g)[0]);
                    //按照cookie参数进行渲染
                    setSize(size);
                    setButtonSize(size);
                    setTitleSize(size);
                    $("#autInput").val(size);
                    if (db) {
                        $("#dbClick").attr("checked", true);
                        //双击自动刷新页面
                        $(document).dblclick(() => {
                            $(".btn_blue").first().click();
                        });
                    }
                    if (hd) {
                        $("#hdButton").attr("checked", true);
                        $("table input:visible").add(".showpic tbody tr:nth-child(3)").css('display', 'none');
                    }
                } else {
                    //尺寸初始化
                    document.cookie = "size=131;";
                    document.cookie = "db=0;";
                    document.cookie = "hd=0;";
                    $("#autInput").val(131);
                    setSize(130);
                    setButtonSize(130);
                    setTitleSize(130);
                }
                //脚本控制面板事件处理
                $(".mytool").on("click", "input", function(e) {
                    if (this.id === 'dbClick') {
                        if ($(this).is(':checked')) {
                            document.cookie = "db=1;";
                        } else {
                            document.cookie = "db=0;";
                        }
                    } else if (this.id === 'hdButton') {
                        if ($(this).is(':checked')) {
                            document.cookie = "hd=1;";
                        } else {
                            document.cookie = "hd=0;";
                        }
                    }
                });
                $(".how").click(function() {
                    alert("    1 图片尺寸设置即直播截屏宽度设置,设置不同的宽度会按照图片原有比例对应设置图片高度。。可根据个人喜好和电脑屏幕宽高设置,设置自定义宽度须先点击自定义按钮,随后进行设置。设置值为大于等于130小于等于25的纯阿拉伯数字。\n    2当前脚本对截屏审核界面做了比较大的改动,为了尽可能多的展示图片内容。隐藏掉了 拉黑 推荐 按钮,并且将用户昵称,才艺,PK中,接收方,发起方这些文字信息做了简短处理。但是如果想查看完整的用户昵称信息,只需要将鼠标悬停在经过处理的昵称上就可以了。\n    4 双击页面换一批为,当选中开启后,在页面的任意地方双击会触发 换一批 按钮的单击执行。默认为关闭!\n 以上所有效果均为在当前页面设置,在提交 换一批 之后的所有此页面上生效。关闭当前选项卡之后所有设置的参数会被清空,再次打开请重新设置!\n    5 当鼠标移动到需要处罚的用户时,可以触发快捷键。鼠标移出时失效");
                });
                $("#autInput").mousedown(function() {
                    this.value = '';
                });
                $("#autInput").prev().mousedown(function() {
                    $("#autInput").val('');
                });
                $("#autInput").blur(function() {
                    const value = parseInt(this.value);
                    if (value < 130) {
                        document.cookie = "size=130;";
                        this.value = 130;
                        alert("设定宽度过小,已经为你设置为130px");
                    } else if (parseInt(this.value.trim()) > 250) {
                        document.cookie = "size=250;";
                        this.value = 250;
                        alert("设定宽度过大,已经为你设置为250px");
                    } else if (value >= 130 && value <= 250) {
                        document.cookie = `size=${value};`;
                        this.value = value;
                    } else {
                        this.value = size;
                        alert("请输入设定宽度");
                    }
                });
                //页面自动滚动
                window.scrollTo(0, 72);
                //页面内文字不可选
                $("body").css("-webkit-user-select", "none");
                //修复空白bug,设定单个用户界面最小宽高
                $(".showpic").css({
                    "margin": "0px 2px",
                    "float": "none",
                    "display": "inline-block",
                    "margin-right": "-4px",
                    "min-height": "250px"
                }).children("table").css({
                    "width": "130px",
                    "margin": "0",
                    "height": "250px",
                    "padding": "0px"
                });
                $("tbody tr:nth-child(2) td font").each(function(i, e) {
                    e.style.display = "none";
                });
                //替换显示文字
                $('span').each(function(i, e) {
                    if (e.innerHTML === '才艺') {
                        e.innerHTML = '';
                    } else if (e.innerHTML === 'PK') {
                        e.innerHTML = '';
                    } else if (e.innerHTML === '已推流') {
                        e.innerHTML = '已推';
                    }
                });
                //取消动画
                $('.close').hide();
                $(document).click(() => {
                    $(':animated').stop(true, true);
                });
                //键盘控制部分
                $($('.content_div')[0]).on('mouseover', 'table', function(e) {
                    this.tabIndex = 0;
                    this.focus();
                    var Q = 0;
                    var W = 0;
                    var E = 0;
                    var width = document.body.offsetWidth;
                    this.style.outline = "blue solid 2px";
                    this.onkeydown = function(e) {
                        if (e.code == 'KeyQ') {
                            if (Q % 2 == 0) {
                                document.body.onkeydown = null;
                                $(this).find('.btn_blue').filter(function(i, e) {
                                    if (e.value == '警告') {
                                        $(e).click();
                                    }
                                });
                                $('.showbox:animated').stop(true, true);
                                if (this.offsetLeft + this.offsetWidth + 300 > width) {
                                    $('.showbox:visible')[0].style.left = this.offsetLeft - 300 + 'px';
                                    $('.showbox:visible')[0].style.top = this.offsetTop + 80 + 'px';
                                } else {
                                    $('.showbox:visible')[0].style.left = this.offsetLeft + this.offsetWidth + 'px';
                                    $('.showbox:visible')[0].style.top = this.offsetTop + 80 + 'px';
                                }
                                setTimeout(function() {
                                    document.body.tabIndex = 0;
                                    document.body.onkeydown = function(e) {
                                        if (e.code == 'KeyQ') {
                                            $('.showbox:visible').find('.btn_blue').eq(1).click();
                                            $('.showbox:animated').stop(true, true);
                                            $('.showbox #jg_div').find('h2>span').html('请选择警告的理由');
                                        }
                                    }
                                }, 1);
                                var name = $(this).find('a').html();
                                $('.showbox #jg_div').find('h2>span').html('请选择警告 ' + name.fontcolor('orange') + ' 的理由');
                            }
                            Q++;
                        } else if (e.code == 'KeyW') {
                            if (Q % 2 == 0) {
                                document.body.onkeydown = null;
                                $(this).find('.btn_blue').filter(function(i, e) {
                                    if (e.value == '下榜') {
                                        $(e).click();
                                    }
                                });
                                $('.showbox:animated').stop(true, true);
                                if (this.offsetLeft + this.offsetWidth + 300 > width) {
                                    $('.showbox:visible')[0].style.left = this.offsetLeft - 300 + 'px';
                                    $('.showbox:visible')[0].style.top = this.offsetTop + 80 + 'px';
                                } else {
                                    $('.showbox:visible')[0].style.left = this.offsetLeft + this.offsetWidth + 'px';
                                    $('.showbox:visible')[0].style.top = this.offsetTop + 80 + 'px';
                                }
                                setTimeout(function() {
                                    document.body.tabIndex = 0;
                                    document.body.onkeydown = function(e) {
                                        if (e.code == 'KeyW') {
                                            $('.showbox:visible').find('.btn_blue').eq(1).click();
                                            $('.showbox:animated').stop(true, true);
                                        }
                                    }
                                }, 1);
                                var name = $(this).find('a').html();
                                $('.showbox #xb_div').find('h2>span').html('请选择下榜 ' + name.fontcolor('orange') + ' 的理由');
                            }
                            Q++;
                        } else if (e.code == 'KeyE') {
                            if (Q % 2 == 0) {
                                document.body.onkeydown = null;
                                $(this).find('.btn_blue').filter(function(i, e) {
                                    if (e.value == '禁播') {
                                        $(e).click();
                                    }
                                });
                                $('.showbox:animated').stop(true, true);
                                if (this.offsetLeft + this.offsetWidth + 300 > width) {
                                    $('.showbox:visible')[0].style.left = this.offsetLeft - 300 + 'px';
                                    $('.showbox:visible')[0].style.top = this.offsetTop + 80 + 'px';
                                } else {
                                    $('.showbox:visible')[0].style.left = this.offsetLeft + this.offsetWidth + 'px';
                                    $('.showbox:visible')[0].style.top = this.offsetTop + 80 + 'px';
                                }
                                setTimeout(function() {
                                    document.body.tabIndex = 0;
                                    document.body.onkeydown = function(e) {
                                        if (e.code == 'KeyE') {
                                            $('.showbox:visible').find('.btn_blue').eq(1).click();
                                            $('.showbox:animated').stop(true, true);
                                        }
                                    }
                                }, 1);
                                var name = $(this).find('a').html();
                                $('.showbox #jb_div').find('h2>span').html('请选择禁播 ' + name.fontcolor('orange') + ' 的时长');
                            }
                            Q++;
                        } else if (e.code == 'KeyR') {
                            $(this).find('.btn_blue').filter(function(i, e) {
                                if (e.value == '推流') {
                                    $(e).click();
                                }
                            });
                        } else if (e.code == 'KeyT') {
                            $('.btn_blue').first().click();
                        }
                    }
                });
                $($('.content_div')[0]).on('mouseleave', 'table', function(e) {
                    this.tabIndex = 9999;
                    this.blur();
                    this.style.outline = "none";
                    this.onkeydown = null;
                });
                $('.showpic').on('click', 'input', function(e) {
                    if ($(':animated').length) {
                        if (this.value == '警告') {
                            $(':animated').find('h2>span').html('请选择警告的理由');
                        } else if (this.value == '下榜') {
                            $(':animated').find('h2>span').html('请选择下榜的理由');
                        } else if (this.value == '禁播') {
                            $(':animated').find('h2>span').html('请选择禁播的时长');
                        }
                        $(':animated').stop(true, true);
                        if ($('.showbox:visible')[0]) {
                            $('.showbox:visible')[0].style.position = 'absolute';
                            $('.showbox:visible')[0].style.left = '50%';
                            $('.showbox:visible')[0].style.top = '400px';
                        }
                    }
                })
                $('.showbox td .btn_blue').click(function() {
                    $(':animated').stop(true, true);
                });
                //压缩表格各行高度
                $(".showpic tbody tr:nth-child(1)").css("height", "190px");
                $(".showpic tbody tr:nth-child(2)").css("height", "10px");
                $(".showpic tbody tr:nth-child(3)").css("height", "10px");
                $(".showpic tbody tr:nth-child(4)").css("height", "10px");
                $(".showpic tbody tr td").css("padding", "0px");
                //加载提示
                $('<div class="loading" style="display: none; width: 300px; height: 40px; background: #f40; border-radius: 8px; opacity: 0.6; color: #fff; position: fixed; left: 50%; top: 50%; margin-left: -150px; margin-top: -20px; line-height: 40px; text-align: center; font-size: 28px;">加载中,请稍后</div>').appendTo("body");
                $(".toolbar .btn_blue").first().add('.toolbar .btn_blue:nth-child(1)').click(function() {
                    $(".loading").css("display", "block");
                    let i = 0;
                    setInterval(() => {
                        if (i % 3 == 0) {
                            $(".loading").html(". 加载中,请稍后 .");
                        } else if (i % 3 == 1) {
                            $(".loading").html(". . 加载中,请稍后 . .");
                        } else if (i % 3 == 2) {
                            $(".loading").html(". . . 加载中,请稍后 . . .");
                        }
                        i++;
                    }, 200);
                });
            }
        }
    }
})(window.parent.$);