我想使用控制台点击gmail中的下一个按钮,以便我可以查看较旧的邮件。有可能吗?
我找到了他们正在使用的按钮的ID,但这似乎没有做任何事情
document.getElementById(":hc").click();
答案 0 :(得分:1)
ids似乎是动态的,但是看到旧邮件在给定代码下方尝试: -
var acc = document.getElementsByClassName("accordion");
var showMore = function(){
hideOthers();
this.classList.toggle('active');
this.nextElementSibling.classList.toggle("show");
};
var hideOthers = function(){
var elements = document.getElementsByClassName("accordion active");
for (var i = 0; i < elements.length; i++) {
elements[i].nextElementSibling.classList.toggle('show');
elements[i].classList.toggle('active');
}
}
并触发鼠标事件功能代码: -
function clickNext(id) {
var cl = document.getElementById(id);
triggerMouseEvent(cl, "mousedown");
triggerMouseEvent(cl, "mouseup");
}
在clickNext函数中传递我的情况下按钮的ID代码工作正常,我能够在gmail中看到旧邮件: -
function triggerMouseEvent (node, eventType) {
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent (eventType, true, true);
node.dispatchEvent (clickEvent);
}