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

Autplay not working. Ver 4.820 #2137

Open
sonal-g123 opened this issue Mar 31, 2024 · 76 comments
Open

Autplay not working. Ver 4.820 #2137

sonal-g123 opened this issue Mar 31, 2024 · 76 comments
Labels
Bug Bug or required update after YouTube changes good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) related thread/s exist/s. (Link or consolidate maybe) Thanks!! Riddle up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥

Comments

@sonal-g123
Copy link

By autoplay, I mean the video I click on, not the videos lined up in my playlist. This play button has not been working for months now and I have to manually click on the "play" button on the 20+ videos I watch daily

Not sure if this is a bug or if it's bc of YT's changed algorithm, but is it possible to take a look at it?

Thank you <3

@sonal-g123 sonal-g123 added Bug Bug or required update after YouTube changes Feature request Wish or idea good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥ labels Mar 31, 2024
@raszpl
Copy link
Contributor

raszpl commented Apr 4, 2024

Are you sure this is ImproveTube. If anything ImproveTube has trouble pausing videos in the first place.
Try temporarily disabling it and browsing YT for few hours.

@sonal-g123
Copy link
Author

Are you sure this is ImproveTube. If anything ImproveTube has trouble pausing videos in the first place. Try temporarily disabling it and browsing YT for few hours.

I did. I uninstalled all extensions except IT and nothing changed. I uninstalled IT and kept all my other extensions, and YT videos started auto playing. I tried it with both their main and Beta extensions - the result was the same. I finally decided to permanently remove this extension from my browser. It's wonderful, but I really loathe having to manually click play on 20+ videos on a daily basis.

@raszpl
Copy link
Contributor

raszpl commented Apr 8, 2024

Did you switch Autoplay in options of ImproveTube? The only way for ImproveTube to do anything to video playback is for you to switch Autoplay off first.

@sonal-g123
Copy link
Author

sonal-g123 commented Apr 9, 2024 via email

@MRiCEQB
Copy link

MRiCEQB commented Apr 19, 2024

I have the same issue - or a similar one.
Whenever I go on YouTube and find several videos I want to watch, I use the middle mouse button to open them in individual tabs.
In the past they started to autoplay, once I selected the desired tab - now they are always on pause.
This doesn't happen when I open a video right away (left mouse button).

I first suspected my uBlock Origin extension but the error indeed only goes away, once I disable ImproveTube.
If you require any logs or something, please let me know.

@sonal-g123
Copy link
Author

sonal-g123 commented Apr 25, 2024 via email

@MRiCEQB
Copy link

MRiCEQB commented Apr 25, 2024

When you now disable ImprovedTube, does it autoplay in the next tab?

@sonal-g123
Copy link
Author

sonal-g123 commented Apr 26, 2024 via email

@MRiCEQB
Copy link

MRiCEQB commented Apr 26, 2024

So (at least to my understanding) ImprovedTube does something, that causes this behavior.

@raszpl
Copy link
Contributor

raszpl commented Apr 26, 2024

Default youtube setting is ALL videos Pause when opened in background tab, but start autoplaying when you click on that tab and make it active/visible.

@MRiCEQB
Copy link

MRiCEQB commented Apr 26, 2024

Default youtube setting is ALL videos Pause when opened in background tab, but start autoplaying when you click on that tab and make it active/visible.

Correct and this behavior does not work for us, as long as ImprovedTube is active.
Once we disable ImprovedTube, it works as intended.

@ImprovedTube
Copy link
Member

ImprovedTube commented Apr 26, 2024

hi, please open the browser console when (before or after) the issue happens to copy any errors or log message from us (not those from Youtube or third parities)
@sonal-g123 @MRiCEQB
thanks!

@MRiCEQB
Copy link

MRiCEQB commented Apr 26, 2024

This is a bit tricky to catch, because the console needs to be activated for each tab (as fas as i can tell).
So opening a new tab -> clicking it -> hitting F12, might not catch the error in time or any log at all.
Here I have one entry from ImrovedTube, but that also shows up, when I open a video directly in the same window (means not in a new tab).

www.youtube.com-1714134095880.log

@raszpl
Copy link
Contributor

raszpl commented Apr 26, 2024

console doesnt need to be open prior to log errors. there are no errors in your log file
what browser? can you try disabling all other extensions but improvetube?

@MRiCEQB
Copy link

MRiCEQB commented Apr 26, 2024

I'm using Chrome.
Disabled everything except ImprovedTube and the error still remains.
Once ImprovedTube is disabled, the video start to play as expected, once I switch to their tab.

@ImprovedTube ImprovedTube added Riddle and removed Feature request Wish or idea labels Apr 26, 2024
@ImprovedTube
Copy link
Member

ImprovedTube commented Apr 26, 2024

thank you! @MRiCEQB
please type in the browser console
yt.config_.EXPERIMENT_FLAGS
(enter)
rightclick on the result: copy object

@sonal-g123 @Jerrk @CodeClimberNT @Sidonly @DrNopt killthe3vil @Evoden1 @xeophyte


( then we can compare further which might be the reason
https://docs.google.com/spreadsheets/d/1GidvMduxTl6jXpDCKj-sOPg8KSqDfCYO2OlCdBADaSI/edit#gid=0 )

#1851 (comment)


March

without IYT extension also doesn't work.
#1809 (comment)

December

It just started to work for me
#1851 (comment)

December

And today the autoplay stopped working again ;]

#2136 (with @Jerrk's ctrl+u.txt already )
#1867 #2012

@Jerrk
Copy link

Jerrk commented Apr 26, 2024

I did the result twice, once when the problem occurs and then another time after clearing cookies and the problem is gone.

I ran a diff check on both of them and there is no difference

problem.txt

@CodeClimberNT
Copy link

CodeClimberNT commented Apr 26, 2024

Just as an FYI I had to format and reinstall my Windows 11 and most of the problem were fixed (not all of it!), anyway those are my flags: experimental-flags.json.
One thing I think I need to mention, before formatting my computer was very slow and found similar issue using another extension to change YouTube behavior to be unreliable with respect of another computer of mine that never had issue whatsoever (lot of RAM, very powerful CPU). I don't know if actually using YouTube for a long time make you more susceptible to have those flags changed, or maybe is some sort of memory saving of the browser that in some particular condition (previously I had a lot of memory swap used and still am, but now it's very limited) will limit the functionality of the extension. I found the latter very difficult to believe but better give as much information as possible.
As others have noted, clearing the browser cookie (or reinstalling the OS in my case) will fix a lot of issues.

@xeophyte
Copy link

xeophyte commented Apr 26, 2024

image


edit: hi @xeophyte! Can type console prompts just below, after the ">"

@Evoden1
Copy link

Evoden1 commented Apr 26, 2024

https://gist.github.com/Evoden1/747254eb676cf5da1a4f8044dbe64757

the yt.config_.EXPERIMENT_FLAGS result

@sonal-g123
Copy link
Author

sonal-g123 commented Apr 27, 2024 via email

@raszpl
Copy link
Contributor

raszpl commented Apr 27, 2024

Ok, since we have couple of you here able to trigger this reliably. Experiment:

  • search for /js&css/web-accessible/player.js file on your disk, should be in Chrome \User Data\Default\Extensions\ directory somewhere.
  • open in text editor
  • search for "setTimeout(function () { video.pauseVideo(); }); " and delete this line
  • save file
  • reload YT page, usually works off the bat, sometimes requires manually reloading extensions or just restarting browser.

edit: hi @raszpl! applies with unzipped "developer mode" installations. If it was installed from the webstore, modifying and reloading an extension will be noticed as corrupted and won't load.

@xeophyte
Copy link

I deleted setTimeout(function () { video.pauseVideo(); }); and restarted browser and extension and still have no autoplay.

ImprovedTube added a commit that referenced this issue May 4, 2024
Update player.js quick bodge fix for #2137
@raszpl
Copy link
Contributor

raszpl commented May 4, 2024

last test. Edit original \js&css\web-accessible\www.youtube.com\player.js

ImprovedTube.autoplay = function () {
    var video = ImprovedTube.elements.player;
    if (ImprovedTube.video_url !== location.href) {
        ImprovedTube.ignore_autoplay_off = false;
    }
    // if (allow autoplay is false) and  (no ads playing) and
	// ( there is a video and ( (it is not in a playlist and  auto play is off ) or ( playlist auto play is off and it is not in a playlist ) ) ) or (if we are in a channel and the channel trailer autoplay is off)  )
    if (ImprovedTube.ignore_autoplay_off === false && video.classList.contains('ad-showing') === false &&
        ( 
// quick fix #1703  thanks to @AirRaid#9957
            (/* document.documentElement.dataset.pageType === "video" */ location.href.indexOf('/watch?') !== -1 && ((location.href.indexOf('list=') === -1 && ImprovedTube.storage.player_autoplay === false) || (ImprovedTube.storage.playlist_autoplay === false && location.href.indexOf('list=') !== -1))) ||
            (/* document.documentElement.dataset.pageType === "channel" */ ImprovedTube.regex.channel.test(location.href) && ImprovedTube.storage.channel_trailer_autoplay === false)
        )
    )         
	{if (!ImprovedTube.autoplayDeniedOnce) {  
	 setTimeout(function () {  video.pauseVideo();  });        
	 ImprovedTube.autoplayDeniedOnce = true; 
	} else { console.log("autoplay:off - should we pause here again?"); } }
};

to

ImprovedTube.autoplay = function (videoElement) {
	const video = ImprovedTube.elements.player || videoElement.closest('#movie_player');
    if (ImprovedTube.video_url !== location.href) {
        ImprovedTube.ignore_autoplay_off = false;
    }
	if (video && ImprovedTube.ignore_autoplay_off === false && video.classList.contains('ad-showing') === false &&
        ( 
// quick fix #1703  thanks to @AirRaid#9957
            (/* document.documentElement.dataset.pageType === "video" */ location.href.indexOf('/watch?') !== -1 && ((location.href.indexOf('list=') === -1 && ImprovedTube.storage.player_autoplay === false) || (ImprovedTube.storage.playlist_autoplay === false && location.href.indexOf('list=') !== -1))) ||
            (/* document.documentElement.dataset.pageType === "channel" */ ImprovedTube.regex.channel.test(location.href) && ImprovedTube.storage.channel_trailer_autoplay === false)
        )
    )         
	{if (!ImprovedTube.autoplayDeniedOnce) {  
	 setTimeout(function () {  video.pauseVideo();  });        
	 ImprovedTube.autoplayDeniedOnce = true; 
	} else { console.log("autoplay:off - should we pause here again?"); } }
};

and js&css\web-accessible\functions.js line 340
ImprovedTube.autoplay();
to
ImprovedTube.autoplay(this);

@xeophyte
Copy link

xeophyte commented May 4, 2024

I don't have this video.pauseVideo(); in either of these two .js files.

oh, so you deleted it when I asked earlier, and this still didnt cure YT?

Yes.

With if (ImprovedTube.ignore_autoplay_off === false && video.classList.contains('ad-showing') === false && ( (uncommented) and even without restarting the browser I have

ImprovedTube.autoplay !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
player.js:6 undefined
player.js:8  true
player.js:9 false

when not clicking the player to play and

ImprovedTube.autoplay !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
player.js:6 <div class=​"html5-video-player ytp-transparent ytp-exp-bottom-control-flexbox ytp-modern-caption ytp-exp-ppp-update ytp-fit-cover-video ytp-bigboards ytp-fine-scrubbing-exp ytp-hide-info-bar ytp-large-width-mode ytp-heat-map-v2 ytp-heat-map ytp-autonav-endscreen-cancelled-state playing-mode buffering-mode" tabindex=​"-1" id=​"movie_player" data-version=​"/​s/​player/​7d1f7724/​player_ias.vflset/​pl_PL/​base.js" aria-label=​"Odtwarzacz wideo YouTube" data-default-quality=​"hd1080">​…​</div>​
player.js:8  true
player.js:9 false
player.js:10 false
player.js:11 true
player.js:12 /\/(@|c\/@?|channel\/|user\/)(?<name>[^/]+)/
player.js:13 undefined
player.js:14 ImprovedTube.autoplay ______________________________________________________

after clicking the play.

@raszpl
Copy link
Contributor

raszpl commented May 4, 2024

sorry, I was still editing last message. Try that , in theory should be fixed

@xeophyte
Copy link

xeophyte commented May 4, 2024

#2137 (comment) works for me.

@raszpl
Copy link
Contributor

raszpl commented May 4, 2024

can you test if switching autoplay to off in extension options(player section) also works for you? just a quick toggle and couple of refreshes. Its not 100% reliable now because sometimes YT tries to autoplay several times, in that case you can try commenting out
//ImprovedTube.autoplayDeniedOnce = true;

Hopefully it will be fixed in next release

@xeophyte
Copy link

xeophyte commented May 4, 2024

Yes, autoplay off also works. Tested on few videos with many refreshes and nothing played. Same with //ImprovedTube.autoplayDeniedOnce = true;

@Evoden1
Copy link

Evoden1 commented May 4, 2024

last test. Edit original \js&css\web-accessible\www.youtube.com\player.js

ImprovedTube.autoplay = function () {
    var video = ImprovedTube.elements.player;
    if (ImprovedTube.video_url !== location.href) {
        ImprovedTube.ignore_autoplay_off = false;
    }
    // if (allow autoplay is false) and  (no ads playing) and
	// ( there is a video and ( (it is not in a playlist and  auto play is off ) or ( playlist auto play is off and it is not in a playlist ) ) ) or (if we are in a channel and the channel trailer autoplay is off)  )
    if (ImprovedTube.ignore_autoplay_off === false && video.classList.contains('ad-showing') === false &&
        ( 
// quick fix #1703  thanks to @AirRaid#9957
            (/* document.documentElement.dataset.pageType === "video" */ location.href.indexOf('/watch?') !== -1 && ((location.href.indexOf('list=') === -1 && ImprovedTube.storage.player_autoplay === false) || (ImprovedTube.storage.playlist_autoplay === false && location.href.indexOf('list=') !== -1))) ||
            (/* document.documentElement.dataset.pageType === "channel" */ ImprovedTube.regex.channel.test(location.href) && ImprovedTube.storage.channel_trailer_autoplay === false)
        )
    )         
	{if (!ImprovedTube.autoplayDeniedOnce) {  
	 setTimeout(function () {  video.pauseVideo();  });        
	 ImprovedTube.autoplayDeniedOnce = true; 
	} else { console.log("autoplay:off - should we pause here again?"); } }
};

to

ImprovedTube.autoplay = function (videoElement) {
	const video = ImprovedTube.elements.player || videoElement.closest('#movie_player');
    if (ImprovedTube.video_url !== location.href) {
        ImprovedTube.ignore_autoplay_off = false;
    }
	if (video && ImprovedTube.ignore_autoplay_off === false && video.classList.contains('ad-showing') === false &&
        ( 
// quick fix #1703  thanks to @AirRaid#9957
            (/* document.documentElement.dataset.pageType === "video" */ location.href.indexOf('/watch?') !== -1 && ((location.href.indexOf('list=') === -1 && ImprovedTube.storage.player_autoplay === false) || (ImprovedTube.storage.playlist_autoplay === false && location.href.indexOf('list=') !== -1))) ||
            (/* document.documentElement.dataset.pageType === "channel" */ ImprovedTube.regex.channel.test(location.href) && ImprovedTube.storage.channel_trailer_autoplay === false)
        )
    )         
	{if (!ImprovedTube.autoplayDeniedOnce) {  
	 setTimeout(function () {  video.pauseVideo();  });        
	 ImprovedTube.autoplayDeniedOnce = true; 
	} else { console.log("autoplay:off - should we pause here again?"); } }
};

and js&css\web-accessible\functions.js line 340 ImprovedTube.autoplay(); to ImprovedTube.autoplay(this);

i did it and now autoplay works on Firefox Beta

@Evoden1
Copy link

Evoden1 commented May 4, 2024

can you test if switching autoplay to off in extension options(player section) also works for you? just a quick toggle and couple of refreshes. Its not 100% reliable now because sometimes YT tries to autoplay several times, in that case you can try commenting out //ImprovedTube.autoplayDeniedOnce = true;

Hopefully it will be fixed in next release

I toggled it off, and the video pauses after the page loads

I toggled it on, and the autoplay function works perfectly

@raszpl
Copy link
Contributor

raszpl commented May 5, 2024

Thank you @Jerrk @Evoden1 @xeophyte for helping debug the problem.

@Jerrk
Copy link

Jerrk commented May 5, 2024

I'm glad it seems to have been figured out :)

Would this also fix my issue #2136 where the fullscreen and playback speed isn't applied either? since it seems to me that the cause is the same where the player element isn't loaded in time and crashes the script

@xeophyte
Copy link

xeophyte commented May 5, 2024

I thought it would solve my other problem but it didn't #1867

@raszpl
Copy link
Contributor

raszpl commented May 5, 2024

I'm glad it seems to have been figured out :)

Would this also fix my issue #2136 where the fullscreen and playback speed isn't applied either? since it seems to me that the cause is the same where the player element isn't loaded in time and crashes the script

not directly, both fullscreen and playback speed functions appear to check for existence of player element being set properly, but its possible autoplay was crashing whole extension before those could be applied.

I thought it would solve my other problem but it didn't #1867

wasnt that in Vivaldi? I cant reproduce this problem in Vivaldi :( The thing that can fix it is commenting out //ImprovedTube.autoplayDeniedOnce = true;

@Jerrk
Copy link

Jerrk commented May 6, 2024

I'm glad it seems to have been figured out :)
Would this also fix my issue #2136 where the fullscreen and playback speed isn't applied either? since it seems to me that the cause is the same where the player element isn't loaded in time and crashes the script

not directly, both fullscreen and playback speed functions appear to check for existence of player element being set properly, but its possible autoplay was crashing whole extension before those could be applied.

I did the changes in #2137 (comment) and autoplay now works. toggling it on/off also works.

The change doesn't appear to affect the auto fullscreen setting nor the playback speed though.

@ImprovedTube
Copy link
Member

wow! 65 comments!

clearing cookies and the problem is gone.

💭


if ImprovedTube.elements.player can be undefined, we have something to research! ❤️

let tries=0;  
(function waitForVideo(){ 
	if(ImprovedTube.elements.player 
	|| ImprovedTube.elements.player = document.body.closest('#movie_player')){	return;
	}else if(tries++<101) {setTimeout(waitForVideo,50); if(console.log("waiting for #movie_player"); 
	}else if(tries===101) {console.error("resigning to wait for #movie-player after > 5s")}  
})()  
document.addEventListener("DOMContentLoaded", () => tries = 101);

crashing

  • it should only break that single function call, no? ( var player=ImprovedTube.elements.player alone should be equal to as if if (typeof ImprovedTube.elements.player === undefined) return; was before it) (@raszpl)

    • ImprovedTube.autoplay(); I commented this one only, and the autoplay problem is fixed

      and you didnt have the autoplay disabled in the settings? 😲 @Evoden1

    • With HTMLMediaElement.prototype.play_disabled = (function (original) { autoplay works, even without restarting the browser.

      appending _disabled to the function in line 326 does actually autoplay the videos now.

      was the extension was still running then? (/loaded unpacked in "developer mode") @Jerrk @xeophyte

      If it was installed from the webstore, modifying and reloading an extension will be noticed as corrupted and won't load.


Looks like Firefox picks up file changes without restarting, so thats good.

Chrome does too afaik for the web-accessible files. @raszpl


Experiment Flags:

I ran a diff check on both of them and there is no difference
problem.txt

thank you! @Jerrk

I cleared cookies and site data for youtube and google and:

  • when I'm not logged in YT: autoplay works
  • when I'm logged in YT: autoplay doesn't work

That would teach us what part of youtube is required for the bug, if we compare your experiment flags ( @xeophyte logged in & logged out, to see which might change when you log out. #2137 (comment) )

https://gist.github.com/Evoden1/747254eb676cf5da1a4f8044dbe64757
the yt.config_.EXPERIMENT_FLAGS result

thanks! @Evoden1. (logged in?)

previously:

#1851 (comment)

@raszpl
Copy link
Contributor

raszpl commented May 6, 2024

I dont think its experimental flags, it might be FFs different JS engine combined with caching (YT serviceworker) letting YT initialize faster thus outpacing improvetube terrible mechanism of walking all nodes in childHandler

} else if (id === 'movie_player') {
if (!this.elements.player) {
ImprovedTube.elements.player = node;

Sadly improvetube has at least a few timing assumptions that only hold by sheer luck :) like #1803 (comment)

	|| ImprovedTube.elements.player = document.body.closest('#movie_player')){	return;

document.querySelector('#movie_player')
and more like
(document.querySelector('#movie_player') && !ImprovedTube.elements.player)

But I dont think you can run a function that would show it in Chrome due to the way Javascript event loop works. I think its only showing up in Firefox due to JS engine differences, FF one is somehow more/less aggressively serializing and somehow calling play() before mutationObserver triggers.

@ImprovedTube
Copy link
Member

then we can adjust and/or report something to firefox
🎉

For me on Firefox 124 and IYT v4.805 autoplay doesn't work, v3.901 also doesn't work, without IYT extension also doesn't work.

#1809 (comment)

I dont think its experimental flags

one error can have multiple requirements (even we don't always need to know all of them) (Or "working when logged out" was a coincidence, deleting cookies too, just like disabling autoplay-off)

@Evoden1
Copy link

Evoden1 commented May 7, 2024

https://gist.github.com/Evoden1/747254eb676cf5da1a4f8044dbe64757
the yt.config_.EXPERIMENT_FLAGS result

thanks! @Evoden1. (logged in?)

Yes logged in

@ImprovedTube ImprovedTube added the related thread/s exist/s. (Link or consolidate maybe) Thanks!! label May 9, 2024
@xeophyte
Copy link

Doesn't seem to be fixed in 4.921.

@Evoden1
Copy link

Evoden1 commented May 10, 2024

Is there any way I can install the latest improvetube version on Firefox permanently and not as a as a temporary add-on?

I downloaded Firefox Nightly and did this:
Disabled signature checks about:config, change xpinstall.signatures.required to false

and tried to install Improvetube zip
but it said Add-on "appears to be corrupt."

I don't want to self-sign the extension is there any other way?

@Evoden1
Copy link

Evoden1 commented May 10, 2024

nvm I did it

I had to put a random email in the manifest ID.

and repacked the zip and brought the manifest and other files to root level and not inside youtube-4.920.

@raszpl
Copy link
Contributor

raszpl commented May 10, 2024

Doesn't seem to be fixed in 4.921.

I dont know when 4.921 was build, code looks 2 weeks old? its pre #2210

@xeophyte
Copy link

I don't know, updated 10.05 on chrome webstore

@ImprovedTube
Copy link
Member

4.921

= just 4.805. Rolled back from 4.920 because it had 100+ uninstalls in the first hour https://improvedtube.com/uninstalls-hours-days-usatime-updated-every-3-minutes . Google just added such immediate rollback (amazingly late, while other extensions can be worth billions, like honey)
roll back extension


Mozilla Firefox might takes some days to release the 4.920rev4

and tried to install Improvetube zip

named .xpi? @Evoden1

@Evoden1
Copy link

Evoden1 commented May 13, 2024

named .xpi? @Evoden1

no zip

I modified the zip (from github releases) by moving the manifest and everything to root level, not inside youtube-4.920.
and installed it on Firefox Nightly and it works but i had to change "xpinstall.signatures.required " to false in about:config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug or required update after YouTube changes good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) related thread/s exist/s. (Link or consolidate maybe) Thanks!! Riddle up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥
Projects
None yet
Development

No branches or pull requests

9 participants