Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# plugin for Google Chrome

Can I communicate to Google Chrome in C#?

For writing a chrome plugin for example.

like image 754
Tony The Lion Avatar asked Dec 10 '09 14:12

Tony The Lion


1 Answers

What I have done to address is use Simple Message Host, it will trigger an executable on the local machine that you code in c#, sending stdin messages and listening to stdout messages so you can build this host to use as a bridge, but like I said, it needs to be on your local network at least, and you have to do some editing in the windows registry, so it has its limitations.

But for the system I am working with, this solution worked perfectly because I have a controlled environment that I can set up all these prerequisites.

So, just to clarify, what I did here is:

  1. Create a chrome extension with background.js opening up the listener to the website's javascript.

  2. Add a registry in windows registry pointing to the path of the executable.

  3. Create the executable in C# doing all your logic.

  4. Send a response from the executable to the extension and then back to the website.

There are several guides on how to do this, so I won't detail these steps here so I don't replicate it.

But for the moment, it is the best way to do what you want, if you have control of your environment that is.

So, if your plugin (extension or chrome app) will work on a controlled environment, this is the way to go, otherwise, I would consider something related to ClickOnce perhaps or WebAssembly but that's not fully released yet.

like image 64
Zorkind Avatar answered Oct 12 '22 00:10

Zorkind