Ah, ok. Wenn die Sprache ein Grund dagegen ist, dann bleiben wir hier.
Code
var { Services } = ChromeUtils.import(
"resource://gre/modules/Services.jsm"
);
var { MsgHdrToMimeMessage } = ChromeUtils.import(
"resource:///modules/gloda/MimeMessage.jsm"
);
var AllowHtmlTempApi = class extends ExtensionCommon.ExtensionAPI {
getAPI(context) {
return {
AllowHtmlTempApi: {
async checkMailForHtmlpart(messageId, optionsDebug) {
if (optionsDebug)
console.debug("AHT: run checkMailForHtmlpart ----------------");
let ahtMsgHdr = context.extension.messageManager.get(messageId);
// let ahtMsgHdr = gFolderDisplay.selectedMessage;
// First check MsgHdr without decrypting to prevent an additional passphrase dialog in case of PGP/MIME
let aMimeMsg = await new Promise(resolve => {
MsgHdrToMimeMessage(
ahtMsgHdr,
null,
(aMsgHdr, aMimeMsg) => resolve(aMimeMsg),
true,
{
examineEncryptedParts: false
}
);
})
// multipart/encrypted enables the button for encrypted PGP/MIME messages
// in this case we don't check for HTML, because the check seems not to be possible for PGP/MIME
if (aMimeMsg.prettyString().search("multipart/encrypted") != -1) {
if (optionsDebug)
console.debug("AHT: message is PGP/MIME multipart/encrypted");
return true;
// enableUiElements(tabId, optionsDebug);
} else {
// search for 'Body: text/html' in MIME parts,
// it seems this is only working if messages are downloaded for offline reading?
let aMimeMsg = await new Promise(resolve => {
MsgHdrToMimeMessage(
ahtMsgHdr,
null,
(aMsgHdr, aMimeMsg) => resolve(aMimeMsg),
true,
{
examineEncryptedParts: true
}
);
})
if (optionsDebug) {
console.debug("AHT: Check for html part ----------------");
console.debug("AHT: Body: text/html " + aMimeMsg.prettyString().search("Body: text/html"));
console.debug("AHT: text/html " + aMimeMsg.prettyString().search("text/html"));
console.debug("AHT: Body: plain/html " + aMimeMsg.prettyString().search("Body: plain/html"));
console.debug("AHT: plain/html " + aMimeMsg.prettyString().search("plain/html"));
console.debug("AHT: multipart/alternative " + aMimeMsg.prettyString().search("multipart/alternative"));
console.debug("AHT: multipart/signed " + aMimeMsg.prettyString().search("multipart/signed"));
console.debug("AHT: multipart/encrypted " + aMimeMsg.prettyString().search("multipart/encrypted"));
}
// 'Body: text/html' is found, enable ahtButtons
if (aMimeMsg.prettyString().search("Body: text/html") != -1) {
if (optionsDebug)
console.debug("AHT: message contains HTML body part");
return true;
// enableUiElements(tabId, optionsDebug);
}
// no 'Body: text/html', disable ahtButtons
else {
if (optionsDebug)
console.debug("AHT: no HTML body part");
return false;
// disableUiElements(tabId, optionsDebug);
}
}
}
}
}
}
};
Alles anzeigen