I'm trying to find a way to extract the HTML code of a web page using JavaScript in two editions:
Before the DOM / Before JS is applied After the DOM / After JS is applied
All the JavaScript methods that I know just take it from the DOM element, like document.body or document.all... but non of them work specifically for before or after the DOM.
Added: Just to focus the question further, this is not my page so I can't install any on the page, this is for any random web page.
Can you point me in the right direction? is there a specific method/command/process that is used in JavaScript and can do that? maybe I should stop the page load at specific point and take the code and then let it continue loading and take the code with the JS included?
Well, If you put a <script /> tag in the middle of your HTML your code will get executed before the continuation of the rest of your HTML.
also you can use
document.addEventListener("DOMContentLoaded", fn);
to call your function when the DOM is ready (it comes in the name of the event listener so sorry for over-explaination!)
Getting all the stuff is easy via the window object, can not imagine anything else you might need.
So if you want to do something before the DOM loads just put a <script /> tag at the top. if you want the dom to be ready use the DOMContentLoaded.
You can find great and complete documentation on this subject of script, async, defer on javascript.info. if there is anything that my explanation did not cover for you.