Skip to content

Instantly share code, notes, and snippets.

@vinhjaxt
Created February 2, 2025 10:02
Show Gist options
  • Save vinhjaxt/940d7dea88291e351936725700af5401 to your computer and use it in GitHub Desktop.
Save vinhjaxt/940d7dea88291e351936725700af5401 to your computer and use it in GitHub Desktop.
Gmail delete all mail (to trash)
var delay = ms => new Promise(resolve => setTimeout(resolve, ms))
function simulateMouseClick(targetNode) {
function triggerMouseEvent(targetNode, eventType) {
var clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent(eventType, true, true);
targetNode.dispatchEvent(clickEvent);
}
["mouseover", "mousedown", "mouseup", "click"].forEach(function(eventType) {
triggerMouseEvent(targetNode, eventType);
});
};
(async function a(){
while(true){
try{
var a = document.querySelector('div[role="toolbar"]').nextElementSibling.querySelector('span[role="checkbox"]')
if (a.attributes.getNamedItem('aria-checked').value != "true") a.click()
simulateMouseClick(document.querySelector(`[aria-label="Xóa"]`))
}catch(e){
console.error(e)
}
await delay(1000)
}})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment