📢 Try installing a desktop browser extension and synchronize bookmarks with your XBrowser.

Tampermonkey Script API Examples

Series Navigation

TL;DR (Quick Start)

  • X Browser: Directly open example script -> Install -> Open https://www.example.com to test.
  • Chrome: Use Tampermonkey’s “Install from URL” -> Open https://www.example.com to test.

Quick Navigation

To help everyone better understand how to use Tampermonkey script APIs, we provide a Tampermonkey script API example. The example contains usage methods for most GM functions. By running the example and combining it with the script code, we can quickly master the usage of Tampermonkey APIs.

Below we introduce the steps to install and run the example script in X Browser and Chrome respectively.

Running Example Script in X Browser

  1. Confirm that X Browser version is 3.7.8 or above. You can directly open here in X Browser to install directly.

X Browser script installation prompt dialog showing user script example

  1. Open the https://www.example.com page to prepare for testing.

After the script runs successfully, the web page you see will look like this.

  1. At the same time, X Browser’s page tools menu will add multiple options as entries for testing each API function. Each menu option corresponds to a usage method of a GM function, so we can easily understand the usage of GM functions.

X Browser page tools menu with GM API test options

Running Example Script in Chrome

  1. We assume that you have already installed the Tampermonkey extension in Chrome. Open the management panel, switch to the “Utilities” tab, and select “Install from URL”.

  2. After the script is successfully installed, also open the https://www.example.com page.

After the script runs successfully, the web page you see will look like this:

Chrome browser with Tampermonkey extension showing example script running

  1. Click the Tampermonkey extension and you will see the test options for the Tampermonkey script.

Tampermonkey extension menu displaying GM API test options in Chrome

GitHub

https://github.com/examplecode/user-script-example