1

I have written a CLI app that helps me to deploy code from code.html to a specified URL address by clicking F5 (it's configured in launch.json thorugh Powershell extension)

That command deploys my code, then opens a Chromium instance with the target page on which the code starts to run.

I want to debug this code (it's simply JavaScript embedded in HTML) in my local code.html file (setting breakpoints etc).

To do that, I have configured the described task as a prelaunchTask and then added a configuration that attaches a debugger to my running Chromium when it's ready (See below).

Everything is super cool, the browser attaches fine, but I simply can't map my local code.html to a code file(s) automatically generated at the specified URL location, because my code is not running in the same page I wrote in, but it's embedded into a remote page, which is autogenerated, i.e. I only know the URL address where it runs.

Is there a way to map the code.html file to a remote URL, so I could debug that code while running?

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "attach",
            "name": "Attach to Chrome",
            "port": 1234,
            "urlFilter": "https://somewebsite.com*",
            "webRoot": "${workspaceFolder}",
            "preLaunchTask": "deployment"
        }
    ],
}

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "deployment",
            "type": "shell",
            "command": "C:\\Something.exe",
            "args": [ someargs ]
        }
    ]
}
Movsar Bekaev
  • 888
  • 1
  • 12
  • 30
  • 1
    Seems like a better option would be to write a Chrome Extension instead. You can run the script you want by configuring the page you are visiting for the extension only to work on that site. For example, this [repo](https://github.com/ramazansancar/netflix-viewing-activity) will help you. – Ramazan Sancar Jan 04 '23 at 10:44

0 Answers0