Skip to content

Instantly share code, notes, and snippets.

@chnbohwr
Created May 11, 2018 05:45
Show Gist options
  • Save chnbohwr/0b7bdf6ec8a54734e541417e7630f02f to your computer and use it in GitHub Desktop.
Save chnbohwr/0b7bdf6ec8a54734e541417e7630f02f to your computer and use it in GitHub Desktop.
const ele = document.querySelector('body > div.hero > div > div.test-wrapper.ng-scope > div');
let flag = true;
const mouseDownEvent = document.createEvent('MouseEvents');
mouseDownEvent.initEvent('mousedown', true, true);
const observer = new MutationObserver((mutations) => {
mutations.every((mutation) => {
if(mutation.target.classList.contains('view-go') && flag){
ele.dispatchEvent(mouseDownEvent);
flag = false;
return false;
}
return true;
});
});
const config = { attributes: true, attributeFilter: ['class'] };
observer.observe(ele, config);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment