serverHow to install Tampermonkey and a script for WebRTC debugging

Installing Tampermonkey in Chrome and adding a custom script

Installing Tampermonkey

To run user scripts in Chrome, it is convenient to use the extension Tampermonkey.

Go to the Chrome Web Store and install the extension:

After installation, click the extensions icon in the top right and pin it Tampermonkey.

circle-info

The extension is only needed to run the script in the browser. By itself, it does not eliminate WebRTC leaks.

How to add a script manually

For this guide, use the script from the Gist:

1

Open the Gist with the script

Follow the link to the Gist.

Open the file with the script and copy its contents in full.

2

Create a new script in Tampermonkey

Click the icon Tampermonkey and select Create a new script.

Delete the default template that opens in the editor.

3

Paste the script code

Paste the copied code from the Gist into the Tampermonkey editor.

Save the changes with the keyboard shortcut Ctrl + S or the button File → Save.

4

Check that the script is enabled

Make sure the new script appears in the Tampermonkey list and has the status Enabled.

How to check that the script is working

  1. Make sure the toggle for the script is enabled.

  2. Refresh the required page.

  3. Open DevTools with F12.

  4. Go to the Console.

  5. It is convenient to filter the output by labels \[TM], \[WebRTC] and \[NET].

What logs should appear

Immediately after the script starts, service messages usually appear:

If the page creates RTCPeerConnection, WebRTC logs will appear in the console:

During candidate gathering, local and remote candidates will be visible:

If the connection reached route selection, the script will show the final path:

If the site sends WebRTC data through fetch, xhr, WebSocket or sendBeacon, the script will show that too:

What to look at first

  • \[TM] WebRTC hook installed — the script loaded successfully.

  • \[WebRTC] created — the page actually created a WebRTC connection.

  • \[WebRTC] local candidate parsed — the local candidate is visible.

  • \[WebRTC] remote candidate parsed — the remote candidate is visible.

  • \[WebRTC] REAL REMOTE ENDPOINT — the most useful log. It shows the final remote endpoint chosen by WebRTC.

If there are few logs

This script adds two manual commands to the console:

The first command reprints the selected paths.

The second shows a full snapshot of candidate-pair, local-candidate, remote-candidate and transport.

Useful to check after installation

After launching the script, you can check WebRTC behavior through the services from the article How to check for a WebRTC leak.

If you want to understand the leak mechanism itself, see the article How a leak through WebRTC works.

Last updated

Was this helpful?