google.cn JavaScript 跳转代码

var gcn=gcn||{ };
gcn.IS_IMAGES=(/images\.google\.cn/.exec(window.location)||window.location.hash=='#images'||window.location.hash=='images');
gcn.HOMEPAGE_DEST='http://www.google.com.hk/webhp?hl=zh-CN&sourceid=cnhp';
gcn.IMAGES_DEST='http://images.google.com.hk/imgcat/imghp?'+'hl=zh-CN&sourceid=cnhp';
gcn.DEST_URL=gcn.IS_IMAGES?gcn.IMAGES_DEST:gcn.HOMEPAGE_DEST;
gcn.READABLE_HOMEPAGE_URL='google.com.hk';
gcn.READABLE_IMAGES_URL='images.google.com.hk';
gcn.redirectIfLocationHasQueryParams=function(){
  if(window.location.search&&/google\.cn/.exec(window.location)&&!/webhp/.exec(window.location)){
    window.location=String(window.location).replace('google.cn','google.com.hk')
  }
}();
gcn.replaceHrefsWithImagesUrl=function(){
  if(gcn.IS_IMAGES){
    var a=document.getElementsByTagName('a');
    for(var i=0,len=a.length;
        i<len;
        i++){
      if(a[i].href==gcn.HOMEPAGE_DEST){
        a[i].href=gcn.IMAGES_DEST
      }
    }
  }
}();
gcn.listen=function(a,e,b){
  if(a.addEventListener){
    a.addEventListener(e,b,false)
  }else if(a.attachEvent){
    var r=a.attachEvent('on'+e,b);
    return r
  }
};
gcn.stopDefaultAndProp=function(e){
  if(e&&e.preventDefault){
    e.preventDefault()
  }else if(window.event&&window.event.returnValue){
    window.eventReturnValue=false;
    return false
  }if(e&&e.stopPropagation){
    e.stopPropagation()
  }else if(window.event&&window.event.cancelBubble){
    window.event.cancelBubble=true;
    return false
  }
};
gcn.resetChildElements=function(a){
  var b=a.childNodes;
  for(var i=0,len=b.length;
      i<len;
      i++){
    gcn.listen(b[i],'click',gcn.stopDefaultAndProp)
  }
};
gcn.redirect=function(){
  window.location=gcn.DEST_URL
};
gcn.setInnerHtmlInEl=function(a){
  if(gcn.IS_IMAGES){
    var b=document.getElementById(a);
    if(b){
      b.innerHTML=b.innerHTML.replace(gcn.READABLE_HOMEPAGE_URL,gcn.READABLE_IMAGES_URL)
    }
  }
};
 
gcn.listen(document, 'click', gcn.redirect);
gcn.setInnerHtmlInEl('target');