Script Summary: A great YouTube script adapted to work with Opera.
Version: 1.1.6_opera
Hi,
I took some time to make the YouTube HD Ultimate userscript (http://userscripts.org/scripts/show/31864) work with Opera latest stable release.
There is still some work to do, but my modifications make it work with Opera too (still working on FF of course!).
For those interested, see : http://code.google.com/p/youtubehd/issues/detai...
(Or the following message)
Help from other Opera developers could be helpful.
See u ++
---------------------
Even if I like Firefox, I'm mainly an Opera user.
Because I really like the YouTube HD Ultimate userscript (http://userscripts.org/scripts/show/31864), I took some time to make it work on
Opera latest stable version, without breaking the FF compatibility.
There is still some work to do, but it's good step.
------------------------------------------------------
//--------------------
/* Opera compatibility :
-Added basic mapping : console, GM_log, unsafeWindow
-Added GM_addStyle function
-Modify the way to begin the script in FF & Opera : (function(){ ... })();
[-Workaround with unsafeWindow ; but this command should be avoided. (var
config moved)
Idea (weird) : inject & execute a code in the page (via an anonymous
function call, like in 'Attach Method 1' on http://wiki.greasespot.net/
UnsafeWindow) that copy yt.config_ in a text format in an hidden div, then
get the data back in the userscript ?]
-Remove 'each' in `function Element(A, B, C)`
-Protect use of GM_getValue for now -> "Show Ultimate Options" panel not
working
---------------------------------
Most of powerful functionnalities are working :
-resize to max size
-hq auto
-auto buffer
-auto play
-Get link (with & without current position)
-Download links
-Keyboard controls
---------------------------------
Known issues :
-[Most of the time] As long as the page hasn't been fully loaded,
including video, the script isn't executed
=>typically the player starts, and several seconds later, the
video is resized while playing.
=>Need to work on that of course ^^ It's weird because sometimes
it works great. And most of the time the execution is delayed, unless the
video is in the cache...
-unsafeWindow.onYouTubePlayerReady callback function is not called :(
=> HD video aren't in hd (red bouton ... not red :-/)
I guess it's because the player.src += ""; `hack` doesn't work has
expected in Opera :
alert('before');
player.src += "";
alert('after');
=> On FF, HD is on (red bouton) when the 'after' alert is show ; On
Opera : nothing change.
player.addEventListener("onStateChange","stateChanged"); seems unrelated ?
I'm lost here, plz help !
---------------------------------
What isn't working with Opera :
- GM_setValue & GM_getValue not defined for Opera => not possible to store
preferences (for now) -> manually edit the script...
A cookie base implementation is possible, I'll try later.
-The update function (using GM_xmlhttpRequest)
=> The 'check for update' link or automatic check don't work.
Hum maybe possible to bypass the problem by doing so :
Inject http://userscripts.org/scripts/source/31864.use... with a
tag, in order to bypass the domain limitation.
Because I'm using a self-invoking function now `(function(){})()`, the
script is executed automatically.
-> Check if a global variable defining the userscript is present.
-> If so compare version and warn if necessary
For example:
(function()
{
var vers = 116; // current script version
if(YOUTUBEHDULTIMATE) // userscript aldready loaded
{
if(YOUTUBEHDULTIMATE.version < vers)
{
alert('New version available ! Plz update');
}
return; // stop [the injected script] !!
}
YOUTUBEHDULTIMATE = {version:vers}; // define the global variable
if(not check since a while)
{
var s = document.createElement('script');
s.src = 'http://userscripts.org/scripts/
source/31864.user.js';
s.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild
(s); // inject 31864.user.js
}
//----
...
})();
Other ideas :
-Replace childNodes[1] with getElementsByClassName
*/



