M
M
Matthew7772022-02-18 20:35:50
JavaScript
Matthew777, 2022-02-18 20:35:50

Is it possible to edit the page code with a script while it is loading?

Let's say there is a page code for a regular site. In it, I want to add a button through a tampermonkey script.
But my self-written button will be displayed only after the page is fully loaded. I am aware that it is possible to render after a full load, with scripts already applied. But the question is, is it possible to change the page code during loading, so that my button appears along with the default ones, as if it were by default? How to embed between loading html and its display.

I have little to no understanding of the page load hierarchy, so I apologize in advance for possible stupidity.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Matthew777, 2022-02-23
@Matthew777

I solved the problem by running a script with the very start of the page via // @run-at document-start, created a function for tracking the appearance of standard buttons, and actually screwed the addition of custom buttons to this self-written "event".

A
alekssamos, 2022-02-20
@alekssamos

Yes, you can. There are two events. One is onload after loading and the other is onDOMContentLoaded after DOM parsing.
The first one will be executed after loading all scripts, styles, pictures,
and the second one right after reading the HTML.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question