Greasy Fork

IP Hunter for ZTE-MF63

This userscript automatically reconnects the mobile data for some ZTE MF63 modems until it connects to a matching IP address.

目前为 2017-01-17 提交的版本。查看 最新版本

// ==UserScript==
// @name         IP Hunter for ZTE-MF63
// @namespace    Unknown
// @version      1.0.0
// @description  This userscript automatically reconnects the mobile data for some ZTE MF63 modems until it connects to a matching IP address.
// @author       Jhayr
// @match        http://192.168.0.1/index.html
// @grant        none
// @license MIT License

// ==/UserScript==

/*
 * IP Hunter
 *
 *
 * THIS WORK IS COPYRIGHT PROTECTED
 * http://www.copyrighted.com/copyrights/view/jqv4-u3m7-erfv-b730
 *
 * MODIFYING THE TOOL FOR YOUR PERSONAL USE IS PERMITTED
 * HOWEVER, RE-BRANDING OR REMOVING THIS COPYRIGHT NOTICE IS NOT ALLOWED.
 *
 * IF YOU HAVE ANY SUGGESTIONS TO IMPROVE THIS TOOL,
 * YOU CAN PM ME ON FACEBOOK.
 * https://www.facebook.com/jayrditona
 */

(function() {
    'use strict';
    //if(document.location.hash !== "#login"){

        var zte_service = null;
        var zte_device_info = null;
        var zte_device_info_init = null;
        var valid_ip = "";
        var hunter_handler = null;
        var ppp_status = null; //connected: "ppp_connected", disconnected: "ppp_disconnected"
        var ppp_loading = null;

        // Your code here...
        $('<div id="footer" class="side-center">'+
          '</div>'+
          '<div id="frm-iphunt" style="background-size:cover;background-image:url("www.media.istockphoto.com/photos/blue-gradient-blurred-abstract-background-picture-id523159398?k=6&m=523159398&s=170667a&w=0&h=QaH57rXTcu6XUsgfl7XGgmBaz2Vbz0AKaHgC2T50hsI=")" class="form-body" ">'+
          '<div style="text-align:center;"><h2 style="font-family: cursive;" >IP Hunter</h2> <span style="font-size:12px;color:#4d4d4d;font-family: monospace;"> by Jhay-R </span></div>'+
          '<div id="footer" class="side-center">'+
          '</div>'+
          '<div class="content">'+
          '<div class="row-fluid">'+
          '<label class="span4 side-right" for="txt_pattern"><i class="colorRed">&nbsp;</i></label>'+
          '<div class="span8">'+
          '<textarea type="text" required placeholder="IP (eg: 10.;100.35" name="txt_pattern" id="txt_pattern" style="width: 369px;height: 50px;"></textarea>'+
          '<input type="button" class="span2 btn-1" id="btn_init" name="btn_init" value="Search" style="width: 85px;height: 50px;margin-left: 8px;margin-top: 5px;">'+
          '</div>'+
          '</div>'+
          '<div class="row-fluid">&nbsp;</div>'+
          '<div class="row-fluid">'+
          '<div class="span4"></div>'+
          '<div class="span6" style="line-height: normal;">'+
          '<div id="div_iphunt_logs" style="margin-left:7px;width:360px;height:200px;overflow-y:auto;border: 1px dashed #ddd; box-shadow: 0 0 0 3px #fff, 0 0 0 5px #ddd, 0 0 0 10px #fff, 0 0 2px 10px #eee;"></div>'+
          '</div>'+
          '</div>'+
          '</div>'+
          '</div>').appendTo('body');

        $("#txt_pattern").val(localStorage.zte_valid_ip || valid_ip);    
    
        $("#btn_init").click(function(){
            var valid_ip_val = $("#txt_pattern").val() || valid_ip;
            localStorage.zte_valid_ip = valid_ip_val;
            //zte_device_info_init = require.s.contexts._.defined['status\/device_info'];
            //zte_device_info_init.init();
            zte_service = require.s.contexts._.defined.service;
            zte_device_info = zte_service.getDeviceInfo();

            ppp_status = zte_device_info.connectStatus;

            if(this.value == "Search"){
                $("#div_iphunt_logs").empty();
                this.value = "Stop";
                hunter_handler = setInterval(function(){
                    if(ppp_loading) return;
                    zte_device_info = zte_service.getDeviceInfo();
                    var e = zte_device_info.wanIpAddress;
                    $("#div_iphunt_logs").append("<span>Current IP: <strong>"+ e + "</strong></span></br>");
                    var res_ip = false;
                    localStorage.zte_valid_ip.split(";").forEach(function(l,a){res_ip = res_ip || e.startsWith(l);});
                    if(!res_ip){
                        $("#div_iphunt_logs").append("<span>Reconnecting...</span><br/>");
                        if(ppp_status == "ppp_connected"){
                            ppp_loading = 1;
                            zte_service.disconnect({}, function(d){
                                zte_service.connect({}, function(d){
                                    ppp_status = d.status;
                                    ppp_loading = null;
                                });
                            });
                        }
                    }
                    else{
                        $("#div_iphunt_logs").append("<span>Success. Found IP: <strong>"+ e + "</strong></span><br/>");
                        $("#div_iphunt_logs").append("<span><strong>Stopped.</strong></span><br/>");
                        $("#btn_init").val("Search");
                        ppp_loading = null;
                        clearInterval(hunter_handler);
                    }
                    $("#div_iphunt_logs").scrollTop($("#div_iphunt_logs")[0].scrollHeight);

                }, 300);
            }
            else if(this.value == "Stop"){
                this.value = "Search";
                ppp_loading = null;
                clearInterval(hunter_handler);
            }

        });
    //}
    setInterval(function(){
        var $frm_iphunt = $("#frm-iphunt");
     if(document.location.hash !== "#login"){
         if($frm_iphunt.is(":visible")) return;
         $frm_iphunt.show();
     }
     else{
         if(!$frm_iphunt.is(":visible")) return;
         $frm_iphunt.hide();
     }
    }, 300);
})();