Use 
unsafeWindow.channel
instead of
channel

http://wiki.greasespot.net/UnsafeWindow


W dniu piątek, 30 października 2015 01:03:45 UTC+1 użytkownik mens sana 
napisał:
>
> Hello ! I'm going nuts trying to figure out how to use *@grant* and still 
> access the webpage contents properly.
>
> My script is waiting for the window property *channel* to be defined, 
> then it sets a few listeners. In Firefox, the property *channel* becomes 
> unavailable when *@grant* is different than *none*.
>
> Here is a simplified version of the script :
>
> // ==UserScript==
> // @name         foo
> // @version       1
> // @grant          GM_getResourceURL
> // ==/UserScript==
>
> var lookup = function()
> {
>     if (typeof channel !== "undefined")
>     {
>         console.log("Loaded");
>         clearInterval(nextInitHnd);
>         setListeners();
>     }
>     else
>         console.log("Not loaded, waiting...");
> }
>
> var setListeners = function()
> {
>     console.log("Setting listeners");
>     
>     channel.socket.on("chatMessage", function(e)
>     {
>         console.log(e.text);
>     });
> }
>
> var nextInitHnd = setInterval(lookup, 1000);
>
>
> Please note that this works perfectly in Chrome, or in Firefox with *@grant 
> none*. The problem only appears in Firefox with *@grant GM_getResourceURL* 
> (or any other value different than *none*).
>
> I tried changing *channel *to *window.channel *or *unsafeWindow.channel* 
> but this doesn't help. I just want to make the property accessible for 
> Firefox, while keeping the working code for Chrome.
>
> Thanks for your advice
>

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/greasemonkey-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to