Issue with GM_getValue from GM_listValues array in firefox.
It's broken in the official GM2.3, arantius has somewhat fixed it in his dev fork, and here's an apparently working backport plus a zipped xpi in the attachment (unzip it and drop on the firefox window manually):
--- a/modules/miscapis.js
+++ b/modules/miscapis.js
@@ -127,9 +127,7 @@ GM_ScriptStorage.prototype.listValues = function() {
}
// See #1637.
- var vals = Array.prototype.slice.call(valueNames);
- vals.__exposedProps__ = {'length': 'r'};
- return vals;
+ return JSON.stringify(valueNames || []);
};
@@ -189,8 +187,6 @@ GM_ScriptStoragePrefs.prototype.deleteValue = function(name) {
GM_ScriptStoragePrefs.prototype.listValues = function() {
// See #1637.
- var vals = Array.prototype.slice.call(this.prefMan.listValues());
- vals.__exposedProps__ = {'length': 'r'};
- return vals;
+ return JSON.stringify(this.prefMan.listValues() || []);
};
// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ //
--- a/modules/sandbox.js
+++ b/modules/sandbox.js
@@ -106,7 +106,12 @@ function createSandbox(aScript, aContentWin, aUrl) {
}
if (GM_util.inArray(aScript.grants, 'GM_listValues')) {
- sandbox.GM_listValues = GM_util.hitch(scriptStorage, 'listValues');
+ // Return plain (JSON) string from chrome, parse it in the sandbox,
+ // to avoid issues with objects (Array) crossing security boundaries.
+ sandbox._GM_listValues = GM_util.hitch(scriptStorage, 'listValues');
+ Components.utils.evalInSandbox(
+ 'function GM_listValues() { return JSON.parse(_GM_listValues()); }',
+ sandbox);
}
if (GM_util.inArray(aScript.grants, 'GM_openInTab')) {
sandbox.GM_openInTab = GM_util.hitch(
A bug I see,
That explains why somehow the array length is working normal in firefox, but no values to collect from the array.
Thanks wOxxOm, or rather thanks again.
I hope the GreaseMonkey team fixes this in a GA version soon.
I don't want to ask my colleagues to run any beta stuff, but at least I can make my code do, what it should do.
https://github.com/greasemonkey/greasemonkey/issues/2033
var list = cloneInto(GM_listValues(), window);
works as a temporary fix until they release a perm fix.
Thanks TimidScript,
I'm trying to get to the list of created variables to do some housekeeping and delete variables related to long closed cases.
Depending on how long the next release will take (provided it contains the fix) I may want to use the workaround you provided.
The workaround was okay in my Firefox 35.01:var list = cloneInto(GM_listValues(), window);
Now in FF 36 i get a new JS error message:Permission denied to pass object to privileged code
Is there another way to still work with Greasemonkey 2.3 AND listValues ?
Issue with GM_getValue from GM_listValues array in firefox.
This code works in chrome, and nicely gives me a list of variables I have defined.
Chrome console log.
Firefox console log.
So Basically GM_getValue( arry[p] ) returns something else in firefox then in chrome.
Does this ring a bell to anyone?