MT论坛

MT论坛效果增强,如自动签到、自动展开帖子、自动展开评论、显示uid、屏蔽用户、手机版小黑屋等

目前為 2022-05-28 提交的版本,檢視 最新版本

// ==UserScript==
// @name         MT论坛
// @namespace    http://tampermonkey.net/
// @description  MT论坛效果增强,如自动签到、自动展开帖子、自动展开评论、显示uid、屏蔽用户、手机版小黑屋等
// @version      2.3.8
// @author       MT-戒酒的李白染
// @icon         https://bbs.binmt.cc/favicon.ico
// @match        *://bbs.binmt.cc/*
// @compatible   edge Beta/Dev/Candy 测试通过
// @compatible   火狐 测试通过
// @compatible   Yandex 测试通过
// @compatible   Kiwi 测试通过
// @license      GPL-3.0-only
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// @grant        GM_setClipboard
// @grant        GM_xmlhttpRequest
// @run-at       document-start
// @supportURL   https://github.com/893177236/Monkey_script
// @require	     https://cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.js
// ==/UserScript==

(function () {
    'use strict';
    const log = {
        success: (str) => {
            console.log("%c" + str, "color: #81b453");
        },
        error: (str) => {
            console.trace("%c" + str, "color: #f20000");
        }
    }
    let mt_config = {
        dom_obj: {
            beauty_select: function () { //下拉列表对象
                return document.getElementsByClassName("beauty-select")[0];
            },
            combobox_switch: function () { //复选框对象
                return document.getElementsByClassName("switch_1")[0];
            },
            comiis_verify: function () { //帖子内各个人的信息节点【list】
                return document.getElementsByClassName("comiis_verify");
            },
            comiis_formlist: function () { //导航中最新、热门、精华、恢复、抢沙发的各个帖子【list】
                return document.getElementsByClassName("forumlist_li");
            },
            comiis_postli: function () { //帖子内评论,包括帖子内容主体,第一个就是主体【list】
                return document.getElementsByClassName("comiis_postli comiis_list_readimgs nfqsqi")
            },
            post_bottom_controls: function () { // 帖子底部一栏控件
                return document.getElementsByClassName("comiis_znalist_bottom b_t cl")

            },
            post_list_of_comments: function () { //帖子内评论列表
                return $(".comiis_postlist.kqide");
            },
            post_next_commect: function () { //帖子内评论下一页的按钮
                return document.querySelector("div.comiis_page.bg_f>a:nth-child(3)");
            }
        },
        rexp: {
            search_url: /bbs.binmt.cc\/search.php/g, //搜索页
            chat_url: /home.php\?mod=space&do=pm&subop=view/g, // 聊天页
            home_url: /home.php\?mod=spacecp&ac=profile&op=info/g, //个人空间页
            home_kmisign_url: /bbs.binmt.cc\/(forum.php\?mod=guide&view=hot(|&mobile=2)|k_misign-sign.html)/g, //主页和签到页链接
            home_space_url: /bbs\.binmt\.cc\/home\.php\?mod=space/g, //【我的】 个人信息页链接
            home_space_pc_uid_url: /space-uid-(.*?).html/, //PC 个人空间链接uid
            reply_url: "",
            sign_url: "",
            navigation_url: "",
            forum_post: /(bbs.binmt.cc\/thread-|bbs.binmt.cc\/forum.php\?mod=viewthread)/g, //帖子链接
            forum_post_pc: /.*:\/\/bbs.binmt.cc\/thread.*/, //帖子链接-PC
            forum_guide_url: /bbs.binmt.cc\/forum.php\?mod=guide/g, // 导航链接
            forum_post_reply: /forum.php\?mod=post&action=reply/g, //帖子中回复的链接
            forum_post_page: '&page=(.*)', //帖子链接的当前所在页 page
            forum_post_pc_page: 'thread-(.*?)-', //PC帖子链接的当前所在页 page
            forum_plate_text: /休闲灌水|求助问答|逆向教程|资源共享|综合交流|编程开发|玩机教程|建议反馈/g, //各版块名称
            plate_url: /bbs.binmt.cc\/forum-[0-9]{1,2}-[0-9]{1,2}.html/g, // 板块链接
            formhash: /formhash=(.*)&/, //论坛账号的凭证
            font_special: /<br>|&nbsp;|<font.*?>|<\/font>|<strike>|<strong>|<i>|<u>|align=".*?"/g, //帖子内特殊字体格式
            forum_post_guide_url: /bbs.binmt.cc\/page-[1-5].html|bbs.binmt.cc\/forum.php\?mod=guide/g, //帖子链接和导航链接
            mt_uid: /uid=(\d+)/,
            nologin: /member.php\?mod=logging&action=login(|&mobile=2)/g, //未登录(不可用)
            pc_useragent: 'Windows', //pc识别
            k_misign_sign: "bbs.binmt.cc\/k_misign-sign.html",
        }
    }


    function Latest_publication() {
        var ele = document.createElement('li');
        var url = window.location.href;
        ele.id = "latest_publication";
        ele.innerHTML = '<a href="https:\/\/bbs.binmt.cc\/forum.php?mod=guide&view=newthread" hidefocus="true" title="最新发表">最新发表<\/a>';
        document.getElementsByClassName("wp comiis_nvbox cl")[0].children[1].appendChild(ele);
        if (url == 'https:\/\/bbs.binmt.cc\/forum.php?mod=guide&view=newthread') {
            document.getElementById("mn_forum_10").children[0].style = "background: url(";
            ele.style.cssText = 'background: url("https:\/\/cdn2.bbs.binmt.cc\/template\/comiis_mi\/img\/nv_a.png") repeat-x 50% -50px;';

        }
    }

    function removeFontStyle() { // 移除帖子内容特殊字体
        if (window.localStorage.getItem("v1") && location.href.match(mt_config.rexp.forum_post)) {
            var rule = mt_config.rexp.font_special;
            var h_content = document.getElementsByClassName("comiis_a comiis_message_table cl");
            h_content[0].innerHTML = h_content[0].innerHTML.replace(rule, '');
        }

    }

    function getLocalTime() {
        let GM_myDate = new Date;
        let GM_year = GM_myDate.getFullYear(); //获取当前年
        let GM_mon = GM_myDate.getMonth() + 1; //获取当前月
        let GM_date = GM_myDate.getDate();
        let GM_alldate = GM_year.toString() + GM_mon.toString() + GM_date.toString();
        GM_alldate = parseInt(GM_alldate);
        return GM_alldate
    }

    function getFormHash() { // 获取账号的formhash
        return document.querySelector("input[name=formhash]") ? document.querySelector("input[name=formhash]").value : document.querySelector("div[class=sidenv_exit]>a").href.match(mt_config.rexp.formhash)[1];
    }

    function autoSignIn() { //mt签到
        if (window.localStorage.getItem("v17")) {
            console.log("尚未开启每日签到");
            return;
        }
        if (GM_getValue("mt_sign") != getLocalTime()) {
            if ((window.location.href == location.origin + "/") || (window.location.href == location.origin + "/forum.php") || window.location.href.match(mt_config.rexp.home_kmisign_url)) {
                if (!document.querySelector("div[class=comiis_dlq]>a") || (document.getElementsByClassName("sidenv_user")[0].href.match(mt_config.rexp.nologin) == null)) {
                    let getMTFormHash = getFormHash();
                    if (getMTFormHash != null) {
                        let GM_localTime = getLocalTime();
                        $.get("/k_misign-sign.html?operation=qiandao&format=button&formhash=" + mt_formhash + "&inajax=1&ajaxtarget=midaben_sign", function (data, status) {
                            console.log(data.responseText);
                            GM_setValue("mt_sign", GM_localTime);
                            window.location.reload();
                        });
                    } else {
                        console.log("获取账号formhash失败")
                    }
                } else {
                    console.log("当前账号尚未登录(不可用)")
                }
            } else {
                console.log("当前不在主页 pc")
            }
        } else {
            console.log("今日已签到")
        }

    }

    function searchHistory() {
        if (window.localStorage.getItem("v19") && location.href.match(mt_config.rexp.search_url)) {
            search_event();
            add_search_history();
            add_clear_history();
        }
    }

    function search_event() {
        //搜索界面增加关闭按钮事件,清空input内容
        //点击搜索保存搜索记录
        $(".ssclose.bg_e.f_e").click(function () {
            $("#scform_srchtxt").val("")

        })
        $("#scform_submit").click(function () {
            let getsearchtext = $("#scform_srchtxt").val();
            if ((getsearchtext != null) && (getsearchtext != "")) {
                let search_history_array = new Array(getsearchtext);
                let has_history = GM_getValue("search_history");
                if (has_history != null) {
                    if ($.inArray(getsearchtext, has_history) != -1) {
                        console.log("已有该搜索历史记录")
                        search_history_array = has_history
                    } else {
                        console.log("无该记录,追加");
                        search_history_array = search_history_array.concat(has_history);
                    }
                } else {
                    console.log("空记录,添加")
                }
                GM_setValue("search_history", search_history_array);
            }

        })
    }

    function add_search_history() { //搜索界面添加搜索历史记录
        $("#scform_srchtxt").attr("list", "search_history");
        var search_history_list = GM_getValue("search_history");
        var dom_datalist = document.createElement("datalist");
        dom_datalist.id = "search_history";
        var option_text = "";
        if (search_history_list) {
            for (var i = 0; i < search_history_list.length; i++) {
                option_text = option_text + '<option value="' + search_history_list[i] + '">';
            }
            dom_datalist.innerHTML = option_text;
            $(".comiis_flex").append(dom_datalist);
        }

    }

    function add_clear_history() { //搜索界面添加清理历史记录和历史记录个数
        let search_history_list = GM_getValue("search_history");
        let search_history_nums = 0;
        if (search_history_list != null) {
            search_history_nums = search_history_list.length;
        }
        let clear_history_innerHTML =
            `<div class="comiis_p12 f14 bg_f f_c b_b cl" style="padding-bottom:10px">搜索记录个数: ` +
            search_history_nums +
            `<button class="btn_clear_search_history" style="
            border: none;
            float: right;
            background: red;
            color: #fff;
            border-radius: 3px;
            font-weight: 600;
            min-width: 20vw;
            width: 20vw;
        ">清理记录</button></div>`;
        let insertdom = $(".comiis_p12.f14.bg_f.f_c.b_b.cl,.comiis_tagtit.b_b.f_c");
        insertdom.before(clear_history_innerHTML);
        $(".btn_clear_search_history").click(function () {
            GM_deleteValue("search_history");
            window.location.reload();
        })
    }


    function show_latest_sign() { // 显示签到的最先几个人,最多10个
        if (window.location.href.match(mt_config.rexp.k_misign_sign)) {
            let today_ranking_ele = document.querySelector(".comiis_topnv .comiis_flex .flex");
            today_ranking_ele.after($(`<li class="flex"><a href="javascript:;" id="k_misignlist_today_latest" onclick="ajaxlist('todayLatest');">今日最先</a></li>`)[0]);
            let getMaxPage = (urlextra) => {
                return new Promise(res => {
                    GM_xmlhttpRequest({
                        url: "https://bbs.binmt.cc/k_misign-sign.html?operation=" + urlextra,
                        async: false,
                        dataType: 'html',
                        headers: {
                            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53"
                        },
                        onload: function (resp) {
                            let last_url = $(resp.response).find("#J_list_detail .pg .last")[0].href;
                            let last_page = last_url.match(/page=([0-9]*)/)[1];
                            res(last_page);

                            // console.log(data);
                            // $("#ranklist").html(data);
                            // $('#ranklist').attr('listtype', listtype);
                        },
                        onerror: function (resp) {
                            console.log(resp);
                            res(0);
                        }
                    })
                })
            }

            let getPagePeople = (page) => {
                return new Promise(res => {
                    GM_xmlhttpRequest({
                        url: "https://bbs.binmt.cc/k_misign-sign.html?operation=list&op=&page=" + page,
                        async: false,
                        dataType: 'html',
                        headers: {
                            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53"
                        },
                        onload: function (resp) {
                            let peoples = $(resp.response).find("#J_list_detail tbody tr");
                            let ret_array = [];
                            for (let i = 1; i <= peoples.length - 2; i++) {
                                let people = peoples[i];
                                let ret_json = {};
                                let user_name = people.children[0].getElementsByTagName("a")[0].textContent;
                                let space_url = people.children[0].getElementsByTagName("a")[0].href;
                                let uid = space_url.match(/space-uid-([0-9]*)/)[1];
                                let sign_all_days = people.children[1].textContent;
                                let sign_month_days = people.children[2].textContent;
                                let sign_time = people.children[3].textContent;
                                let sign_reward = people.children[5].textContent;
                                ret_json["user"] = user_name;
                                ret_json["uid"] = uid;
                                ret_json["avatar"] = "https://avatar-bbs.mt2.cn/uc_server/avatar.php?uid=" + uid + "&size=small";
                                ret_json["days"] = sign_all_days;
                                ret_json["monthDays"] = sign_month_days;
                                ret_json["time"] = sign_time;
                                ret_json["reward"] = sign_reward;
                                ret_array = ret_array.concat(ret_json);
                            }
                            res(ret_array)
                        },
                        onerror: function (resp) {
                            console.log(resp);
                            res({});
                        }
                    })
                })
            }

            function changeRankList(data, listtype) {
                $("#ranklist").html(data);
                $('#ranklist').attr('listtype', listtype);
            }

            ajaxlist = async (listtype) => {
                listtype = listtype;
                if (listtype == 'today') {
                    loadingdelay = false;
                    urlextra = 'list&op=today';
                } else if (listtype == 'month') {
                    loadingdelay = false;
                    urlextra = 'list&op=month';
                } else if (listtype == 'zong') {
                    loadingdelay = false;
                    urlextra = 'list&op=zong';
                } else if (listtype == 'calendar') {
                    loadingdelay = true;
                    urlextra = 'calendar';
                } else {
                    loadingdelay = false;
                    urlextra = 'list';
                }
                //alert(loadingdelay);
                if (listtype == 'todayLatest') {
                    loadingdelay = false;
                    urlextra = 'list&op=&page=0';
                    let maxPage = await getMaxPage(urlextra);
                    let latestPeople = await getPagePeople(maxPage);
                    let peopleHTML = '';
                    latestPeople.reverse();
                    latestPeople.forEach(people => {
                        peopleHTML = peopleHTML + `
                        <tbody id="autolist_` + people["uid"] + `">
                            <tr>
                                <td class="k_misign_lu">
                                    <a href="home.php?mod=space&amp;uid=` + people["uid"] + `"><img
                                            src="` + people["avatar"] + `"></a>
                                </td>
                                <td class="k_misign_ll"><span></span></td>
                                <td class="k_misign_lc">
                                    <h4 class="f_c"><a href="home.php?mod=space&amp;uid=` + people["uid"] + `">` + people["user"] + `</a><span>` + people["time"] + `</span><span
                                            class="y">总天数 ` + people["days"] + `天</span></h4>
                                    <p class="f_0">月天数 ` + people["monthDays"] + ` 天
                                        ,
                                        上次奖励
                                        ` + people["reward"] + `</p>
                                </td>
                            </tr>
                        </tbody>
                        `
                    })
                    let latestHTML = `<li class="styli_h bg_e"></li>
                    <div class="comiis_topnv bg_f b_t b_b">
                        <ul class="comiis_flex">
                            <li class="flex"><a href="javascript:;" id="k_misignlist_today" onclick="ajaxlist('today');">今日排行</a></li>
                            <li class="flex f_0"><em class="bg_0"></em><a href="javascript:;" id="k_misignlist_today_latest" onclick="ajaxlist('todayLatest');">今日最先</a>
                            </li>
                            <li class="flex"><a href="javascript:;" id="k_misignlist_month" onclick="ajaxlist('month');" class="f_c">本月排行</a>
                            </li>
                            <li class="flex"><a href="javascript:;" id="k_misignlist_zong" onclick="ajaxlist('zong');" class="f_c">总排行</a></li>
                        </ul>
                    </div>
                    <div class="k_misign_wp">
                        <div class="k_misign_list bg_f">
                            <table id="misign_list">
                            ` + peopleHTML + `
                            </table>
                        </div>
                    </div>`
                    changeRankList(latestHTML, listtype)
                } else {
                    $.ajax({
                        type: 'GET',
                        url: "plugin.php?id=k_misign:sign&operation=" + urlextra,
                        async: false,
                        dataType: 'html',
                        success: function (data) {
                            // console.log(data);
                            data = data.replace(`今日排行</a></li>`, `今日排行</a></li><li class="flex"><a href="javascript:;" id="k_misignlist_today_latest" onclick="ajaxlist('todayLatest');">今日最先</a></li>`);
                            changeRankList(data, listtype);

                        },
                        complete: function (XHR, TS) {
                            XHR = null
                        }
                    });
                }

            }

        }

    }

    function setCheckBoxCSS() {
        var checkBox_css_ = document.createElement("style");

        checkBox_css_.innerHTML = `
        body{background:#000;margin:0;padding:0;}
            .wrapper{
                display: -webkit-box;
                display: -ms-flexbox;
                display: flex;
                width: 400px;
                margin: 50vh auto 0;
                -ms-flex-wrap: wrap;
                    flex-wrap: wrap;
                -webkit-transform: translateY(-50%);
                    transform: translateY(-50%);
            }

            .switch_box{
                display: -webkit-box;
                display: -ms-flexbox;
                display: flex;
                max-width: 200px;
                min-width: 200px;
                height: 200px;
                -webkit-box-pack: center;
                    -ms-flex-pack: center;
                    justify-content: center;
                -webkit-box-align: center;
                    -ms-flex-align: center;
                    align-items: center;
                -webkit-box-flex: 1;
                    -ms-flex: 1;
                    flex: 1;
            }

            /* Switch 1 Specific Styles Start */

            .box_1{
                background: #eee;
            }

            input[type="checkbox"].switch_1{
                font-size: 14px;
                -webkit-appearance: none;
                -moz-appearance: none;
                    appearance: none;
                width: 3.5em;
                height: 1.5em;
                background: #ddd;
                border-radius: 3em;
                position: relative;
                cursor: pointer;
                outline: none;
                -webkit-transition: all .2s ease-in-out;
                transition: all .2s ease-in-out;
            }

            input[type="checkbox"].switch_1:checked{
                background: #0ebeff;
            }

            input[type="checkbox"].switch_1:after{
                position: absolute;
                content: "";
                width: 1.5em;
                height: 1.5em;
                border-radius: 50%;
                background: #fff;
                -webkit-box-shadow: 0 0 .25em rgba(0,0,0,.3);
                    box-shadow: 0 0 .25em rgba(0,0,0,.3);
                -webkit-transform: scale(.7);
                    transform: scale(.7);
                left: 0;
                -webkit-transition: all .2s ease-in-out;
                transition: all .2s ease-in-out;
            }

            input[type="checkbox"].switch_1:checked:after{
                left: calc(100% - 1.5em);
            }

            /* Switch 1 Specific Style End */


            /* Switch 4 Specific Style Start */

            .box_4{
                background: #eee;
            }

            .input_wrapper{
            width: 80px;
            height: 40px;
            position: relative;
            cursor: pointer;
            }

            .input_wrapper input[type="checkbox"]{
            width: 80px;
            height: 40px;
            cursor: pointer;
            -webkit-appearance: none;
                -moz-appearance: none;
                appearance: none;
            background: #315e7f;
            border-radius: 2px;
            position: relative;
            outline: 0;
            -webkit-transition: all .2s;
            transition: all .2s;
            }

            .input_wrapper input[type="checkbox"]:after{
            position: absolute;
            content: "";
            top: 3px;
            left: 3px;
            width: 34px;
            height: 34px;
            background: #dfeaec;
            z-index: 2;
            border-radius: 2px;
            -webkit-transition: all .35s;
            transition: all .35s;
            }

            .input_wrapper svg{
            position: absolute;
            top: 50%;
            -webkit-transform-origin: 50% 50%;
                transform-origin: 50% 50%;
            fill: #fff;
            -webkit-transition: all .35s;
            transition: all .35s;
            z-index: 1;
            }

            .input_wrapper .is_checked{
            width: 18px;
            left: 18%;
            -webkit-transform: translateX(190%) translateY(-30%) scale(0);
                transform: translateX(190%) translateY(-30%) scale(0);
            }

            .input_wrapper .is_unchecked{
            width: 15px;
            right: 10%;
            -webkit-transform: translateX(0) translateY(-30%) scale(1);
                transform: translateX(0) translateY(-30%) scale(1);
            }

            /* Checked State */
            .input_wrapper input[type="checkbox"]:checked{
            background: #23da87;
            }

            .input_wrapper input[type="checkbox"]:checked:after{
            left: calc(100% - 37px);
            }

            .input_wrapper input[type="checkbox"]:checked + .is_checked{
            -webkit-transform: translateX(0) translateY(-30%) scale(1);
                transform: translateX(0) translateY(-30%) scale(1);
            }

            .input_wrapper input[type="checkbox"]:checked ~ .is_unchecked{
            -webkit-transform: translateX(-190%) translateY(-30%) scale(0);
                transform: translateX(-190%) translateY(-30%) scale(0);
            }
            .beauty-select{
                background-color: #fff;
                height:28px;
                width:180px;
                padding:0 10px;
                line-height:28px;
                border: 1px solid #ececec;
                background: url(w.png) no-repeat;
                background-position: 95% 50%;

                -webkit-appearance: none;  /*去掉样式 for chrome*/
                    appearance:none;/*去掉样式*/
                    -moz-appearance:none;/*去掉样式*/
            }
	    `;
        document.head.appendChild(checkBox_css_);

    }

    function set_select_clicked() {
        // document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select").onclick = function () {
        mt_config.dom_obj.beauty_select().onclick = function (e) {
            // console.log(e);

            // var b = document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select").value;
            var selected_value = e.target.value;
            if (window.localStorage.getItem(selected_value)) {
                mt_config.dom_obj.combobox_switch().checked = true;
            } else {
                mt_config.dom_obj.combobox_switch().checked = false;
            }
        }

    }

    function set_select_change_clicked() {
        $('.beauty-select').change(function () {
            var select_value = $('.beauty-select').val();
            // var a = document.getElementsByClassName("switch_1")[0];
            window.localStorage.setItem("last", select_value);
            if (window.localStorage.getItem(select_value)) {
                mt_config.dom_obj.combobox_switch().checked = true;
            } else {
                mt_config.dom_obj.combobox_switch().checked = false;
            }
        });

    }

    function set_checked_clicked() { //设置复选框点击事件特效
        mt_config.dom_obj.combobox_switch().onclick = function () {
            // var a = document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select").value;
            var a = mt_config.dom_obj.beauty_select().value;
            var b = window.localStorage.getItem(a);
            if (b) {
                window.localStorage.removeItem(a);
            } else {
                window.localStorage.setItem(a, "true");
            }
            var c = window.localStorage.getItem(a);
            // var d = document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select").selectedIndex; //当前索引值
            // var e = document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select").options[d].text; //当前索引对应的文本
            var d = mt_config.dom_obj.beauty_select().selectedIndex;
            var e = mt_config.dom_obj.beauty_select().options[d].text;
            if (c) {
                iosOverlay({
                    text: e + "已开启",
                    duration: 2000,
                    icon: "https://www.helloimg.com/images/2022/05/24/ZoDS05.png"
                });
            } else {
                iosOverlay({
                    text: e + "已关闭",
                    duration: 2000,
                    icon: "https://www.helloimg.com/images/2022/05/24/ZoDS05.png"
                });
            }
            setTimeout(function () {
                location.reload()
            }, 2000);

        }

    }


    function set_display_last_click() { //初始化设置上次点击的select内容
        console.log("修改内容");
        // var a = document.querySelector("#comiis_menu_vtr_menu > ul > li:nth-child(6) > select");
        var last_select_value = window.localStorage.last;
        var combobox_switch = mt_config.dom_obj.combobox_switch();
        mt_config.dom_obj.beauty_select().value = last_select_value;
        console.log("上次点击的是:" + mt_config.dom_obj.beauty_select().value)
        if (window.localStorage.getItem(last_select_value)) {
            combobox_switch.checked = true;
        } else {
            combobox_switch.checked = false;
        }
    }

    const blackHome = {
        httpGetSrc: async (url) => {
            return new Promise(res => {
                GM_xmlhttpRequest({
                    url: url,
                    method: "GET",
                    async: false,
                    timeout: 5000,
                    onload: (r) => {
                        res(r.response);
                    },
                    onerror: (r) => {
                        console.log(r);
                        res();
                    }
                })
            })
        },
        loadJS: async (url) => {
            let ret = await blackHome.httpGetSrc(url);
            await eval(ret);
        },
        loadCSS: async (url) => {
            let ret = await blackHome.httpGetSrc(url);
            GM_addStyle(ret);
        },
        showBlackHomeView: async () => { // 显示小黑屋界面
            $.NZ_MsgBox.alert({
                title: "小黑屋名单",
                content: "获取中",
                type: "",
                location: "center",
                buttons: {
                    confirm: {
                        text: "确定"
                    }
                }
            });
            let blacklistret = await blackHome.getBlackList('');
            let blacklist = eval('(' + blacklistret + ')');
            let blackContent = '';

            function sortByProperTyName(data, propertyname) {
                let _list_ = [];
                $.each(data, function (index, value) {
                    _list_ = _list_.concat(value);
                });

                function compareDesc(propertyName) {
                    return function (object1, object2) {
                        var value1 = object1[propertyName];
                        var value2 = object2[propertyName];
                        if (value2 < value1) {
                            return -1;
                        } else if (value2 > value1) {
                            return 1;
                        } else {
                            return 0;
                        }
                    }
                }
                _list_.sort(compareDesc("cid"));
                return _list_;
            }
            let newBlacklist = sortByProperTyName(blacklist["data"], "cid");

            $.each(newBlacklist, function (index, value) {
                let blackreson = (value["reason"] == "") ? "无" : value["reason"];
                blackContent = blackContent + `
                <tbody id="autolist">
                    <tr>
                        <td class="k_misign_lu" style="text-align: center;overflow-wrap: break-word;width: 76px;">
                            <a href="home.php?mod=space&uid=` + value["uid"] + `&do=profile">
                                <img src="https://avatar-bbs.mt2.cn/uc_server/avatar.php?uid=` + value["uid"] + `&amp;size=small">
                            </a>
                            <div class="f_c" style="display: flex;justify-content: center;margin-top: 5px;word-break: break-word;">
                                <h4>
                                    <a href="home.php?mod=space&uid=` + value["uid"] + `&do=profile">` + value["username"] + `</a>
                                </h4>
                            </div>
                        </td>
                        <td class="k_misign_ll" style="width: 10px;">
                            <span></span>
                        </td>
                        <td class="k_misign_lc" style="max-width: 200px;">
                            <div class="f_c" style="display: flex;justify-content: space-between;">
                                <h4>
                                    <div class="y">操作时间: ` + value["dateline"] + `</div>
                                </h4>
                            </div>
                            <div class="f_c" style="display: flex;justify-content: space-between;">
                                <p class="f_0">操作行为: ` + value["action"] + `</p>
                            </div>
                            <div class="f_c" style="display: flex;justify-content: space-between;">
                                <p class="f_0">过期时间: ` + value["groupexpiry"] + `</p>
                            </div>
                            <div class="f_c" style="display: flex;justify-content: space-between;">
                                <p class="f_0" style="color: #fc2a2a !important;">操作人员: ` + value["operator"] + `</p>
                            </div>
                            <div class="f_c" style="display: flex;justify-content: space-between;">操作理由: ` + blackreson + `</div>
                            
                        </td>
                    </tr>
                    <tr style="height:15px;"></tr>
                </tbody>
                `;
                // console.log(value);
            })
            let mainBlackContent = '<table id="misign_list" style="overflow: auto;height: inherit;margin: 15px 0px;">' + blackContent + "</table>";
            $(".msgcon").html(mainBlackContent);
            $(".NZ-MsgBox-alert.NZ-MsgBox--motion").css("top", "100px");
            $(".msgcon").css("height", "350px");

        },
        insertMobileBlackHomeButton: function () { // 插入手机版查看小黑屋的按钮
            if ((window.location.href.match(mt_config.rexp.home_space_url) != null) && (window.localStorage.getItem("v30"))) {
                // @require      https://cdn.bootcdn.net/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shCore.js
                // @require      https://cdn.bootcdn.net/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushJScript.js
                // gitee需要公开仓库,那我只能引用资源站的js和css了
                // this.loadJS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Js/NZ-Plugin/Js/NZ-MsgBox.min.js");
                // this.loadJS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Js/NZ-Plugin/Js/NZ-Drag.min.js");
                blackHome.loadJS("https://www.jq22.com/demo/NZ-Plugin-MsgBox202201130154/Js/NZ-Plugin/Js/NZ-MsgBox.min.js");
                blackHome.loadJS("https://www.jq22.com/demo/NZ-Plugin-MsgBox202201130154/Js/NZ-Plugin/Js/NZ-Drag.min.js");
                // this.loadJS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Js/spin/spin.js");

                // this.loadCSS("https://cdn.bootcdn.net/ajax/libs/SyntaxHighlighter/3.0.83/styles/shCoreRDark.min.css");
                // this.loadCSS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Js/NZ-Plugin/Css/NZ-MsgBox.min.css");
                blackHome.loadCSS("https://www.jq22.com/demo/NZ-Plugin-MsgBox202201130154/Js/NZ-Plugin/Css/NZ-MsgBox.min.css");
                // this.loadCSS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Css/fontawesome-free-5.11.2-web/css/all.min.css");
                // this.loadCSS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Css/animate.min.css");
                // this.loadCSS("https://gitee.com/whitesev/static_resource/raw/master/NZ_MsgBox/Js/spin/spin.css");


                let black_home_ele = document.createElement("a");
                black_home_ele.setAttribute("href", "javascript:;");
                black_home_ele.className = "comiis_flex comiis_styli bg_f b_t cl blacklist";
                black_home_ele.innerHTML = `
                    <div class="styli_tit f_c">
                        <i class="comiis_font" style="color:#FFB300;visibility: hidden;"></i>
                    </div>
                    <div class="flex">小黑屋</div>
                    <div class="styli_ico">
                        <i class="comiis_font f_e"></i>
                    </div>`;
                GM_addStyle(`
                .NZ-MsgBox-alert .msgcontainer .msgtitle {
                    text-align: center !important;
                }
                #autolist .k_misign_lu img {
                    width: 40px;
                    height: 40px;
                    -moz-border-radius: 20px;
                    -webkit-border-radius: 20px;
                    border-radius: 20px;
                }
                .k_misign_lc .f_c{
                    margin: 5px 0px;
                }`)
                black_home_ele.onclick = () => {
                    blackHome.showBlackHomeView();
                }
                let parent_ele = document.querySelectorAll(".comiis_myinfo_list.bg_f.cl");
                parent_ele[parent_ele.length - 1].append(black_home_ele);
            }
        },
        getBlackList: async (cid) => { // 获取黑名单列表
            return new Promise(res => {
                GM_xmlhttpRequest({
                    url: "https://bbs.binmt.cc/forum.php?mod=misc&action=showdarkroom&cid=" + cid + "&t=&ajaxdata=json",
                    timeout: 5000,
                    method: "GET",
                    async: false,
                    headers: {
                        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.53"
                    },
                    onload: (r) => {
                        res(r.responseText);
                    },
                    onerror: (r) => {
                        console.log(r);
                        res({});
                    }
                })
            })
        }
    }

    const quickUBB = {
        code: {
            "rainbow1": {
                "key": "转普通彩虹",
                "value": "",
                "isFunc": true,
                "num": 1
            },
            "rainbow2": {
                "key": "转黑白彩虹",
                "value": "",
                "isFunc": true,
                "num": 2
            },
            "rainbow3": {
                "key": "转黑红彩虹",
                "value": "",
                "isFunc": true,
                "num": 3
            },
            "rainbow4": {
                "key": "转蓝绿彩虹",
                "value": "",
                "isFunc": true,
                "num": 4
            },
            "size": {
                "key": "size",
                "value": "[size=][/size]",
                "tagL": "=",
                "tagR": "]"
            },
            "color": {
                "key": "color",
                "value": "[color=][/color]",
                "tagL": "=",
                "tagR": "]"
            },
            "b": {
                "key": "加粗",
                "value": "[b][/b]",
                "tagL": "]",
                "tagR": "["
            },
            "u": {
                "key": "下划线",
                "value": "[u][/u]",
                "tagL": "]",
                "tagR": "["
            },
            "i": {
                "key": "倾斜",
                "value": "[i][/i]",
                "tagL": "]",
                "tagR": "["
            },
            "s": {
                "key": "中划线",
                "value": "[s][/s]",
                "tagL": "]",
                "tagR": "["
            },
            "lineFeed": {
                "key": "换行",
                "value": "[*]"
            },
            "longHorizontalLine": {
                "key": "长横线",
                "value": "[hr]"
            },
            "link": {
                "key": "链接",
                "value": "[url=][/url]",
                "tagL": "=",
                "tagR": "]"

            },
            "hide": {
                "key": "隐藏",
                "value": "[hide][/hide]",
                "tagL": "]",
                "tagR": "["

            },
            "quote": {
                "key": "引用",
                "value": "[quote][/quote]",
                "tagL": "]",
                "tagR": "["

            }
        },
        insertQuickReplyUBB: () => {
            if (window.localStorage.getItem("v31") && (window.location.href.match(mt_config.rexp.forum_post) != null)) {
                quickUBB.jqueryExtraFunction();
                let message_ele = $("#needmessage");
                let fastpostsubmitline_ele = $("#fastpostsubmitline");
                if (message_ele && fastpostsubmitline_ele) {
                    GM_addStyle(`
                    .quickUBBs{
                        display: flex;
                        flex-wrap: wrap;
                    }
                    .quickUBBs .quickUBB{
                        width: 100px;
                        text-align: center;
                        color: #999999;
                        padding: 15px 0px;
                    }
                    .quickUBBs .quickUBB em{
                        font-size: calc(20px/1.2);
                        font-weight: bold;
                    }`);
                    let ubbs = document.createElement("div");
                    ubbs.className = "quickUBBs";

                    $.each(quickUBB.code, function (index, value) {
                        let ubb_ele = document.createElement("a");
                        ubb_ele.className = "quickUBB";
                        ubb_ele.setAttribute("href", "javascript:;");
                        ubb_ele.setAttribute("data-id", index)
                        ubb_ele.innerHTML = "<em>" + value["key"] + "</em>";
                        ubb_ele.onclick = (e) => {
                            let data_id = e.target.parentElement.getAttribute("data-id");
                            let text = quickUBB.code[data_id]["value"];
                            if (quickUBB.code[data_id]["isFunc"]) {

                                text = quickUBB.set_rainbow(quickUBB.code[data_id]["num"], $("#needmessage").val());
                                $("#needmessage").val(text);
                            } else {
                                $("#needmessage").insertAtCaret(text);
                            }
                            if (quickUBB.code[data_id]["tagL"] != undefined || quickUBB.code[data_id]["tagR"] != undefined) {
                                $("#needmessage").moveCursorInCenterByText(quickUBB.code[data_id]["tagL"], quickUBB.code[data_id]["tagR"]);
                            }
                        };
                        ubbs.appendChild(ubb_ele);

                    })
                    $(".comiis_post_ico.comiis_minipost_icot").after(ubbs);

                } else {
                    console.log("未找到快捷回复框");
                }
            }
        },
        set_rainbow: (num, text) => {
            if (text == "") {
                return '';
            }
            var wr_text = text;
            var wr_code, wr_rgb, r, g, b, i, j, istep
            var wr_rgb1, wr_rgb2, r1, g1, b1, r2, g2, b2

            r1 = g1 = b1 = r2 = g2 = b2 = 0;
            r = 0;
            g = 0;
            b = 0;
            istep = 0;
            wr_code = '';

            if (num == 1) {
                istep = 40;
                r = 255;
                i = 1;
                j = 0;
                do {
                    if (wr_text.charCodeAt(j) != 32) {
                        if (g + istep < 256) {
                            if (i == 1) g += istep;
                        } else if (i == 1) {
                            i = 2;
                            g = 255;
                        }
                        if (r - istep > -1) {
                            if (i == 2) r -= istep;
                        } else if (i == 2) {
                            i = 3;
                            r = 0;
                        }
                        if (b + istep < 256) {
                            if (i == 3) b += istep;
                        } else if (i == 3) {
                            i = 4;
                            b = 255;
                        }
                        if (g - istep > -1) {
                            if (i == 4) g -= istep;
                        } else if (i == 4) {
                            i = 5;
                            g = 0;
                        }
                        if (r + istep < 256) {
                            if (i == 5) r += istep;
                        } else if (i == 5) {
                            i = 6;
                            r = 255;
                        }
                        if (b - istep > -1) {
                            if (i == 6) b -= istep;
                        } else if (i == 6) {
                            i = 1;
                            b = 0;
                        }
                        wr_rgb = '';
                        wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16);
                        wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16);
                        wr_rgb += parseInt(b).toString(16).length == 1 ? 0 + parseInt(b).toString(16) : parseInt(b).toString(16);
                        wr_rgb = wr_rgb.toUpperCase();
                        wr_code += '[color=#' + wr_rgb + ']' + wr_text.charAt(j) + '[/color]';
                    } else {
                        wr_code += wr_text.charAt(j);
                    }
                    j++;
                } while (j < wr_text.length);
            } else if (num == 2) {
                istep = 255 / wr_text.length;
                for (i = 1; i < wr_text.length + 1; i++) {
                    if (wr_text.charCodeAt(i - 1) != 32) {
                        r += istep;
                        g += istep;
                        b += istep;
                        if (r > 255) r = 255;
                        if (g > 255) g = 255;
                        if (b > 255) b = 255;
                        wr_rgb = '';
                        wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16);
                        wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16);
                        wr_rgb += parseInt(b).toString(16).length == 1 ? 0 + parseInt(b).toString(16) : parseInt(b).toString(16);
                        wr_rgb = wr_rgb.toUpperCase();
                        wr_code += '[color=#' + wr_rgb + ']' + wr_text.charAt(i - 1) + '[/color]';
                    } else {
                        wr_code += wr_text.charAt(i - 1);
                    }
                }
            } else if (num == 3) {
                istep = 255 / wr_text.length;
                for (i = 1; i < wr_text.length + 1; i++) {
                    if (wr_text.charCodeAt(i - 1) != 32) {
                        r += istep;
                        g = 29;
                        b = 36;
                        if (r > 255) r = 255;
                        if (g > 255) g = 255;
                        if (b > 255) b = 255;
                        wr_rgb = '';
                        wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16);
                        wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16);
                        wr_rgb += parseInt(b).toString(16).length == 1 ? 0 + parseInt(b).toString(16) : parseInt(b).toString(16);
                        wr_rgb = wr_rgb.toUpperCase();
                        wr_code += '[color=#' + wr_rgb + ']' + wr_text.charAt(i - 1) + '[/color]';
                    } else {
                        wr_code += wr_text.charAt(i - 1);
                    }
                }
            } else if (num == 4) {
                istep = 255 / wr_text.length;
                for (i = 1; i < wr_text.length + 1; i++) {
                    if (wr_text.charCodeAt(i - 1) != 32) {
                        r = 0;
                        g = 174;
                        b += istep;
                        if (r > 255) r = 255;
                        if (g > 255) g = 255;
                        if (b > 255) b = 255;
                        wr_rgb = '';
                        wr_rgb += parseInt(r).toString(16).length == 1 ? 0 + parseInt(r).toString(16) : parseInt(r).toString(16);
                        wr_rgb += parseInt(g).toString(16).length == 1 ? 0 + parseInt(g).toString(16) : parseInt(g).toString(16);
                        wr_rgb += parseInt(255 - b).toString(16).length == 1 ? 0 + parseInt(255 - b).toString(16) : parseInt(255 - b).toString(16);
                        wr_rgb = wr_rgb.toUpperCase();
                        wr_code += '[color=#' + wr_rgb + ']' + wr_text.charAt(i - 1) + '[/color]';
                    } else {
                        wr_code += wr_text.charAt(i - 1);
                    }
                }
            }
            return wr_code;
        },
        jqueryExtraFunction: () => {
            $.fn.extend({
                insertAtCaret: function (myValue) {
                    var $t = $(this)[0];
                    if (document.selection) {
                        this.focus();
                        var sel = document.selection.createRange();
                        sel.text = myValue;
                        this.focus();
                    } else
                    if ($t.selectionStart || $t.selectionStart == '0') {
                        var startPos = $t.selectionStart;
                        var endPos = $t.selectionEnd;
                        var scrollTop = $t.scrollTop;
                        $t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length);
                        this.focus();
                        $t.selectionStart = startPos + myValue.length;
                        $t.selectionEnd = startPos + myValue.length;
                        $t.scrollTop = scrollTop;
                    } else {
                        this.value += myValue;
                        this.focus();
                    }
                },
                selectRange: function (start, end) {
                    if (end === undefined) {
                        end = start;
                    }
                    return this.each(function () {
                        if ('selectionStart' in this) {
                            this.selectionStart = start;
                            this.selectionEnd = end;
                        } else if (this.setSelectionRange) {
                            this.setSelectionRange(start, end);
                        } else if (this.createTextRange) {
                            var range = this.createTextRange();
                            range.collapse(true);
                            range.moveEnd('character', end);
                            range.moveStart('character', start);
                            range.select();
                        }
                    });
                },
                getCursorPosition: function () {
                    var el = $(this)[0];
                    var pos = 0;
                    if ('selectionStart' in el) {
                        pos = el.selectionStart;
                    } else if ('selection' in document) {
                        el.focus();
                        var Sel = document.selection.createRange();
                        var SelLength = document.selection.createRange().text.length;
                        Sel.moveStart('character', -el.value.length);
                        pos = Sel.text.length - SelLength;
                    }
                    return pos;
                },
                moveCursorInCenterByText: function (leftText, rightText) {
                    var el = $(this)[0];
                    var el_text = el.value;
                    for (let i = el.selectionStart - 1; i > 0; i--) {
                        let prevText = el_text[i - 1];
                        let currentText = el_text[i];
                        if (prevText == leftText && currentText == rightText) {
                            this.selectRange(i);
                            break;
                        }
                    }
                }
            });
        }
    }

    function insert_checked_select() {
        if (location.href.match(mt_config.rexp.home_space_url) != null) {
            var setting_content = document.createElement("li");
            // var setting_combobox = document.createElement("li");
            setting_content.className = "f_b";
            setting_content.innerHTML = '<select style="vertical-align:top;border-color:transparent" class="beauty-select">' +
                '<option value="v2">识别链接<\/option>' +
                '<option value="v17">自动签到<\/option>' +
                '<option value="v18">自动展开帖子<\/option>' +
                '<option value="v16">自适应帖子内图片的宽度<\/option>' +
                '<option value="v15">显示用户的UID<\/option>' +
                '<option value="v19">显示搜索历史<\/option>' +
                '<option value="v1">移除帖子字体效果<\/option>' +
                '<option value="v3">移除评论区字体效果<\/option>' +
                '<option value="v6">评论区开启点评<\/option>' +
                '<option value="v32">自动加载上一页评论<\/option>' +
                '<option value="v21">自动加载下一页评论<\/option>' +
                '<option value="v30">小黑屋<\/option>' +
                '<option value="v31">快捷回复UBB代码<\/option>' +
                '<input type="checkbox" class="switch_1" style="float:right;position:relative;margin-top: revert;">' +
                '<\/select>';
            setting_content.style = " top;padding: 8px 0px 8px 8px;margin: 0px 15px;border-top:1px solid #efefef !important;";
            let mt_commis_menu = document.getElementsByClassName("comiis_myinfo_list bg_f cl")[1];
            mt_commis_menu.appendChild(setting_content);
            var setting_selectValue = mt_config.dom_obj.beauty_select().value;
            if (window.localStorage.getItem(setting_selectValue) != null) {
                mt_config.dom_obj.combobox_switch().checked = true;
            } else {
                mt_config.dom_obj.combobox_switch().checked = false;
            }
        }
    }

    function insert_blacklist() {
        if (location.href.match(mt_config.rexp.home_space_url) != null) {
            var white_space_ele = document.createElement("div");
            var black_list_ele = document.createElement("div");
            white_space_ele.className = "styli_h cl";
            black_list_ele.setAttribute("id", "blacklistallmain");
            black_list_ele.className = "comiis_myinfo_list bg_f cl";
            black_list_ele.innerHTML = `<li class="comiis_styli b_b cl">
                                            <textarea name="blacklistuid" id="blacklistuid" placeholder="输入想要屏蔽的用户的uid,多个uid用英文逗号分隔,如1234,5678,9231"></textarea>
                                            <textarea name="blacklistplate" id="blacklistplate" placeholder="输入想要屏蔽的板块,多个板块用顿号分隔,如求助问答、休闲灌水"></textarea>
                                            <a href="javascript:void(0)" id="blacklistsave" class="comiis_flex comiis_styli bg_f b_t cl">
                                                <div class="flex">保存</div>
                                            </a>
                                        </li>`;
            GM_addStyle(`
            #blacklistallmain{
                height: 232px;
            }
            #blacklistallmain li.comiis_styli{
                height: 180px;
            }
            #blacklistallmain #blacklistuid{
                width: 90%; 
                resize: none; 
                opacity: 0.7; 
                height: 70% !important; 
                line-height: inherit;
                -webkit-appearance: none;
                border: none !important;
                font-size: 14px;
                vertical-align: middle;
                background-color: transparent;
                border-bottom: 3px solid #efefef !important;
            }
            #blacklistallmain #blacklistplate{
                width: 90%; 
                resize: none; 
                opacity: 0.7; 
                height: 30% !important;
                line-height: inherit;
                -webkit-appearance: none;
                border: none !important;
                font-size: 14px;
                vertical-align: middle;
                background-color: transparent;
            }
            #blacklistsave{
                text-align: center;
                background: transparent !important;
                border-color: transparent !important;
            }
            `);
            let mt_commis_menu = document.getElementsByClassName("comiis_myinfo cl")[0];
            mt_commis_menu.appendChild(white_space_ele);
            mt_commis_menu.appendChild(black_list_ele);
            mt_commis_menu.appendChild(white_space_ele);
            document.getElementById("blacklistuid").textContent = localStorage.blacklistuid ? localStorage.blacklistuid : "";
            document.getElementById("blacklistplate").textContent = localStorage.blacklistplate ? localStorage.blacklistplate : "";
            document.getElementById("blacklistsave").onclick = () => {
                let blackListUIDValue = document.getElementById("blacklistuid").value;
                let blackListPlateValue = document.getElementById("blacklistplate").value;
                localStorage.setItem("blacklistuid", blackListUIDValue);
                localStorage.setItem("blacklistplate", blackListPlateValue);
                iosOverlay({
                    text: "保存成功",
                    duration: 2000,
                    icon: "https://www.helloimg.com/images/2022/05/24/ZoDS05.png"
                });
            }
        }
    }


    function link() {
        if (window.localStorage.getItem("v2")) {
            /*TEXT link to Clickable Hyperlink From Via*/
            var clearLink, excludedTags, filter, linkMixInit, linkPack, linkify, observePage, observer, setLink, url_regexp, xpath;
            url_regexp = /((https?:\/\/|www\.)[\x21-\x7e]+[\w\/]|(\w[\w._-]+\.(com|cn|org|net|info|tv|cc))(\/[\x21-\x7e]*[\w\/])?|ed2k:\/\/[\x21-\x7e]+\|\/|thunder:\/\/[\x21-\x7e]+=)/gi;
            clearLink = function (a) {
                var b;
                a = null != (b = a.originalTarget) ? b : a.target;
                if (null != a && "a" === a.localName && -1 !== a.className.indexOf("texttolink") && (b = a.getAttribute("href"), 0 !== b.indexOf("http") && 0 !== b.indexOf("ed2k://") && 0 !== b.indexOf("thunder://"))) return a.setAttribute("href", "http://" + b)
            };
            document.addEventListener("mouseover", clearLink);
            setLink = function (a) {
                if (null != a && typeof (a.parentNode.className) === "string" && -1 === a.parentNode.className.indexOf("texttolink") && "#cdata-section" !== a.nodeName) {
                    var b = a.textContent.replace(url_regexp, '<a href="$1" target="_blank" class="texttolink" style="border: 1px solid #f00;">$1</a>');
                    if (a.textContent.length !== b.length) {
                        var c = document.createElement("span");
                        c.innerHTML = b;
                        return a.parentNode.replaceChild(c, a)
                    }
                }
            };
            excludedTags = "a svg canvas applet input button area pre embed frame frameset head iframe img option map meta noscript object script style textarea code".split(" ");
            xpath = "//text()[not(ancestor::" + excludedTags.join(") and not(ancestor::") + ")]";
            filter = new RegExp("^(" + excludedTags.join("|") + ")$", "i");
            linkPack = function (a, b) {
                var c, d;
                if (b + 1E4 < a.snapshotLength) {
                    var e = c = b;
                    for (d = b + 1E4; b <= d ? c <= d : c >= d; e = b <= d ? ++c : --c) setLink(a.snapshotItem(e));
                    setTimeout(function () {
                        return linkPack(a, b + 1E4)
                    }, 15)
                } else
                    for (e = c = b, d = a.snapshotLength; b <= d ? c <= d : c >= d; e = b <= d ? ++c : --c) setLink(a.snapshotItem(e))
            };
            linkify = function (a) {
                a = document.evaluate(xpath, a, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
                return linkPack(a, 0)
            };
            observePage = function (a) {
                for (a = document.createTreeWalker(a, NodeFilter.SHOW_TEXT, {
                        acceptNode: function (a) {
                            if (!filter.test(a.parentNode.localName)) return NodeFilter.FILTER_ACCEPT
                        }
                    }, !1); a.nextNode();) setLink(a.currentNode)
            };
            observer = new window.MutationObserver(function (a) {
                var b, c;
                var d = 0;
                for (b = a.length; d < b; d++) {
                    var e = a[d];
                    if ("childList" === e.type) {
                        var g = e.addedNodes;
                        var f = 0;
                        for (c = g.length; f < c; f++) e = g[f], observePage(e)
                    }
                }
            });
            linkMixInit = function () {
                if (window === window.top && "" !== window.document.title) return linkify(document.body), observer.observe(document.body, {
                    childList: !0,
                    subtree: !0
                })
            };
            var clearlinkF = function (a) {
                    var url = a.getAttribute("href");
                    if (0 !== url.indexOf("http") && 0 !== url.indexOf("ed2k://") && 0 !== url.indexOf("thunder://")) return a.setAttribute("href", "http://" + url)
                },
                clearlinkE = function () {
                    for (var a = document.getElementsByClassName("texttolink"), b = 0; b < a.length; b++) clearlinkF(a[b])
                };
            setTimeout(clearlinkE, 2500);
            setTimeout(linkMixInit, 1100);
        }
    }

    function online_status() {
        if (window.location.href.match(mt_config.rexp.forum_post_pc)) {
            var quanju = [];
            var cishu = 0;
            for (var sss = document.getElementsByClassName("pls favatar"), ll = 0; ll < sss.length; ll++) {
                var sendmessage = sss[ll].getElementsByClassName("comiis_o cl")
                if (sendmessage.length == 0) {} else {
                    var sendmessageurl = sendmessage[0].getElementsByTagName('a')[1].href;

                    let xhr = new XMLHttpRequest();
                    xhr.open("GET", sendmessageurl, false);
                    xhr.onreadystatechange = function () {
                        if (xhr.readyState == 4) {
                            let pattern = /正在.*]/g;
                            let str = xhr.responseText;
                            let newstr = str.match(pattern)[0];
                            quanju.push(newstr);
                        }
                    }
                    xhr.send();
                    if (quanju[cishu].match('离线')) {
                        cishu = cishu + 1;
                        var imi2 = document.createElement('img');
                        imi2.src = 'https:\/\/cdn2.bbs.binmt.cc\/static\/image\/smiley\/doge\/54.png';
                        imi2.smilied = '1353';
                        imi2.border = "0";
                        imi2.style = 'float:right';
                        sss[ll].insertAdjacentElement('afterbegin', imi2);
                    } else {
                        cishu = cishu + 1;
                        var imi = document.createElement('img');
                        imi.src = 'https:\/\/cdn2.bbs.binmt.cc\/static\/image/smiley\/doge\/35.png';
                        imi.smilied = '1384';
                        imi.border = "0";
                        imi.style = 'float:right';
                        sss[ll].insertAdjacentElement('afterbegin', imi);
                    }
                }
            }
        }
    }

    function reviews() {
        if (window.localStorage.getItem("v6") && location.href.match(mt_config.rexp.forum_post)) {
            var hongbao = document.getElementsByClassName("bottom_zhan y");
            if (hongbao.length == 0) {} else {
                var cishu2 = 0;
                var replyhref = hongbao[cishu2].getElementsByTagName('a')[0].href;
                var page = replyhref.match(mt_config.rexp.forum_post_page)[1];
                //console.log(page);
                for (cishu2 = 0; cishu2 < hongbao.length; cishu2++) {
                    if (hongbao[cishu2].children.length == 1) {
                        var rewardhref = hongbao[cishu2].getElementsByTagName('a')[0].href.replace('mod=post&', 'mod=misc&');
                        rewardhref = rewardhref.replace("action=reply&", "action=comment&");
                        var reviews_href = rewardhref + '&extra=page%3D1&page=' + page;
                        let reviews_pid = hongbao[cishu2].parentElement.parentElement.id.replace("pid", "&pid=");
                        reviews_href = reviews_href + reviews_pid;
                        //console.log(rewardhref)
                        var oa = document.createElement('a');
                        var ob = document.createElement('i');
                        var lm = document.getElementsByClassName("bottom_zhan y")[cishu2];
                        oa.href = reviews_href;
                        oa.className = "f_c dialog";
                        ob.style = "content: url(https://s1.ax1x.com/2020/04/26/Jcq8VU.png);height: 15px;";
                        ob.className = "comiis_font mt_review";
                        ob.innerHTML = "";
                        oa.appendChild(ob);
                        let review_username = hongbao[cishu2].parentElement.parentElement.getElementsByClassName("top_user f_b")[0].text;
                        oa.onclick = function () {
                            let click_time = Date.now();
                            var mt_interval = setInterval(function () {
                                let run_time = parseInt((Date.now() - click_time) / 1000);
                                if (run_time >= 5) {
                                    console.log("超时");
                                    clearInterval(mt_interval);
                                } else if (document.querySelector("div[id=ntcmsg_popmenu]>div>span.f_c") != null) {
                                    console.log("存在,清理定时器");
                                    console.log("点评用户:", review_username);
                                    console.log("该对象出现用时:", run_time);
                                    try {
                                        document.querySelector("div[id=ntcmsg_popmenu]>div>span.f_c").innerText = "点评 " + review_username;
                                    } catch (err) {
                                        console.log("修改点评失败", err);
                                    }
                                    clearInterval(mt_interval);
                                }
                            }, 100)
                        }
                        lm.insertAdjacentElement('afterBegin', oa);
                    } else {
                        console.log("已有点评按钮,无需再次添加");
                    }
                }
            }
        }
    }

    function changeFontColorToBlack() {
        if (window.localStorage.getItem("v3") && location.href.match(mt_config.rexp.forum_post)) {
            var hide = document.getElementsByTagName('font');
            var i = 0;
            for (i = 0; i < hide.length; i++) {
                hide[i].removeAttribute('color');
                hide[i].removeAttribute('style');
                hide[i].removeAttribute('size');
            }
            var content = document.getElementsByClassName("comiis_message bg_f view_all cl message");
            var rule = /<br>|&nbsp;|<font.*?>|<\/font>|<strike>|<strong>|<i>|<u>|align=".*?"/g;
            var j = 0,
                k = 1;
            for (j = 0; j < content.length; j++ & k++) {
                content[j].innerHTML = content[j].innerHTML.replace(rule, '');
            }
        }

    }

    function collect() {
        var own_formhash = document.querySelector("#scform > input[type=hidden]:nth-child(1)").value;
        var collect_href_id = window.location.href.match(mt_config.rexp.forum_post_pc_page)[1];
        var collect_href = 'https:\/\/bbs.binmt.cc\/home.php?mod=spacecp&ac=favorite&type=thread&id=' + collect_href_id + '&formhash=' + own_formhash;
        var new_collect = document.createElement('span');
        var old_Suspended = document.getElementById("scrolltop");
        new_collect.innerHTML = '<a href="' + collect_href + '" id="k_favorite" onclick="showWindow(this.id, this.href, \'get\', 0);" onmouseover="this.title = $(\'favoritenumber\').innerHTML + \' 人收藏\'" ><img src="https:\/\/s1.ax1x.com\/2020\/04\/29\/JTk3lD.gif" height="26" width="26" style="position:absolute;top:10px;left:11px"><\/a>';
        old_Suspended.insertAdjacentElement('afterBegin', new_collect);
    }

    function quick_reply() {  //快捷回复
        document.querySelector("#scrolltop > span:nth-child(2) > a").onclick = function () {
            showWindow('reply', this.href);
            var a = document.querySelector("#postsubmit");
            setTimeout(
                'document.querySelector("#moreconf").innerHTML=document.querySelector("#moreconf").innerHTML+\'<button type="button" id = "insertspace2" style="float: left;">一键空格<\/button>\';document.querySelector("#insertspace2").onclick=function(){document.querySelector("#postmessage").value=document.querySelector("#postmessage").value+"           ";}', 200)
        }


    }

    function user_level() {
        var a = document.getElementsByClassName("pls favatar");
        var i = 0;
        var e = "0级";
        for (i = 0; i < a.length; i++) {
            var b = a[i].getElementsByTagName("em")[1].outerText;
            var c = a[i].getElementsByTagName("tr")[0];
            var d = document.createElement("td");
            switch (b) {
                case "幼儿园":
                    e = "1级";
                    break;
                case "小学生":
                    e = "2级";
                    break;
                case "初中生":
                    e = "3级";
                    break;
                case "高中生":
                    e = "4级";
                    break;
                case "大学生":
                    e = "5级";
                    break;
                case "硕士生":
                    e = "6级";
                    break;
                case "博士生":
                case "实习版主":
                case "版主":
                case "审核员":
                    e = "7级";
                    break;
                case "博士后":
                case "超级版主":
                case "网站编辑":
                    e = "8级";
                    break;
                case "管理员":
                case "信息监察员":
                    e = "9级";
                    break;


            }
            d.innerHTML = '<p><a class="dj">' + e + '<\/a><\/p>Lv';
            c.appendChild(d);
        }

    }

    function showUserUID() { //显示用户的uid
        if (window.localStorage.getItem("v15") && ((window.location.href.match(mt_config.rexp.forum_post_guide_url) || (window.location.href.match(mt_config.rexp.forum_post)) || (window.location.href.match(mt_config.rexp.plate_url))))) {
            window.findUserFormList = false;
            window.findUserFormListNums = 0;
            let findSetInval = setInterval(function () {
                let formList = mt_config.dom_obj.comiis_formlist() ? mt_config.dom_obj.comiis_formlist() : [];
                formList = formList.length == 0 ? mt_config.dom_obj.comiis_postli() : formList;
                window.findUserFormList = formList.length ? true : false;
                if (findUserFormListNums >= 10) {
                    console.log("清理定时器");
                    clearInterval(findSetInval);
                }
                if (window.findUserFormList) {
                    GM_addStyle(`
                    .comiis_postli_top.bg_f.b_t h2{
                        height: auto;
                    }`);

                    function matchUIDByArray(data) {
                        for (let i = 0; i < data.length; i++) {
                            let url = data[i].href;
                            let uid = url.match(mt_config.rexp.mt_uid);
                            if (uid) {
                                return uid[1];
                            }
                        }
                        return null
                    }
                    $.each(formList, (index, value) => {
                        let mtUIDOM = value.getElementsByClassName("mt_uid_set");
                        if (!mtUIDOM.length) {
                            let childrenByATagetElement = value.getElementsByTagName("a");
                            let mt_uid = null;
                            mt_uid = matchUIDByArray(childrenByATagetElement);
                            if (mt_uid != null) {
                                let uid_control = document.createElement("a");
                                uid_control.className = "mt_uid_set";
                                let uid_control_margin_top = "1px;";
                                uid_control.style = `
                                    font: 13px 隶书;
                                    background: rgb(255, 118, 0);
                                    margin-left: 4px;
                                    padding: 0px 3px;
                                    color: white;
                                    float: left;
                                    margin-top: ${uid_control_margin_top}
                                    height: 14px;
                                    line-height: 15px;
                                    border-radius: 1.5px;`;
                                uid_control.innerHTML = "UID:" + mt_uid;
                                uid_control.onclick = function () {
                                    try {
                                        GM_setClipboard(mt_uid);
                                        iosOverlay({
                                            text: mt_uid + "已复制",
                                            duration: 2000,
                                            icon: "https://www.helloimg.com/images/2022/05/24/ZoDS05.png"
                                        });
                                        console.log("复制:", mt_uid)
                                    } catch (err) {
                                        iosOverlay({
                                            text: mt_uid + "复制失败",
                                            duration: 2000,
                                            icon: "https://whitesev.gitee.io/static_resource/ios_loading/img/cross.png"
                                        });
                                    }
                                }
                                let mtUidDomInsertElement = value.getElementsByClassName("top_lev")[0];
                                mtUidDomInsertElement.parentElement.append(uid_control);
                            }
                        }
                    })
                    console.log("出现,清理定时器");
                    clearInterval(findSetInval);
                } else {
                    findUserFormListNums += 1;
                }

            }, 800)

        }
    }

    function shield_user() { // 屏蔽用户
        if (window.location.href.match(mt_config.rexp.forum_guide_url) || window.location.href.match(mt_config.rexp.plate_url)) {
            console.log("屏蔽YH——1");
            let infos = document.querySelectorAll(".comiis_forumlist .forumlist_li");
            let black_list = window.localStorage.getItem("blacklistuid") ? window.localStorage.getItem("blacklistuid") : "";
            let black_list_array = black_list.split(",");
            Array.from(infos).forEach((info) => {
                let usr = info.getElementsByClassName("wblist_tximg")[0].href;
                let usr_uid = usr.match(mt_config.rexp.mt_uid)[1];
                if (black_list_array.indexOf(usr_uid) != -1) {
                    console.log("屏蔽用户:" + usr_uid);
                    info.setAttribute("style", "display:none !important;");
                }
            })
        }
        if (window.location.href.match(mt_config.rexp.forum_post)) {
            console.log("屏蔽YH——2");
            let comments = document.querySelectorAll(".comiis_postlist .comiis_postli");
            let black_list = window.localStorage.getItem("blacklistuid") ? window.localStorage.getItem("blacklistuid") : "";
            let black_list_array = black_list.split(",");
            Array.from(comments).forEach((comment) => {
                let usr = comment.getElementsByClassName("postli_top_tximg")[0].href;
                let usr_uid = usr.match(mt_config.rexp.mt_uid)[1];
                if (black_list_array.indexOf(usr_uid) != -1) {
                    console.log("屏蔽用户:" + usr_uid);
                    comment.setAttribute("style", "display:none !important;");
                }
            })
        }

    }

    function shield_plate() { // 屏蔽板块
        if (window.location.href.match(mt_config.rexp.forum_guide_url)) {
            console.log("屏蔽BK");
            let infos = document.querySelectorAll(".comiis_forumlist .forumlist_li");
            let black_list = window.localStorage.getItem("blacklistplate") ? window.localStorage.getItem("blacklistplate") : "";
            let black_list_array = black_list.split("、");
            Array.from(infos).forEach((info) => {
                let from_plate = info.querySelector(".forumlist_li_time a.f_d").text;
                from_plate = from_plate.replace(/\s*/g, "");
                from_plate = from_plate.replace("来自", "");
                if (black_list_array.indexOf(from_plate) != -1) {
                    console.log("屏蔽板块:" + from_plate);
                    info.setAttribute("style", "display:none !important;");
                }
            })
        }
    }

    function autoExpendFullText() { //自动展开
        if (window.localStorage.getItem("v18") && location.href.match(mt_config.rexp.forum_post)) {
            GM_addStyle(`
            div.comiis_message.bg_f.view_one.b_b.cl.message > div.comiis_messages.comiis_aimg_show.cl{
                max-height: inherit !important;
                overflow-y: inherit !important;
                position: inherit !important;
            }
            .comiis_lookfulltext_key,
            .comiis_lookfulltext_bg{
                display: none !important;
            }`)
        }

    }

    function recoveryIMGWidth() { // 图片宽度
        if (window.localStorage.getItem("v16") && location.href.match(mt_config.rexp.forum_post)) {
            GM_addStyle(`
            .comiis_messages img{
                max-width: 100% !important;
            }
            `)
        }
    }

    function post_setting_js() { //帖子内需要重复加载的脚本

        tryCatch(shield_user);
        tryCatch(reviews);
        tryCatch(link);
        tryCatch(showUserUID);
        tryCatch(changeFontColorToBlack);
        popup.init()
    }

    function auto_load_next_comments(post_comments_list) { //自动加载下一页的评论
        $("#loading-comment-tip")[0].parentElement.style.display = "";
        let next_page_url = post_comments_list.children[2].href
        let isloding_flag = false;
        console.log("获取下一页:", next_page_url);
        if (next_page_url.indexOf("javascript:;") != -1) {
            console.log(post_comments_list);
            console.log("无多页评论");
            $("#loading-comment-tip")[0].parentElement.style.display = "none";
            return;
        }
        $(window).bind("scroll", function () {
            // scroll at bottom
            if (Math.ceil($(window).scrollTop() + $(window).height() + 150) >= $(document).height()) {
                // load data
                if (isloding_flag == false) {
                    isloding_flag = true;
                    $("#loading-comment-tip").text("正在加载评论中...");
                    $("#loading-comment-tip")[0].parentElement.style.display = "";
                    $.get(next_page_url, function (data, status, xhr) {
                        console.log("正在请求的下一页url", next_page_url);
                        let postlist = $(data);
                        let kqideSourceNode = $(".comiis_postlist.kqide");
                        let postDOM = postlist.find(".comiis_postlist.kqide").html();
                        let get_next_page_url = postlist.find(".nxt");
                        if (get_next_page_url.length != 0) {
                            console.log("成功获取到下一页-评论");
                            next_page_url = get_next_page_url.attr("href");
                            $("#loading-comment-tip")[0].parentElement.style.display = "none";
                        } else {
                            console.log("评论全部加载完毕,关闭监听事件");
                            $(".comiis_page.bg_f").remove();
                            $("#loading-comment-tip").text("已加载完所有评论")
                            $("#loading-comment-tip")[0].parentElement.style.display = "";
                            $(window).unbind();
                        }
                        isloding_flag = false;
                        kqideSourceNode.append(postDOM);
                        post_setting_js();
                    })

                } else {
                    console.log("正在加载中请稍后");
                }


            }
        })
        $("#loading-comment-tip").text("请上下滑动一下");
    }

    function auto_load_prev_comments() { //自动加载上一页的评论
        let post_comments_list = document.querySelector(".comiis_page.bg_f");
        let prev_page_url = post_comments_list.children[0].href
        let isloding_flag = false;
        console.log("获取上一页:", prev_page_url);
        $("#loading-comment-tip-prev").text("请上下滑动一下");

        function loadPrevComments() {
            if ($(window).scrollTop() <= 50) {
                if (isloding_flag) {
                    console.log("正在加载上一页中请稍后");
                } else {
                    isloding_flag = true;
                    $("#loading-comment-tip-prev").text("正在加载评论中...");
                    $("#loading-comment-tip-prev")[0].parentElement.style.display = "";
                    $.get(prev_page_url, function (data, status, xhr) {
                        console.log("正在请求的上一页评论:", prev_page_url);
                        let postlist = $(data);
                        let kqideSourceNode = $(".comiis_postlist.kqide");
                        let postDOM = postlist.find(".comiis_postlist.kqide").html();
                        let get_pregv_page_url = postlist.find(".prev");
                        if (get_pregv_page_url.length != 0) {
                            console.log("成功获取到上一页-评论");
                            prev_page_url = get_pregv_page_url.attr("href");
                            $("#loading-comment-tip-prev")[0].parentElement.style.display = "none";
                            isloding_flag = false;
                            kqideSourceNode.prepend(postDOM);
                            post_setting_js();
                        } else {
                            isloding_flag = false;
                            kqideSourceNode.prepend(postDOM);

                            console.log("上一页评论全部加载完毕,关闭监听事件");
                            let page_title = postlist.find(".comiis_viewtit")[0].outerHTML;
                            console.log($(page_title));
                            kqideSourceNode.prepend($(page_title)[0]);
                            post_setting_js();
                            // $(".comiis_page.bg_f").remove();
                            $("#loading-comment-tip-prev").remove();
                            $(window).unbind("scroll", loadPrevComments);

                        }

                    })
                }
                // $(window).unbind("scroll",loadPrevComments);
            }
        }
        $(window).bind("scroll", loadPrevComments);
    }

    function loadNextComments() {
        if (window.localStorage.getItem("v21") && window.location.href.match(mt_config.rexp.forum_post)) {
            let tip_html = `
            <div class="comiis_multi_box bg_f b_t">
                <label class="comiis_loadbtn bg_e f_d" id="loading-comment-tip">
                正在等待页面加载完毕
                </label>
            </div>`;
            $(".comiis_bodybox").append($(tip_html));
            let commentsEle = document.querySelector(".comiis_pltit span.f_d") || document.querySelector("#comiis_foot_memu .comiis_kmvnum");
            if (document.querySelector(".comiis_pltit h2") && document.querySelector(".comiis_pltit h2").textContent.indexOf("暂无评论") != -1) {
                console.log("暂无评论");
                $("#loading-comment-tip")[0].parentElement.style.display = "none";
                return;
            }
            let commentsNum = parseInt(commentsEle.textContent);
            if (commentsNum >= 10) {
                let setAutoLoadInterval = setInterval(function () {
                    let post_comments_list = document.querySelector(".comiis_page.bg_f"); //评论列表
                    if (post_comments_list) {
                        auto_load_next_comments(post_comments_list);
                        clearInterval(setAutoLoadInterval);
                    } else {
                        console.log("正在等待下一页列表元素出现");
                    }
                }, 500)
            } else {
                console.log("无多页评论");
                $("#loading-comment-tip")[0].parentElement.style.display = "none";
            }
        }
    }

    function loadPrevComments() {
        if (window.localStorage.getItem("v32") && window.location.href.match(mt_config.rexp.forum_post)) {
            if (!document.querySelector(".comiis_pltit span.f_d")) {
                console.log("当前不在第一页,加载上一页评论");
                let tip_html = `
                <div class="comiis_multi_box bg_f b_t">
                    <label class="comiis_loadbtn bg_e f_d" id="loading-comment-tip-prev">
                    正在等待页面加载完毕
                    </label>
                </div>`;
                $(".comiis_bodybox script")[0].after($(tip_html)[0]);
                auto_load_prev_comments();
            }
        }
    }

    function Hooks() {
        return {
            initEnv: function () {
                Function.prototype.hook = function (realFunc, hookFunc, context) {
                    var _context = null; //函数上下文
                    var _funcName = null; //函数名

                    _context = context || window;
                    _funcName = getFuncName(this);
                    _context['realFunc_' + _funcName] = this;

                    console.log(window);

                    if (_context[_funcName].prototype && _context[_funcName].prototype.isHooked) {
                        console.log("Already has been hooked,unhook first");
                        return false;
                    }

                    function getFuncName(fn) {
                        // 获取函数名
                        var strFunc = fn.toString();
                        var _regex = /function\s+(\w+)\s*\(/;
                        var patten = strFunc.match(_regex);
                        if (patten) {
                            return patten[1];
                        };
                        return '';
                    }
                    try {
                        eval('_context[_funcName] = function ' + _funcName + '(){\n' +
                            'var args = Array.prototype.slice.call(arguments,0);\n' +
                            'var obj = this;\n' +
                            'hookFunc.apply(obj,args);\n' +
                            "return _context['realFunc_" + _funcName + "'].apply(obj,args);\n" +
                            '};');
                        _context[_funcName].prototype.isHooked = true;
                        return true;
                    } catch (e) {
                        console.log("Hook failed,check the params.");
                        return false;
                    }
                }
                Function.prototype.unhook = function (realFunc, funcName, context) {
                    var _context = null;
                    var _funcName = null;
                    _context = context || window;
                    _funcName = funcName;
                    if (!_context[_funcName].prototype.isHooked) {
                        console.log("No function is hooked on");
                        return false;
                    }
                    _context[_funcName] = _context['realFunc' + _funcName];
                    delete _context['realFunc_' + _funcName];
                    return true;
                }
            },
            cleanEnv: function () {
                if (Function.prototype.hasOwnProperty("hook")) {
                    delete Function.prototype.hook;
                }
                if (Function.prototype.hasOwnProperty("unhook")) {
                    delete Function.prototype.unhook;
                }
                return true;
            }
        };
    }

    function pageAfterDOMChangeRunFunction() { // 当页面内容元素添加时需要执行的函数
        if (window.location.href.match(/bbs.binmt.cc\/forum/)) {
            document.body.addEventListener("DOMNodeInserted", (event) => {
                let ele = event.target;
                if (ele.className != null && ele.className.indexOf("comiis_forumlist") != -1) {
                    beforeHookRun();
                }
            })

            function beforeHookRun() {
                tryCatch(showUserUID);
                tryCatch(shield_user);
                tryCatch(shield_plate);
            }


        }
    }

    function mobile_all_setting() {
        tryCatch(reviews);
        tryCatch(recoveryIMGWidth);
        tryCatch(link);
        tryCatch(showUserUID);
        tryCatch(removeFontStyle);
        tryCatch(changeFontColorToBlack);
        tryCatch(autoSignIn);
        tryCatch(autoExpendFullText);
        tryCatch(pageAfterDOMChangeRunFunction);
        tryCatch(searchHistory);
        tryCatch(loadNextComments, '', '$("#loading-comment-tip").text("加载评论失败")');
        tryCatch(loadPrevComments, '', '$("#loading-comment-tip-prev").text("加载评论失败")');
    }


    function tryCatch(func, params, errorFunc) { // 捕获错误
        try {
            func(params);
        } catch (error) {
            console.log("%c" + (func.name + "出现错误"), "color: #f20000");
            console.log("%c" + ("错误原因:" + error), "color: #f20000");
            eval(errorFunc);
        }
    }

    function ios_js_css() {
        var ios_js = document.createElement("script");
        var ios_css = document.createElement("link");
        ios_js.src = "https://whitesev.gitee.io/static_resource/ios_loading/js/iosOverlay.js";
        ios_js.type = "text/javascript";
        ios_css.rel = "stylesheet";
        ios_css.type = "text/css";
        ios_css.href = "https://whitesev.gitee.io/static_resource/ios_loading/css/iosOverlay.css";

        document.head.appendChild(ios_js);
        document.head.appendChild(ios_css);
    }

    function set_PC_js() {
        var a = document.createElement("script");
        var b = document.createElement("script");
        a.src = "https://cdn2.bbs.binmt.cc/static/js/smilies.js?x6L";
        b.src = "https://cdn2.bbs.binmt.cc/static/js/common.js?x6L";
        a.type = "text/javascript";
        b.type = "text/javascript";
        document.head.appendChild(a);
        document.head.appendChild(b);
    }

    function np() { //这是入口
        var usa = navigator.userAgent.match(mt_config.rexp.pc_useragent);
        if (usa != null) {
            tryCatch(set_PC_js);
            $(document).ready(function () {
                tryCatch(Latest_publication);
                // tryCatch(online_status);
                tryCatch(link);
                tryCatch(collect);
                tryCatch(quick_reply);
                tryCatch(user_level);
                tryCatch(autoSignIn);

            });
        } else {
            $(document).ready(function () {
                mobile_all_setting()
                tryCatch(shield_user);
                tryCatch(shield_plate);
                try {
                    insert_checked_select();
                    set_display_last_click();
                    set_select_clicked();
                    set_checked_clicked();
                    set_select_change_clicked();
                    setCheckBoxCSS();
                } catch (err) {}
                tryCatch(blackHome.insertMobileBlackHomeButton);
                tryCatch(quickUBB.insertQuickReplyUBB);
                tryCatch(insert_blacklist);
                tryCatch(show_latest_sign);
                tryCatch(ios_js_css);
            })

        }
    } //function np()的结束处
    $(document).ready(function () {
        np()
    });

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址