A User Script is a small piece of code that runs inside matching web pages. Start with a few lines, make one useful change, then learn JavaScript only as you need it.
Before running code from the internet: read it, understand what pages it matches, check storage/network behavior, and test it in a controlled Profile. These examples intentionally avoid passwords, cookies and session data.
GM API examples library
Useful GM recipes you can copy, read and adapt.
Each example is intentionally small. Start with one problem, copy the script, read every line, then change only the selectors, URLs or labels you understand.
Show a browser notification only for a meaningful event.
JavaScript · GM_notification
// @grant GM_notificationfunction notifyReady(label) { GM_notification({ title: 'Social Browser User Script', text: `${label} is ready to review`, timeout: 5000 });}// Call this only after your script detects the result.notifyReady('The report');
Before you run copied codeRead it, narrow its @match rules, review every @grant and @connect, and test it in a safe Profile first.
User Scripts CourseCourse overview
Choose a lesson or start the guided course.
Starter · Lesson 1
What a User Script actually is
Time 5 minGoal Understand what User Scripts can change
A User Script is JavaScript that the browser runs for you on pages that match rules you choose. It can make small changes to a website after the page opens: highlight information, add a shortcut, hide clutter, assist a repeated form, or react to page events.
Without a script
Open the page.
Make the same small adjustment.
Repeat it on the next visit.
With a User Script
Create the rule once.
Limit it to the right pages.
Let it run automatically when those pages open.
Why User Scripts are useful inside Social Browser
Social Browser combines User Scripts with persistent browser Profiles. A Profile can keep its own session, storage, settings and scripts, so a small customization can stay close to the browser context where you actually use it.
Important: a User Script runs code inside web pages. Install scripts only from sources you understand and trust. A useful script should be easy to read, limited to the pages it needs, and easy to disable.
Starter · Lesson 2
Create your first User Script
Time 5–10 minGoal Run a tiny script and see a page change
Start with something harmless and visible. The goal is to prove the complete flow: create → save → enable → open a matching page → see the result.
1
Open User Scripts
Open the built-in User Script manager in Social Browser and create a new script.
2
Give it a clear name
Use a name that says what the script does, such as Highlight Test Heading.
3
Choose a safe test page
Use a page you control or a harmless page where changing the display will not submit data or change an account.
Reload the matching page. If the heading gets an outline, your first script is working.
Beginner rule: one script, one visible result. Do not start by copying a 500-line script you cannot explain.
Starter · Lesson 3
Make the script run only where it belongs
Time 5 minGoal Use allowed and excluded URL rules safely
Page matching is one of the most important User Script skills. A script that should customize one dashboard does not need permission to run on every website you visit.
1
Allowed URLs
Describe the pages where the script is useful.
2
Excluded URLs
Block pages inside that area where the script should stay inactive.
3
Test both sides
Open one matching page and one non-matching page before you trust the rule.
Stage 1 completeIf your script runs only on the page you intended, you are ready to build something useful.
Builder · Lesson 4
The JavaScript you actually need first
Time 10 minGoal Read and change simple page elements
You do not need the whole JavaScript language to make useful User Scripts. Start with four ideas: find an element, read a value, change something, and respond to an event.
Need
Simple JavaScript
Find one element
document.querySelector('.price')
Read its text
element.textContent
Change text
element.textContent = 'Done'
Change a style
element.style.fontWeight = '700'
React to a click
button.addEventListener('click', handler)
Always check that an element exists before using it. Websites change, and a missing element should not crash the whole script.
Builder · Lesson 5
Use JavaScript, CSS and HTML for different jobs
Time 8 minGoal Choose the simplest tool for a page change
JS
JavaScript
Use it for logic, events, reading values and changing behavior.
CSS
CSS
Use it for appearance: hide, resize, highlight or rearrange visual elements.
HTML
HTML
Use it when the script needs a small helper panel, label or control.
Keep page changes small: adding one helper box is easier to maintain than rebuilding a website interface inside a script.
Builder · Lesson 6
Use the built-in Script Manager
Time 7 minGoal Create, find, enable and edit scripts confidently
The Script Manager is where reusable scripts should stay organized. Use clear names, keep disabled experiments separate from working scripts, and make it easy to turn a script off when you are debugging a page.
Create and edit a script.
Search or identify it by a clear name.
Enable or disable it without deleting it.
Review JavaScript, CSS, HTML and URL rules together.
Keep experimental scripts visibly named as tests.
Builder · Lesson 7
Import scripts without treating the internet as trusted code
Time 8 minGoal Import from a file or URL and review before enabling
Social Browser can create scripts manually or import them from a file or direct URL. It can also recognize common User Script installation flows. Importing is convenient, but convenience is not the same as trust.
1
Know the source
Prefer code you wrote, your team owns, or a source you can verify.
2
Read the metadata
Check the name, matching URLs and execution behavior.
3
Review the code
Look for unexpected network requests, hidden form actions, storage access or broad page matching.
4
Test in a safe Profile
Enable it on a controlled page before using it in an important browser session.
Builder · Lesson 8
Metadata tells the browser how the script should run
Time 8 minGoal Understand the settings around the code
A useful User Script is more than JavaScript. Social Browser can use script information such as the title/name, allowed and excluded URLs, menu visibility, window/frame scope, automatic execution and preload-stage execution.
Setting
Question it answers
Name / title
What does this script do?
Allowed URLs
Where may it run?
Excluded URLs
Where must it not run?
Window / frame scope
Which document context should receive it?
Automatic execution
Should it run without a manual menu action?
Preload stage
Does it need to start earlier in page loading?
Menu visibility
Should the user be able to trigger it from the script menu?
React · Lesson 9
React to the page instead of constantly checking it
Time 8 minGoal Use DOM events for simple interactions
Pages already produce events: clicks, input changes, focus, navigation and more. Listening for the event you need is usually cleaner than running a fast loop that checks the entire page over and over.
Performance rule: prefer an event or a bounded observer over a permanent high-frequency timer.
React · Lesson 10
Handle pages that change after they load
Time 10 minGoal Work with delayed and re-rendered elements
Modern websites often render content after the first page load. If your target element does not exist yet, the script can wait for it or observe a specific part of the page for changes.
Avoid arbitrary long delays. Waiting five seconds everywhere may hide the problem but makes scripts slow and unreliable. Wait for the thing you actually need, and stop waiting after a sensible limit.
React · Lesson 11
Save small preferences, not secrets
Time 7 minGoal Remember harmless script settings
A script may need to remember a harmless preference such as whether a helper panel is collapsed or which display mode you selected. Browser storage can help, but sensitive account information, passwords, 2FA secrets and session material should not be stored casually inside scripts.
Good preference data
Panel open/closed.
Rows per page.
Display option.
Treat as sensitive
Passwords.
2FA secrets.
Session/cookie material.
React · Lesson 12
Read page data first; request other data only when needed
Time 8 minGoal Keep data access simple and understandable
If the information is already in the page, read it from the DOM. If your script genuinely needs another web resource, normal browser networking rules still matter. Keep requests visible in your code and avoid sending page/account data somewhere the user did not expect.
Simple rule: if the script sends data away from the page, a reviewer should be able to see exactly what is sent and why.
Integrate · Lesson 13
User Scripts become more useful with persistent Profiles
Time 8 minGoal Understand script behavior inside separate browser contexts
A Social Browser Profile keeps its own browser context. That means you can keep account sessions and page state separate while reusing the same scripting idea where appropriate. Test a script in the specific Profile context where it will actually run.
Do not assume a script that works in one website state will automatically work in every Profile. Different sessions can show different layouts, permissions or content.
Integrate · Lesson 14
Frames and timing: run in the right document at the right moment
Time 10 minGoal Choose scope and execution timing deliberately
A page may contain the main document plus one or more frames. A script can also need normal automatic execution or an earlier preload stage. These options solve different problems, so do not change all of them when one element is missing.
Scope
Main page or frame?
Identify which document actually contains the element.
Timing
Normal or preload?
Start early only when the script truly needs to affect initialization.
Dynamic
Rendered later?
If the page creates the element later, handle the dynamic content instead of changing scope blindly.
Integrate · Lesson 15
Debug a User Script without guessing
Time 10 minGoal Find whether the problem is matching, timing, code or the website
1
Confirm the script is enabled
Do not debug code that is currently disabled.
2
Confirm the URL matches
Check allowed and excluded rules.
3
Add clear console messages
Log when the script starts and before the operation you are testing.
4
Check the target element
See whether it exists yet and whether the page re-rendered it.
5
Disable the script and compare
If the page problem remains after disabling it, the script may not be the cause.
Stage 4 completeYou can now create, scope and debug normal User Scripts inside Social Browser.
Advanced · Lesson 16
Write scripts that are easy to trust and maintain
Time 10 minGoal Reduce unnecessary access and hidden behavior
Match only the pages the script needs.
Use clear names and comments for non-obvious behavior.
Keep network destinations visible in the code.
Avoid storing sensitive account information.
Stop observers and timers when they are no longer needed.
Do not hide important side effects behind vague helper functions.
Test changes in a safe Profile before important sessions.
Keep a quick way to disable the script.
Advanced · Lesson 17
Practical User Script recipes
Time 15 minGoal Start from small reusable patterns
Recipe 1 · Highlight important valuesBeginner
Match one specific page.
Find the value elements.
Add a CSS class or style.
Do nothing if the elements are missing.
Recipe 2 · Add a page shortcutBeginner
Create one small helper button.
Insert it near the relevant area.
Listen for its click.
Perform one local page action.
Recipe 3 · Clean up a dashboardIntermediate
Hide only clearly identified visual clutter.
Keep the main page controls untouched.
Save one harmless display preference if useful.
Recipe 4 · Assist a repeated formIntermediate
Detect the form.
Fill only non-sensitive repeated values the user expects.
Leave the final submit decision visible to the user unless the workflow explicitly requires automation.
Recipe 5 · Wait for dynamic contentIntermediate
Look once for the element.
If missing, observe a narrow parent area.
Stop observing after the element appears or after a timeout.
Advanced · Lesson 18
User Script, Automation Studio, or both?
Time 8 minGoal Choose the simplest tool for the job
I want to…
Start with…
Change how one matching page looks or behaves whenever I open it
User Script
Add a small page helper or shortcut
User Script
Run an ordered multi-step browser process
Automation Studio Workflow
Run the same process across Profiles or on a schedule
Automation Studio
Keep a helpful page customization while an Automation Workflow runs
User Script + Automation Studio
Need custom page logic inside a larger workflow
Use the simplest supported combination and keep responsibilities clear
Good architecture is boring: keep persistent page customization in a User Script and workflow orchestration in Automation Studio. Do not turn one giant script into an entire automation system if the Studio already provides the workflow feature.
GM API Reference
GM APIs in Social Browser — from first use to advanced scripts
Use this when plain page JavaScript is not enoughGoal Use browser-level script capabilities safely
GM APIs give a User Script capabilities that normal page JavaScript does not always have, such as script-scoped storage, cross-origin requests, notifications, downloads, clipboard access, resources and script menu commands. In Social Browser, an explicit @grant script receives only the capabilities it asks for.
Browse by category or search by API name.
Start small: do not add every @grant line “just in case.” Ask only for the APIs the script actually uses. That makes the script easier to understand, review and trust.
For new scripts, declare every privileged API you use. Social Browser runs scripts with explicit grants in an isolated User Script world and bridges only the requested capabilities. A script with @grant none runs without GM capabilities.
Social Browser supports the familiar classic names and their modern GM.* forms for the main GM capability set. The modern form is Promise-friendly, so use await. Pick one style per script and stay consistent.
Use script information when you need to inspect the current script, version, grants, matches or Social Browser runtime information. Do not hard-code behavior around version strings unless you really need compatibility logic.
GM storage is scoped to the User Script instead of being ordinary page storage. It is ideal for harmless preferences, counters and script state. Do not use it as a casual vault for passwords, 2FA secrets, cookies or session material.
API
What it does
Typical result
GM_getValue(key, defaultValue)
Read one saved value.
The saved value or your default.
GM_setValue(key, value)
Save one value.
Updates script-scoped storage.
GM_deleteValue(key)
Remove one value.
The key disappears.
GM_listValues()
List saved keys.
An array of key names.
GM_getValues(...)
Read several values together.
An object of values.
GM_setValues(object)
Save several values together.
Updates each supplied key.
GM_deleteValues(keys)
Delete several keys.
Removes the listed values.
JavaScript · save user preferences
// @grant GM_getValue// @grant GM_setValue// @grant GM_deleteValueconst settings = GM_getValue('settings', { compact: true, rowsPerPage: 25});settings.rowsPerPage = 50;GM_setValue('settings', settings);// Reset later if the user asks for defaults.// GM_deleteValue('settings');
Watch a value change
GM_addValueChangeListener is useful when the same script is open in more than one frame or tab. The callback receives (name, oldValue, newValue, remote). In Social Browser, value-change events can synchronize across frames/tabs in the same Profile/session.
JavaScript · storage listener
// @grant GM_addValueChangeListener// @grant GM_removeValueChangeListenerconst listenerId = GM_addValueChangeListener( 'displayMode', (name, oldValue, newValue, remote) => { console.log({ name, oldValue, newValue, remote }); });// Remove it when you no longer need it.// GM_removeValueChangeListener(listenerId);
Page helpers
Add styles or small elements
GM_addStyle(css) / GM.addStyle(css)
Use this when a page customization is mostly visual. It is cleaner than setting many individual element.style properties.
Normal page fetch() is controlled by the page's normal browser/CORS rules. Social Browser's GM request API uses a dedicated browser-process request channel. Before a request is sent, its destination is checked against the script's @connect rules.
Network access deserves review. Keep destinations narrow and visible. Never send account/page data to a service the user would not expect.
The request API supports common request callbacks and returns a handle that can be aborted. Use a timeout even when you also support aborting.
JavaScript · callbacks + abort
// @connect api.example.com// @grant GM_xmlhttpRequestconst request = GM_xmlhttpRequest({ url: 'https://api.example.com/slow-report', timeout: 15000, onload(response) { console.log('Loaded:', response.status); }, onerror(error) { console.error('Request failed:', error); }, ontimeout() { console.warn('Request timed out'); }, onabort() { console.log('Request aborted'); }});// Cancel only if your script no longer needs the result.// request.abort();
Modern form:GM.xmlHttpRequest(...) and GM.xmlhttpRequest(...) map to the same request capability.
Resources
Bundle reusable text, CSS or other assets
Declare an asset with @resource, then read it by name. GM_getResourceText returns decoded text. GM_getResourceURL returns a data URL that preserves the response MIME type.
These APIs store small User Script state associated with tabs. They are useful when a script needs to remember which step or view belongs to a particular tab without mixing it with global script preferences.
Show a browser notification for something the user should actually notice. Avoid notification spam for routine script activity.
JavaScript · notification
// @grant GM_notificationawait GM_notification({ title: 'Report ready', text: 'The page data is ready to review.'});
GM_setClipboard(data, type)
Copy text (or HTML when requested) to the clipboard. Use it after a clear user action when possible, so the user understands why their clipboard changed.
unsafeWindow: bridge to page globals only when necessary
Explicit-grant User Scripts normally run in an isolated world. unsafeWindow is an opt-in bridge to globals in the page's MAIN world. Use it only when the website exposes a page variable or function that ordinary isolated script access cannot reach.
Use narrowly: page globals belong to the website and may change without notice. Prefer normal DOM APIs when they solve the problem.
Runs in the exact target frame's MAIN world with no GM capability injection.
One or more explicit @grants
Runs in a deterministic isolated User Script world; only requested capabilities are bridged.
No @grant metadata
Legacy MAIN-world compatibility mode is retained for existing Social Browser scripts.
Complete example
A small script that combines storage, styles, menu commands and clipboard
This example stays intentionally small. It remembers whether highlighting is enabled, adds one style rule, lets the user toggle it from the User Script menu, and copies a visible page value only when asked.
What this guide treats as the supported GM contract
This guide focuses on the capabilities that are part of Social Browser's current explicit @grant bridge: storage, value-change listeners, styles/elements, privileged requests, resources, tabs, notifications, clipboard, downloads, menu commands, GM_info and unsafeWindow.
Some legacy/internal names may exist for backward compatibility, but they are intentionally not presented here as recommended public APIs until they are part of the explicit capability contract. That keeps new scripts on the stable path instead of teaching accidental implementation details.
Open User Scripts quick referenceOpen when needed
Script capabilities in Social Browser
Capability
Purpose
Name / title
Identify the script clearly.
Allowed URLs
Choose where it may run.
Excluded URLs
Block specific pages from execution.
JavaScript
Add logic and page behavior.
CSS
Change page appearance.
HTML
Add small page interface elements.
Menu visibility
Control whether it appears as a user-triggered script action.
Window / frame scope
Choose which document context receives the script.
Automatic execution
Run on matching pages automatically.
Preload-stage execution
Start earlier when the script requires it.
Import from file / URL
Bring existing scripts into the manager.
Common User Script metadata
Use familiar metadata conventions where supported.
Glossary
User Script
JavaScript, optionally with CSS/HTML, that runs in selected browser pages.
Match rule
A rule that limits which URLs receive the script.
DOM
The browser's object representation of the page that JavaScript can read and change.
Event
A page signal such as a click or input change.
Frame
A document embedded inside another page.
Preload
An earlier execution stage used when normal page timing is too late for a specific need.
Profile
A persistent isolated Social Browser environment with its own browser state.
Beginner checklist
I can explain what a User Script is.
I created and disabled a test script.
I can limit a script to the correct URLs.
I can find and change a simple page element.
I know when CSS is enough.
I review imported code before enabling it.
I can use the console to debug a script.
Advanced checklist
I keep match rules narrow.
I understand dynamic pages and bounded observers.
I treat storage and network access intentionally.
I choose frame scope and timing for a reason.
I test scripts in the intended Profile context.
I know when Automation Studio is a better tool.
Open common User Script questionsOpen when needed
Do I need to be a JavaScript developer?
No. Small useful scripts often need only basic DOM selection, events and simple conditions. Learn more JavaScript when a real use case requires it.
Can a User Script include CSS and HTML?
Yes. Social Browser's User Script system can include JavaScript and, depending on the script, CSS and HTML customizations.
Can I import existing User Scripts?
Scripts can be created manually or imported from a file or direct URL, and common User Script installation/metadata conventions are supported where applicable. Review imported code before enabling it.
Are User Scripts the same as Automation Studio?
No. User Scripts are best for code that lives with matching pages. Automation Studio is designed for ordered workflows, Profile targeting, execution policy, scheduling, verification and recovery. They can complement each other.
Can scripts run in different Profiles?
User Scripts operate in browser page contexts. Test and manage them in the intended Social Browser Profile because profiles can have different sessions, content and browser state.
What is the safest way to install a script from the internet?
Know the source, read the metadata, inspect the code, check URL scope and network/storage behavior, then test in a controlled Profile before important use.
Ready to try it?
Make one page better with a tiny script.
Download Social Browser, create one test Profile, add a small User Script, and keep it simple enough that you can explain every line.