我的 Chrome 扩展程序如何侦听 Gmail 中打开的 Compose window?

How can my Chrome extension listen for the Compose window opening in Gmail?

我正在为 Gmail 写一个 Google Chrome 扩展,它修改了 Compose window。每当我刷新页面并在页面刷新后打开 Compose window 时,它都能正常工作,但下次我打开 Compose window(没有 Gmail 刷新)时,内容脚本无法加载。我的内容脚本是这样开始的:

updateContent.js:

document.addEventListener('DOMContentLoaded', addUpdateButton, true);

addUpdateButton();

.
.
.

很明显,监听 DOMContentLoaded 不是我想要的,那我监听什么呢?我清单的相关部分如下所示:

"content_scripts": [
{"run_at": "document_end",
 "matches": ["https://mail.google.com/mail/*"],
 "js": ["updateContent.js", "colorHeaders.js", "renderContent.js", "sendOptions.js", 
 "base64.js", "jsaes.js"]
}
],

我通过将以下代码添加到我的内容脚本之一解决了我的问题:

            // Listen for Compose button-click
        var composeButton = document.getElementsByClassName('T-I J-J5-Ji T-I-KE L3');
        composeButton[0].addEventListener("click", addUpdateButton);

我在函数底部添加了代码,该函数仅在页面加载完成后调用(我每 200 毫秒检查一次加载是否已完成)。