主頁 > 知識庫 > 超簡陋瀏覽器

超簡陋瀏覽器

熱門標(biāo)簽:徐州天音防封電銷卡 鄭州智能外呼系統(tǒng)運(yùn)營商 獲客智能電銷機(jī)器人 電話機(jī)器人適用業(yè)務(wù) 哈爾濱外呼系統(tǒng)代理商 不錯的400電話辦理 佛山防封外呼系統(tǒng)收費(fèi) 湛江電銷防封卡 南昌辦理400電話怎么安裝
可是那些破站點(diǎn)讓人太郁悶了...不是彈出廣告,就是滿屏幕飄浮動廣告....氣死我了...

所以做了一個超簡陋的瀏覽器,把頁面中的 JS 基本上全禁掉了(禁用JS的正則不是很好,此外CSS里的沒禁掉,不過目前反正夠俺用就好了),順便把 iframe 也全部干掉

還可以自動記得上次瀏覽的頁面,打開就直接進(jìn)入,看書的時候就不怕打斷了

因?yàn)槌喡?,所以連 表單也不支持,只支持鏈接,哈哈,看書倒是夠用了....

代碼中的 偽session 處理 和 俺自己封裝的 xmlhttp 值得一看


不能直接運(yùn)行,保存到本地,另存為 HTA 使用,哈哈
復(fù)制代碼 代碼如下:

head>
title>Book Viewer/title>
meta http-equiv="content-type" content="text/html; charset=UTF-8" />
style>
body { margin:0px; padding:0px; overflow:auto; border-style:none; font-size:12px; background-color:buttonface; }
iframe { width:100%; border-style:none; position:absolute; top:25px; }

#i1 { height:22px; line-height:18px; width:100%; border:1px solid #666; margin:0px 2px; padding:0px 10px; }
/style>
script>
strSessionName="bookviewer_lastURL";
lastURL="";
xp=new xmlhttp();

function checkMe(){
    if(i1.value!=lastURL){
        lastURL=i1.value;
        session_set(strSessionName,lastURL);
    }
    try{
        for(var i=0;if1.document.links.length;i++)f1.document.links[i].onclick=n0;
    }catch(e){}
    if(/book\.5seecn/i.test(lastURL))f1.document.body.onkeydown=chkKey;
}

function chkKey(){
    var allLinks;
    if(f1.event.keyCode==39){
        allLinks=f1.document.links;
        for(var i=0;iallLinks.length;i++)if(/下一頁/.test(allLinks[i].innerHTML)){
            i1.value=allLinks[i].href; n2(); return;
        }
    }else if(f1.event.keyCode==37){
        allLinks=f1.document.links;
        for(var i=0;iallLinks.length;i++)if(/上一頁/.test(allLinks[i].innerHTML)){
            i1.value=allLinks[i].href; n2(); return;
        }
    }
}

function init(){
    i1.onkeydown=function(){ if(event.keyCode==13)n2(); }
    resizeWin();
    i1.focus();
    i1.select();
    if(session_exists(strSessionName)){ i1.value=session_get(strSessionName); n2(); }
    setInterval(checkMe,200);
}

function resizeWin(){
    document.getElementById("f1").style.height=document.body.clientHeight-25;
}

function n0(){
    n1(this.href);
    return(false);
}

function n1(str){
    i1.value=str;
    n2();
}

function n2(){
    str=i1.value;
    if(i1=="")return;
    if(!/^http:\/\//i.test(str))str="http://"+str;
    document.title="Book Viewer - Loading...";
    xp.open("get",str);
    xp.onreadystatechange=n22;
    xp.send("");
}

function n22(){
    var str;
    if(this.readyState==4){
        if(this.status==200){
            str=adodb_binary2string(this.getAttribute("responseBody"));
            str=str.replace(/script[\s\S]+?\/script>/gi,"").replace(/iframe[\s\S]+?\/iframe>/gi,"").replace(/on(load|mouseover|mouseout|mousemove|focus|blur|keydown|keyup|keypress|change|readystatechange|click|dblclick|mousewheel) *= *\"[\s\S]+?\"/gi,"");
            f1.document.open();
            f1.document.write("base href=\""+i1.value.substring(0,i1.value.lastIndexOf("/")+1)+"\" \/>");
            try{
                f1.document.write(str);
            }catch(e){}
            f1.document.close();
            f1.document.body.focus();
            document.title="Book Viewer - Ready";
        }
    }
}

function cancelErr(){ return(true); }

html_encode=function(strV){
    return(strV.replace(//g,"").replace(/"/g,"quot;").replace(/ /g,"nbsp;").replace(/\t/g,"nbsp;nbsp;nbsp;nbsp;").replace(//g,"lt;").replace(/>/g,"gt;").replace(/\r\n/g,"br>"));
}

function adodb_binary2string(b){
    var adodbStream=new ActiveXObject("ADODB.Stream"); 
    adodbStream.Type=1;//1=adTypeBinary
    adodbStream.Open();
    adodbStream.write(b);
    adodbStream.position=0;
    adodbStream.Type=2;
    adodbStream.charset="_autodetect_all";
    var re=adodbStream.readText();
    adodbStream=null;
    return(re);
}

function session_delete(strName){
    var str, reg, expt, dt;
    if(!session_exists(strName))return;
    strName=escape(strName);
    strValue="";
    dt=new Date();
    dt.setYear(1980);
    expt=";expires="+dt.toGMTString()+";";
    str=strName+"="+strValue+expt;
    document.cookie=str;
}

function session_get(strName){
    var str, reg;
    str=document.cookie;
    strName=escape(strName);
    reg=new RegExp(strName+"=([^;]+)");
    if(!reg.test(str))return;
    return(unescape(str.match(reg)[1]));
}

function session_set(strName,strValue,blnExpireAfterClose){
    var str, reg, expt, dt;
    strName=escape(strName);
    strValue=escape(strValue);
    dt=new Date();
    dt.setYear(2099);
    expt=blnExpireAfterClose?"":";expires="+dt.toGMTString()+";";
    str=strName+"="+strValue+expt;
    document.cookie=str;
}

function session_exists(strName){
    var str, reg;
    str=document.cookie;
    strName=escape(strName);
    reg=new RegExp(strName+"=(.+);?");
    if(!reg.test(str)){return(false);}else{return(true);}
}

function xmlhttp(){
    // declare all the private variable
    var aryArgu, aryOnPropertyChange_AttachedEvents, aryRequestHeaders, blnAsyn, objRequest, objSelf, objThat, strMethod, strProtocol, strToBeSend, strUID, strUrl;
    // declare all the private functions
    var defaultEvent_onreadystatechange, getXMLRequester, init, realEvent_onreadystatechange, uid;

    
    // declare public variable
    this.blnSendDefaultHeader=false;
    this.readyState=0;
    this.responseText="";
    this.responseXML="";
    this.status=-1;

    // public event
    this.onreadystatechange=defaultEvent_onreadystatechange;

    // public method
    this.attachEvent=function(eventHandle,functionHandle){
        var eventHandle=String(eventHandle).toLowerCase();
        switch(eventHandle){
            case "onreadystatechange":
                if(this.onreadystatechange!=defaultEvent_onreadystatechange){
                    this.onreadystatechange=defaultEvent_onreadystatechange;
                    aryOnPropertyChange_AttachedEvents=new Array();
                }
                aryOnPropertyChange_AttachedEvents.push(functionHandle);
                return(true);
            break;
            default:
                return("Not reallized yet.");
            break;
        }
    }

    this.deleteRequestHeader=function(strName){
        delete aryRequestHeaders[strName];
    }

    this.detachEvent=function(eventHandle,functionHandle){
        var eventHandle=String(eventHandle).toLowerCase();
        switch(eventHandle){
            case "onreadystatechange":
                if(this.onreadystatechange!=defaultEvent_onreadystatechange){
                    this.onreadystatechange=defaultEvent_onreadystatechange;
                    aryOnPropertyChange_AttachedEvents=new Array();
                    return(true);
                }
                for(var i=0;iaryOnPropertyChange_AttachedEvents.length;i++){
                    if(aryOnPropertyChange_AttachedEvents[i]==functionHandle){
                        aryOnPropertyChange_AttachedEvents.splice(i,1);
                        break;
                    }
                }
                return(true);
            break;
            default:
                return("Not reallized yet.");
            break;
        }
    }

    this.flush=function(){
        try{ this.readyState=objRequest.readyState; }catch(e){}
        try{ this.responseText=objRequest.responseText; }catch(e){}
        try{ this.responseXML=objRequest.responseXML; }catch(e){}
        try{ this.status=objRequest.status; }catch(e){}
    }

    this.getAllResponseHeaders=function(){
        return(objRequest.getAllResponseHeaders());
    }

    this.getAttribute=function(strName,strRef){
        switch(strName){
            case "allHeaders":
                return(objRequest.getAllResponseHeaders());
            case "asyn":
                return(blnAsyn);
            case "header":
                return(objRequest.getResponseHeader(strRef));
            case "method":
                return(strMethod);
            case "protocol":
                return(strProtocol);
            case "readyState":
                return(objRequest.readyState);
            case "responseBody":
                return(objRequest.responseBody);
            case "responseText":
                return(objRequest.responseText);
            case "responseXML":
                return(objRequest.responseXML);
            case "send": case "sendString": case "strSend":
                return(strToBeSend);
            case "status":
                return(objRequest.status);
            case "uid":
                return(strUID);
            case "url":
                return(strUrl);

            default:
                return(false);
        }
    }

    this.getResponseHeader=function(strHeaderName){
        return(objRequest.getResponseHeader(strHeaderName));
    }

    this.init=init;

    this.open=function(method,url,asyn){
        var theURL;
        strMethod=String(method).toLowerCase()=="POST"?"POST":"GET";
        strUrl=String(url);
        blnAsyn=String(asyn).toLowerCase()=="false"?false:true;
        strProtocol=strUrl.match(/http:\/\//i)?"http":"other";
        theURL=strUrl
        //if(strProtocol=="http")theURL=strUrl+(strUrl.indexOf(".")==-1?"\/":"")+(strUrl.indexOf("?")==-1?"?":"")+uid()+"=true";
        objRequest.open(strMethod,theURL,blnAsyn);
    }

    this.reset=init;

    this.send=function(strSend){
        strToBeSend=String(strSend);
        for(var i in aryRequestHeaders){
            objRequest.setRequestHeader(i,aryRequestHeaders[i]);
        }
        if(this.blnSendDefaultHeader){
            objRequest.setRequestHeader("Content-Length",strToBeSend.length);
        }
        objRequest.onreadystatechange=realEvent_onreadystatechange;
        objRequest.send(strToBeSend);
    }

    this.setRequestHeader=function(strName,strValue){
        aryRequestHeaders[strName]=strValue;
    }

    // private functions
    function defaultEvent_onreadystatechange(){}

    function getXMLRequester(){
        var xmlhttp_request = false;
        try{
            if( window.ActiveXObject ){
                for( var i = 5; i > -1; i-- ){
                    try{
                        if( i == 2 ){
                            xmlhttp_request = new ActiveXObject( "Microsoft.XMLHTTP" );
                        }else{
                            xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
                        }
                        break;
                    }catch(e){
                        xmlhttp_request = false;
                    }
                }
            }else if( window.XMLHttpRequest ){
                xmlhttp_request = new XMLHttpRequest();
            }
        }catch(e){
            xmlhttp_request = false;
        }
        return xmlhttp_request;
    }

    function init(){
        // init private variable
        aryArgu=new Array();
        aryOnPropertyChange_AttachedEvents=new Array();
        aryRequestHeaders=new Array();
        blnAsyn=true;
        objRequest=getXMLRequester();
        objSelf=this;
        objThat=this;
        strMethod="GET";
        strProtocol="unknown";
        strResponseText="";
        strToBeSend="";
        strUID=strUID?strUID:uid();
        strUrl="";
        // init public variable
        this.blnSendDefaultHeader=false;

        // regist this object to window
        window[strUID]=this;
    }

    function realEvent_onreadystatechange(){
        objThat.flush();
        if(objThat.onreadystatechange==defaultEvent_onreadystatechange){
            for(var i=0;iaryOnPropertyChange_AttachedEvents.length;i++){
                try{
                    if(typeof(aryOnPropertyChange_AttachedEvents[i])=="function"){
                        aryOnPropertyChange_AttachedEvents[i].call(objThat);
                    }else if(typeof(aryOnPropertyChange_AttachedEvents[i])=="string"){
                        eval(aryOnPropertyChange_AttachedEvents[i]);
                    }
                }catch(e){alert("004"+e.description)}
            }
        }else{
            try{
                if(typeof(objThat.onreadystatechange)=="function"){
                    objThat.onreadystatechange();
                }else if(typeof(objThat.onreadystatechange)=="string"){
                    eval(objThat.onreadystatechange);
                }
            }catch(e){alert("005"+e.description)}
        }
    }

    function uid(){
        return("u"+(new Date()).getTime().toString(35)+parseInt(Math.random()*999999).toString(35));
    }

    
    // do init
    this.init();

}




window.onload=init;
window.onresize=resizeWin;
window.onerror=cancelErr;
/script>
/head>
body>
input id="i1">br>
iframe id="f1">/iframe>
/body>    

標(biāo)簽:蕪湖 蘭州 廣西 安康 懷化 呂梁 紹興 吉安

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《超簡陋瀏覽器》,本文關(guān)鍵詞  超,簡陋,瀏覽器,超,簡陋,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《超簡陋瀏覽器》相關(guān)的同類信息!
  • 本頁收集關(guān)于超簡陋瀏覽器的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章