Sleep for a certain milliseconds.
This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/482358/1296680/sleep.js
// ==UserScript==
// @name sleep
// @description Sleep for a certain milliseconds.
// @author Jason Kwok
// @namespace https://jasonhk.dev/
// @version 1.0.0
// @license MIT
// ==/UserScript==
function sleep(ms)
{
return new Promise(resolve => setTimeout(resolve, ms));
}
function sleepSync(ms)
{
const endTime = Date.now() + ms;
while (Date.now() < endTime) {}
}