Skip to content

Instantly share code, notes, and snippets.

@Chematronix
Forked from Yonezpt/YT RMV-AP-UN.user.js
Last active January 9, 2021 18:48
Show Gist options
  • Save Chematronix/43c4212328821e408781513d9db97ed7 to your computer and use it in GitHub Desktop.
Save Chematronix/43c4212328821e408781513d9db97ed7 to your computer and use it in GitHub Desktop.
Removes the autoplay up next feature
// ==UserScript==
// @version 02--2017.09.12
// @name Disable autoplay next in Youtube
// @description Turns off autoplay next video in Youtube after a few (WAIT_SECS) seconds when you first (re)load a page. You can toggle it back on anytime, if you want to go jukebox mode, and it will stay on as long as you don't reload the page.
// @match *://www.youtube.com/*
// @run-at document-idle
// @noframes
// ==/UserScript==
(function () {
'use strict';
var SCRIPT_NAME = 'Disable autoplay next in Youtube';
var WAIT_SECS = 3;
function disableAutoPlay() {
// Toggle AutoPlay button if it's enabled
if( document.getElementById('toggle').active ) document.getElementById('toggle').click();
}
// Wait for the Next videos section to load
// Obsolete events are not working (readystatechange, spfdone), as expected.
// Couldn't get new ones to do it either (yt-navigate-* only seems to trigger after navigating to *another* video).
// Good old timeout does the trick tho
setTimeout(disableAutoPlay, WAIT_SECS*1000);
}());
@jeffmbellucci
Copy link

jeffmbellucci commented Sep 12, 2017

Anyone is welcome to fork this one, or copy it into their script runner of choice. Uses recursion to avoid race condition on load.

https://gist.github.com/jeffmbellucci/8db3a8b27664dac6b8f9cf10b416b433

@Chematronix
Copy link
Author

Hi again,

first than anything, I never had the intention of demeaning you, much less so make you angry. I wrote my answer with all the good intentions I profess in and out the keyboard, so I was quite a bit surprised by your last bit. I'm not sure if it was the smileys, a platonic sense of justice, the frustrating coworkers you mention or the limited expressive nature of text that twisted what I see as an honest-but-friendly to cockiness, but again, I would never provoke such reaction on purpose, so, for what it's worth, I'm sorry for that.

My points still stands though. You have to draw a line on how much nitpicking you'll deal with, and I guess mine is higher than yours. We are talking about a small hack with a minimal impact in the world, that will break with the next Youtube refactoring. That's very low on my scale.

Learning, on the contrary, is very high, so for me learning or stating someone does it is never a bad thing. I did assume you were new to JavaScript and friends, however, seeing you quiz two elements when one would suffice, and query accessibility values instead of proper properties. Perhaps you aren't, but still, you had to learn to find your solution, by your own admission, and that's all I stated. I'm sure Google is still a big tool in your own field.

On the other hand, the assumptions you make about me are a bit more extreme; and mostly wrong, I'm happy to say.

So, I hope things are a little more clear now. And if not, oh well, we both have better things to do in any case.

Cheers.

P.S: thanks for the advice.

@jeffmbellucci
Copy link

jeffmbellucci commented Sep 13, 2017

I appreciate your clarification. I'll delete my comments from the more public arena, aside from the one with the gist. Like you mentioned about taking little time on your re-write, initially, I spent only a few minutes fiddling in the console, to help make a working script again, I didn't refactor, or think that much about code quality.

Multiple people thanked the original author, which I think is appropriate, and I do my best to give credit where credit is due. I do think this field lacks a certain amount of mutual respect, and I have found over years of working with many devs, that there is a constant one-upmanship and concerted attempts to find flaws in other's work. I'll never understand that. I don't think it fosters cooperation or makes people want to join our field.

I studied economics and computer science in college, but graduated into the dotcom bust, so I chose to pursue EMS instead of development after school. About 5 years ago, I went back into the software industry because it was burgeoning again. Coming from being a paramedic and firefighter, where teamwork and positive communication is so important, I find the culture of software development frustrating much of the time. It has nothing to do with thick or thin skin, no one will bust your balls more than medics, cops, and fire guys. I find that type of negativity in software development counterproductive.

Anyway, you're more than welcome to code review my gist/script. I rewrote it to be more readable, from my point of view anyway. I know it's possible to make it shorter, I wrote it to make it clear, but people have different opinions on whether condensing code is a good or bad thing. More generally speaking, I won't make anymore assumptions about you, and I have no interest in a pissing match or trying to prove who is the most awesomest software superstar.

Take care.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment