wme-sync-lib adds WME Sync to a Waze Map Editor userscript: the editor’s settings and data follow them to every browser they edit from. It handles the username, the PIN, tokens and retries, so your script only calls get and set. Using an AI coding agent? Point it at /AGENTS.md, the same guide written for agents.
scriptId), as JSON values under keys.Add @require https://sync.wmekit.com/wme-sync-lib.js to your header along with the GM @grants and @connect sync.wmekit.com. Keep any @grants you already have. @grant none won’t work, because the library talks through GM_xmlhttpRequest and stores its tokens with GM_setValue (so CORS doesn’t apply). With any grant, your script runs sandboxed, so read the WME SDK globals (getWmeSdk, SDK_INITIALIZED) from unsafeWindow. The library defines a global WMESync.
Call WMESync.init(options) after wme-ready. It makes no network request: the first data call (or ensureSignedIn()) runs the PIN step. It throws if there’s no username, which happens when the editor isn’t logged in to WME, so wrap it in try/catch and skip syncing.
Everything except getPin() returns a promise. Expired tokens are refreshed for you, and the first call in a browser runs the PIN step.
Every failure is a WMESyncError with .status and .body ({ error, code? } from the server).
The defaults use window.alert to show a new PIN and window.prompt to ask for one. They work, but a script with its own UI should replace them. Also add a “Show my WME Sync PIN” item (getPin()) and a “Disconnect” item (signOut()) to your settings: editors lose PINs.
Make sync an enhancement on top of local storage, never a hard dependency. Load local settings first, sync after, save locally on every change and debounce the upload.
By default the last write wins, which is right for settings. If two browsers can change the same structured data, such as a list, read it with getEntry, write with ifVersion and merge again on a 409.
Writing the integration with an AI coding agent? Give it /AGENTS.md: it has all of the above plus a checklist to finish with.