(nb, not an issue in this exact case I think but I forgot about line
wrap in emails so not everything is formatted *exactly* as I typed
it..)


On 29 November 2010 23:13, Kwah <[email protected]> wrote:
> I suggest using the 'location hack' rather than unsafeWindow.
>
> http://wiki.greasespot.net/Location_hack
>
> Long story short, if you redirect the page location to a javascript:
> url (basically the same as typing it into the URL bar), it executes
> code in the 'page' context (with access to the wmp plugin etc) as
> opposed to in the 'script' context. This stops the script from being
> (potentially) 'unsafe'.
>
> Helper functions such as this would help make it a bit easier to do:
>
> function mutePlayer(arg_playerId)
> {
>  location.href = "javascript:(" + function() {
>    // do something
>    document.getElementById(arg_playerId).mute = true;
>  } + ")()";
> }
>
> // Similar to above but in fewer lines
> function playPlayer(arg_playerId) {
>  location.href = "javascript:(" + function() {
> document.getElementById(arg_playerId).play(); } + ")()";
> }
>
>
> I've not had a proper play with this yet so perhaps this snippet
> *might* not work exactly as I've written it, but that's the general
> idea.
>
>
>
> On 19 October 2010 06:36, RY78 <[email protected]> wrote:
>> I got it to work through unsafeWindow from another tipster ;)
>>
>> var player = unsafeWindow.document.getElementById("wmp_p");
>>
>> player.settings.mute = true;
>> player.controls.play();
>>
>>
>> Thanks for replying. And wow, I didn't expect to get an answer from a
>> Mozilla rep. Cool stuff guys!
>>
>>
>> On Oct 18, 5:26 am, Vectorspace <[email protected]> wrote:
>>> I wrote that demo page, so I can probably help.
>>>
>>> Could you post your script?
>>>
>>> ----- Original message -----
>>> > Hi all,
>>> > I'm having some problem with controlling WMP plugin through
>>> > greasemonkey. For example moz demo page (http://plugindoc.mozdev.org/
>>> > testpages/wmp11.html) shows how to control (play/pause/stop) wmp
>>> > plugin using javascript. However, when I define those control function
>>> > in a greasemonkey script, it wouldn't work when called and returned
>>> > that those functions are not defined.
>>>
>>> > Function like controls.play() or settings.mute() would work for
>>> > javascript that is already in that page, but those fail to work in gm.
>>> > Can anyone shred some light on this issue for me? I've been
>>> > scavenging   the web with no luck.
>>>
>>> > --
>>> > 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.
>>
>> --
>> 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.
>>
>>
>

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