Skip to content
Snippets Groups Projects
Commit b29df335 authored by Igor Markin's avatar Igor Markin
Browse files

Properly remove QR code from outlook.

parent 021a76ca
No related branches found
No related tags found
1 merge request!3Fix normalisation cases
......@@ -12,57 +12,9 @@ describe("Outlook emails HTML normalization", () => {
EMAIL_VENDORS.OUTLOOK
);
describe(
"Emails Chrome",
describeFunction("chrome", [
"20",
"20forward",
"20reply",
"21",
"21forward",
"21reply",
"22",
"23",
"24",
"25",
"26",
"28",
])
);
describe(
"Emails Edge",
describeFunction("edge", [
"20",
"20forward",
"20reply",
"21",
"22",
"23",
"24",
"25",
"26",
"28",
])
);
describe(
"Emails Safari",
describeFunction("safari", [
"04",
"20",
"20forward",
"20reply",
"21",
"21forward",
"21reply",
"22",
"23",
"24",
"25",
"26",
"28",
])
);
describe("Emails Chrome", describeFunction("chrome"));
describe("Emails Edge", describeFunction("edge", ["21"]));
describe("Emails Safari", describeFunction("safari", ["04"]));
// describe(
// "Emails MacOS",
// describeFunction("macos", ["20", "21", "22", "23", "24", "25", "26"])
......
......@@ -28,6 +28,36 @@ export const pruneOutlookElement = (element: HTMLElement): boolean => {
return !!element.nodeName.toLowerCase().startsWith("o:");
};
const qrCodeContainerId = "test-for-us";
const removeQrCodeNodes = (document: HTMLDocument) => {
const remove = (node: Element) => {
let toRemove = [];
let child = node.firstChild;
while (child) {
if (child.nodeType == child.ELEMENT_NODE) {
toRemove = [...toRemove, ...remove(child as Element)];
const childElement = child as Element;
const id = childElement.getAttribute("id");
if (id && id.includes(qrCodeContainerId)) {
toRemove.push(childElement.parentNode);
}
}
child = child.nextSibling;
}
return toRemove;
};
const elementsToRemove = remove(document.body);
elementsToRemove.forEach((element) =>
element.parentNode.removeChild(element)
);
};
export const amendOutlookNodes = (document: HTMLDocument): void => {
/**
* Remove quoted text
......@@ -78,6 +108,11 @@ export const amendOutlookNodes = (document: HTMLDocument): void => {
// child = nextSibling as Node;
// }
// }
/**
* Remove QR code entries
*/
removeQrCodeNodes(document);
/**
* Get rid of attachments panes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment