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

autoplay quickfix #1703

Open
ImprovedTube opened this issue Jun 10, 2023 · 5 comments
Open

autoplay quickfix #1703

ImprovedTube opened this issue Jun 10, 2023 · 5 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.) Knowledge Base / Dokumenation for developers We should repurpose this for future reference / Wiki / Education / Introduction related thread/s exist/s. (Link or consolidate maybe) Thanks!! up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥

Comments

@ImprovedTube
Copy link
Member

ImprovedTube commented Jun 10, 2023

AirRaid
Videos don't always auto-pause when navigating to them. Is there something I should look for; other than disabling Player\Auto-play?

AirRaid
And yeah, confirming - it was pageType === "video" and pageType === "channel"

  • undoing the use of the pageType function for now: 4491a2c
    • the original author might had a reason not to use that there.

ImprovedTube.pageType = function () {
if (/\/watch\?/.test(location.href)) {
document.documentElement.dataset.pageType = 'video';
} else if (location.pathname === '/') {
document.documentElement.dataset.pageType = 'home';
} else if (/\/subscriptions\?/.test(location.href)) {
document.documentElement.dataset.pageType = 'subscriptions';
} else if (/\/@|(\/(channel|user|c)\/)[^/]+(?!\/videos)/.test(location.href)) {
document.documentElement.dataset.pageType = 'channel';
} else {
document.documentElement.dataset.pageType = 'other';
}
};

  • also the timing of above function is slightly later through: f5d8593
    • as of:
      extension.inject([
      '/js&css/web-accessible/core.js',
      '/js&css/web-accessible/functions.js',
      '/js&css/web-accessible/www.youtube.com/appearance.js',
      '/js&css/web-accessible/www.youtube.com/themes.js',
      '/js&css/web-accessible/www.youtube.com/player.js',
      '/js&css/web-accessible/www.youtube.com/playlist.js',
      '/js&css/web-accessible/www.youtube.com/channel.js',
@ImprovedTube ImprovedTube added Bug Bug or required update after YouTube changes help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥ labels Jun 10, 2023
@ImprovedTube ImprovedTube changed the title autoplay fix autoplay quickfix Jun 10, 2023
ImprovedTube added a commit that referenced this issue Jun 10, 2023
@ImprovedTube
Copy link
Member Author

ImprovedTube commented Jun 10, 2023

dc0dc71

@raszpl
Copy link
Contributor

raszpl commented Jun 13, 2023

There must be another more efficient way of disabling autoplay. Current

HTMLMediaElement.prototype.play = (function (original) {
still allows for a sub second play time and fetches few seconds of video to a buffer :(. On the other hand YT detects if viewport is visible/tab active and will not start playing at all if you open YT page in the background until you switch to that tab.

dodieboy added a commit to dodieboy/YouTube-Extension that referenced this issue Jul 29, 2023
This should fix disable autoplay still play for a milisecond before the video pause when video is open using new tab.

code-charity#1703
@ImprovedTube ImprovedTube added the Knowledge Base / Dokumenation for developers We should repurpose this for future reference / Wiki / Education / Introduction label Sep 3, 2023
ImprovedTube added a commit that referenced this issue Jan 12, 2024
ImprovedTube pushed a commit that referenced this issue Jan 12, 2024
This should fix disable autoplay still play for a milisecond before the video pause when video is open using new tab.

#1703
@ImprovedTube ImprovedTube reopened this Apr 3, 2024
@ImprovedTube
Copy link
Member Author

There must be another more efficient way of disabling autoplay. Current

HTMLMediaElement.prototype.play = (function (original) {

still allows for a sub second play time and fetches few seconds of video to a buffer :(. On the other hand YT detects if viewport is visible/tab active and will not start playing at all if you open YT page in the background until you switch to that tab.

hi! @raszpl, btw

should we try the stop() function as possible or repeatedly within 0.x seconds?
@dodieboy thought about this before after youtube removed a function.

this one:

} else if (id === 'movie_player') {
if (!this.elements.player) {
ImprovedTube.elements.player = node;
// if (this.storage.player_autoplay === false) { ImprovedTube.elements.player.stopVideo(); }

was placed critically/misplaced, because depending what changes over time during the sessions, our mutation handler could reach there too (https://github.com/code-charity/youtube/blob/master/js%26css/web-accessible/init.js )

@raszpl
Copy link
Contributor

raszpl commented Apr 4, 2024

stop() function as possible or repeatedly within 0.x seconds?

pause works fine in other extensions, just need to slightly rework where its being called
as for reliably pausing every time this needs to be removed

{if (!ImprovedTube.autoplayDeniedOnce) {
setTimeout(function () { video.pauseVideo(); });
ImprovedTube.autoplayDeniedOnce = true;
} else { console.log("autoplay:off - should we pause here again?"); } }

I have no idea what its for, but its breaking autoplayDisable

@ImprovedTube
Copy link
Member Author

#2157 (comment)

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.) Knowledge Base / Dokumenation for developers We should repurpose this for future reference / Wiki / Education / Introduction related thread/s exist/s. (Link or consolidate maybe) Thanks!! up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥
Projects
None yet
Development

No branches or pull requests

2 participants