【发布时间】:2020-04-14 10:43:55
【问题描述】:
我只是在玩基于本教程 https://cloud.google.com/blog/products/gcp/deepbreath-preventing-angry-emails-with-machine-learning 的 chrome 扩展。
当我出于某种原因使用扩展程序时,我无法使用 gmail.js https://github.com/josteink/gmailjs-node-boilerplate 获取草稿电子邮件的正文。
使用 gmail.js 样板文件,
"use strict";
console.log("Extension loading...");
const jQuery = require("jquery");
const $ = jQuery;
const GmailFactory = require("gmail-js");
const gmail = new GmailFactory.Gmail($);
window.gmail = gmail;
/*
This code uses the Gmail library to observe emails being sent, turn them into XML,
then return a json data, body, which is put into the request and parsed with ML.
*/
gmail.observe.on("load", () => {
const userEmail = gmail.get.user_email();
console.log("Hello, " + userEmail + ". This is your Rhea talking with a new version better loading!!");
gmail.observe.on("view_email", (domEmail) => {
console.log("Looking at email:", domEmail);
const emailData = gmail.new.get.email_data(domEmail);
console.log("Email data:", emailData);
});
//var main = function () {
gmail.observe.on('save_draft', function (id, url, body, xhr) {
var draftId = url['permmsgid'];
console.log("draft saved" + draftId)
});
});
//
前两个控制台日志工作正常,因此不确定处理此问题的最佳方法。
提前致谢:)
【问题讨论】:
-
你能发布一个工作存储库吗?您提供的 repo 甚至不起作用...您在使用之前更新了一些东西吗?
标签: javascript google-chrome-extension gmail-api gmail.js