Tried this script with firefox 3.6.13 and GM 0.9:

// ==UserScript==
// @name           testScript
// @namespace      testScript
// @include        http://*
// @include        https://*
// ==/UserScript==

localStorage.setItem('foo', 'bar');           //line 1
alert(localStorage.getItem('foo'));

I get the alert message "bar" only on google domain, apparentlly.
Other websites generates some "Security error" on line 1 in Error
Console.

What is the correct way to *et values with localStorage?

Your help is much appreciated. Thank you !

On Jan 23, 6:56 pm, Matt Sargent <[email protected]> wrote:
> If they're both using the same domain, localStorage is a better
> solution. Far less of a maintenance headache, since you're not trying to
> maintain two scripts mashed into one.
>
> On 1/23/2011 7:03 AM, nw wrote:
>
> > Thank you for your suggestion ... since my scripts have different
> > includes I will make a test for window.location.href at the top.
>
> > On Jan 23, 2:59 pm, RodMcguire<[email protected]>  wrote:
> >> What you need to do is is take both scripts and
> >> 1)  make a new script that contain both
> >> 2)  put some test at the top of it that decides which part to run.
On Jan 23, 5:04 pm, Sherkaner <[email protected]> wrote:
> You could also try to use localStorage for something like this, I
> overwrite setValue and getValue now for chrome, and those variables
> are per site.
>
> On 23 jan, 13:58, nw <[email protected]> wrote:
>
> > Got it, thx.
>
> > my question is:
>
> > What method can I use to get a value in a script that was set in
> > another script?
> > I want the value to be visible across all scripts.
>
> > On Jan 23, 11:54 am, esquifit <[email protected]> wrote:
>
> > > On Sun, Jan 23, 2011 at 10:21 AM, nw <[email protected]> wrote:
>
> > > [...]
>
> > > > I want to know if GM_setValue is used in a script I can get the value
> > > > with GM_getValue from another script. Or what other alternative I
> > > > have, maybe setting the values to about:config in firefox with
> > > > javascript.
>
> > > > I tried grouping the two scripts in the same namespace but is no use.
>
> > > GM_*etValue are local to the script.  They access information coded
> > > into a string stored in a *Firefox* preference named after a
> > > combination of the script's (normalized) name, the script's namespace
> > > and of course the specific preference name used in the script:
>
> > > greasemonkey.scriptvals.<namespace><normalized script name>.<script
> > > preference name>

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


Reply via email to