Introduction

Build Status

Instant WebView is a scriptable WebView for developers.

The WebView uses the QtWebEngine (which is based on Chromium) to render the HTML content. There is also a simple protocol to get data, send commands and listen for events: through Unix Socket, TCP or WebSocket. The window of WebView does not have any UI component what you see in a standard web browser like an address bar, status bar, navigation buttons, etc.

Use Cases

Building

Before building Instant WebView you need to install GCC 6, Qt and QtWebEngine 5.6 on the system.

qmake PREFIX=/usr
make
make install

Usage

instant-webview

The WebView itself.

Usage: instant-webview [options]
Instant WebView is a scriptable WebView for developers.

Options:
  -h, --help                                  Displays this help.
  -v, --version                               Displays version information.
  -t, --transport <tcp|unixsocket|websocket>  IPC Transport Layer to use.
  -r, --reverse <ID>                          Enable reverse mode. The ID is
                                              used to identify your session in
                                              the server.
  -s, --script <path>                         Script to run.

Example:

instant-webview -t unixsocket:/tmp/instant-webview

instant-webview-ctl

A utility to interact with the WebView.

Usage: instant-webview-ctl [options] command
Instant WebView is a scriptable WebView for developers.

Options:
  -h, --help                                  Displays this help.
  -v, --version                               Displays version information.
  -t, --transport <tcp|unixsocket|websocket>  IPC Transport Layer to use.

Arguments:
  command                                     Command to execute. Pass "-" to
                                              read from stdin.

Example:

echo "open maximized" | instant-webview-ctl -t unixsocket:/tmp/instant-webview -

Commands

Instant WebView reads commands from TCP, Unix Socket or WebSocket. Each command starts with the name of a command and is terminated by a newline. Empty line are interpreted as end of connection.

If the command starts with @ the command is marked as single-shot.

Due to the simplicity of the protocol, it is possible to interact with the WebView using the command-line utility GNU Netcat. However, there is instant-webview-ctl utility that can be used to interact with the WebView, so you don't need extra tools to interact with the WebView.

Simple example using the GNU Netcat utility to demonstrate how simple is the protocol:

echo "open maximized" | nc -U /tmp/instant-webview
echo "load http://google.com" | nc -U /tmp/instant-webview

In the below example a maximized window is open and the http://google.com is loaded.

Single-shot commands

Single-shot commands might be used to wait until command response is received. It might be useful to get data from the WebView using both instant-webview-ctl and GNU Netcat utility.

URL=$(echo "@current_url" | instant-webview-ctl -t unixsocket:/tmp/instant-webview)
echo "The current URL is $URL"

Command response

The response of a command may vary according the type of command. If the command is marked as single-shot, the response only contains the returned data from the command, otherwise it is not a single-shot command, the response is composed of the command name and returned data, separated by space.

Note that not all commands have a response.

Navigation

Window

Page

Content

Events

Available events

Instant WebView