Page 1 of 1
How to disable JavaScript navigation for a domain?
Posted: Mon Dec 29, 2014 2:16 pm
by jez9999
YouTube has recently introduced a damned annoying "feature" - when you're viewing a playlist, it immediately navigates to the next video when the current video ends. There doesn't seem to be any setting to stop this.
I think the easiest way to stop it would be to disable all JavaScript navigation on youtube.com, or preferably display a yes/no prompt each time it tries. Is there a way to do this with NoScript? If not, I think it would be a good addition. I want to continue allowing all other JavaScript, so I have set NoScript to allow scripts globally, and it doesn't stop YouTube from JS-navigating away from the page.
Re: How to disable JavaScript navigation for a domain?
Posted: Mon Dec 29, 2014 4:45 pm
by therube
URL:
https://www.youtube.com/watch?v=toHlMD5 ... jPbNs2M6Yo
> when you're viewing a playlist, it immediately navigates to the next video when the current video ends
I believe that "squiggly"-like icon is supposed to control that?
(I find it a PITA too cause I typically don't want it enabled, but am never sure in what state it is?)
Oh, it looks like they've removed it?
Re: How to disable JavaScript navigation for a domain?
Posted: Mon Dec 29, 2014 7:42 pm
by barbaz
I think you will need to use a surrogate script to do what you want.
Would the following work for you?
WARNING: UNTESTED
Code: Select all
noscript.surrogate.confirm_yt_exit.replacement : if (window.top.location.hostname == 'www.youtube.com') { window.addEventListener('beforeUnload', function(e){return 'Llllllll';}, false); }
noscript.surrogate.confirm_yt_exit.sources : @.youtube.com/watch?*
This would pop up a confirmation dialog *every time* you try (or the page tries) to leave a video page on YouTube, so it might be annoying...
I block so much on YouTube that I can't test this myself, sorry.
Re: How to disable JavaScript navigation for a domain?
Posted: Mon Dec 29, 2014 7:46 pm
by jez9999
barbaz wrote:I think you will need to use a surrogate script to do what you want.
Would the following work for you?
WARNING: UNTESTED
Code: Select all
noscript.surrogate.confirm_yt_exit.replacement : if (window.top.location.hostname == 'www.youtube.com') { window.addEventListener('beforeUnload', function(e){return 'Llllllll';}, false); }
noscript.surrogate.confirm_yt_exit.sources : @.youtube.com/watch?*
This would pop up a confirmation dialog *every time* you try (or the page tries) to leave a video page on YouTube, so it might be annoying...
I block so much on YouTube that I can't test this myself, sorry.
Is there no way to detect whether it's JavaScript that's caused the navigation, as opposed to your manually changing the URL?
Re: How to disable JavaScript navigation for a domain?
Posted: Mon Dec 29, 2014 7:50 pm
by barbaz
Well there are a number of different ways for JS to change the location, including but not limited to the following
Code: Select all
window.location.href = 'https://noscript.net/';
Code: Select all
document.getElementsByTagName('a')[0].click();
Code: Select all
document.location.href='https://noscript.net/';
Re: How to disable JavaScript navigation for a domain?
Posted: Mon Dec 29, 2014 7:51 pm
by jez9999
True, but it would be nice if the browser provided some kind of general "JS caused this navigation" flag.
Re: How to disable JavaScript navigation for a domain?
Posted: Mon Dec 29, 2014 7:52 pm
by barbaz
jez9999 wrote:True, but it would be nice if the browser provided some kind of general "JS caused this navigation" flag.
Nice but probably not technically possible (note the second one is actually just clicking on a link, which is a normal thing for a user to do)
Re: How to disable JavaScript navigation for a domain?
Posted: Mon Dec 29, 2014 8:01 pm
by jez9999
Sure, but the browser knows whether it's been triggered by JS or a user clicking.
Re: How to disable JavaScript navigation for a domain?
Posted: Mon Dec 29, 2014 8:24 pm
by barbaz
I did a quick Internet search about how to check if firefox browser location was changed by javascript, and couldn't find anything on the subject...
Re: How to disable JavaScript navigation for a domain?
Posted: Thu Jan 01, 2015 11:27 pm
by Thrawn
Probably a more practical, but still complex solution would be to find the piece of script that is actually performing the unwanted behavior, and write a surrogate that specifically targets it.