嗨我想寫一個需要閱讀電子郵件附件(普通文本)的Chrome擴展。我覺得這應該是可能的,因爲Gmail給你一個下載鏈接,但它不是一個直接的鏈接,這是否使它不可能?從Chrome擴展程序訪問Gmail附件?
我有下面的代碼讀取其中的作品只是不適合Gmail的遠程文件:
<script>
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "http://remote.com/remote_file", true);
txtFile.onreadystatechange = function() {
if (txtFile.readyState === 4) { // Makes sure the document is ready to parse.
if (txtFile.status === 200) { // Makes sure it's found the file.
allText = txtFile.responseText;
lines = txtFile.responseText.split("\n"); // Will separate each line into an array
alert(allText)
}
}
}
txtFile.send(null);
</script>
有誰知道我可以讀取Gmail附件這樣嗎? 謝謝
來自控制檯的錯誤消息? – Skomski
不幸的是沒有,但是如果我註釋掉if語句,警報只是返回一個空白警報。 –
@RichardMosse你找到了這個解決方案?這是我的擴展所必需的。 –