如何在Gmail中触发新的撰写电子邮件

时间:2019-05-15 10:06:45

标签: javascript google-chrome gmail

我正在为Gmail编写Chrome扩展程序时,除了我的上一个任务:从Popup调用/触发一封新的撰写电子邮件外,几乎所有工作都已完成,因为我仍在寻找正确的方法为此。

一些注意事项:

  • 我已经能够将MESSAGE从弹出脚本发送到内容脚本。内容脚本本身会正确接收MESSAGE。

这是我的内容脚本的示例代码:

if (request.message === 'FROM_POPUP.NEW_EMAIL') {

   // Trying to get the Compose button on current page
   // The selector is just for illustration purpose. In real code it
   // would take a bit to find and decide the correct one.
   const button = document.querySelector('button[Compose]')

   // Trigger clicking event on Compose button
   button & button.click();

}

到目前为止,这是我的方法,但是某种程度上新的撰写邮件没有显示出来。有什么合适的方法可以解决这个问题吗?

预先感谢

0 个答案:

没有答案