#14 new
Olivier Cornu

Object storage support for GM_setValue/GM_getValue

Reported by Olivier Cornu | September 12th, 2009 @ 07:34 PM

So far GM_setValue and GM_getValue only support integers, boolean and strings. It would be nice if they supported objects as well, in order to load/save a bunch of values (this object properties) at once.
As i see it, a preferences branch would be named after the key parameter, with object properties saved as key.propertyName values of this branch.

Example code:

// ==UserScript==
// @name           name
// @namespace      namespace
// ==/UserScript==
var object = {
  aBoolean = true,
  aInt     = 1,
  aString  = "string"
}
GM_setValue("key", object);

about:config would thus contain the following:

webmonkey.scriptvals.namespace/name.key.aBoolean = true
webmonkey.scriptvals.namespace/name.key.aInt     = 1
webmonkey.scriptvals.namespace/name.key.aString  = string

GM_getValue("key") would perform the opposite operation.

Notes:

  • Such preferences values would also be reachable individually using the standard syntax.
  • The mechanism could be recursive: it could support properties of Object type as well, as long as there is no reference loops (same as JSON).
  • Safe manipulation of the (possibly trapped) object is required

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Webmonkey is a fork of the popular Greasemonkey extension for Firefox.

People watching this ticket

Pages