1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
var ahtFunctions = {
allowHtmlTemp: async function(tabId, infoModifiers, remoteButton) {
// RemoteContent popupmenu item clicked in remote content bar in a HTML message
if (remoteButton === true) {
consoleDebug("AHT: allowHtmlTemp: remoteButton === true");
ahtFunctions.ShowRemote(tabId);
}
// We must now differ the chosen function by modifier key (ahtKeyboardEvent).
// Addon button clicked + both CTRL and SHIFT key
else if((infoModifiers.includes("Ctrl") || infoModifiers.includes("Command")) && infoModifiers.includes("Shift")) {
consoleDebug("AHT: allowHtmlTemp: Addon button clicked + both CTRL and SHIFT key");
ahtFunctions.ShowSanitizedHTML();
}
// Addon button clicked + only CTRL key
else if((infoModifiers.includes("Ctrl") || infoModifiers.includes("Command")) && !(infoModifiers.includes("Shift"))) {
consoleDebug("AHT: allowHtmlTemp: Addon button clicked + only CTRL key");
ahtFunctions.ShowRemote(tabId);
}
// Addon button clicked + only SHIFT key
else if ((infoModifiers.includes("Shift")) && !((infoModifiers.includes("Ctrl") || infoModifiers.includes("Command")))) {
consoleDebug("AHT: allowHtmlTemp: Addon button clicked + only SHIFT key");
ahtFunctions.ShowPlaintext();
}
// Addon button clicked - no key pressed
else if (!(infoModifiers.includes("Shift") || infoModifiers.includes("Ctrl") || infoModifiers.includes("Command"))) {
consoleDebug("AHT: allowHtmlTemp: keyboard command pressed || button clicked + no key pressed");
consoleDebug("AHT: allowHtmlTemp: options.buttonHtmlMode = " + options.buttonHtmlMode);
switch (options.buttonHtmlMode) {
case "buttonMode_html":
if (options.tempRemoteContent) {
consoleDebug("AHT: html + tempRemoteContent");
ahtFunctions.ShowRemote(tabId);
} else {
consoleDebug("AHT: html");
ahtFunctions.ShowOriginalHTML();
}
break;
case "buttonMode_sanitized":
consoleDebug("AHT: sanitized");
ahtFunctions.ShowSanitizedHTML();
break;
case "buttonMode_plaintext":
consoleDebug("AHT: plaintext");
ahtFunctions.ShowPlaintext();
break;
default:
consoleDebug("AHT: default");
}
}
},
ShowPlaintext: async function() {
consoleDebug("AHT: ShowPlaintext");
try {
let updateProperties = {
msgBodyAs: "plaintext"
};
await messenger.messageContentPolicy.update(updateProperties);
} catch (e) {
console.error("AHT: Plaintext error");
}
},
ShowSanitizedHTML: async function() {
consoleDebug("AHT: ShowSanitizedHTML");
try {
let updateProperties = {
msgBodyAs: "sanitized"
};
await messenger.messageContentPolicy.update(updateProperties);
} catch (e) {
console.error("AHT: ShowSanitizedHTML error");
}
},
ShowOriginalHTML: async function() {
consoleDebug("AHT: ShowOriginalHTML");
try {
let updateProperties = {
msgBodyAs: "original",
// do not use false for attachmentsInline, but null to leave option unset if not tempInline
attachmentsInline: ((options.tempInline === true) ? true : null)
};
await messenger.messageContentPolicy.update(updateProperties);
} catch (e) {
console.error("AHT: ShowOriginalHTML error");
}
},
ShowRemote: async function(tabId) {
consoleDebug("AHT: ShowRemote");
try {
let message = await messenger.messageDisplay.getDisplayedMessage(tabId);
consoleDebug("AHT: ShowRemote: message.id = ", message.id);
await messenger.remoteContent.setContentPolicy(message.id, "Allow");
} catch (e) {
console.error("AHT: ShowRemote ERROR with remoteContent policy");
}
try {
let updateProperties = {
msgBodyAs: "original",
disableRemoteContent: false,
// do not use false for attachmentsInline, but null to leave option unset if not tempInline
attachmentsInline: ((options.tempInline === true) ? true : null)
};
await messenger.messageContentPolicy.update(updateProperties);
} catch (e) {
console.error("AHT: ShowRemote ERROR with messageContent policy");
}
}
};
|