I tried
let { setTimeout } = require('sdk/timers');
browser.webNavigation.onCompleted.addListener(setTimeout(resetSpeed, 3000));
browser.webNavigation.onHistoryStateUpdated.addListener(setTimeout(resetSpeed, 3000));
(...)
it didn't work. Another try:
browser.webNavigation.onCompleted.addListener(resetSpeed);
browser.webNavigation.onHistoryStateUpdated.addListener(resetSpeed);
function resetSpeed() {
await new Promise(r => setTimeout(r, 2000));
(...)
That didn't work also.
Without the sleep function, my code used to automatically speed up audio/videos on page load works ~25% of the time, and 100% of the time when I run it with my custom key-press combination. I want to add sleep functionality to get it to 100% as I think it runs way too quickly.
My permissions:
"permissions": [
"contextMenus",
"tabs",
"<all_urls>",
"http://*/*",
"https://*/*",
"file:///*/*",
"webNavigation"
]