title: Edit clipboard text without losing format style and run script continuously
body: <p>I'm using this AppleScript to edit my clipboard data. But there are some things I couldn't figure out how to do:</p>
  
  <ol>
  <li><p>This script removes the whole format-style of the text in the clipboard. Is there a way to preserve all the formats?</p></li>
  <li><p>I tried to run this script as an application (with stay open checked on saving) but it just works once after a fresh start and doesn't edit any new copied text. How can I get this script to run continuously?  </p></li>
  </ol>
  
  <p>Here's my script:</p>
  
  <pre><code>on idle
  
      get the clipboard
      replacement of "SqlConnection" by "OleDbConnection" for the result
      replacement of "SqlDataAdapter" by "OleDbDataAdapter" for the result
      set the clipboard to (replacement of "SqlCommand" by "OleDbCommand" for the result)
  
  end idle
  
  on replacement of oldDelim by newDelim for sourceString
      set oldTIDs to text item delimiters of AppleScript
      set text item delimiters of AppleScript to oldDelim
      set strtoks to text items of sourceString
      set text item delimiters of AppleScript to newDelim
      set joinedString to strtoks as string
      set text item delimiters of AppleScript to oldTIDs
      joinedString
  end replacement
  </code></pre>