On 23 Sep, 07:57, mjh563 <[email protected]> wrote:
> Hi, I'm trying to understand what happens when you declare a variable
> in an in-content (@grant none) and unwrapped script.
>
> Consider this example:
>
> // ==UserScript==
> // @name          Test script
> // @include       *
> // @grant         none
> // ==/UserScript==
>
> var testvar = 1;
>
> As I understand it, this script will be run in the content scope and
> without an anonymous function wrapper. So I expected that 'testvar'
> would get added to the global window object and be available to the
> page's scripts (and possibly over-write an existing global 'testvar'
> variable set by the page), but that doesn't appear to be the case.
>

For example, the following page displays 0 even when the above
userscript is run on the page. I was expecting the userscript would
change the page's testvar to 1:

<!DOCTYPE HTML>
<html>
<head>
<title>Test page</title>
<script>
        var testvar = 0;
        window.onload = function() {
                document.body.innerHTML = testvar;
        }
</script>
</head>
<body></body>
</html>

-- 
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