As mentioned by wOxxOm, in order for 2 domains to share data via GM storage API, the script must run on both e.g. via @match
.
However, in Tampermonkey the domains will get access to the data at the time script was injected.
Update: As pointed out by wOxxOm, "Both Tampermonkey/Violentmonkey provide real-time access to the real values. They do it by propagating the change to all tabs/frames where this script instance runs."
You can also use GM_addValueChangeListener()
to listen to changes to the storage.
GM_addValueChangeListener()
Adds a change listener to the storage and returns the listener ID.
'name' is the name of the observed variable.
The 'remote' argument of the callback function shows whether this value was modified from the instance of another tab (true) or within this script instance (false).
Therefore this functionality can be used by scripts of different browser tabs to communicate with each other.
Note: In Greasemonkey & FireMonkey, the asynchronous GM.getValue()
would always get the current up-to-date data.