function createhttprequest(){
    var requestB=null;
    if("XMLHttpRequest" in window){
        requestB= new XMLHttpRequest();
    }
    else if("ActiveXObject" in window){
        try{
            requestB=new ActiveXobject("Msxml2.XMLHTTP");
        }catch(e){
            try{
                requestB=new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e){
            }
        }
    }
    return requestB;
}

var request;
var timer;

function requestsource(url){
    request=createhttprequest();
    timer = setInterval("timeoutError()",1000);
    request.open("GET",url,true);
    request.onreadystatechange=sourceget;
    request.send("");
}

function addFigure(str) {
    var num = new String(str).replace(/,/g, "");
    while(num != (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
    return num;
}

function sourceget(){
    if (request.readyState == 4 && request.status == 200){
      clearInterval(timer);
      var src = request.responseText;
      src = src.replace(/\n/g, "");
      src = src.replace(/<.+?>/g, "");
      var srcCountAll = src.length;
      var srcAll = src;
      src = src.replace(/(w|W|ｗ|Ｗ)/g,"");
      var srcCountW = srcCountAll - src.length;
      var outputHtml = '<div>このページのｗの数は･･･<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-weight:bold;font-size:16px;color:green;">' + addFigure(srcCountW) + '</span> コ くらいｗｗｗ<br /><a href="http://wwwwwwwwwwwwww.net/" style="color:blue;">wwwカウンター</a></div>';
//      outputHtml = outputHtml + ' <a href="javascript:void(0)" onclick="document.body.innerHTML=document.body.innerHTML.split(&#039;w&#039;).join(&#039;<span style=&quot;color:yellow;&quot;>w</span>&#039;); return false;">ｗｗｗをハイライト！</a>';
//      outputHtml = outputHtml + ' <a href="javascript:void(0)" onclick="document.body.innerHTML=document.body.innerHTML.replace(/>([^w><]*)w([^w><]*)?</g, &#039;>&#039;$1&#039;<span style=&quot;color:yellow;&quot;>w</span>&#039&#039;$2&#039;<); return false;">ｗｗｗをハイライト！</a>';
//      outputHtml = outputHtml + ' <a href="javascript:void(0)" onclick="document.body.innerHTML=document.body.innerHTML.replace(/>(.*)w(.*)?</g, &#039;>&#039;$1&#039;<span style=&quot;color:yellow;&quot;>w</span>&#039&#039;$2&#039;<); return false;">ｗｗｗをハイライト！</a>';
//http://java.cocolog-nifty.com/blog/2005/12/javascripthtml_03d5.html
      var vId = 'wwwwwwwwwwwwww';
      document.getElementById(vId).style.backgroundColor = '#efefef';
      document.getElementById(vId).style.border = '1px solid rgb(136, 136, 136)';
      document.getElementById(vId).style.color = '#333333';
      document.getElementById(vId).style.width = '160px';
      document.getElementById(vId).style.padding = '5px';
      document.getElementById(vId).style.fontSize = '12px';
    
      document.getElementById(vId).innerHTML = outputHtml;
    }
    else{
    }
}
function timeoutError()
{
    clearInterval(timer);	//	タイマーとめる
    request.abort();
}

requestsource(location.pathname);