我正在構建一個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