Skip to content

Instantly share code, notes, and snippets.

@aereal
Created August 3, 2018 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aereal/905ace0dfaf67314fb5b007309c0aa08 to your computer and use it in GitHub Desktop.
Save aereal/905ace0dfaf67314fb5b007309c0aa08 to your computer and use it in GitHub Desktop.
(() => {
const submitBtn = document.querySelector('input[type=submit]');
let startedAt;
const flash = (ts) => {
if (!startedAt) startedAt = ts;
const elapsed = ts - startedAt;
if (elapsed > 100) {
const e = new MouseEvent('click', {
view: window,
bubbles: true,
cancelable: true,
})
submitBtn.dispatchEvent(e);
startedAt = undefined;
}
window.requestAnimationFrame(flash);
};
window.requestAnimationFrame(flash);
})();