Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using resources ? #4

Closed
momala454 opened this issue Oct 25, 2018 · 6 comments
Closed

Using resources ? #4

momala454 opened this issue Oct 25, 2018 · 6 comments

Comments

@momala454
Copy link

hello
it seems the script is called every 500ms that check if there is a popup.
That seems to be resource intensive.
Could it be in a better way to use less resource ?

Also, i saw a popup that says it will "soon" pause the video if i don't confirm. So, instead of detecting that the video is paused by youtube, could it detect that it will soon pause the video if we don't click, and click on that instead, so no need to unpause the video, just click on that, and also maybe run the script much less than 2 times a second (i guess you do that to quickly unpause the video and not cause interruption ?)

@lawfx
Copy link
Owner

lawfx commented Oct 26, 2018

Auto-clicking the small notification that appears in the left bottom corner doesn't stop the actual pausing from happening. It was among the first things I tried and I guess YouTube is smarter than that and can figure out if the clicking was legit.
That's why even though this script overrides the pausing, it still gets triggered pretty soon, compared to clicking it by hand.

Furthermore, if the YouTube tab is inactive, the popup never gets spawned, because the DOM elements aren't updated. The video just gets paused and only if you navigate to the tab the actual popup spawns. This was a problem I didn't know about in the first versions.

So to conclude, the script is called every 500ms to un-pause the video as fast as possible in a reasonable manner.

A way I thought of but didn't have the time yet to explore, that might work, is maybe if you can bind an event to the elements of interest and just detect their change... that would eliminate the need for the 500ms interval.

@momala454
Copy link
Author

on the video page there is a json object with some (maybe) interesting variables :

"youthere_innertube_actions":true
"disable_youthere_lact_threshold_check":true

and on polymer js there are some functions :
resetYouThere_
b.youThereData_=a.configData.youThereData

@lawfx
Copy link
Owner

lawfx commented Oct 31, 2018

Sorry for the late reply, busy week. I've also tried debugging the polymer js to see what makes it tick but didn't get far. And even if I find what triggers the check, since it looks to be some internal js, I have no idea how to stop it from executing or even if it's possible at all without blocking js altogether.
I also tried checking to see if some kind of request is being made to the youtube servers so that i can block it or something, but nothing. Everything seems to be just pure polymer js.
Funny thing is that this check can be triggered manually even if you don't watch youtube for a long time, eg. try clicking this -> https://www.youtube.com/watch?v=6gN0LFriw9E&t=5769

@momala454
Copy link
Author

momala454 commented Nov 28, 2018

i found this code which modify a function that return the time since activity. I don't know why it still use setInterval if it modifies the function : https://greasyfork.org/en/scripts/35157-remove-youtube-activity-check/code

maybe it can be improved ?

edit: even better !
there is the flag yt.config_.EXPERIMENT_FLAGS.disable_youthere_lact_threshold_check if set to true that disable that annoying thing.

Strangely, it seems like it is already true for me right now ... ?

edit: maybe it's with value false as with true i got the video pause

@momala454
Copy link
Author

youtube is using the variable window._lact to store the last time an activity was recorded
this variable is obviously not modified when you do nothing so another solution would be to modify this variable to some date in future by example every 10 minutes

@lawfx
Copy link
Owner

lawfx commented May 4, 2019

I was never able to make it work by changing this variable or any other variable for that matter. Also the script you attached didn't work for me. If you have any success, feel free to submit a pull request and I'll examine it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants