Skip to content

User Scripts

Creating User Scripts

What Are User Scripts

User scripts are JavaScript code snippets injected into matching web pages by PageMod. They can modify page appearance, add new features, automate actions, and more. Scripts generated by PageMod are fully Tampermonkey-compatible.

  1. Open the target web page you want to modify or enhance.
  2. Click the PageMod icon in the toolbar and select "Open Side Panel" (or use the keyboard shortcut).
  3. In the side panel's Chat tab, describe your needs in natural language. Examples:
    • "Remove all popup ad banners on this site"
    • "Redesign Hacker News as a modern card UI"
    • "Auto-expand all collapsed content on this page"
    • "Remember my form info and auto-fill next time"
  4. The AI will analyze the current page, generate a user script, and enter preview mode.
  5. In preview mode, the script takes effect immediately so you can see results in real time. If unsatisfied, continue refining in the chat.

Method 2: Manual Coding

  1. Write JavaScript code directly in the Editor tab.

Managing Scripts

Viewing the Script List

On the settings page (right-click PageMod icon → Options), you can see all installed scripts. Each shows its name, version, match rules, and status.

Enabling & Disabling Scripts

In the script list, each script has an enable/disable toggle. When disabled, the script won't run on any page, but its code and settings are preserved. You can also toggle scripts directly in the side panel editor.

Manual Editing

  1. Switch to the Editor tab in the side panel.
  2. Select the script to edit from the dropdown.
  3. The editor provides JavaScript syntax highlighting, autocomplete, and bracket matching.
  4. Code is auto-saved as a draft, with live preview updating after a 1-second debounce.
  5. You can also click a script on the settings page to enter full-screen editing mode.

Script Settings

Each script can be individually configured:

  • Name / Description / Version: Script identity; version affects update detection.
  • Match Rules (@match): Controls which pages the script runs on. Supports standard match patterns (e.g., https://example.com/*).
  • Exclude Rules (@exclude): Excludes specific pages from script execution.
  • Run At (@run-at): When the script executes — document_start (earliest), document_body, document_end, document_idle (default).
  • @grant Permissions: GM API permissions required by the script. The script can only call GM_* functions after checking the corresponding box.
  • @require External Libraries: Reference external JS library URLs (e.g., jQuery).
  • @resource Assets: Declare external resource files available to the script.

Previewing & Publishing Scripts

  1. Auto-preview after AI generation: When the AI creates or modifies a script, it automatically enters preview mode and takes effect on matching pages.
  2. Manual preview: After editing code in the editor, the preview auto-updates within 1 second.
  3. Publish: Once satisfied, click the "Publish" button in the editor. The preview version replaces the official version.
  4. Undo: If the preview is unsatisfactory, click "Undo" to revert to the pre-modification version.
  5. Auto-cleanup on close: Unpublished preview scripts are automatically cleaned up when the side panel closes, restoring the original script.

Deleting Scripts

Find the target script in the list and click the delete button. Deletion removes the script code and configuration from local browser storage. Deleted scripts cannot be recovered; we recommend using the backup feature beforehand.