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

Fixed Issue #1508 #1585

Merged
merged 2 commits into from
Feb 22, 2023
Merged

Fixed Issue #1508 #1585

merged 2 commits into from
Feb 22, 2023

Conversation

MohamedLebda
Copy link
Contributor

bug #1508

bug 1508
as we can see here when we choose autoplay off and playlist auto plays off the pause of the video become dependent on ImprovedTube.allow_autoplay once it equals false it stops the video and only plays again if the value of ImprovedTube.allow_autoplay changes to true and that happens, when we start the video again the reason it becomes false, is when the ImprovedTube.video_url !== location. href but in ImprovedTube.initPlayer in function.js the ImprovedTube.video_url = location.href and that function fires when the event listener of yt-navigate-finish' fire but
The "yt-navigate-finish" event listener in the YouTube website's scripts will not work in the following situations:

When the YouTube website is not loaded: If the user is not currently on the YouTube website, the event listener will not be triggered.

When the page does not finish loading: If there is an error or some other issue that prevents the page from fully loading, the "yt-navigate-finish" event will not be triggered.

When the listener is not properly registered: If the event listener is not registered correctly or is removed before the page finishes loading, it will not be triggered.

When the listener conflicts with other scripts: If there are other scripts running on the page that conflict with the "yt-navigate-finish" event listener, it may not be triggered.

When the page is dynamically updated: If the page is dynamically updated using AJAX or other similar techniques, the "yt-navigate-finish" event may not be triggered as it only listens for full page loads.

In general, the "yt-navigate-finish" event listener is reliable and should work in most situations where a user navigates to a new page or video on the YouTube website. However, it is important to keep in mind the limitations listed above and to test your code thoroughly to ensure that it works as expected.

which means that in those cases ImprovedTube.video_url will never equal location.href so it causes the bug of constant pause (freeze)

@ImprovedTube
Copy link
Member

ImprovedTube commented Feb 22, 2023

thanks! @MohamedLebda

ImprovedTube.allow_autoplay once it equals false it stops the video and only plays again if the value of

which means that in those cases ImprovedTube.video_url will never equal location.href so it causes the bug of constant pause (freeze)

doesnt seem to cause an ethernal loop 🤔

  • ImprovedTube.allow_autoplay should be called ignore_autoplayOFF_because_of_user_action

https://github.com/code-for-charity/ImprovedTube-for-YouTube/blob/ba7c738ab1cc429899a8786465334347da567eda/content-scripts/website-context/core.js#L45-L47

https://github.com/code-for-charity/ImprovedTube-for-YouTube/blob/ba7c738ab1cc429899a8786465334347da567eda/content-scripts/website-context/functions.js#L362-L388

what if we removed this?


  • pausing (aka autoplay off) only needs to happen within the first few seconds seconds after a <video> is active 🤔

https://stackoverflow.com/questions/37706626/yt-getplayerstate-not-a-function

https://stackoverflow.com/questions/34077641/how-to-detect-page-navigation-on-youtube-and-modify-its-appearance-seamlessly


#1456 :

https://github.com/code-for-charity/ImprovedTube-for-YouTube/blob/be5a182bfb41159850490e8dc83806e57931211b/content-scripts/website-context/functions.js#L215

  • this could exclude /videos$ (also there is a / too much //channel|/user|/c/|/@.*/.test(location.href)) )
    done

iframes youtube.com/emded/...&autoplay=1 #1227 #1065

@ImprovedTube ImprovedTube merged commit f73e418 into code-charity:master Feb 22, 2023
@MohamedLebda
Copy link
Contributor Author

doesnt seem to cause an ethernal loop 🤔

it will because then ImprovedTube.allow_autoplay will always still be false because will always stay ImprovedTube.video_url !== location.href if "yt-navigate-finish" didn't work.

what if we removed this?

that will cause the video to freeze (always in pause if (auto_play is off) because the ImprovedTube.allow_autoplay will forever be false

@ImprovedTube
Copy link
Member

ImprovedTube commented Feb 23, 2023

always

only if the user is active already while before autoplay
onkeydown || onmousedown html5-main-video, ytp-play-button

what if we removed this

i meant, please try to understand, what is the disanvantage when removing the 5 4 lines https://github.com/code-for-charity/ImprovedTube-for-YouTube/blob/f73e4180a816d87663e87601bba75a9cb799a39c/content-scripts/website-context/youtube-features/player.js#L11-L14

@MohamedLebda
Copy link
Contributor Author

ImprovedTube-for-YouTube/content-scripts/website-context/functions.js

Lines 362 to 388 in ba7c738

sorry I thought you meant this.

removing the 5 lines

if we removed the first line which is var video = ImprovedTube.elements.player;
that will result in the video will never pause at the start even tho the auto-play is off because the video will not be identified in

if (ImprovedTube.allow_autoplay === false && video.classList.contains('ad-showing') === false &&
(
(document.documentElement.dataset.pageType === "video" && ((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.storage.channel_trailer_autoplay === false)
)
) {
setTimeout(function () {
video.pauseVideo();
});
}
};

and if we removed the next 4 lines in

ImprovedTube-for-YouTube/content-scripts/website-context/youtube-features/player.js

Lines 10 to 14 in f73e418

that will result in( auto play off will not work when open a new video because the value of ImprovedTube.allow_autoplay will be true form when we opened a new video

ImprovedTube added a commit that referenced this pull request Mar 25, 2023
ImprovedTube added a commit that referenced this pull request Jan 12, 2024
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

Successfully merging this pull request may close these issues.

2 participants