Simple Windows Command line (CLI) tool to open URLs in WebView2 (Microsoft Edge web browser control).
Report Bug
·
Request Feature
·
Contribute
·
Sponsor project
·
Sponsor via PayPal
This is a Windows simple command line interface (CLI) tool for opening web page URLs in an embedded Microsoft WebView2 control. It has a variety of options to control the behavior of the window and the embedded web browser. Further, it supports customization of the output via JavaScript which allows, for example, to use it for letting the user select anything from the web page and return it as result on standard output.
Note: This tool was written by me in my spare time and will be developed only sporadically.
Note: I would like to make this tool also available on Linux some day. I have chosen WinForms initially because it was the fasted way for me to put this tool together 😃, it is open source and is still supported by Microsoft. And, I still haven't given up hope that it will eventually be available on Linux including the WebView2 wrapper control. In case WPF or MAUI should be available on Linux earlier than WinForms, the source code should be migrated. Alternatively, Avalonia UI could be considered.
-
Latest .NET SDK
winget install -e --id Microsoft.dotnet
-
Microsoft Edge WebView2 (if not already installed with the operating system)
https://go.microsoft.com/fwlink/p/?LinkId=2124703
-
Download the self-contained single executable file from the releases section
-
Copy it to a location where you can easily call it, perhaps in a folder which is in your PATH environment variable
-
Open a command prompt or PowerShell and type
WebPageHost open --help
-
Try the following simple example:
WebPageHost open https://github.com/thgossler/WebPageHost#readme
-
Try the following more complicated example:
WebPageHost open "https://github.com/trending?since=monthly&spoken_language_code=en" -z 0.7 -s 800x1024 -x "const regex = new RegExp('github.com\\/([^\\/]+\\/[^\\/]+)', 'gm'); let m = regex.exec(window.location.host+window.location.pathname); 'Selected GitHub project: '+(m !== null ? m[1] : 'none');" --ontop
-
Clone the repo
git clone https://github.com/thgossler/WebPageHost.git
-
Build
dotnet build
-
Run without arguments to get help
dotnet run
Alternatively, you can open the folder in VS Code or the solution (.sln file) in the Microsoft Visual Studio IDE and press F5.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star 😉 Thanks!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
If you are using the tool but are unable to contribute technically, please consider promoting it and donating an amount that reflects its value to you. You can do so either via PayPal
or via GitHub Sponsors.
Distributed under the MIT License. See LICENSE
for more information.