Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Add functions to remove text / tags from quoted parts #31
The functions %replaceText% and %deleteText% only work in the template and quote header, but not in the quoted email when replying. We need some functions to remove (or replace) text / html from quoted material.
I think it is also important to specify a minimum quote level starting with
This way it could be used to remove images from older emails in a thread to conserve disk (and server) space.
Proposal for 4 new functions:
1 - replace all images containing attribute moz-do-not-send=false from 2nd quote level onwards and replace with [SNIPPED]
2 - remove the sentence "Message received from external source." from quotes:
Here is a first trial version which implements the variable
Here is a test template:
To install, unzip the contained xpi file and drag into extensions manager. (github doesn't accept xpi in issues)
OK, next I have implemented the function
For instructions on how to install / regular expressions use, please read the previous comment.
OK, I added 2 more functions, just tested them. These are for removing tags (mainly images) from quoted mails:
Here is a nice example:
(drag unzipped contents into Add-on manager to install)
Quote level calculation was slightly off, here is a new improved version
I added an additional parameter minSize for replacing / removing tags:
selector - what you would use to address the tag in css. simplest case "img", or "p" but attribute selectors can be added as long as double quotes can be avoided.
replacementHTML - must be in double quotes - text or a html tag which will be inserted in plage.
quoteLevel - optional, (number) which minimal quote level to start from quoteLevel - for images I would recommend 2 if you want to remove images to retain some context in your replies.
minSize - (optional, numeric) - number of kByte, minimal size for removing the tag. This way you can keep smaller images like icons / emojis while discarding large images.
To Do: create a section in the "Variables" tab on the settings dialog
Please make sure to test relentlessly.
A little problem with the minSize parameter (mostly relevant to images) is that apparently large images can be "not yet loaded" when composer opens (I see a class "loading-internal" and the src is abbreviated, so no valid size can be calculated). So I remove them anyway in that case in %replaceQuotedTags%. But I feel this should be handled by either a global setting or there should be some way to tell the variable in the parameters. Not quite sure how yet because I am very reluctant to add yet another parameter...