You can use GM_getValue, GM_setValueand GM_addValueChangeListenerto achieve communication between the user script.
script .
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addValueChangeListener
script.
function GM_onMessage(label, callback) {
GM_addValueChangeListener(label, function() {
callback.apply(undefined, arguments[2]);
});
}
function GM_sendMessage(label) {
GM_setValue(label, Array.from(arguments).slice(1));
}
, , , : .
GM_onMessage('_.unique.name.greetings', function(src, message) {
console.log('[onMessage]', src, '=>', message);
});
GM_sendMessage('_.unique.name.greetings', 'hello', window.location.href);
, . , GM_addValueChangeListener , , , , GM_setValue.