greneholt / youtube5

Safari extension that converts YouTube videos on any site into HTML5 video tags
http://www.verticalforest.com
Other
111 stars 17 forks source link

clicking on suggested videos doesn't work anymore #41

Closed knlr closed 11 years ago

knlr commented 11 years ago

youtube changed their site so it doesn't reload the whole page anymore when you click on any of the suggested videos, but merely swaps the video. This is broken with youtube5 it seems, the current video just remains there.

greneholt commented 11 years ago

I cannot reproduce this issue on my machine. What version of YouTube5/Safari are you using, and do you have plugins enabled or disabled?

knlr commented 11 years ago

Safari Version 6.0.5 (7536.30.1) Mac OS X 10.7.5, plugin-ins enabled and flash installed ;)

greneholt commented 11 years ago

YouTube5 version?

knlr commented 11 years ago

2.6.4

greneholt commented 11 years ago

Hmm, I'm running the beta of Safari 6.1, and I'm definitely not encountering this issue. I'll probably have to downgrade to figure out what's happening.

dlh commented 11 years ago

I started having this issue lately. I guess it's a gradual roll-out of a new feature by YouTube. I'm using OS X 10.8 with Safari 6.0.5 (8536.30.1). The issue occurs with plug-ins enabled and disabled.

Here's one video were the issue occurs (click one of the suggested videos from the same uploader).

I fixed the issue by disabling the history API—I couldn't find a better method.

https://github.com/dlh/youtube5/tree/suggested-videos

Edit: Ah right, I forgot this loads for every page. It needs to be modified to only run on youtube.com.

greneholt commented 11 years ago

Yes, I've been experiencing this issue now too, just haven't had time to look into it. I'll examine your pull, thanks!

greneholt commented 11 years ago

That seems like a relatively simple solution to the problem that doesn't require a lot of complicated page modification. The problem is that your script runs on every website, not just YouTube. Also, it's not necessary to inject another script into the page, just put window.history.pushState = null;.

Once you've made those changes, please submit a pull request.

dlh commented 11 years ago

I think the only solution is to inject another script. You can't modify the page's window.history from an injected script. The documentation says:

Injected scripts have an implied namespace—you don’t have to worry about your variable or function names conflicting with those of the website author, nor can a website author call functions in your extension. In other words, injected scripts and scripts included in the webpage run in isolated worlds, with no access to each other’s functions or data.

I couldn't get it work by simply setting window.history.pushState = null in the injected script.

The problem is that your script runs on every website, not just YouTube.

Yeah, I noted that in an edit above. I haven't looked into fixing that yet.

greneholt commented 11 years ago

Hmm, curious, I thought you could change the global page by accessing the window, but I just tried it as well, and no dice. Oh well, it seems clunky, but that's the only way.

In util.js there is a function called getDomain that will reduce a full URL to a domain with the 'www'. That should be sufficient for determining if its on youtube currently.

greneholt commented 11 years ago

I moved your code into a DOMContentLoaded event in inject.js because the end script wasn't working for me for some reason, but it's working now in v2.6.5.