扣代碼工具h(yuǎn)ta版

字號(hào):


    復(fù)制下面的代碼,最好用editplus等專業(yè)點(diǎn)的編輯工具。
    代碼如下:
    <!doctype html public -//w3c//dtd xhtml 1.0 transitional//en http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd>
    <html xmlns=http://www.w3.org/1999/xhtml>
    <head>
    <meta http-equiv=content-type content=text/html; charset=utf-8 />
    <title>頁面內(nèi)容捕獲器</title>
    <style>
    * { font-size:12px; }
    html { padding:0px; margin:0px; border-style:none; border-width:0px; overflow:auto; background-color:buttonface; }
    body { padding:0px; margin:0px; border-style:none; border-width:0px; background-color:buttonface; }
    li { line-height:24px; height:24px; margin:10px 0px -10px 15px; }
    a { color:blue; }
    input { border-width:1px; }
    #output { width:90%; height:150px; overflow:auto; }
    </style>
    <script>
    var win;
    function $(s){ return document.getelementbyid(s); }
    window.onload = function(){
        var myheight = 320;
        window.moveto(0,0);
        window.resizeto(screen.availwidth, myheight);
        //打開一個(gè)瀏覽器
        win = new activexobject(internetexplorer.application);
        win.left = 0; win.top = myheight;
        win.width = screen.availwidth; win.height = screen.availheight - myheight;
        win.navigate2(about:blank);
        win.visible = true;
        setinterval(function(){ try{ win.document; }catch(e){ window.close(); } }, 1); //窗口關(guān)閉后自動(dòng)退出程序
        //頁面卸載時(shí)關(guān)閉瀏覽器
        window.onunload = function(){ win.quit(); }
        //自動(dòng)捕獲
        setinterval(docapture, 1);
    }
    function docapture(){
        try{
            win.document.onclick = capit;
        }catch(e){}
    }
    function capit(){
        var d = win.document, w = d.parentwindow, e = w.event, el = e.srcelement;
        $(currentobj).bound = el;
        $(currentobj).innerhtml = el.tagname;
        showcapture(el);
        e.cancelbubble = true;
        e.returnvalue = false;
        return false;
    }
    function showcapture(el){
        if(!el)return;
        var oldborderstyle = el.style.borderstyle, oldborderwidth = el.style.borderwidth, oldbordercolor = el.style.bordercolor;
        el.style.border = 2px solid red;
        settimeout(function(){ try{ el.style.borderstyle = oldborderstyle; el.style.borderwidth = oldborderwidth; el.style.bordercolor = oldbordercolor; }catch(e){} }, 300);
    }
    function parentcapture(){
        var el = $(currentobj).bound;
        if(!el || !el.parentnode || el.parentnode.nodetype != 1 )return;
        el = el.parentnode;
        $(currentobj).bound = el;
        $(currentobj).innerhtml = el.tagname;
        showcapture(el);
    }
    function showcapturecurrentstyle(){
        var el = $(currentobj).bound;
        if(!el)return;
        var re = [], s = el.currentstyle;
        for(var i in s)if(s[i] != )re.push(i+:+s[i]+;);
        $(output).value += \r\n<!--current style:\r\n + re.join( ) + \r\n-->\r\n;
    }
    function showcaptureallevent(){
        var el = $(currentobj).bound, re = [];
        if(!el)return;
        for(var i in el)if(string(i).indexof(on) == 0 && el[i])re.push(string(el[i]));
        $(output).value += \r\n<!--all bound event:\r\n + re.join(\r\n) + \r\n-->\r\n;
    }
    function doexporthtml(){
        if(!$(currentobj).bound)return;
        $(output).value += \r\n + $(currentobj).bound.outerhtml + \r\n;
    }
    function doexportinnercss(){
        var o = win.document.getelementsbytagname(style);
        for(var i=0; i<o.length; i++)$(output).value += \r\n<style>\r\n + o[i].innerhtml + \r\n<\/style>\r\n;
    }
    function doexportfunction(){
        var o = win.document.parentwindow, str = $(funcname).value.split(.), i = -1;
        while(++i< str.length && (o = o[str[i]]));
        if(!o)return;
        $(output).value += \r\n<script>\r\n + o + \r\n<\/script>\r\n;
    }
    function dotest(){
        var nw = window.open(, _blank);
        nw.document.open();
        nw.document.write($(output).value);
        nw.document.close();
    }
    </script>
    </head>
    <body>
    <ul>
        <li>
            目前已捕獲到對(duì)象:
            <a href=### onclick=showcapture(this.bound); return false; id=currentobj>無</a>    <<   
            <a href=### onclick=parentcapture(); return false;>獲取其父對(duì)象</a>
              |  
            <a href=### onclick=doexporthtml(); return false;>導(dǎo)出html</a>
              |  
            <a href=### onclick=showcapturecurrentstyle(); return false;>導(dǎo)出其當(dāng)前樣式</a>
              |  
            <a href=### onclick=showcaptureallevent(); return false;>導(dǎo)出其綁定的所有事件</a>
        </li>
        <li>
            導(dǎo)出內(nèi)部樣式表:
            <a href=### onclick=doexportinnercss(); return false;>導(dǎo)出</a>
        </li>
        <li>
            導(dǎo)出js函數(shù):
            <input type=text value= onfocus=this.value=''; size=30 id=funcname>
              |  
            <a href=### onclick=doexportfunction(); return false;>導(dǎo)出</a>
        </li>
        <li>
            導(dǎo)出的數(shù)據(jù):
              |  
            <a href=### onclick=dotest(); return false;>測(cè)試</a>
              |  
            <a href=### onclick=$('output').value=''; return false;>清除</a>
            <br/>
            <textarea id=output></textarea>
        </li>
    </ul>
    </body>
    </html>
    使用方法是這樣的:
    1. 壓縮包中的文件
    2. 運(yùn)行后會(huì)出現(xiàn)一個(gè)程序窗口和一個(gè)ie瀏覽器窗口,上下排列
    3.在瀏覽器中輸入需要扣代碼的網(wǎng)站地址,回車進(jìn)去需要的站點(diǎn)
    4.在需要扣代碼的效果上點(diǎn)擊鼠標(biāo),例如上圖中的鏈接??梢钥吹匠绦虼翱谥幸呀?jīng)捕獲到了這個(gè)對(duì)象。如果需要其父對(duì)象,只需要單擊程序窗口中的 “獲取其父對(duì)象” 鏈接。
    5. 單擊程序窗口中的 “導(dǎo)出html” 鏈接,可以得到當(dāng)前對(duì)象的html內(nèi)容(即使這個(gè)內(nèi)容是用腳本動(dòng)態(tài)生成的也可以捕獲)
    6.在 “導(dǎo)出js函數(shù)” 后的文本框中輸入想查看的 js函數(shù)名(支持 “gbar.qs” 這種形式),可以得到 js 函數(shù)內(nèi)容。免去一個(gè)一個(gè)外部 js 文件查找的辛苦。
    其他功能請(qǐng)自己琢磨。