fw

对蜂网路由器后台进行优化,1.首页显示温度模块,2.内网主机显示搜索框,3.不会自动退出登录(不可用),4.点击logo会复制地址和cookie并打开新窗口跳转到新系统,不会替换当前页面

当前为 2024-03-20 提交的版本,查看 最新版本

// ==UserScript==
// @name         fw
// @namespace    http://tampermonkey.net/
// @version      0.2.1
// @description  对蜂网路由器后台进行优化,1.首页显示温度模块,2.内网主机显示搜索框,3.不会自动退出登录(不可用),4.点击logo会复制地址和cookie并打开新窗口跳转到新系统,不会替换当前页面
// @author       005
// @match        *://*/*?PAGE=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';


    const time = 1500;//跳转时间(单位:毫秒)
    const isDev = 0;







    {

        //防止自动退出登录(不可用)
        setInterval(() => {
            i = 1
        }, 600000)
        sessionStorage.setItem('login', '1')



        // 首页
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        let IndexTime = null
        if (location.search.indexOf("?PAGE=index") !== -1) {
            IndexTime = null
            $.get('/action/env_check.htm', {}, function (msg) {
                // console.log(msg);
                let html = ''
                if (msg.cpu_term < 10 || msg.cpu_term > 85) {
                    html += '<span>CPU温度:&nbsp;&nbsp;&nbsp;&nbsp;[&nbsp;<font style="color:#ff0000;">' + msg.cpu_term + ' ℃</font>&nbsp;]<img src="images/warning.png"  title="温度异常,请及时清理设备,检查设备散热问题。" style="margin-left: 5px;width:14px; height:14px;"></span>';

                    $(".box-B10 p:nth(5)").after(`
    <div class="H10"></div>
    <p class="blk_tit"><span class="info_tit">CPU温度</span><span class="blk_txt" id="cpu_term"><font style="color:#ff0000;">${msg.cpu_term} ℃</font><img src="images/warning.png"  title="温度异常,请及时清理设备,检查设备散热问题。" style="margin-left: 5px;width:14px; height:14px;">
    </span></p>
                                  `)
                } else {
                    html += '<span>CPU温度:&nbsp;&nbsp;&nbsp;&nbsp;[&nbsp;<font style="color:#59CBA0">' + msg.cpu_term + ' ℃</font>&nbsp;]</span>';
                    $(".box-B10 p:nth(5)").after(`
    <div class="H10"></div>
    <p class="blk_tit"><span class="info_tit">CPU温度</span><span class="blk_txt" id="cpu_term">${msg.cpu_term} ℃
    </span></p>
                                  `)
                }

                $(".box-B10 p:last-of-type").css("display", "none")

            }, "JSON")
            IndexTime = setInterval(() => {
                $.get('/action/env_check.htm', {}, function (msg) {
                    //console.log(msg)
                    if (msg.cpu_term < 10 || msg.cpu_term > 85) {
                        $("#cpu_term").html(`<font style="color:#ff0000;">${msg.cpu_term} ℃</font><img src="images/warning.png"  title="温度异常,请及时清理设备,检查设备散热问题。" style="margin-left: 5px;width:14px; height:14px;">
                    `)
                    } else {
                        $("#cpu_term").html(msg.cpu_term + " ℃")
                    }
                }, "JSON")
            }, 4000)

            //关闭跳转事件
            $(".col-xs-7").off("click");

        }

        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------







        //内网主机
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        if (location.search.indexOf("?PAGE=hosts_info") !== -1) {
            $(".seitchH-ul>.PPPOE_div>.H20>p").html('')

            {
                $(".PPPOE_div>.div-tab").prepend(`
        <input type="text" id="ipInp"
          style="
        background-color: #ffffff;
        color: #666666;
        font-size: 14px;
        height: 28px;
        line-height: 28px;
        text-indent: 10px;
        width: 198px;
        border: 1px solid #dbdfe6;
        padding: 0;
        border-radius: 4px;"
        />
 
        <div id="searchBtn"  style="
        margin-right:24x;
        display:inline-block;
        cursor:pointer;
        margin-left:10px;
        padding:5px 20px;
        background-color:#26A3E9;
        border-radius:4px;
        color:#fff;
        font-size:12px;
         -webkit-user-select: none;
         -moz-user-select: none;
         -ms-user-select: none;
         user-select: none";  >搜索</div>
 
        <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;</span>
        `)


            }

            //IP正则
            let ipaddress = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])/;


            //搜索按钮点击事件
            $(document).on("click", "#searchBtn", function () {
                let ip = $(this).parent().children()[0].value;

                //判断输入IP是否正确
                if (ipaddress.test(ip)) {
                    let data = JSON.stringify({ ip, wan: "all" })
                    //请求数据
                    $.get('/action/show_connect_exe.htm', { data }, function (msg) {
                        //console.log(msg);
                        if (msg.length > 0) {
                            $(".connect_table tbody").empty();
                            let html = ''
                            for (let i = 0; i < msg.length; i++) {
                                html += '<tr>';
                                html += '<td>' + msg[i].appstat + '</td>';
                                html += '<td>' + convert_pri(msg[i].pri) + '</td>';
                                html += '<td>' + convert_speed(msg[i].up) + '</td>';
                                html += '<td>' + convert_speed(msg[i].down) + '</td>';
                                html += '<td>' + msg[i].proto + '</td>';
                                html += '<td>' + msg[i].sport + '</td>';
                                html += '<td>' + msg[i].dport + '</td>';
                                html += '<td>' + msg[i].daddr + '</td>';
                                html += '<td>' + msg[i].wan + '</td>';
                                let status = "";
                                if (msg[i].status == "1")
                                    status = "未响应";
                                else
                                    status = "稳定";
                                html += '<td>' + status + '</td>';
                                //html += '<td>'+msg[i].exe+'</td>';
                                html += '</tr>';
                            }
                            $(".connect_table tbody").html(html);
                            modalShow("listModal");
                        } else {
                            //没有查到数据
                            alert("该IP无数据!")
                        }
                    }, "JSON")
                } else {
                    alert("IP有误!")
                    $(this).parent().children()[0].value = ''
                }
            });


            function modalShow(modalid) {
                console.log(12312)
                $("#modalBack").show();
                //$("#"+modalid).animate({top:'20%'},"2s");
                $("#" + modalid).css("top", "20%");
            }
            function modalHide(modalid) {
                //$("#"+modalid).animate({top:'-100%'},".3s");
                $("#" + modalid).css("top", "-100%");
                $("#modalBack").hide();
            }
            function convert_speed(data, unit) {
                var ret = "";
                if (data >= 0 && data < 1024) {
                    ret = parseFloat(data).toFixed(2) + "B";
                } else if (data >= 1024 && data < 1048576) {
                    ret = parseFloat(data / 1024).toFixed(2) + "KB";
                } else if (data >= 1048576 && data < 1073741824) {
                    ret = parseFloat(data / 1048576).toFixed(2) + "MB";
                } else if (data >= 1073741824) {
                    ret = parseFloat(data / 1073741824).toFixed(2) + "GB";
                }
                if (unit == 'unit') {
                    ret = ret + "/s";
                }
                return ret;
            }
            function convert_pri(pri) {
                switch (pri) {
                    case "1":
                        pri = "最高"; break;
                    case "2":
                        pri = "高"; break;
                    case "3":
                        pri = "中"; break;
                    case "4":
                        pri = "低"; break;
                    case "5":
                        pri = "最低"; break;
                }
                return pri;
            }



            //列表关闭按钮
            $(".sure").click(function () {
                modalHide("listModal");
            });

        }

        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------







        //newfw
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        if (window.location.host.indexOf(':') > 0 && !isPrivateIpAddress(window.location.hostname) || isDev == 1) $(".back_logo").css({ "cursor": "pointer" });
        // logo点击事件
        $(".back_logo").click(function () {

            if (window.location.host.indexOf(':') > 0 && !isPrivateIpAddress(window.location.hostname) || isDev == 1) {
                let str = ''

                if (window.location.host.split(':').length == 1) {
                    str = window.btoa(window.location.host + ':80' + '*@*' + ($.cookie("NAME") || ''));
                } else {
                    str = window.btoa(window.location.host + '*@*' + ($.cookie("NAME") || ''));
                }

                let $temp = $('<input>');
                $('body').append($temp);
                $temp.val(str).select();
                document.execCommand('copy');
                $temp.remove();

                $(".back_logo").html(`
        <div style="
        width:100%;
        height:100%;
        display: flex;
        justify-content: center;
        align-items: center;
        color:#666;
        font-size:20px;
        background-color:rgba(255, 255, 255,.8);
        user-select: none;
        ">OK</div>
        `);

                setTimeout(() => {
                    if (isDev == 1) {
                        window.open("http://localhost:5173/login");
                    } else {
                        window.open("http://47.108.191.179:8887/login");
                    }

                    $(".back_logo").html("");
                }, time)
            }

        });



        // ip私有地址正则
        function isPrivateIpAddress(ip) {
            // CIDR格式的私有IP地址段
            var privateRegex = /^(?:(?:10|172\.(?:[1-9]|[1][0-9])|192\.168)\.)/;

            return privateRegex.test(ip);
        }

        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    }

    {

        $('#menu').css("border", "1px solid red !important")



    }











})();

QingJ © 2025

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