我正在为 Mozilla Thunderbird 构建一个扩展,它可以翻译一些消息。我想添加一个翻译附件功能,尽管我在获取每个附件的内容时遇到了一些麻烦。目前,我正在进入attachmentListContext
弹出窗口,并且我有一些代码可以收集相关的附件 URI 和 URL。如何访问每个相关附件的二进制数据?
获取选定附件的当前代码:
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()?
}
},