firefox扩展:myip.xpi更新ip.cn版本

2011年2月20日 | 分类: Document | 标签: , , , , ,

插件下载地址:http://u.115.com/file/f71cb93ac7
如图:
主要代码如下

if(!cn) var cn={};
if(!cn.yishan) cn.yishan={};
if(!cn.yishan.myip) cn.yishan.myip={};

cn.yishan.myip = function(){
  var pub = {};
  var http_request = false;
  var oldip = null;
  pub.aktivieren = function(){
    doRequest('http://www.ip.cn/getip.php?action=getip&ip_url=locaIp');
  };
  ergebnisverarbeiten = function(){
	var ip = http_request.responseText;
	  ip = ip.replace(/[\s\S]*来自\:/,"");
		ip = ip.replace(/\<br[\s\S]*/,"");
//    ip=gb2utf8(ip);
	var change = false;
	if(oldip == null){
		oldip = ip;
		change = true;
	
	} else if(oldip != ip){
		oldip = ip;
		change = true;
	}
	
	if(change){	
		setLabel(ip);
	}
  };
  setLabel = function(text){
	document.getElementById('myip-panel').setAttribute("label",text);
  };
  doRequest = function(url){
    http_request = false;
    if (window.XMLHttpRequest) {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) {
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e) {}
        }
    }
    if (!http_request) {
        alert('Es kann kein Request Objekt erzeugt werden.');
        return false;
    }
    http_request.onreadystatechange = myHandler;
    http_request.open('GET', url, true);
    http_request.send(null);  
  };
  myHandler = function(){
     if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            ergebnisverarbeiten();
        } else{
		//	setLabel('loading');
		}
		
        //window.setTimeout(function() { pub.aktivieren() },3000);
    }  
  };
  
  pub.start = function(){
	window.setTimeout(function() { pub.aktivieren() },2000);
  };
  return pub;  
}();

cn.yishan.myip.start();

  1. 611e
    2011年12月19日03:00

    提取碼已過期

    Firefox 8.0.1 Windows 7 x64 Edition

返回顶部