Remove text from a draft using scripting

When I add something to Drafts using the maildrop from my work email account, it always has a GDPR ‘banner’ at the bottom. This is true for any email sent from my work email account, and is centrally managed and so not something I can turn off.

At the moment, I have to manually remove this block of text every time I email something to Drafts.

I believe that there is a way to use scripting to automatically (or at least create an action) that will do this for me. The text is the same every time.

I’ve tried looking it up online and found that in JavaScript there is the replace() function. However, having never used JavaScript before I’m getting stuck.

The code that I’m trying to run is:


let result = text.replace("************************************************************************************** ******************************  
  
This message may contain confidential information. If you are not the intended recipient please:  
i) inform the sender that you have received the message in error before deleting it; and  
ii) do not disclose, copy or distribute information in this e-mail or take any action in relation to its content (to do so is strictly prohibited and may be unlawful).  
Thank you for your co-operation.", "");

However, when I run this I get the error:

Script Error: SyntaxError: Unexpected EOF

Line number: 1, Column undefined

Any help or advice would be greatly appreciated!

Literal string values wrapped in double quotes cannot be multiple lines in JavaScript. You would have to escape the line feeds a \n. Or, you can use backticks to make a multi-line template string, like:


let result = text.replace(`************************************************************************************** ******************************  
  
This message may contain confidential information. If you are not the intended recipient please:  
i) inform the sender that you have received the message in error before deleting it; and  
ii) do not disclose, copy or distribute information in this e-mail or take any action in relation to its content (to do so is strictly prohibited and may be unlawful).  
Thank you for your co-operation.`, "");