Bug 468046 - GM.getValue / GM.setValue don't work as expected
Summary: GM.getValue / GM.setValue don't work as expected
Status: RESOLVED WORKSFORME
Alias: None
Product: Falkon
Classification: Applications
Component: extensions (other bugs)
Version First Reported In: 22.12.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Rosca
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-01 20:03 UTC by Schimon Jehudah
Modified: 2023-06-10 18:49 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.