我正在构建一个Mozilla Thunderbird的扩展,它可以对消息进行一些翻译。我想添加翻译附件功能,尽管我在查看每个附件的内容时遇到了一些问题。目前,我正在接入attachmentListContext
弹出窗口,并且我有一些代码收集相关的附件URI和URL。如何访问每个相关附件的二进制数据?如何获取Mozilla Thunderbird扩展中的附件内容?
当前代码获取所选的附件:
handleAttachmentTranslate : function() {
// see code in msgHeaderViewOverlay.js in Thunderbird source
var attachmentList = document.getElementById('attachmentList');
var selectedAttachments = new Array();
for (var i in attachmentList.selectedItems) {
var attachment = attachmentList.selectedItems[i].attachment;
// we can now access attachment.url or attachment.uri, etc
selectedAttachments.push(attachment.url);
// or (ideally)
// alert(this.translate(getData(attachment.url)))
// but what is getData()?
}
},
好的。我看着FiltaQuilla代码,它不提取附件,因此它不相关。 – minghua 2011-03-25 06:18:11