I am creating a script for Gmail, which open Single compose Box in the Gmail page like when click on compose button. I have tried the following code but sometimes it opens multiple compose Boxes. But I want to open only one compose box when script will run. Is there any other way to open Compose Box.
var down = new MouseEvent('mousedown');
var up = new MouseEvent('mouseup');
var elem = document.getElementsByClassName("T-I-KE")[0];
elem.dispatchEvent(down);
elem.dispatchEvent(up);
You could be more robust and only dispatch the mouse events if the compose frame is not showing. The following seems to work for me.
var composeButton = document.getElementsByClassName("T-I-KE")[0];
var down = new MouseEvent('mousedown');
var up = new MouseEvent('mouseup');
function openCompose() {
if (document.querySelectorAll('.dw.np').length) {
composeButton.dispatchEvent(down);
composeButton.dispatchEvent(up);
}
}
openCompose();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.