Greasy Fork is available in English.

Discussions » Creation Requests

Opening From YouTube To YouTube videos in new tab

Deleted user 128
§
Posted: 2015.08.06.
Edited: 2015.08.06.

Opening From YouTube To YouTube videos in new tab

Hi,

I have a slight problem with YouTube videos when opened from YouTube by default left-click : the video runs fine but the page totally ignores be it scripts be it Firefox add-ons applied to the rendered page :

Resize YT To Window Size script here available : ignored
YouTube HD Override script here available : ignored
YouTube HD Plus :: Add-ons for Firefox : ignored

But : if I either middle-click on the link (open in new tab) or right-click and from menu choose Open in This Tab/Open in New Tab... the video page opens and external scripts/add-ons above mentioned are respected!

So : I'd really care for a script that does the following :
Concerned pages (// @include OR // @match) : https://www.youtube.com/*
Concerned links : https : //www.youtube.com/watch?v=*

Pardon the newbies syntax! You get the idea I guess :)

At this time I systematically middle-click to open those videos in a new tab but I'd appreciate it being automatic, just for the sake's beauty.

Hope you can make it. It is perhaps so obvious that some of you will smile but I just happen to ignore the basics.

§
Posted: 2015.08.08.
Edited: 2015.08.08.

This is because of the way youtube loads there videos, if you're on the same page, and you click a video link to go to next, it pre-fetches, or something, not quite sure what it does, but what it doesn't do, is a full page reload which is required by most extensions (TamperMonkey, GreaseMonkey, etc.) to re-initiate a script. But when you open links in a new tab, it's doing a full page load, that is why the script works.

Simply refreshing the page after visiting a link is a way to do this. But I am currently working a script to make loading videos keep scripts compatible.

__________________________
EDIT:
Here is the userscript to fix video loads
https://greasyfork.org/en/scripts/11576

Deleted user 128
§
Posted: 2015.08.08.
Edited: 2015.08.08.

Thanks for your interest, William.

If I refresh the page it sends me back to Youtube Homepage, because when left-clicking the link the called video page's url is not passed to the urlbar :
i.e : I'm on youtube.com - I call (left-click) a video youtube.com/watch?v=xyz - In my urlbar the address remains youtube.com ... so if I refresh the video page I return to the homepage ... of course, no problem if I middle-click the link (open in new tab) but more surprisingly : if I right-click and choose 'Open Link in this tab' then everything is OK : urlbar shows youtube.com/watch?v=xyz, and all scripts/addons run correctly!

This is new to YouTube with its latest changes : it seems Youtube intercepts the left-click before my computer does and processes it with its scripts : any other opening of the video url is not problematic, only left-click...

Really weird!

§
Posted: 2015.08.08.

YouTube has implemented a pre-fetch of videos, and I think I've figured out how to fix it, the script I just updated in the post above should have the fix working, let me know if it doesn't work for you and I'll give it another go.

Deleted user 128
§
Posted: 2015.08.09.

William, your script doesn't work here. You wrote "[...]if it doesn't work for you[...]", does this mean it works on your system?
At this time the script's effect seems to be null (nothing added nor removed).
Thanks again for your time and work.

I stay tuned of course. Moreover a solution to the issue could benefit to everyone. But I get to wonder if this issue precisely is universal or if it appears only on certain configurations, mainly those including maybe specific scripts/add-ons. Forgot to mention I'm running Cyberfox 39.0.3 x-64 on Windows 7 x64 if this may be of any importance.

§
Posted: 2015.08.09.
Edited: 2015.08.09.

I have made several updates since then, and it should be working for most browsers, what extension are you using to run the script, and I'll test it in Cyberfox right now.


____________
EDIT:
Tested and working in Cyberfox 39 as well. It doesn't change anything appearance wise, but when navigating from the home YouTube page to any video link it should work, you should make your your script is also being updated by checking for updates, and refreshing the YouTube page, as in a hard refresh (ctrl+r). This will ensure the script is actually running, and it will continue to work, but as mentioned before, navigating to another video before doing this will not make the script start because of YouTube's weird pre-load mechanic.. BUT, once you have the script running, it'll stay working because it removes the pre-fetch thing YouTube introduced.


________
2nd EDIT:
Also, auto play will probably break the script as AutoPlay will continue to pre-fetch, and the script will not start on the newly loaded content.

Deleted user 128
§
Posted: 2015.08.09.
Edited: 2015.08.09.

I'm running scripts with Greasemonkey 3.3 Firefox add-on on Cyberfox 39.0.3 64-BIT / Windows 7 64-BIT.

Wait a minute... just installed again your script (ver 0.6) and it is now efficient : it works! (good thing I checked again).
I had tried it just before my 8:27AM post above and as I had mentioned there were no results. I cannot remember if the version was 0.6 as it is now, but now states updated 10hours ago which means before my 8:27AM comment ... have you updated your script after 8:27AM? I'm puzzled.

Whatever, great! left-clicking on a video's url opens the video in the same page, with the video's url in the urlbar and my concerned scripts & add-ons run flawlessly.

Thanks, I truly appreciate it, and I'm sure many of us will. YouTube's code modification fixed by your script is (was) annoying and NOT understandable.

Million thanks (that's what I call talent!)

§
Posted: 2015.08.09.

Not a problem, and it was probably it being created 10 hours ago, my last update (0.6) was under an hour ago, maybe closer to an hour, and thank you very much for the compliment, and I'm glad I could help.

Deleted user 128
§
Posted: 2015.08.09.
Edited: 2015.08.09.

I'm afraid I have to bring up what seems to be an exception ...

When running your script from youtube.com (or youtube.com/?gl=fr or youtube.com/?gl=US) the script runs fine
Now, if I run the script from a channel, a user page such as www.youtube.com/user/JustPlanes :
Those user pages include an autoplay video (channel autoplay) -> I pause the video -> I click on another video -> your script does not work anymore.

Sorry for that, please don't hate me :) It's already much better than before.

---

EDIT : this is just a newbie's idea, but wouldn't it be simpler (though less "pure") to have links to videos open in a new tab? No fuss.

---

EDIT2 : I found the Youtube script which, blocked, prevents the very issue described here, that is video pages blocking my scripts :

https://s.ytimg.com/yts/jsbin/spf-vflbit-XM/spf.js

I use an add-on called uBlock Origin and I had a look at the scripts ran by YouTube when opening a video. Blocking above mentioned restores normal display of video, with video url in urlbar and my scripts/addons respected.
Now : blocking this https://s.ytimg.com/yts/jsbin/spf-vflbit-XM/spf.js when on a channel page such as youtube.com/user/JustPlanes has this time the side-effect of blocking retrieval of the videos' thumbnails. Hopeless. But at least we know that the crappy code is in that ytimg.com script. For what it can help.

§
Posted: 2015.08.09.
Edited: 2015.08.09.

It would be easier to open in new tab, but then you would have hundreds of tabs, and what if you wanted to navigate elsewhere, you'd have to close the previous tab, etc. etc, but I could easily implement this.

Update 0.7: Now should work truly all over youtube.

_________________
EDIT:
Also, having it open in a new tab would still require it to alter all links, youtube has most(closer to all) links bound to their pre-fetch.

_________________
EDIT 2:
This update should have *ALL* links fixed, so there shouldn't be any more updates needed for the script, but I will fix any problems I find.. Also, yes that is the script that's causing the problem/pre-fetching.. I suppose blocking the script source would be easier than using my script. xD

Deleted user 128
§
Posted: 2015.08.09.
Edited: 2015.08.09.

Just installed 0.7 and still won't be efficient on a channel page such as https://www.youtube.com/user/JustPlanes where I've just tested it.
What a pain.

As I said, blocking this https://s.ytimg.com/yts/jsbin/spf-vflbit-XM/spf.js when on a channel page such as youtube.com/user/JustPlanes has this time the side-effect of blocking retrieval of the videos' thumbnails. Hopeless.

Thanks for what is becoming your commitment, William.

§
Posted: 2015.08.09.
Edited: 2015.08.09.

I am sorry to hear that the script is not working for you, it still functions for me on the channels, home, and everywhere else. I will keep investigating this, and yes, blocking the script is probably the most effective way, so I'll find a way to fetch the thumbnails too when I get a little bit of free time today.


_____________
EDIT:
Found the issue on user channel's.. when on the /videos/ tab, it still prefetches, I am working on a fix right now.

_____________
EDIT 2:
0.7 works for me in FF 39, I just tested this, but does not work in /videos/ for Chrome as of right now..
/Edit 3:
Works in chrome, maybe it took a bit for my script to update for me, but it seems to be working perfectly for me in both browsers..

Deleted user 128
§
Posted: 2015.08.09.

For what it's worth, I forgot to mention that I read YouTube videos with HTML5 (I've removed Flash system-wide).
YouTube's new spf.js is a true pain behaving like dirty black code (companies learn a lot from devil's brains).
At least remains the middle-click option.
Thanks for your work, William.

Post reply

Sign in to post a reply.