Tweak script reference
A Dea tweak is a local JavaScript file with a userscript metadata header. Dea loads enabled files from its Tweaks directory and executes matching code in the website's main JavaScript world. Read Dea Tweaks for an overview or the walkthrough for installation and management.
Files and execution#
Use the OS Documents directory, under Dea/Tweaks/. Dea reads nonhidden .js files, including .user.js. Settings, enabled state, and this directory are shared across profiles and workspaces.
Only HTTP and HTTPS website pages are eligible. Dea's own app pages are excluded. Code is selected on page load; editing or disabling a file takes effect on the next load. There is no automatic script-update service.
Each tweak runs inside a function wrapper. Its declared variables are local to that invocation; DOM changes and event listeners still affect the page. This is not an extension isolated world or a Node.js context. Normal browser APIs and page rules apply.
Metadata header#
// ==UserScript==
// @name Example heading
// @description Underlines the heading on Example Domain.
// @match https://example.com/*
// @exclude https://example.com/account/*
// @run-at document-end
// ==/UserScript==
GM_addStyle('h1 { text-decoration: underline; }');| Key | Meaning |
|---|---|
@name | Display name. Defaults to the filename if absent. |
@description | Description shown in Tweaks. |
@match | A URL match pattern. May be repeated. |
@include | Whole-URL glob or /regex/flags. May be repeated. |
@exclude | Whole-URL glob or /regex/flags that prevents execution. May be repeated and takes precedence. |
@run-at | document-start, document-end (default), or document-idle. |
@grant dea.judge | Requests the optional Jev judgment helper. Other grant names do not add APIs. |
At least one @match or @include must match, and no exclusion may match. Without a valid positive rule, the script runs nowhere.
URL rules#
@match has the form scheme://host/path:
| Pattern | Matches |
|---|---|
https://example.com/* | HTTPS pages on that hostname. |
https://*.example.com/* | That hostname and its subdomains. |
*://example.com/reports/* | HTTP or HTTPS report paths on that hostname. |
<all_urls> | All HTTP and HTTPS websites. Use only when that scope is intended. |
The path rule includes the URL's query string. Host matching uses the hostname; to restrict a local development port, use a whole-URL include such as @include http://localhost:3000/*.
@include and @exclude globs use * as a wildcard over the whole URL. Regex forms support i, m, s, and u flags. Keep rules narrow enough that the script will not affect an unrelated account, site, or page.
Run times and dynamic pages#
| Value | Execution time |
|---|---|
document-start | As the page starts, possibly before a head or body exists. |
document-end | At DOMContentLoaded, after the HTML is parsed. Images and later app content may still be loading. |
document-idle | Shortly after the page load event. |
Single-page apps can replace their content without a new page load. A script is not automatically reinjected for every in-app navigation. Use stable observed selectors, handle route changes when needed, and make injected controls idempotent so they are not duplicated.
For content inserted later, a scoped MutationObserver can watch the relevant container. Disconnect observers when they are no longer needed and avoid repeatedly observing changes the script itself creates. Styling persistent selectors with CSS can be enough when no JavaScript behavior is needed.
Supported helpers#
| API | Behavior |
|---|---|
GM_addStyle(css) or GM.addStyle(css) | Creates and returns a style element. Waits for a document root when used at document-start. |
GM_info or GM.info | Metadata object containing script.name and scriptHandler: "Dea". |
unsafeWindow | The page's window. |
dea.judge(question, itemOrItems) | Optional asynchronous Jev judgments; requires @grant dea.judge. |
The script can use page APIs such as document, timers, fetch, and localStorage. Storage belongs to the website's origin and browser profile; it is shared with that website's own code. localStorage is not a separate private tweak store. Browser CORS rules still apply to requests.
Optional Jev judgments#
Configure a TypeSafe key under Settings → Jev. Declare @grant dea.judge in the header. The helper returns the probability, between 0 and 1, that the answer to a yes/no question is yes.
Example usage inside a granted script, with a text value already extracted from the page:
(async () => {
const main = document.querySelector('main');
if (!main) return;
const p = await dea.judge(
'Does this text describe an urgent service outage?',
main.innerText.slice(0, 1000)
);
if (p === null) return; // Unavailable: leave the page unchanged.
if (p > 0.8) main.dataset.deaUrgent = 'true';
})();The selector and question are illustrative. Use a real observed content region and a question relevant to the person's request. This snippet records a DOM marker; styling or a visible label would be a separate script choice.
Pass an array of texts to get an array of probabilities or null entries. Supported items can also be { text, image }, with an image URL for the optional image path. Image retrieval and classification can fail; handle an unknown result.
Current request limits are 100 items, 1000 characters per item's text, and 500 characters for the question. The helper also applies a per-tab allowance. Batch relevant items, avoid repeated classifications of unchanged content, and treat null as unknown rather than “no.” Use an async IIFE because the script wrapper does not allow bare top-level await.
Supplied content is sent to TypeSafe. Request only the content needed for the customization. The API key stays in Dea rather than being passed to the tweak's page code. The uses Jev label describes the declared grant; it does not guarantee that a call will succeed.
Report progress to an agent#
A running tweak can send an event through Dea's page message bridge:
window.dea.send({
tweak: GM_info.script.name,
event: 'finished',
done: 5
});Here, done: 5 is an example count: report the actual verified number. Send useful states such as started, progress, stuck, or finished. An agent can use get_events or wait_for_event with kind: "message" and a relevant text filter, retaining a sequence cursor when a fast completion could otherwise be missed.
This reports status to the connected agent; it does not restart a closed agent or turn the script into a durable scheduled job.
Compatibility limits#
Dea supports userscript-style headers and a small helper surface. It does not implement every Tampermonkey API:
| Unsupported API or metadata | What to use or expect |
|---|---|
GM_setValue, GM_getValue, GM_deleteValue | Website storage where appropriate, subject to the site's origin/profile boundaries. |
GM_xmlhttpRequest | Normal fetch, subject to browser rules. |
GM_notification, GM_openInTab, GM_registerMenuCommand, GM_setClipboard | Normal page APIs or an explicit on-page control, with normal browser permissions. |
@require, @resource, @connect, @noframes, @version, @updateURL | Ignored. Keep required code in the script file and manage updates locally. |
User-triggered clipboard or window operations may require an actual user gesture. A script from another manager may need changes before it works in Dea.
Errors and recovery#
Initial execution errors log as [Dea tweak: <name>]. Later errors in timers, callbacks, or asynchronous work can appear as ordinary page errors. DevTools identifies injected source as dea-tweak:<name>.
If a tweak causes problems, disable it in Tweaks and reload the page. Disable or removal does not reverse website writes or persistent storage changes the script already made. See the walkthrough's troubleshooting table.