2

I found this question in stackoverflow, which is a bit similar but did not help me.

I would like to find some extension/plugin for vscode that would inject a JS and CSS code into a given URL.

For example, after setting a url in vscode, I create a js and when saving the file this script is injected into google chrome in the url mapped or in the tab that is open in chrome.

There is an extension to chrome that does just that: User JavaScript and CSS

Gama11
  • 31,714
  • 9
  • 78
  • 100
Paiva83
  • 23
  • 3

1 Answers1

1

This is non-trivial but definitely possible.

I sadly cannot provide you with all the necessary information as I am not sufficiently familiar with the way VSCode extensions function.

First of all, there is this project which you should take a look at. It's source code will have useful information.

Alternatively, and my personal recommendation, you should go with abusing the remote debugger which chrome provides. This project is a good example of how it can be used. It connects to the chrome remote debugger and exposes a REPL.

There is readily available documentation on how to use the remote debugger to execute arbitrary javascript.

The next part will be to make an actual extension which takes the above, ties it together and listens to a "on file save" event or something of the sort.

Slava Knyazev
  • 5,377
  • 1
  • 22
  • 43