title: Get the text attributes on same line in doc
body: <p>I am working on google app script and stuck in a scenario.
  I have a checkbox and it will perform </p>
  
  <p><strong>1. if checked</strong>
  than it will show all the hyperlinks in the doc in plain text.</p>
  
  <p><strong>2. if unchecked</strong> 
  than it will convert all the plain text into hyperlink.</p>
  
  <p>If user changes the color of any hyperlink (by default is blue) than on checked that text should retain its color. Its working.</p>
  
  <p>But, if there are two hyper link text in the same line, than with this code, only second text color is changed. 
  Is there any way, can we check if there are more than one hyperlink in the same line. </p>
  
  <pre><code>function removeHyperlink() {
    var Docattributes=body.getAttributes();
    var docdetails = DocumentApp.getActiveDocument();
    var Fields = doc.getNamedRanges(" Fields");
  
  
    for(var i = 0; i &lt; Fields.length; i++) {   
      var rangeElement = Fields[i].getRange().getRangeElements()[0]; 
      var startIndex = rangeElement.getStartOffset(); 
  
      var endOfIndex = rangeElement.getEndOffsetInclusive(); 
  
      var obj = rangeElement.getElement().asText().editAsText();
      var forFont= rangeElement.getElement().asText();        
      var attributes = {};
      attributes[DocumentApp.Attribute.UNDERLINE] = false;//to remove the hyperlinks
      attributes[DocumentApp.Attribute.FOREGROUND_COLOR] = '#000000'; 
      // If there are more than one hyperlink in same line
      if (startIndex &gt; 0) { 
        attributes[DocumentApp.Attribute.FOREGROUND_COLOR] =  obj.getAttributes(startIndex-1)[DocumentApp.Attribute.FOREGROUND_COLOR];
      }
  
      obj.setAttributes(startIndex,endOfIndex,attributes); 
    }
  }
  </code></pre>
  
  <p>I tried to explain this question as simple as I can. </p>