Okay, maybe I have more luck posting code in a comment(?):
var *gm4test *= {
INFO: true,
DEBUG: false,
*log*: function(s, info) {
if ((info && window.console) || (gm4test.DEBUG && window.console)) {
window.console.log('*GM4test* '+s);
}
},
*getValue*: function(name, defval) {
var rt;
if (typeof GM_getValue === 'function') { // GM3 etc
rt = GM_getValue(name, defval);
} else if (typeof GM === 'object' && typeof GM.setValue ===
'function') { // GM4
rt = (async function(){return await GM.getValue(name,
defval);})();
} else {
alert('Sorry, no support for GM getValue API method');
gm4test.log('Sorry, no support for GM getValue API method',
gm4test.INFO);
}
return rt;
},
*setValue*: function(name, value) {
if (typeof GM_setValue === 'function') { // GM3 etc
GM_setValue(name, value);
} else if (typeof GM === 'object' && typeof GM.setValue ===
'function') { // GM4
(async function(){await GM.setValue(name, value);})();
} else {
alert('Sorry, no support for GM setValue API method');
gm4test.log('Sorry, no support for GM setValue API method',
gm4test.INFO);
}
},
*run*: function () {
gm4test.log('Running...');
// Set...
gm4test.*setValue*('gm4val', 42);
// and get again...
var rv = gm4test.*getValue*('gm4val', '');
*alert('value='+rv)*; // Expected "value=42", but with GM4 I get
"value=[object Promise]" !
}
};
*gm4test.run();*
--
You received this message because you are subscribed to the Google Groups
"greasemonkey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/greasemonkey-users.
For more options, visit https://groups.google.com/d/optout.