Bug 468046

Summary: GM.getValue / GM.setValue don't work as expected
Product: [Applications] Falkon Reporter: Schimon Jehudah <sch>
Component: extensionsAssignee: David Rosca <nowrep>
Status: RESOLVED WORKSFORME    
Severity: normal    
Priority: NOR    
Version First Reported In: 22.12.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Schimon Jehudah 2023-04-01 20:03:56 UTC
GM.getValue / GM.setValue don't work as expected

Tested against the following example from https://wiki.greasespot.net/GM.getValue#Examples

// ==UserScript==
// @name        Greasemonkey set-and-get Example
// @description Stores and logs a counter of executions.
// @grant       GM.setValue
// @grant       GM.getValue
// ==/UserScript==

(async () => {
  let count_before = await GM.getValue('count', 0);
  
  // Note awaiting the set -- required so the next get sees this set.
  await GM.setValue('count', count_before + 1);

  // Get the value again, just to demonstrate order-of-operations.
  let count_after = await GM.getValue('count');
  
  console.log('Greasemonkey set-and-get Example has run', count_after, 'times');
})();

I need this feature to fix enable (true / false) value for this program https://openuserjs.org/scripts/sjehuda/Dimmer
Comment 1 Schimon Jehudah 2023-06-09 15:11:40 UTC
I have made a update to a userscript[1] which adds dark view mode to it.
It uses GM.getValue / GM.setValue to save last used mode.

GM_getValue / GM_setValue[2] don't appear to save info or or retrieve values as expected; and
GM.getValue / GM.setValue[3] doesn't appear to work
Both ways were tested with Tampermonkey and are working as expected.

This script adds a Falkon banner to bottom of every Web Feed page. See function setBanner().
The banner was featured only in the openuserjs.org version[4] because they don't require antifeature metablock.
However, I will remove this banner from the openuserjs.org until GM.getValue / GM.setValue are supported.

[1]: https://greasyfork.org/en/scripts/465932-newspaper-native-rss-reader
[2]: https://greasyfork.org/en/scripts/465932-newspaper-native-rss-reader/diff?v1=1202515&v2=1202391
[3]: https://greasyfork.org/en/scripts/465932-newspaper-native-rss-reader/diff?v1=1202515&v2=1198552
[4]: https://openuserjs.org/scripts/sjehuda/Newspaper
Comment 2 Schimon Jehudah 2023-06-09 15:14:48 UTC
I think that the banner, currently, will cause harm, because once a new person will use Falkon, he would see that the userscript that has the banner, doesn't fully work with Falkon.
On the other hand, this person might be a C++ programmer that would contribute to this extension.
The banner will be disabled unless you would tell me otherwise.
Comment 3 Schimon Jehudah 2023-06-10 18:49:25 UTC
I was wrong. It appears that only GM.getValue or reading value doesn't (always) work.