Is it possible to get the sources page?

Want to get all attached js and css files to the page. Can it be done?
If Yes - by what?
I need to get all attached files to the page and then display its code.
By the way, I need(!) to use frames, so it is advisable to have captured a file with all html pages
March 19th 20 at 09:28
2 answers
March 19th 20 at 09:30
Solution
<!DOCTYPE html>
<html lang="en">
the <head>
 <meta charset="UTF-8" />
<title>Document</title>

 <link rel="stylesheet" href="/src/style.foo.css" />
 <script src="src/script.foo.js"></script>
</head>
the <body>
 <div id="nest"></div>

 <link rel="stylesheet" href="/src/style.bar.css" />
 <script src="src/script.bar.js"></script>

the <script>
 const nest = document.querySelector("#nest");
 const elems = document.querySelectorAll('link[rel="stylesheet"], script[src]');

 elems.forEach(el => {
 fetch(el.src || el.href)
 .then(r => r.text())
 .then(src => {
 const pre = document.createElement("pre");
 const hr = document.createElement("hr");

 pre.innerText = src;
nest.appendChild(pre);
nest.appendChild(hr);
});
});
</script>
</body>
</html>


a link to the document from the iframe you can get this:
const myIframeDocument = document.querySelector('iframe').contentDocument;

myIframeDocument.querySelectorAll('link[rel="stylesheet"], script[src]');
//well, then the same thing...

only if iframe on different domain, then it will be lock request due to a cors'
March 19th 20 at 09:32
document.documentElement.innerHTML;
and then parse the link[href], script[src] and iframe[src]

Find more questions by tags HTML