Suppose I have a website and I want to know can I inject Javascript in an already loaded JS file. like I want to console.log from an already loaded JS any way to do it?
You can add a cript tag or change the contents of an existing one:
<html> <script id="script-a"></script> <body> <div> </div> <script id="script-b"> const scriptA = document.getElementById('script-a'); scriptA.innerText = "const myLog = () => console.log('BLABLA')"; myLog(); </script> </body> </html>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.