扣代碼工具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;">測試</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)自己琢磨。
    有什么疑問請(qǐng)留言。