Skip to content

Instantly share code, notes, and snippets.

@sunrise2575
Created November 26, 2021 03:26
Show Gist options
  • Save sunrise2575/4195981ef068b2145b1647752ea406cf to your computer and use it in GitHub Desktop.
Save sunrise2575/4195981ef068b2145b1647752ea406cf to your computer and use it in GitHub Desktop.
// paste into Google Chrome DevTools
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);
});
}
let target = document.querySelector("div.view-splash")
let observer = new MutationObserver(m=>{
if (target.getAttribute("class").includes('view-go')) {
simulateMouseClick(target);
}
if (target.getAttribute("class").includes('view-result')) {
simulateMouseClick(target);
}
})
let option = {attributes:true, childList: true, characterData: true}
observer.observe(target, option)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment