No Login Data Private Local Save

Tampermonkey Script Skeleton - Online UserScript Generator

12
0
0
0
Copied to clipboard!

Tampermonkey Script Generator

Generate a complete userscript skeleton with metadata, grants, and ready-to-use code templates.

Basic
Empty skeleton
DOM Ready
Wait for page load
API Request
GM_xmlhttpRequest
Style Override
Inject custom CSS
Basic Information
@match URL Patterns

Define which pages the script should run on.

All Sites HTTPS Only *.google.com *.youtube.com
@grant Permissions

Select the GM_* APIs your script needs.

Execution Options
Advanced Options

userscript_preview.user.js
// ==UserScript== // @name My Awesome Script // @namespace http://tampermonkey.net/ // @version 1.0.0 // @description A userscript that enhances browsing experience. // @author You // @license MIT // @match *://*/* // @run-at document-idle // ==/UserScript== (function() { 'use strict'; // Your code here... })();

Frequently Asked Questions

Tampermonkey is a popular userscript manager browser extension available for Chrome, Firefox, Safari, and Edge. It allows you to run custom JavaScript (called "userscripts") on specific websites to modify their behavior, add features, automate tasks, or change their appearance. Each script includes metadata headers (like @name, @match, @grant) that tell Tampermonkey when and how to execute the script.

@match uses a strict pattern-matching syntax defined by Chrome's Match Patterns specification — it's more predictable and secure. @include is the older Greasemonkey-style glob pattern that's more flexible but less strict. Tampermonkey recommends using @match whenever possible. Our generator defaults to @match patterns for better compatibility and security.

@grant declares which special GM_* APIs your script needs access to (like GM_setValue for storage or GM_xmlhttpRequest for cross-origin requests). This is a security feature — scripts can only use the APIs they explicitly request. If no @grant is specified, the script runs in the page's context without access to GM APIs. You can also use @grant none explicitly.

After generating your script with this tool: 1) Click "Download .user.js" to save the file. 2) Open Tampermonkey's dashboard in your browser. 3) Drag and drop the downloaded file onto the dashboard, or use the "Utilities" tab to import from file. 4) The script will be installed and active immediately. You can also copy the code and paste it directly into Tampermonkey's "Create new script" editor.

document-start executes before any page scripts or DOM is loaded — ideal for blocking content or polyfills. document-end fires right after the DOM is ready but before images/iframes finish loading. document-idle (the default) waits until the page is fully loaded and idle — best for most DOM manipulation tasks. Choose based on when your script needs to interact with the page.

Open your browser's Developer Tools (F12) and go to the Console tab. Your userscript's logs and errors will appear there. Tampermonkey also has its own script editor with a built-in linter. Use console.log() for debugging output. For advanced debugging, you can add debugger; statements in your code to set breakpoints. The GM_log() function also writes to Tampermonkey's internal log if granted.

Yes! Use the @require directive to include external libraries. For example, add // @require https://code.jquery.com/jquery-3.7.1.min.js to your metadata block. The library will be loaded before your script runs. You can add multiple @require lines for different libraries. Our generator's "Advanced Options" section lets you add any number of @require URLs.

@connect whitelists domains that your script can make requests to via GM_xmlhttpRequest. Without it, cross-origin requests to domains not listed in @connect will fail. You can specify exact domains like api.example.com or use wildcards like *.example.com. This is a security measure to prevent malicious scripts from exfiltrating data to unknown servers.
Pro Tips
  • Always test your script on a small set of URLs before expanding the @match pattern to all sites.
  • Use 'use strict'; at the top of your code to catch common JavaScript errors early.
  • Wrap your entire script in an IIFE (function(){ ... })(); to avoid polluting the global namespace.
  • When using GM_xmlhttpRequest, always handle both onload and onerror callbacks for robust error handling.
  • Keep your @version updated so Tampermonkey can notify users of updates when using @updateURL.