Greasy Fork is available in English.

sleep

Sleep for a certain milliseconds.

Dette scriptet burde ikke installeres direkte. Det er et bibliotek for andre script å inkludere med det nye metadirektivet // @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) {}
}