jackun / VLCTube

The Unlicense
15 stars 4 forks source link

Greasemonkey access violation: unsafeWindow cannot call GM_xmlhttpRequest #5

Closed Sonic0170 closed 10 years ago

Sonic0170 commented 10 years ago

seems they just won't play, like something changed in the way live streams work

jackun commented 10 years ago

Iike what? young turks seems to work.

Sonic0170 commented 10 years ago

sorry i forgot to add a link to an example stream, and thats interesting i havent caught TYT live recently so i didn't know that. 1 example: http://www.youtube.com/watch?v=1Ap0mgnakO8 stream only available until 6pm definitely something different about how this stream works, none of the resolutions show up

Sonic0170 commented 10 years ago

here is a pastebin of the source for you to go over if you don't have time now http://pastebin.com/w92gf8vQ source of whole page on livestream example in previous post

jackun commented 10 years ago

Ok, the IGN stream works for me today atleast. Ok, nevermind, its an "archived/re-encoding-in-progress" stream, but still time stays "00:00 / 00:00" with it though seekbar moves.

Sonic0170 commented 10 years ago

i see, so it may have nothing to do with it being live or not, i guess something just changed recently, im hoping this isn't something super complicated, for you i assume its not ^.^

Sonic0170 commented 10 years ago

one extra question just in case it may just be me so i don't create a new issue needlessly, do embedded videos still load properly for you? example of embedded video not working for me (i haven't gotten an embedded youtube video to work anywhere, regardless of the site for a month now, ignored it till now also lol) https://plus.google.com/115690532745986479700/posts/Kcr5W1MNs3n

jackun commented 10 years ago

With both flash and html5 player work for me. But i also have flashblock on.

Sonic0170 commented 10 years ago

i never knew google did html5 on embedded videos yet. btw i looked into the console and these 2 errors pop up under JS "load player" function () VLCTube.user.js:4172 "loadPlayer" undefined VLCTube.user.js:4123

the ign video also complains about the upsell thingy also

jackun commented 10 years ago

It just prints the user page 'upsell' video DIV element and/or which if/else block in DOMevent loadPlayer is called from. I should probably remove it.

Sonic0170 commented 10 years ago

oh then i guess that error means nothing, ohwell, sorry i couldn't help ...

Sonic0170 commented 10 years ago

here is a full log including all error's and warning's for all elements(except CSS), im also sure none of this changes anything but hell im sure you like seeing these logs on a system besides your own for comparison, I also turn off ABP, flashblock, and RequestPolicy to be 100% sure when checking and only speak if nothing changes ^.^

Use of getAttributeNode() is deprecated. Use getAttribute() instead. rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:81 SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:310 SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:202 SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:97 SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:35 SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:31 SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:30 SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:22 SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:30 SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:35 SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:99 SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead rs=AItRSTPIo8ranTf8eRaE2M2uyRHZ5WookA:2344 Use of getPreventDefault() is deprecated. Use defaultPrevented instead. flashblock.xml:119 "load player" function () VLCTube.user.js:4172 Loading mixed (insecure) display content on a secure page "http://i4.ytimg.com/vi/qugwGT4iJhY/hqdefault.jpg"[Learn More] VLCTube.user.js:3895 "loadPlayer" undefined VLCTube.user.js:4123 GET http://i4.ytimg.com/vi/qugwGT4iJhY/hqdefault.jpg [Mixed Content][HTTP/1.1 200 OK 41ms]

jackun commented 10 years ago

Does it atleast show the "Watch on YT:" and thumbnail? You were using firefox right? Browser Console click the CSS button to remove CSS errors.

Sonic0170 commented 10 years ago

yes that part shows up like it should, vlc just fails to load when i click to play it is all. also if that last post is just garbage and you can't use it, let me know ill remove it since its so huge.

jackun commented 10 years ago

Weird, uh, open the video in new tab, click to play and screenshot it.

Sonic0170 commented 10 years ago

untitled

it won't play/load vlc when i click it

Sonic0170 commented 10 years ago

exactly similar to the first problem

jackun commented 10 years ago

Reinstall from github, try playing the video again and paste the log.

Sonic0170 commented 10 years ago

"Load player for embed. DOMEvent element: " "player1" 25318.user.js:4203 Loading mixed (insecure) display content on a secure page "http://i4.ytimg.com/vi/qugwGT4iJhY/hqdefault.jpg"[Learn More] 25318.user.js:3920 "force loading embed." 25318.user.js:3924 "In loadEmbedVideo" 25318.user.js:3734 GET http://i4.ytimg.com/vi/qugwGT4iJhY/hqdefault.jpg [Mixed Content][HTTP/1.1 200 OK 40ms]

jackun commented 10 years ago

Hm, that is all then looks like GM_xmlhttpRequest fails or is not called.

Successful should look like (ignore line numbers, i added few more log calls):

Loading mixed (insecure) display content on a secure page "http://i4.ytimg.com/vi/qugwGT4iJhY/hqdefault.jpg"[Learn More] 25318.user.js:3922 "force loading embed." 25318.user.js:3926 "In loadEmbedVideo" 25318.user.js:3734 GET https://www.youtube.com/get_video_info [HTTP/1.1 200 OK 196ms] "XHR response:" 200 25318.user.js:3743 "params:" 91 25318.user.js:3750 "param.status:" "ok" 25318.user.js:3757 "after genUrlMapSelect" 25318.user.js:3780 "in if(embed)" 25318.user.js:3816 "exiting if(embed)" 25318.user.js:3846 "playEmbed" 25318.user.js:3823 "in if(!that.$('movie_player'))" 25318.user.js:3826 "setupVLC" 25318.user.js:3808 "setupVLC: OK" 25318.user.js:3810 "exit if(!that.$('movie_player'))" 25318.user.js:3835 "exiting playEmbed" 25318.user.js:3840

jackun commented 10 years ago

Ok, reinstall again and look for "Load url:" in log. Maybe something causes an error there.

Sonic0170 commented 10 years ago

"Load url:" "https://www.youtube.com/get_video_info?video_id=qugwGT4iJhY" 25318.user.js:3735

jackun commented 10 years ago

Ok, added some more GM_xmlhttpRequest events.

Sonic0170 commented 10 years ago

do you want me to open the get video info file as a document and paste it? sanitized of my ip addy of course

jackun commented 10 years ago

Shouldn't matter, but post the log.

Sonic0170 commented 10 years ago

"Load player for embed. DOMEvent element: " "player1" <embed width="100%" height="100%" name="player1" id="player1" tabindex="0" type="application/x-shockwave-flash" src="https://s.ytimg.com/yts/swfbin/player-vflmTHkPE/watch_as3.swf" wmode="opaque" allowscriptaccess="always" allowfullscreen="true"> 25318.user.js:4226 "force loading embed." 25318.user.js:3947 "In loadEmbedVideo" 25318.user.js:3734 "Load url:" "https://www.youtube.com/get_video_info?video_id=qugwGT4iJhY" 25318.user.js:3735

jackun commented 10 years ago

Hm, no noerror or onabort events either.

jackun commented 10 years ago

Ok, try now. If it still doesn't work, then i don't know... some security setting blocks (but why it works for me, even Fx 32.0a1? :P) GM_xmlhttpRequest or something. You can try clean firefox profile too.

Sonic0170 commented 10 years ago

nothing changed, im gonna create a new profile using the manager and test it one more time and post the log if anything changes or close this issue if it is working

Sonic0170 commented 10 years ago

nothing, i guess this error is unfixable. also i went to the "watch on YT" link and it plays fine so its not the video like how IGN is. in fact ign doesn't throw any errors, just errors related to the G+ comment system also unrelated. fucking google is just frustrating, i think they conspire against you lol :P

Sonic0170 commented 10 years ago

one last ditch thought, do you think firefox nightly is related and do you use the nightly version? like something updated in firefox is conflicting i mean in version 33.0a1

jackun commented 10 years ago

Fx 32.0a1 (june 5th build) on linux worked for me, but it is possible javascript security got tightened a bit.

Sonic0170 commented 10 years ago

you know it was doing this in 32 also so i don't think anything changed then. somehow its my fault, i just have no clue how

jackun commented 10 years ago

Ok, Fx 33 is throwing "unsafewindow cannot call GM_xmlrequest..."

Sonic0170 commented 10 years ago

weird though, this was happening to me on 32 O.o idk maybe windows versions really are a tiny bit ahead

jackun commented 10 years ago

For the same reason live streaming also fails. "Greasemonkey access violation: unsafeWindow cannot call GM_xmlhttpRequest. (Xray)"

Annoying. "this" context looks to be GM sandbox, but still mumbles about unsafeWindow.

Sonic0170 commented 10 years ago

so greasemonkey has to fix some code?

jackun commented 10 years ago

Maybe, but in the meantime i'll keep trying to get around this error.

E: Yeah, looks like Firefox's XRay thingy breaks current GM. No 'workarounds' have worked and even calling xhr directly gives a security exception.

Sonic0170 commented 10 years ago

in the bug tracker for greasemonkey it seems they are suffering with multiple GM errors https://github.com/greasemonkey/greasemonkey/issues good luck ill check in later tomorrow probably

Sonic0170 commented 10 years ago

https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_bindings/XPConnect/XPConnect_security_membranes

and then https://developer.mozilla.org/en-US/docs/Safely_accessing_content_DOM_from_chrome

I assume this information is useless to you and greasemonkey needs to change to make things work correctly.

extra info: i use 32bit version of firefox, 64bit version is too much trouble for now

Sonic0170 commented 10 years ago

installed greasemonkey 2.0beta2, new errors appeared, not sure if this changes anything. Tested using your link: https://www.youtube.com/embed/qugwGT4iJhY

Console Log JavaScript warnings/errors only:

Error: Permission denied to access object www-embed-player-vflihVqe9.js:25 "Load player for embed. DOMEvent element: " "player1" VLCTube.user.js:4231 "force loading embed." VLCTube.user.js:3952 "In loadEmbedVideo" VLCTube.user.js:3734 "Load url:" "https://www.youtube.com/get_video_info?video_id=qugwGT4iJhY" VLCTube.user.js:3735 Error: Permission denied to access object www-embed-player-vflihVqe9.js:25

Sonic0170 commented 10 years ago

Error: Permission denied to access object www-embed-player-vflihVqe9.js:25 Contents of Line 25: var nc=function(){var a="",b;if(gc&&l.opera)return a=l.opera.version,fa(a)?a():a;hc?b=/rv:([^);]+)()|;)/:M?b=/\b(?:MSIE|rv): ()|;)/:ic&&(b=/WebKit\/(\S+)/);b&&(a=(a=b.exec(L))?a[1]:"");return M&&(b=mc(),b>parseFloat(a))?String(b):a}(),oc={};function pc(a){return oc[a]||(oc[a]=0<=va(nc,a))}function qc(a){return M&&rc>=a}var sc=l.document,rc=sc&&M?mc()||("CSS1Compat"==sc.compatMode?parseInt(nc,10):5):void 0;!hc&&!M||M&&qc(9)||hc&&pc("1.9.1");M&&pc("9");function tc(a){return a?new uc(vc(a)):na||(na=new uc)}function wc(a){return N(a)}function N(a){var b=document;return u(a)?b.getElementById(a):a}function xc(a){var b=document;return b.querySelectorAll&&b.querySelector?b.querySelectorAll("."+a):yc(a,void 0)}

jackun commented 10 years ago

www-embed stuff looks to be about pubsub, maybe: http://apiblog.youtube.com/2010/10/pubsubhubbub-for-youtube-activities.html and also some botguard stuff.

Sonic0170 commented 10 years ago

woops nvm didnt see you mentioning botguard, does this mean anything?

Sonic0170 commented 10 years ago

greasemonkey 2.0beta2 is broken or at least doesn't work with VLCTube. audio plays but video hangs on thumbnail. Reverted back to greasmonkey 1.15 and videos work properly again, just letting you know.

Sonic0170 commented 10 years ago

http://wiki.greasespot.net/Greasemonkey_access_violation This means that you cannot register a callback with content-defined JavaScript and then call one of these GM APIs from that callback. If you do attempt this, an error message will be sent to the console, like below, and the function will simply fail.

Error: Greasemonkey access violation: unsafeWindow cannot call GM_getValue. 

Code like this will not work:

unsafeWindow.someObject.registerCallback(function() { var value = "bar"; GM_setValue("foo", value); });

Here is a workaround for this limitation:

unsafeWindow.someObject.registerCallback(function() { var value = "bar"; setTimeout(function() { GM_setValue("foo", value); }, 0); });

The code above is only useful when javascript is enabled in the page. If, for example, the NoScript extension prevents execution of javascript code in the current domain, the setTimeout function will never be called. To circumvent this limitation a slightly more elaborate construction can be used:

function fakeTimeout(callback) { // Register event listener window.document.body.addEventListener("timeoutEvent", callback, false); // Generate and dispatch synthetic event var ev = document.createEvent("HTMLEvents"); ev.initEvent("timeoutEvent", true, false); window.document.body.dispatchEvent(ev); }

unsafeWindow.someObject.registerCallback(function() { fakeTimeout(function() { GM_setValue("foo", new Date().getTime()); }); });

Sonic0170 commented 10 years ago

i stumbled across this, i will add more information if i stumble across anything else, unless you tell me you found the problem ^.^

jackun commented 10 years ago

Yeah, tried that before. No go. Calling GM_getValue etc from event listener (addEventListener) work but GM_XHR fails. If Fx 32+ stable either don't work then i'll probably have to make the script inject itself into the page.

Sonic0170 commented 10 years ago

this is interesty here https://blog.mozilla.org/addons/2014/04/10/changes-to-unsafewindow-for-the-add-on-sdk/ check it out and tell me what you think

"The real fix is to use three new APIs to share objects and functions with web content: cloneInto(), exportFunction(), and createObjectIn(). All three of these functions are made available to content scripts as globals."

initially, they left in a work around but it seems they finally stripped the work around out in one of the later updates sometime after june 5th for version 32 just before they pushed version 33 into nightly.

so from what i can see, this updated way of calling an object has nothing to do with greasemonkey, so i guess its your job to work around restrictions in firefox, firefox security is getting really tight, i can understand why but just looking at the code makes me feel frustrated trying to understand it lol, damn mozilla :P

jackun commented 10 years ago

Nice find. Ok, test script with page injection, but now GM_setValue/GM_getValue are pretty broken. https://dl.dropboxusercontent.com/u/235773/25318.user.js

Sonic0170 commented 10 years ago

nope, vlc fails to load and flash player loads instead