Skip to content

Instantly share code, notes, and snippets.

@LiF-Lee
Created November 23, 2023 01:54
Show Gist options
  • Save LiF-Lee/170bbf6b6fe74d22a057a3bfb236489a to your computer and use it in GitHub Desktop.
Save LiF-Lee/170bbf6b6fe74d22a057a3bfb236489a to your computer and use it in GitHub Desktop.
Scheduled callback
(async (ScheduleDate, Callback) => {
const Log = (text, color) => console.log(text, `color: ${color}`);
Log(`Scheduled callback at %c${ScheduleDate.toLocaleString()}`, 'red');
const CheckTime = () => Date.now() >= ScheduleDate.getTime()
? (Log(`Scheduled callback executed at %c${new Date().toLocaleString()}`, 'green'), Callback())
: requestAnimationFrame(CheckTime);
requestAnimationFrame(CheckTime);
})(new Date('2023-11-23 10:38:50'), () => {
const Query = '#app > div > a';
document.querySelector(Query).click();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment