Social BrowserProfiles, IA et automatisation

User Scripts · Learn by changing real pages

Make websites work a little more like you want.

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.

Beginner-friendlyPractice in every lessonJavaScript, CSS & HTMLBuilt into Social BrowserFonctionne avec l’automatisation IA
Never written a script?Start with Lesson 1. We explain the minimum JavaScript you need.
Already use Tampermonkey-style scripts?Jump to metadata, matching, scope and Social Browser Profiles.
Want full workflows?Utilisez User Scripts avec Automation Studio et des workflows IA pilotés via MCP AI.

Working examples

Copy a tiny script. See the page change.

Start with harmless page improvements. Each example is intentionally small so you can understand every line before you use it.

Learn how to create a script →
Starter · JavaScript

Highlight an important value

Find one element and make it easier to notice.

Example
const total = document.querySelector('.total');if (total) { total.style.background = '#fff3a6'; total.style.fontWeight = '700';}

Use it for: dashboards, totals, status labels or QA pages you control.

Learn the JavaScript
Starter · CSS

Hide a distracting sidebar

Sometimes a CSS rule is all you need.

Example CSS
.promo-sidebar { display: none !important;}

Use it for: cleaner internal dashboards or pages you repeatedly review.

Learn CSS & HTML
Builder · JavaScript

Add a Copy button beside a value

Create a tiny helper instead of repeating copy/paste steps manually.

Example
const value = document.querySelector('#order-id');if (value) { const button = document.createElement('button'); button.textContent = 'Copy'; button.onclick = () => navigator.clipboard.writeText(value.textContent.trim()); value.after(button);}

Use it for: IDs, references or non-sensitive values you copy often.

Learn events
React · Dynamic pages

Wait for content that appears later

Modern pages often render after the first load. Observe only what you need.

Example
const observer = new MutationObserver(() => { const result = document.querySelector('.result-ready'); if (!result) return; result.style.outline = '2px solid #4caf50'; observer.disconnect();});observer.observe(document.body, { childList: true, subtree: true });

Use it for: SPA dashboards and delayed page widgets.

Learn dynamic pages
Integrate · Profiles

Use the same helper in separate Profiles

The script stays reusable while each Profile keeps its own browser session and page state.

Same scriptProfile A+Profile B+Profile C
  1. Create one small script.
  2. Match only the intended site.
  3. Open the site in different test Profiles.
  4. Confirm the helper behaves correctly in each context.
Learn Scripts + Profiles
Advanced · Choose the tool

User Script + Automation Studio

Keep persistent page helpers in a User Script and multi-step orchestration in Automation Studio.

User Script+Flux de travailReusable process
  1. User Script improves the matching page.
  2. Workflow performs ordered browser steps.
  3. Automation selects Profiles and execution policy.
  4. Task decides when to run.
Learn when to combine them
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.

Open the full GM API guide →
Remember a setting? StorageRead another origin? RéseauAdd a page helper? Page helpersAdd a user action? Menu commandsAlert the user? NotificationsSave a file? Téléchargements
Starter · Storage

Remember a compact-mode preference

Save a harmless UI preference and restore it on the next page load.

JavaScript · persistent preference
// ==UserScript==// @name Compact mode preference// @match https://example.com/*// @grant GM_getValue// @grant GM_setValue// ==/UserScript== const compact = GM_getValue('compact', false);document.documentElement.classList.toggle('my-compact-mode', compact); const button = document.createElement('button');button.textContent = compact ? 'Use normal mode' : 'Use compact mode';button.addEventListener('click', () => { GM_setValue('compact', !compact); location.reload();});document.body.prepend(button);
Learn GM storage
Builder · Page helper

Add a small helper panel

Inject CSS and a helper element without replacing the website layout.

JavaScript · GM_addStyle + GM_addElement
// @grant GM_addStyle// @grant GM_addElement GM_addStyle(` .sb-helper { position: fixed; right: 16px; bottom: 16px; padding: 10px 12px; background: #111827; color: white; border-radius: 8px; z-index: 2147483647; }`); GM_addElement(document.body, 'div', { class: 'sb-helper', textContent: 'Page helper is active'});
Learn page helpers
Builder · Network

Read JSON from an allowed API

Use a privileged request when the data you need is not part of the current page.

JavaScript · GM_xmlhttpRequest
// ==UserScript==// @name API status helper// @match https://example.com/*// @grant GM_xmlhttpRequest// @connect api.example.com// ==/UserScript== GM_xmlhttpRequest({ method: 'GET', url: 'https://api.example.com/status', responseType: 'json', onload(response) { console.log('Status:', response.response?.status); }, onerror(error) { console.error('Request failed:', error); }});
Learn privileged requests
React · Clipboard

Copy a page reference safely

Copy a non-sensitive value after an explicit user click.

JavaScript · GM_setClipboard
// @grant GM_setClipboard const reference = document.querySelector('#reference-id');if (reference) { const copyButton = document.createElement('button'); copyButton.textContent = 'Copy reference'; copyButton.addEventListener('click', () => { GM_setClipboard(reference.textContent.trim(), 'text'); copyButton.textContent = 'Copied'; }); reference.after(copyButton);}
Learn clipboard access
React · Menu command

Add a script action to the User Script menu

Keep optional actions out of the page UI and run them only when the user asks.

JavaScript · GM_registerMenuCommand
// @grant GM_registerMenuCommand GM_registerMenuCommand('Highlight overdue rows', () => { document.querySelectorAll('[data-status="overdue"]').forEach(row => { row.style.outline = '2px solid currentColor'; });});
Learn menu commands
Integrate · Notification

Notify when a long page task is ready

Show a browser notification only for a meaningful event.

JavaScript · GM_notification
// @grant GM_notification function 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');
Learn notifications
Integrate · Tabs

Open a related page in a background tab

Open supporting information without replacing the page the user is reviewing.

JavaScript · GM_openInTab
// @grant GM_openInTab const helpButton = document.createElement('button');helpButton.textContent = 'Open details';helpButton.addEventListener('click', () => { GM_openInTab('https://example.com/details', { active: false, insert: true });});document.body.prepend(helpButton);
Learn tab APIs
Advanced · Tab state

Remember progress for one browser tab

Keep temporary script state attached to the current tab instead of global storage.

JavaScript · GM_getTab + GM_saveTab
// @grant GM_getTab// @grant GM_saveTab GM_getTab(tabState => { tabState.reviewStep = (tabState.reviewStep || 0) + 1; GM_saveTab(tabState); console.log('Review step:', tabState.reviewStep);});
Learn per-tab state
Advanced · Download

Download a report file

Use the download capability for a file the user intentionally asked the script to save.

JavaScript · GM_download
// @grant GM_download GM_download({ url: 'https://example.com/reports/today.csv', name: 'today-report.csv', saveAs: true, onload() { console.log('Download completed'); }, onerror(error) { console.error('Download failed:', error); }});
Learn downloads
Advanced · Resource

Bundle a small text resource with a script

Reference a declared resource instead of hard-coding a large reusable text asset.

JavaScript · @resource + GM_getResourceText
// ==UserScript==// @name Template resource example// @match https://example.com/*// @resource helperTemplate https://example.com/assets/helper.html// @grant GM_getResourceText// ==/UserScript== const template = GM_getResourceText('helperTemplate');if (template) { const box = document.createElement('div'); box.innerHTML = template; document.body.append(box);}
Learn resources
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

  1. Open the page.
  2. Make the same small adjustment.
  3. Repeat it on the next visit.

With a User Script

  1. Create the rule once.
  2. Limit it to the right pages.
  3. 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.

4

Add a few lines of JavaScript

const heading = document.querySelector('h1');if (heading) heading.style.outline = '3px solid currentColor';
5

Save and enable it

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.

NeedSimple JavaScript
Find one elementdocument.querySelector('.price')
Read its textelement.textContent
Change textelement.textContent = 'Done'
Change a styleelement.style.fontWeight = '700'
React to a clickbutton.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.

SettingQuestion it answers
Name / titleWhat does this script do?
Allowed URLsWhere may it run?
Excluded URLsWhere must it not run?
Window / frame scopeWhich document context should receive it?
Automatic executionShould it run without a manual menu action?
Preload stageDoes it need to start earlier in page loading?
Menu visibilityShould 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.

const button = document.querySelector('#save');button?.addEventListener('click', () => { console.log('Save button clicked');});
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.

ProfilMatching pageUser ScriptSmall page improvement

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.

Périmètre

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
  1. Match one specific page.
  2. Find the value elements.
  3. Add a CSS class or style.
  4. Do nothing if the elements are missing.
Recipe 2 · Add a page shortcutBeginner
  1. Create one small helper button.
  2. Insert it near the relevant area.
  3. Listen for its click.
  4. Perform one local page action.
Recipe 3 · Clean up a dashboardIntermediate
  1. Hide only clearly identified visual clutter.
  2. Keep the main page controls untouched.
  3. Save one harmless display preference if useful.
Recipe 4 · Assist a repeated formIntermediate
  1. Detect the form.
  2. Fill only non-sensitive repeated values the user expects.
  3. Leave the final submit decision visible to the user unless the workflow explicitly requires automation.
Recipe 5 · Wait for dynamic contentIntermediate
  1. Look once for the element.
  2. If missing, observe a narrow parent area.
  3. 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 itUser Script
Add a small page helper or shortcutUser Script
Run an ordered multi-step browser processAutomation Studio Workflow
Run the same process across Profiles or on a scheduleAutomation Studio
Keep a helpful page customization while an Automation Workflow runsUser Script + Automation Studio
Need custom page logic inside a larger workflowUse 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.

Start here

How @grant works

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.

JavaScript · minimal granted script
// ==UserScript==// @name Remember display mode// @namespace https://example.com/my-scripts// @match https://example.com/*// @grant GM_getValue// @grant GM_setValue// ==/UserScript== const mode = GM_getValue('displayMode', 'compact');console.log('Saved mode:', mode); GM_setValue('displayMode', 'comfortable');

Classic GM_* or modern GM.*?

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.

Classic
JavaScript
const theme = GM_getValue('theme', 'dark');GM_setValue('theme', 'light');
Modern
JavaScript
const theme = await GM.getValue('theme', 'dark');await GM.setValue('theme', 'light');

GM_info / GM.info

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.

JavaScript · inspect script metadata
// @grant GM_info console.log('Script:', GM_info.script.name);console.log('Version:', GM_info.version);console.log('Handler:', GM_info.scriptHandler);console.log('Grants:', GM_info.scriptGrants);console.log('Matches:', GM_info.scriptMatches);

Storage

Remember small script data

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.

APIWhat it doesTypical 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_deleteValue const 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_removeValueChangeListener const 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.

JavaScript · inject CSS
// @grant GM_addStyle GM_addStyle(` .important-total { font-weight: 700; outline: 2px solid currentColor; padding: 4px 8px; }`);

GM_addElement(...) / GM.addElement(...)

Create a small DOM element and append it safely. You can pass a parent element first, or omit it to use the page body.

JavaScript · add a helper button
// @grant GM_addElement const panel = document.querySelector('#account-panel');if (panel) { GM_addElement(panel, 'button', { type: 'button', textContent: 'Copy account ID', className: 'my-copy-button', onclick() { const id = panel.querySelector('.account-id')?.textContent?.trim(); if (id) navigator.clipboard.writeText(id); } });}

Réseau

Make privileged requests with GM_xmlhttpRequest

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.
JavaScript · JSON request
// ==UserScript==// @match https://app.example.com/*// @connect api.example.com// @grant GM_xmlhttpRequest// ==/UserScript== const response = await GM_xmlhttpRequest({ method: 'GET', url: 'https://api.example.com/status', responseType: 'json', timeout: 10000, headers: { Accept: 'application/json' }}); console.log(response.status, response.response);

Callbacks and abort

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_xmlhttpRequest const 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.

JavaScript · @resource
// ==UserScript==// @resource helperCss https://example.com/assets/helper.css// @grant GM_getResourceText// @grant GM_getResourceURL// ==/UserScript== const css = await GM_getResourceText('helperCss');console.log(css); const dataUrl = await GM_getResourceURL('helperCss');console.log(dataUrl);

If the resource name does not exist, the API returns undefined. Keep resource names short and descriptive.

Browser helpers

Tabs, notifications and clipboard

GM_openInTab(url, options)

Open a URL in a Social Browser tab. Use active: false when the new tab should open without taking focus.

JavaScript · open a background tab
// @grant GM_openInTab GM_openInTab('https://example.com/report', { active: false});

Per-tab script state: GM_getTab, GM_saveTab, GM_getTabs

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.

JavaScript · remember state for this tab
// @grant GM_getTab// @grant GM_saveTab// @grant GM_getTabs const tabState = await GM_getTab();await GM_saveTab({ ...tabState, lastPanel: 'orders'}); const allScriptTabs = await GM_getTabs();console.log(allScriptTabs);

GM_notification

Show a browser notification for something the user should actually notice. Avoid notification spam for routine script activity.

JavaScript · notification
// @grant GM_notification await 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.

JavaScript · copy a page value
// @grant GM_setClipboard const orderId = document.querySelector('.order-id')?.textContent?.trim();if (orderId) { GM_setClipboard(orderId, 'text');}

Menus & downloads

Add deliberate user actions

GM_registerMenuCommand / GM_unregisterMenuCommand

Register a command in the User Script menu. This is a good pattern for actions that should happen only when the user explicitly asks for them.

JavaScript · menu command
// @grant GM_registerMenuCommand// @grant GM_unregisterMenuCommand const commandId = GM_registerMenuCommand( 'Highlight overdue rows', () => { document.querySelectorAll('.row.overdue').forEach((row) => { row.style.fontWeight = '700'; }); }); // Remove the menu item later if the script no longer needs it.// GM_unregisterMenuCommand(commandId);

GM_download

Start a download through Social Browser. Give the file a clear name and use this only when downloading is part of the script's visible purpose.

JavaScript · download a file
// @grant GM_download await GM_download({ url: 'https://example.com/reports/today.csv', name: 'today-report.csv'});

Advanced

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.
JavaScript · read a page global
// @grant unsafeWindow const appVersion = unsafeWindow.appConfig?.version;if (appVersion) { console.log('Page app version:', appVersion);}

Execution-world rule

MetadataBehavior in Social Browser
@grant noneRuns in the exact target frame's MAIN world with no GM capability injection.
One or more explicit @grantsRuns in a deterministic isolated User Script world; only requested capabilities are bridged.
No @grant metadataLegacy 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.

JavaScript · complete User Script
// ==UserScript==// @name Helpful order-page tools// @namespace https://example.com/my-scripts// @version 1.0.0// @match https://example.com/orders/*// @grant GM_getValue// @grant GM_setValue// @grant GM_addStyle// @grant GM_registerMenuCommand// @grant GM_setClipboard// ==/UserScript== (() => { 'use strict';  GM_addStyle(` .sb-order-highlight { outline: 2px solid currentColor; font-weight: 700; } `);  const applyHighlight = () => { const enabled = GM_getValue('highlightEnabled', true); document.querySelectorAll('.order-total').forEach((element) => { element.classList.toggle('sb-order-highlight', enabled); }); };  GM_registerMenuCommand('Toggle order highlighting', () => { const current = GM_getValue('highlightEnabled', true); GM_setValue('highlightEnabled', !current); applyHighlight(); });  GM_registerMenuCommand('Copy current order ID', () => { const orderId = document.querySelector('.order-id')?.textContent?.trim(); if (orderId) { GM_setClipboard(orderId, 'text'); } });  applyHighlight();})();

Compatibility note

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

CapabilityPurpose
Name / titleIdentify the script clearly.
Allowed URLsChoose where it may run.
Excluded URLsBlock specific pages from execution.
JavaScriptAdd logic and page behavior.
CSSChange page appearance.
HTMLAdd small page interface elements.
Menu visibilityControl whether it appears as a user-triggered script action.
Window / frame scopeChoose which document context receives the script.
Automatic executionRun on matching pages automatically.
Preload-stage executionStart earlier when the script requires it.
Import from file / URLBring existing scripts into the manager.
Common User Script metadataUse 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.
Profil
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.

Prêt à essayer ?

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.