Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (!com) var com = {};
  2. if (!com.RealityRipple) com.RealityRipple = {};
  3.  
  4. com.RealityRipple.GaiaFormat = function()
  5. {
  6.  var pub  = {};
  7.  var priv = {};
  8.  
  9.  priv.Cc = Components.classes;
  10.  priv.Ci = Components.interfaces;
  11.  priv.CccI = function(cName, ifaceName)
  12.  {
  13.   return priv.Cc[cName].createInstance(priv.Ci[ifaceName]);
  14.  }
  15.  priv.CcgS = function(cName, ifaceName)
  16.  {
  17.   if (Cc[cName])
  18.    return priv.Cc[cName].getService(priv.Ci[ifaceName]);
  19.   else
  20.    dumpError("CcgS fails for cName:" + cName);
  21.  }
  22.  
  23.  priv.Prefs = priv.CcgS("@mozilla.org/preferences-service;1","nsIPrefService").getBranch("gaiaformat.");
  24.  
  25.  priv.gBundle        = priv.CcgS("@mozilla.org/intl/stringbundle;1","priv.Ci.nsIStringBundleService");
  26.  priv.locale         = priv.gBundle.createBundle("chrome://gaiaformat/locale/gaiaformat.properties");
  27.  priv.lclDisForm     = priv.locale.GetStringFromName("disableformat.label");
  28.  
  29.  priv.trim = function(s)
  30.  {
  31.   s = s.replace(/(^\s*)|(\s*$)/gi, "");
  32.   s = s.replace(/[ ]{2,}/gi, " ");
  33.   s = s.replace(/\n /, "");
  34.   return s;
  35.  }
  36.  
  37.  priv.getElementsByAttribute = function(findme, attr)
  38.  {
  39.   var alltags = window._content.document.getElementsByTagName("*");
  40.   var foundtags = new Array();
  41.   for (var i = 0; i < alltags.length; i++)
  42.   {
  43.    if (attr == 'class')
  44.    {
  45.     if (alltags[i].className.indexOf(findme) >= 0)
  46.      foundtags.push(alltags[i]);
  47.    }
  48.    else
  49.     if (alltags[i].getAttribute(attr) == findme)
  50.      foundtags.push(alltags[i]);
  51.   }
  52.   return foundtags;
  53.  }
  54.  
  55.  var httpRequestObserver =
  56.  {
  57.   observe: function(subject, topic, data)
  58.   {
  59.    if (topic == "http-on-modify-request")
  60.    {
  61.     var httpChannel = subject.QueryInterface(priv.Ci.nsIHttpChannel);
  62.     if (httpChannel.requestMethod == "POST")
  63.     {
  64.      alert('on-modify POST: ' + httpChannel.URI.asciiSpec);
  65.      this.onModifyRequest(httpChannel);
  66.      this.unregister();
  67.     }
  68.    }
  69.   },
  70.   get observerService()
  71.   {
  72.    return priv.CcgS("@mozilla.org/observer-service;1","nsIObserverService");
  73.   },
  74.   register: function()
  75.   {
  76.    this.observerService.addObserver(this, "http-on-modify-request", false);
  77.   },
  78.   unregister: function()
  79.   {
  80.    this.observerService.removeObserver(this, "http-on-modify-request");
  81.   },
  82.   onModifyRequest: function(oHttp)
  83.   {
  84.    var uri = oHttp.URI.asciiSpec;
  85.    alert('URI: ' + uri);
  86.  
  87.  
  88. /*   this.forceCaching(oHttp);
  89.    var loadFlags = this.getStringVersionOfLoadFlags(oHttp.loadFlags);
  90.    var loadFromCache = this.isLoadFromCache(oHttp.loadFlags);
  91.    var cancelled = false; */
  92.  
  93.    var visitor = new HeaderInfoVisitor(oHttp);
  94.    var requestHeaders = visitor.visitRequest();
  95.    alert('Headers: ' + requestHeaders);
  96.    var postData = visitor.getPostData();
  97.    alert('Post Data: ' + postData);
  98.    var postBodyHeaders = visitor.getPostBodyHeaders();
  99.    alert('Full Info: ' + uri + ',' + requestHeaders + ',' + postBodyHeaders + ',' + postData);
  100.   }
  101.  
  102.  
  103. /*  requestResponse.setRequestData(uri, new Date(), oHttp.requestMethod, requestHeaders, postBodyHeaders, postData, loadFlags);
  104.     var requestResponse = new TamperRequestResponse();
  105.     requestResponse.setRequestData(uri, new Date(), oHttp.requestMethod, requestHeaders, postBodyHeaders, postData, loadFlags);
  106.     if (cancelled)
  107.     {
  108.      requestResponse.cancel();
  109.     }
  110.     else if (loadFromCache)
  111.     {
  112.      requestResponse.setLoadFromCache();
  113.     }
  114.     this.addRow(requestResponse); */
  115.  
  116.  
  117.  };
  118.  
  119.  function HeaderInfoVisitor(oHttp)
  120.  {
  121.   this.oHttp = oHttp;
  122.   this.headers = new Array();
  123.  }
  124.  HeaderInfoVisitor.prototype =
  125.  {
  126.   extractPostData : function(visitor, oHttp)
  127.   {
  128.    function postData(stream)
  129.    {
  130.     this.seekablestream = stream;
  131.     this.stream = TamperUtils.createScriptableInputStream(this.seekablestream);
  132.     this.hasheaders = false;
  133.     this.body = 0;
  134.     this.isBinary = true;
  135.     alert(this.seekablestream);
  136.     if (this.seekablestream instanceof Components.interfaces.nsIMIMEInputStream)
  137.     {
  138.      this.seekablestream.QueryInterface(Components.interfaces.nsIMIMEInputStream);
  139.      this.hasheaders = true;
  140.      this.body = -1;
  141.      this.isBinary = false;
  142.     }
  143.     else if (this.seekablestream instanceof Components.interfaces.nsIStringInputStream)
  144.     {
  145.      this.seekablestream.QueryInterface(Components.interfaces.nsIStringInputStream);
  146.      this.hasheaders = true;
  147.      this.body = -1;
  148.     }
  149.     this.rewind = function() { this..seekablestream.seek(0,0); };
  150.     this.tell = function() { return this.seekablestream.tell(); };
  151.  
  152.    }
  153.    postData.prototype =
  154.    {
  155.     readLine: function()
  156.     {
  157.      var line = "";
  158.      var size = this.stream.available();
  159.      for (var i = 0; i < size; i++)
  160.      {
  161.       var c = this.stream.read(1);
  162.       if (c == '\r')
  163.       {
  164.       }
  165.       else if (c == '\n')
  166.       {
  167.        break;
  168.       }
  169.       else
  170.       {
  171.        line += c;
  172.       }
  173.      }
  174.      return line;
  175.     },
  176.     visitPostHeaders: function(visitor)
  177.     {
  178.      if (this.hasheaders)
  179.      {
  180.       this.rewind();
  181.       var line = this.readLine();
  182.       while(line)
  183.       {
  184.        if (visitor)
  185.        {
  186.         var tmp = line.match(/^([^:]+):\s?(.*)/);
  187.         if (tmp)
  188.         {
  189.          visitor.visitPostHeader(tmp[1], tmp[2]);
  190.          if (!this.isBinary && tmp[1].toLowerCase() == "content-type" && tmp[2].indexOf("multipart") != "-1")
  191.          {
  192.           this.isBinary = true;
  193.          }
  194.         }
  195.         else
  196.         {
  197.          visitor.visitPostHeader(line, "");
  198.         }
  199.        }
  200.        line = this.readLine();
  201.       }
  202.       this.body = this.tell();
  203.      }
  204.     },
  205.     getPostBody: function(visitor)
  206.     {
  207.      if (this.body < 0 || this.seekablestream.tell() != this.body)
  208.      {
  209.       this.visitPostHeaders(visitor);
  210.      }
  211.      var size = this.stream.available();
  212.      if (size == 0 && this.body != 0)
  213.      {
  214.       this.rewind();
  215.       visitor.clearPostHeaders();
  216.       this.hasheaders = false;
  217.       this.isBinary   = false;
  218.       size = this.stream.available();
  219.      }
  220.      var postString = "";
  221.      try
  222.      {
  223.       for (var i = 0; i < size; i++)
  224.       {
  225.        var c = this.stream.read(1);
  226.        c ? postString += c : postString+='\0';
  227.       }
  228.      }
  229.      catch (ex)
  230.      {
  231.       return "" + ex;
  232.      }
  233.      finally
  234.      {
  235.       this.rewind();
  236.      }
  237.      while (postString.indexOf("\r\n") == (postString.length - 2))
  238.      {
  239.       postString = postString.substring(0, postString.length - 2);
  240.      }
  241.      return postString;
  242.     }
  243.    };
  244.    try
  245.    {
  246.     oHttp.QueryInterface(Components.interfaces.nsIUploadChannel);
  247.     if (oHttp.uploadStream)
  248.     {
  249.      alert('Upload Stream!');
  250.      oHttp.uploadStream.QueryInterface(priv.Ci.nsISeekableStream);
  251.      alert(oHttp.uploadStream);
  252.      return new postData(oHttp.uploadStream);
  253.     }
  254.    }
  255.    catch (e)
  256.    {
  257.     return "crap";
  258.    }
  259.    return null;
  260.   },
  261.   visitHeader : function(name, value)
  262.   {
  263.    this.headers[name] = value;
  264.   },
  265.   visitPostHeader : function(name, value)
  266.   {
  267.    if (!this.postBodyHeaders)
  268.    {
  269.     this.postBodyHeaders = {};
  270.    }
  271.    this.postBodyHeaders[name] = value;
  272.   },
  273.   clearPostHeaders : function()
  274.   {
  275.    if (this.postBodyHeaders)
  276.    {
  277.     delete this.postBodyHeaders;
  278.    }
  279.   },
  280.   visitRequest: function()
  281.   {
  282.    this.headers = {};
  283.    this.oHttp.visitRequestHeaders(this);
  284.    var postData = this.extractPostData(this, this.oHttp);
  285.    if (postData)
  286.    {
  287.     var postBody = postData.getPostBody(this);
  288.     if (postBody !== null)
  289.     {
  290.      this.postBody = {body : postBody, binary : postData.isBinary};
  291.     }
  292.    }
  293.    return this.headers;
  294.   },
  295.   getPostData : function()
  296.   {
  297.    return this.postBody ? this.postBody : null;
  298.   },
  299.   getPostBodyHeaders : function()
  300.   {
  301.    return this.postBodyHeaders ? this.postBodyHeaders : null;
  302.   },
  303.   visitResponse: function()
  304.   {
  305.    this.headers = new Array();
  306.    this.oHttp.visitResponseHeaders(this);
  307.    return this.headers;
  308.   }
  309.  };
  310.  
  311.  priv.pagegrabber = function(doc)
  312.  {
  313.   if(priv.isGaia() && priv.isMsg() && !doc.getElementById("fmt_detector"))
  314.   {
  315.    var findurl = window._content.location.href;
  316.    var textbox;
  317.    if (priv.isMsg())
  318.    {
  319.     var fmtForum    = priv.Prefs.getBoolPref("fmtForum");
  320.     var fmtGuild    = priv.Prefs.getBoolPref("fmtGuild");
  321.     var fmtPM       = priv.Prefs.getBoolPref("fmtPM");
  322.     var fmtComm     = priv.Prefs.getBoolPref("fmtComm");
  323.     try
  324.     {
  325.      if (
  326.          (!priv.isGuild() && !priv.isCom() && !priv.isPM() && fmtForum) ||
  327.          (priv.isQR() && fmtForum) ||
  328.          (priv.isGuild() && fmtGuild) ||
  329.          (!priv.isCom() && priv.isPM() && fmtPM) ||
  330.          (priv.isCom() && fmtComm)
  331.         )
  332.      {
  333.       var postBox = priv.getBox();
  334.       var postcheck = priv.trim(postBox.value);
  335.       var alreadyformed = false;
  336.       if (postcheck.indexOf('[quote]') > -1 && postcheck.substr(-8) != '[/quote]' || postcheck.indexOf('[/quote]') < 0 && postcheck.length > 0)
  337.        alreadyformed = true;
  338.       if (!doc.getElementById('fmt_skipauto'))
  339.       {
  340.        var submit_find;
  341.        var insertData = "";
  342.        var insertElement;
  343.        var beforeElement;
  344.        if (priv.isPM())
  345.        {
  346.         submit_find = priv.getElementsByAttribute('attach_sig', 'name')[0].parentNode;
  347.         beforeElement = null;
  348.         insertData = "<input name='afrmchk_" + Math.random() + "' type='checkbox' id='fmt_skipauto' />&nbsp;<label for='fmt_skipauto'>" + priv.lclDisForm + "</label>";
  349.         insertElement = window._content.document.createElement('div');
  350.         insertElement.setAttribute("class", "sig");
  351.        }
  352.        else if(priv.isCom())
  353.        {
  354.         submit_find = priv.getElementsByAttribute('Submit', 'value')[0];
  355.         beforeElement = submit_find;
  356.         insertData = "<br /><input name='afrmchk_" + Math.random() + "' type='checkbox' id='fmt_skipauto' />&nbsp;<label for='fmt_skipauto'>" + priv.lclDisForm + "</label><br /><br />";
  357.         insertElement = window._content.document.createElement('span');
  358.        }
  359.        else if(priv.isGuild())
  360.        {
  361.         submit_find = priv.getElementsByAttribute('attach_sig', 'name')[0].parentNode.parentNode.parentNode.parentNode;
  362.         beforeElement = null;
  363.         insertData = "<tr><td><input name='afrmchk_" + Math.random() + "' type='checkbox' id='fmt_skipauto' /></td><td><span class='gen'><label for='fmt_skipauto'>" + priv.lclDisForm + "</label></span></td></tr>";
  364.         insertElement = window._content.document.createElement('table');
  365.         insertElement.setAttribute("cellspacing","0");
  366.         insertElement.setAttribute("cellpadding","1");
  367.         insertElement.setAttribute("border","0");
  368.        }
  369.        else if(priv.isQR())
  370.        {
  371.         submit_find = doc.getElementById('qr_submit');
  372.         beforeElement = submit_find;
  373.         insertData = "<input name='afrmchk_" + Math.random() + "' type='checkbox' id='fmt_skipauto' />&nbsp;<label for='fmt_skipauto'>" + priv.lclDisForm + "</label>";
  374.         insertElement = window._content.document.createElement('span');
  375.         insertElement.setAttribute("style","margin: 20px 15px 0px 15px; width: 220px; height: 20px; font-size: 11px; vertical-align: middle;");
  376.         submit_find.addEventListener("click", com.RealityRipple.GaiaFormat.AutoFormat, true);
  377.         httpRequestObserver.register();
  378.        }
  379.        else
  380.        {
  381.         submit_find = doc.getElementById("post_action");
  382.         beforeElement = null;
  383.         insertData = "<div id='post_formatting' class='gaia-info nofooter'><div class='hd'><div class='rc_top_left'>&nbsp;</div><div class='rc_top_right'>&nbsp;</div><h3>Post Formatting</h3></div><div class='bd'>";
  384.         insertData+= "<input name='afrmchk_" + Math.random() + "' type='checkbox' id='fmt_skipauto' />&nbsp;<label for='fmt_skipauto'>" + priv.lclDisForm + "</label><br />";
  385.         insertData+= "</div><div class='ft'><div class='rc_bottom_left'>&nbsp;</div><div class='rc_bottom_right'>&nbsp;</div></div></div>";
  386.         insertElement = window._content.document.createElement('div');
  387.        }
  388.        if (submit_find && !doc.getElementById('fmt_skipauto'))
  389.        {
  390.         insertElement.innerHTML = insertData;
  391.         submit_find.parentNode.insertBefore(insertElement, beforeElement);
  392.         if (alreadyformed)
  393.          priv.getElementsByAttribute('fmt_skipauto', 'id')[0].checked = true;
  394.        }
  395.       }
  396.      }
  397.     }
  398.     catch(e){}
  399.     try
  400.     {
  401.      var autoArea = priv.getBox();
  402.      var autoAreaForm = autoArea.form;
  403.      autoAreaForm.addEventListener("submit", com.RealityRipple.GaiaFormat.AutoFormat, true);
  404.     }
  405.     catch(e){}
  406.    }
  407.   }
  408.  }
  409.  
  410.  pub.pagegrabber_start = function()
  411.  {
  412.   var doc = gBrowser.selectedBrowser.contentDocument;
  413.   priv.pagegrabber(doc);
  414.  }
  415.  
  416.  pub.standardLoad = function()
  417.  {
  418.   window.addEventListener('DOMContentLoaded', com.RealityRipple.GaiaFormat.pagegrabber_start,false);
  419.  }
  420.  
  421.  priv.buffer;
  422.  
  423.  pub.tablselect = function(event)
  424.  {
  425.   priv.buffer = gBrowser.getBrowserAtIndex(gBrowser.mTabContainer.selectedIndex);
  426.   setTimeout(com.RealityRipple.GaiaFormat.bufferLoad, 155);
  427.  }
  428.  
  429.  pub.bufferLoad = function()
  430.  {
  431.   if (priv.isGaia())
  432.    priv.pagegrabber(priv.buffer.contentDocument);
  433.  }
  434.  
  435.  pub.reLoad = function()
  436.  {
  437.   gBrowser.mPanelContainer.addEventListener("select", com.RealityRipple.GaiaFormat.tablselect, false);
  438.  }
  439.  
  440.  priv.isGaia = function()
  441.  {
  442.   try
  443.   {
  444.    var x = window.content.location.href;
  445.   }
  446.   catch(e)
  447.   {
  448.    return false;
  449.   }
  450.   if (x.indexOf('gaiaonline.com') > 0)
  451.    return true;
  452.   else
  453.    return false;
  454.  }
  455.  
  456.  priv.isMsg = function()
  457.  {
  458.   var x = window._content.location.href;
  459.   if (x.indexOf('compose/entry') > 0) return true;
  460.   if (x.indexOf('compose/topic') > 0) return true;
  461.   if (x.indexOf('posting.ph') > 0) return true;
  462.   if (x.indexOf('mode=post') > 0) return true;
  463.   if (x.indexOf('mode=reply') > 0) return true;
  464.   if (x.indexOf('mode=entry') > 0) return true;
  465.   if (x.indexOf('mode=comment') > 0) return true;
  466.   if (x.indexOf('comment.AddComment') > 0) return true;
  467.   if (x.indexOf('mode=addcomment') > 0) return true;
  468.   if (x.indexOf('/t.') > 0) return true;
  469.   if (x.substr(-11) == 'privmsg.php') return true;
  470.   if (x.substr(-11) == 'journal.php') return true;
  471.   if (x.substr(-18) == 'guilds/posting.php') return true;
  472.   return false;
  473.  }
  474.  
  475.  priv.isGuild = function()
  476.  {
  477.   var x = window._content.location.href;
  478.   if (x.indexOf('gaiaonline.com/guilds') > 0)
  479.    return true;
  480.   else
  481.    return false;
  482.  }
  483.  
  484.  priv.isCom = function()
  485.  {
  486.   var x = window._content.location.href;
  487.   if (x.indexOf('comment.AddComment') > 0 || x.indexOf('mode=addcomment') > 0)
  488.    return true;
  489.   else
  490.    return false;
  491.  }
  492.  
  493.  priv.isPM = function()
  494.  {
  495.   var x = window._content.location.href;
  496.   if (x.indexOf('privmsg.php') > 0)
  497.    return true;
  498.   else
  499.    return false;
  500.  }
  501.  
  502.  priv.isQR = function()
  503.  {
  504.   var x = window._content.location.href;
  505.   if (x.indexOf('/t.') > 0)
  506.    return true;
  507.   else
  508.    return false;
  509.  }
  510.  
  511.  priv.getBox = function()
  512.  {
  513.   try
  514.   {
  515.    var post  = window._content.document.getElementsByName('message').item(0);
  516.    if(!post)
  517.     var post = window._content.document.getElementsByName("form[comment]").item(0);
  518.    if(!post)
  519.     var post = window._content.document.getElementsByName("comment").item(0);
  520.    if(!post)
  521.     var post = window._content.document.getElementById("comment");
  522.    if(!post)
  523.     var post = window._content.document.getElementById('qr_text');
  524.    return post;
  525.   }
  526.   catch(e){}
  527.  }
  528.  
  529.  priv.specialFormat = function(sIn)
  530.  {
  531.   var fmtExtras  = priv.Prefs.getBoolPref("Extras");
  532.   if (fmtExtras && !priv.isPM())
  533.   {
  534.    var fmtEItems = priv.Prefs.getIntPref("EItems");
  535.    var i         = 0;
  536.    for(i = 0; i < fmtEItems; i++)
  537.    {
  538.     var sLeft    = priv.Prefs.getCharPref("ELeft["+i+"]");
  539.     var sRight   = priv.Prefs.getCharPref("ERight["+i+"]");
  540.     var sBegin   = priv.Prefs.getCharPref("EBegin["+i+"]");
  541.     var sEnd     = priv.Prefs.getCharPref("EEnd["+i+"]");
  542.     var lLeft    = sIn.indexOf(sLeft);
  543.     var lRight   = sIn.indexOf(sRight, lLeft + 1);
  544.     var lLook    = 0;
  545.     while (lLeft >= 0 && lRight > 0)
  546.     {
  547.      if(sIn.substring(0, lLeft).lastIndexOf('[url=') > sIn.substring(0, lLeft).lastIndexOf(']')){}
  548.      else if(sIn.substring(0, lLeft).lastIndexOf('[img]') > sIn.substring(0, lLeft).lastIndexOf('[/img]')){}
  549.      else if(sIn.substring(0, lLeft).lastIndexOf('[imgleft]') > sIn.substring(0, lLeft).lastIndexOf('[/imgleft]')){}
  550.      else if(sIn.substring(0, lLeft).lastIndexOf('[imgright]') > sIn.substring(0, lLeft).lastIndexOf('[/imgright]')){}
  551.      else if(sIn.substring(0, lLeft).lastIndexOf('[imgmap]') > sIn.substring(0, lLeft).lastIndexOf('[/imgmap]')){}
  552.      else if(sIn.substring(0, lLeft).lastIndexOf('[code]') > sIn.substring(0, lLeft).lastIndexOf('[/code]')){}
  553.      else
  554.       sIn   = sIn.substring(0, lLeft) + sBegin + sIn.substring(lLeft, lRight + sRight.length) + sEnd + sIn.substring(lRight + sRight.length);
  555.      lLook  = lRight + 1 + sBegin.length + sEnd.length;
  556.      lLeft  = sIn.indexOf(sLeft, lLook);
  557.      lRight = sIn.indexOf(sRight, lLeft + 1);
  558.     }
  559.    }
  560.   }
  561.   return decodeURIComponent(sIn)
  562.  }
  563.  
  564.  priv.doFormat = function()
  565.  {
  566.   try
  567.   {
  568.    var fmtBegin  = priv.Prefs.getCharPref("Begin");
  569.    var fmtEnd    = priv.Prefs.getCharPref("End");
  570.    var fmtStyle  = priv.Prefs.getIntPref("Style");
  571.    fmtBegin  = decodeURIComponent(fmtBegin);
  572.    fmtEnd    = decodeURIComponent(fmtEnd);
  573.    var post  = priv.getBox();
  574.    var postx = post.value+'';
  575.    if (!priv.isCom() && !priv.isPM() && !priv.isGuild())
  576.    {
  577.     try
  578.     {
  579.      window._content.document.getElementsByName("basic_type")[0].selectedIndex = fmtStyle;
  580.     }
  581.     catch(e){}
  582.    }
  583.    if (post.selectionStart != post.selectionEnd)
  584.    {
  585.     var topstring = postx.substring(0, post.selectionStart);
  586.     var midstring = encodeURIComponent(postx.substring(post.selectionStart, post.selectionEnd));
  587.     var endstring = postx.substring(post.selectionEnd, post.value.length);
  588.     post.value = topstring + fmtBegin + priv.specialFormat(midstring) + fmtEnd + endstring;
  589.    }
  590.    else
  591.    {
  592.     var postUp = postx.toUpperCase();
  593.     var sTmp;
  594.     var nest = 0;
  595.     var nold = 0;
  596.     var outQuote = ['0'];
  597.     var inQuote = [];
  598.     var i;
  599.     var j;
  600.     for (i=0; i < postx.length; i++)
  601.     {
  602.      if (postUp.substr(i, 6) == '[QUOTE')
  603.      {
  604.       if (nest == 0)
  605.        inQuote.push(i);
  606.       nest++;
  607.       for (j=i+1; j < postx.length; j++)
  608.       {
  609.        if (postx.substr(j,1) == ']')
  610.        {
  611.         i=j;
  612.         break;
  613.        }
  614.       }
  615.      }
  616.      else if (postUp.substr(i, 8) == '[/QUOTE]')
  617.      {
  618.       nest--;
  619.       i += 7;
  620.       if (nest == 0)
  621.        outQuote.push(i+1);
  622.      }
  623.      nold=nest;
  624.     }
  625.     if (nest == 0)
  626.     {
  627.      inQuote.push(postx.length);
  628.      sTmp = '';
  629.      for (i = 0; i < inQuote.length; i++)
  630.      {
  631.       if (inQuote[i] - outQuote[i] > 0)
  632.        sTmp += fmtBegin + priv.specialFormat(encodeURIComponent(postx.substr(outQuote[i], inQuote[i]-outQuote[i]))) + fmtEnd;
  633.       if (i + 1 < outQuote.length)
  634.        sTmp += postx.substr(inQuote[i], outQuote[i+1] - inQuote[i]);
  635.      }
  636.      post.value = sTmp;
  637.     }
  638.    }
  639.   }
  640.   catch(e){}
  641.  }
  642.  
  643.  pub.AutoFormat = function()
  644.  {
  645.   try
  646.   {
  647.    var fmtForum = priv.Prefs.getBoolPref("fmtForum");
  648.    var fmtGuild = priv.Prefs.getBoolPref("fmtGuild");
  649.    var fmtPM    = priv.Prefs.getBoolPref("fmtPM");
  650.    var fmtComm  = priv.Prefs.getBoolPref("fmtComm");
  651.    var fmtEnd   = decodeURIComponent(priv.Prefs.getCharPref("End"));
  652.    var doc  = gBrowser.selectedBrowser.contentDocument;
  653.    var post     = priv.getBox().value;
  654.    var bFormed  = false;
  655.    if (post.substr(fmtEnd.length * -1) == fmtEnd) bFormed = true;
  656.    try
  657.    {
  658.     if(!bFormed && doc.getElementById("fmt_skipauto").checked != true)
  659.     {
  660.      if (priv.isCom() && fmtComm)
  661.      {
  662.       if (fmtComm == 1) priv.doFormat();
  663.      }
  664.      if (!priv.isCom() && priv.isPM() && fmtPM)
  665.      {
  666.       if (fmtPM == 1) priv.doFormat();
  667.      }
  668.      if (priv.isGuild() && fmtGuild)
  669.      {
  670.       if (fmtGuild == 1) priv.doFormat();
  671.      }
  672.      if (!priv.isCom() && !priv.isPM() && !priv.isGuild() && fmtForum)
  673.      {
  674.       if (fmtForum == 1) priv.doFormat();
  675.      }
  676.     }
  677.    }
  678.    catch(e){}
  679.    return true;
  680.   }
  681.   catch(e){}
  682.  }
  683.  
  684.  return pub;
  685. }();
  686.  
  687. setTimeout(com.RealityRipple.GaiaFormat.reLoad, 1777);
  688. window.addEventListener('load', com.RealityRipple.GaiaFormat.standardLoad, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement