Greasy Fork is available in English.

Discussions » Development

control youtube progress bar with script?

§
Gönderildi: 30.09.2020
Hello,
I used to watch youtube videos being logged in.
but stuff happened, youtube being a dumb c*nt, and my account got banned.

and I jsut came to realize that youtube without an account is harsh.

there is much stuff to get used to again but what really bugs me is the following:

say I open a site with a video.
the video starts playing automatically.
but as soon as I pause the video for the first time, no matter by what means, a trashy popup comes up telling me to sign in to youtube.
I have to click no.

well back to watching, right?
WRoNG!
first of, the video is paused, so I have to click or such to unpause it.
and even more annoying, the progress bar is set to 0:00 again!

So no matter how far I had watched the video, that progress is gone, I am at the start of the video again!

Sure is annonying.
and even more annoying, this happens with every video, every single time a sit with a video gets opened.
even if I have done the above procedure and jsut reload the site, the same thing will happen again.
so yeah, given that this happens with every single video every single time I want to watch it,
it is beyonf annoying and surely on purpose, youtubes way of telling "Yo f*ggot, there is no going around without an account under my watch!"


very long story short, I wanna get rid of it.
given that I have no idea how popups and such work on a tehcnical level, let alone how blocking them, preventing the pausing and progress reset would work, etc.
I wanna emulate the above mentioned steps with a script, so it's like a split second thingie that I probably wont realize even while watching.

What I wanna do:
Upon opening the video, have some event listener thingie (no idea how these work either by the way)
check every 300 miliseconds or so for the presence of the popup, simply by searching for the class name of that thing. also always in a variable keep the current progress time (like 0:13 or such) in mind.
then emulate the clicking on "No", unpause the video (emulating a click on the video element shoudl do that)
and jump back o where I was before.

the last part is what I have no idea how to do.

I had a video playing with the console on the site, I see that there is a bunch of stuff chainging, like the time 0:12, some progressbar value that goes from 0 (start) to 1(end) and some other stuff (like some string "time is 1 minute 12 seconds of 4 minutes 09 seconds max" or such).

tried to change them, but unpausing the video afterwards didnt do anything. the changed numbers jsut were overwritten with the video values.

apparently the video playing is some sort of event but I dont get how I can control it.

anyone got an idea how I can set the video progress to for example 1:23 or such?

I probably could go the complicated way by simulating a click on the right position on the progress bar, by doing some nasty calculations that would depend on all kinds of stuff...

but I totally wanna avoid that and, if possible, do it with some DOM manipulation or similar things.

anyone got any ideas on how to do that? :-/
§
Gönderildi: 02.10.2020
Düzenlendi: 02.10.2020
1 Check the links here https://greasyfork.org/en/discussions/requests/62860-stop-youtube-from-asking-for-account-creation-with-a-script

2 If you still want to develop what you are developing, then I think that you can somehow track the minutes AND SECONDS in the current youtube player, then store that as an variable, then after the whole process (when your script is finishing everything), you can RELOAD the page adding the following parameters to the end of the url ?t=2357 ,(replace the numbers with the variable, like ?t=CurrentTime), then the url will be like https://youtu.be/dB4lNHYp-Jg?t=2357 .But you need to figure out what 2357 is in minutes and seconds, maybe YT converts the current watched minutes and seconds to milliseconds? I don't know... (If I'm correct this number 2357 is a number in milliseconds). Even if I'm wrong about the milliseconds thing, you will still need to create some function/variables to convert the actual minutes AND seconds to "milliseconds", then you can add the output to the end of the current url.
2357 is equal to 39:17 minutes in YT videos, so I'm wrong... I'm not sure how to do this math...

3 Analyze these scripts and figure out how they work and they may help you. Or simply use them if they work
https://greasyfork.org/en/scripts/25922-youtube-resume
https://greasyfork.org/en/scripts/39153-youtube-auto-resume

Post reply

Sign in to post a reply.