GM_setValue/getValue/listValues are not defined error

2,848 views
Skip to first unread message

Andre Dubois

unread,
Nov 27, 2012, 7:09:33 PM11/27/12
to greasemon...@googlegroups.com
I developed this script: http://userscripts.org/scripts/show/110076

It has worked perfectly fine for over a year, and it recently broke (within past 7 days).  It's something I use daily.

I am using v1.5 with firefox 16.0.2 (I rolled back from 17.0 when I was getting different errors).

My problem is that GM_setValue/getValue/listValues all post the same error; "GM_setValue is not defined" for example.  It can be seen at line 170 of that script.  I have changed nothing in my script.  I also tried to roll back GM to v1.4, but it still didn't work (same issue).

Also, when I was using FF 17.0 with v1.5, I was getting an error at line 1 of both of my @requires (49700, 50018), which are very popular scripts that add user config screens.

Am I the only one having problems?!?!  I swear, this script has worked perfectly for a minimum of a year, and I haven't edited it for at least 10 months, and I use them daily.  Yet, I can't find anybody else with this problem.

Thanks for your help.

Anthony Lieuallen

unread,
Nov 27, 2012, 9:21:57 PM11/27/12
to greasemon...@googlegroups.com
On Tue, Nov 27, 2012 at 7:09 PM, Andre Dubois <andre.j...@gmail.com> wrote:
I am using v1.5 with firefox 16.0.2 (I rolled back from 17.0 when I was getting different errors).
 
Firefox is removing E4X support.  Both of the @requires you are using rely on them, and this breaks in FF17.

Once I remove the E4X references, everything works as expected for me.  Try http://wiki.greasespot.net/Troubleshooting_%28Users%29

Andre Dubois

unread,
Nov 28, 2012, 9:06:28 AM11/28/12
to greasemon...@googlegroups.com
So you're saying I need to contact the devs of those scripts?

Also, any idea why I'm getting errors with GM_setValue, GM_getValue, etc?  These errors are coming from FF16

Thanks for the help so far!

Andre Dubois

unread,
Dec 4, 2012, 10:02:37 PM12/4/12
to greasemon...@googlegroups.com
Please, would someone tell me if GM_setValue, GM_getValue, and GM_listValues have been changed, disabled, or are depreciated?  Is there something new?  Because I'm using FF 17.0.1, and GM 1.5, and even on new scripts I create, I cannot set a GM_setValue.

I can't possibly believe I'm the only one that is having this problem.

Thanks


On Tuesday, November 27, 2012 6:21:57 PM UTC-8, Anthony Lieuallen wrote:

Zulkarnain K.

unread,
Dec 5, 2012, 9:46:05 AM12/5/12
to greasemon...@googlegroups.com
On Wed, Dec 5, 2012 at 10:02 AM, Andre Dubois wrote:
> Please, would someone tell me if GM_setValue, GM_getValue, and GM_listValues
> have been changed, disabled, or are depreciated? Is there something new?
> Because I'm using FF 17.0.1, and GM 1.5, and even on new scripts I create, I
> cannot set a GM_setValue.
>

An example code would help.

GM_getValue, GM_getValue, and GM_listValues work for me
on Firefox 17.0.1, 18.0b, 19.0a2, and GM 1.5

--
Zulkarnain K.
http://userscripts.org/users/12/scripts

Andre Dubois

unread,
Dec 5, 2012, 9:30:17 PM12/5/12
to greasemon...@googlegroups.com
I went to a random website, and created the following script, which gives me the error "GM_setVar is not defined"


// ==UserScript==
// @name        test
// @namespace   http://userscripts.org/scripts/show/110076
// @include     http://www.electrictoolbox.com/pad-number-zeroes-javascript/
// @version     1
// @grant        metadata
// ==/UserScript==

GM_setVar("Test", "this is a test")

Anthony Lieuallen

unread,
Dec 6, 2012, 9:15:31 AM12/6/12
to greasemon...@googlegroups.com
On Wed, Dec 5, 2012 at 9:30 PM, Andre Dubois <andre.j...@gmail.com> wrote:
I went to a random website, and created the following script, which gives me the error "GM_setVar is not defined"


// ==UserScript==
// @name        test
// @namespace   http://userscripts.org/scripts/show/110076
// @include     http://www.electrictoolbox.com/pad-number-zeroes-javascript/
// @version     1
// @grant        metadata
// ==/UserScript==

GM_setVar("Test", "this is a test")

A) "@grant metadata" is meaningless, that value doesn't do anything.
B) Of course.  There is no "GM_setVar".  http://wiki.greasespot.net/Greasemonkey_Manual:API
C) If you specify any @grants, you have to specify one for every (correct/extant) method you want to use.

Andre Dubois

unread,
Dec 6, 2012, 8:36:47 PM12/6/12
to greasemon...@googlegroups.com
1. I added that because my script was getting the prompt "Warning, all scripts should specify @grant metadata".  I thought it was weird, but did it anyway.  It will still do it if there is no @grant data.  I'll change it to @grant none, or disable that message.
2. Indeed... my mistake.  I changed it on my test script, and it works on the test script.  However, I tried testing it on my old script, and it still gives the same error.  I removed the two requires, and moved GM_setValue("foo", "bar") to line 13, and received the same error as before (and yes, I spelled it correct.)
3. I didn't want to specify any @grants, but again, GM was prompting me to do so, and I got annoyed, so I added it.

the code that is currently failing:

// ==UserScript==
// @version            2.2
// @name              Myepisodes Enhanced
// @namespace        http://userscripts.org/scripts/show/110076
// @description       Adds download links, a progress bar, season premiere alerts, better searching, and a whole lot of customization to MyEpisodes.com
// @include           http://*myepisodes.com/*
// @exclude            http://*myepisodes.com/forum*
// @exclude            http://dev.myepisodes.com*
// ==/UserScript==
// Many thanks go to user ReV: http://userscripts.org/scripts/show/29729.  I used your script as a jumping off point.  I'm even still using some of your variables.
 
GM_setValue("foo", "bar")

for me, it returns the same message as before.

-Andre


--
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemon...@googlegroups.com.
To unsubscribe from this group, send email to greasemonkey-us...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.

Anthony Lieuallen

unread,
Dec 6, 2012, 10:57:08 PM12/6/12
to greasemon...@googlegroups.com
On Thu, Dec 6, 2012 at 8:36 PM, Andre Dubois <andre.j...@gmail.com> wrote:
3. I didn't want to specify any @grants, but again, GM was prompting me to do so, and I got annoyed, so I added it.

Specify one @grant for each API you want to use, and it will probably work.
http://wiki.greasespot.net/@grant

Andre Dubois

unread,
Dec 6, 2012, 11:24:46 PM12/6/12
to greasemon...@googlegroups.com
holy crap... I had no idea I needed to at GM_setValue to my @grants.  I suppose I missed those lines when you first sent me the link.

This script worked for far more than a year without needed, and I'm surprised that I never had a problem until now.

Anyway, thanks for your help.  I added the @grant lines, and everything is better now

Thanks!

LWChris@LyricWiki

unread,
Dec 8, 2012, 10:20:57 AM12/8/12
to greasemon...@googlegroups.com
Am 07.12.2012 05:24, schrieb Andre Dubois:
> holy crap... I had no idea I needed to at GM_setValue to my @grants. I
> suppose I missed those lines when you first sent me the link.
>
> This script worked for far more than a year without needed, and I'm
> surprised that I never had a problem until now.
>
> Anyway, thanks for your help. I added the @grant lines, and everything is
> better now
>
> Thanks!

The @grant statement is a security feature. Greasemonkey only grants
access to the API functions you declared. I. e.: just because the script
is allowed to set and read values, it mustn't perform XML requests. In
the previous versions, the @grant statement was silently added for
compatibility, issuing a warning though that you could update your
script to be compatible with GM versions that wouldn't implicitly grant
the API access any more.

And if I am correct, scripts without API access (@grant none) are
executed in the scope of the website, which allows you to write
JavaScript as you're used to, without having to deal with the sandbox
pitfalls like the element wrappers.

Chris

Anthony Lieuallen

unread,
Dec 8, 2012, 8:38:51 PM12/8/12
to greasemon...@googlegroups.com
On Sat, Dec 8, 2012 at 10:20 AM, LWChris@LyricWiki <lwc...@gmx.de> wrote:
And if I am correct, scripts without API access (@grant none) are executed in the scope of the website, which allows you to write JavaScript as you're used to, without having to deal with the sandbox pitfalls like the element wrappers.

Yes, that's the primary reason @grant was created.  http://www.greasespot.net/2012/09/the-design-of-greasemonkey-10.html
Reply all
Reply to author
Forward
0 new messages