Inhaltsverzeichnis Vorheriger Eintrag (settings:content_script_api)
This document describes how to deploy Tampermonkey in a managed environment. It covers both installing the extension and centrally provisioning scripts and settings using managed browser policies.
The deployment approach is supported by:
The configuration itself is provided as a JSON export from a preconfigured Tampermonkey installation and fetched by managed Tampermonkey instances at startup. This requires version 5.5+ or 5.5.6235+ (BETA).
Deployment consists of three steps:
The provisioning file can include:
Tampermonkey provides a built-in export mechanism.
The resulting file (for example tm.json) is the provisioning source used by the browsers.
tm.json{
"version": "1",
"scripts": [
{
"name": "Log location",
"enabled": true,
"position": 1,
"uuid": "4190fc63-64c8-4c68-9a7c-96f41f85729a",
"source": "Ly8gPT1Vc2VyU2NyaXB0PT0KLy8gQG5[...]sb2cobG9jYXRpb24uaHJlZik7",
"requires": [
{
"meta": { "name": "jquery-3.4.1.min.js", "url": "https://code.jquery.com/jquery-3.4.1.min.js", "mimetype": "application/javascript" },
"source": "Ly8ganF1ZXJ5IHN0dWIKdmFyIGpkVjMgPSAxOw=="
}
]
}
],
"settings": {
"configMode": 100,
"logLevel": 80
}
}
Host this file on an internal web server, for example:
php -S localhost:12121 -t .
In production mode – Use a real web server (Apache, Nginx, IIS, …) that serves the file over HTTPS with a valid certificate.
Each provisioning entry requires a content hash to guarantee integrity. If the hash does not match, Tampermonkey logs an error similar to:
Error: Hash mismatch for provisioning jsonImport from http://localhost:12121/tm.json:
expected 1:abcd... !== calculated 1:ef01...
The correct hash is shown in the error output (calculated …). Copy that value into the policy configuration.
A dedicated hash helper tool is planned.
Tampermonkey reads its managed configuration from the browser. Relevant schema excerpt:
{
"jsonImport": [
{
"hash": "1:…",
"url": "https://example.com/tm.json",
"haltOnError": true,
"installAsSystemScripts": false
}
]
}
Tampermonkey identifies provisioned scripts by the uuid value stored in the export.
Re-provisioning a document whose scripts keep the same UUID — the normal case when you re-export from the same preconfigured installation — updates the existing provisioned scripts in place instead of creating a second copy.
The following still apply:
To avoid confusion for users, instruct them to remove the manually installed copies and keep the provisioned one (a system script by default, see installAsSystemScripts).
See Q406 in the FAQ for Tampermonkey's extension IDs.
Firefox supports managed extension configuration via policies.json.
Policies can be inspected at:
about:policiesPlace policies.json in the distribution directory next to firefox.exe.
Find the Firefox install directory (commonly):
C:\Program Files\Mozilla Firefox\
Create:
C:\Program Files\Mozilla Firefox\distribution\
Put this file here:
C:\Program Files\Mozilla Firefox\distribution\policies.json
Alternatively deploy via GPO or Intune.
Place policies.json in the distribution directory.
Find and edit:
Firefox.app/Contents/Resources/distribution/policies.json
Or deploy via configuration profiles / MDM.
System-wide: /etc/firefox/policies/policies.json
{
"policies": {
"Extensions": {
"Install": [
"https://www.tampermonkey.net/xpi/firefox-current-beta.xpi"
]
},
"3rdparty": {
"Extensions": {
"firefoxbeta@tampermonkey.net": {
"jsonImport": [
{
"hash": "1:66849534c66c5bd384f39f7fb5c7c5bdbc8611bfedab082762cb943f853637d0",
"url": "http://localhost:12121/tm.json",
"haltOnError": true,
"installAsSystemScripts": false
}
]
}
}
}
}
}
Mozilla policy documentation:
Policies can be inspected at:
chrome://policy/edge://policy/Create a .reg file (e.g. tampermonkey_provision.reg) and import it with reg import as an administrator:
Windows Registry Editor Version 5.00
; Force-install Tampermonkey (if not already installed)
[HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome\ExtensionInstallForcelist]
"1"="gcalenpjmijncebpfijmoaglllgpjagf"
; 3rd-party policy for the extension
[HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome\3rdparty\extensions\gcalenpjmijncebpfijmoaglllgpjagf\jsonImport\1]
"hash"="1:66849534c66c5bd384f39f7fb5c7c5bdbc8611bfedab082762cb943f853637d0"
"url"="http://localhost:12121/tm.json"
"haltOnError"=dword:00000001
"installAsSystemScripts"=dword:00000000
Deploy via Group Policy or MDM.
Deploy via MCX using .mobileconfig or .plist.
Create /etc/opt/chrome/policies/managed/tampermonkey.json:
{
"ExtensionInstallForcelist": [
"gcalenpjmijncebpfijmoaglllgpjagf"
],
"3rdparty": {
"extensions": {
"gcalenpjmijncebpfijmoaglllgpjagf": {
"jsonImport": [
{
"hash": "1:66849534c66c5bd384f39f7fb5c7c5bdbc8611bfedab082762cb943f853637d0",
"url": "http://localhost:12121/tm.json",
"haltOnError": true,
"installAsSystemScripts": false
}
]
}
}
}
}
Google Workspace customers can deploy the policy via the Chrome Admin Console instead of local policy files:
{
"jsonImport": {
"Value": [
{
"hash": "1:66849534c66c5bd384f39f7fb5c7c5bdbc8611bfedab082762cb943f853637d0",
"url": "https://example.com/tm.json",
"haltOnError": true,
"installAsSystemScripts": false
}
]
}
}
Note the "Value": [...] wrapper around the list: the Admin Console requires list-type policy values to be wrapped in a Value object. This is the only difference from the local policy files shown above.
Chromium documentation: