K
K
Krott1362021-09-28 14:40:36
Mozilla Firefox
Krott136, 2021-09-28 14:40:36

How to run an addon in firefox before the page is loaded?

I need to write an add-on that fires as soon as possible before the page loads. To do this, I registered in the manifest "run_at": "document_start". In a js file, I create an interval and try to catch it at the moment, in chrome it works instantly, and in firefox after a while. How can this be fixed?

let div3 = document.createElement("div");
div3.style.position = "absolute";
div3.style.width = "50%";
div3.style.height = "50vh";
div3.style.top = "50%";
div3.style.left = "50%"
div3.style.backgroundColor = "green";
div3.style.zIndex = "100";

let all = setInterval( () => {
    try {
        document.querySelector('body').appendChild(div3);
    } catch (err) {}
}, 1);
setTimeout(() => { clearInterval(all);}, 1000);

What are the features of developing add-ons in firefox that are worth considering?
I also tried to do it through Tampermonkey and wrote it there // @run-at document-start. But the result is the same, in Google everything is fine in FF with a delay.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question