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

Implemented "Prevent playback looping of youtube shorts video" #2819

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

giulivno
Copy link

@giulivno giulivno commented Feb 17, 2025

⚬ PROBLEM:
YouTube Shorts loop indefinitely, making it hard to stop playback. ⚬ SOLUTION:
Detects when a Shorts video restarts and pauses it at the last frame to prevent looping.

⚬ RELEVANCE / SCOPE:
Affects only Shorts videos.
Doesn’t interfere with regular videos or ads.
Works dynamically via MutationObserver.

⚬ "SIDE EFFECTS":
May pause unintended seeks.
Requires updates if YouTube changes behavior.
Automatically toggled, menu toggle does not function properly (player settings)

⚬ CONTEXT:
Uses chrome.storage.local.get, matching other features. Listens for setting changes dynamically.
Integrates smoothly into ImprovedTube.

⚬ PROBLEM:
YouTube Shorts loop indefinitely, making it hard to stop playback.
⚬ SOLUTION:
Detects when a Shorts video restarts and pauses it at the last frame to prevent looping.

⚬ RELEVANCE / SCOPE:
Affects only Shorts videos.
Doesn’t interfere with regular videos or ads.
Works dynamically via MutationObserver.
⚬ "SIDE EFFECTS":
May pause unintended seeks.
Requires updates if YouTube changes behavior.
Automatically toggled, menu toggle does not function properly (player settings)
⚬ CONTEXT:
Uses chrome.storage.local.get, matching other features.
Listens for setting changes dynamically.
Integrates smoothly into ImprovedTube.
@@ -706,16 +706,19 @@ REPEAT
ImprovedTube.playerRepeat = function () {
setTimeout(function () {
if (!/ad-showing/.test(ImprovedTube.elements.player.className)) {
ImprovedTube.elements.video.setAttribute('loop', '');
// Prevent looping for Shorts videos
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ( Improvedtube.storage.preventLoopingShorts === true) (...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted it back to the original code for the repeat section and functionality remains the same.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ( Improvedtube.storage.preventLoopingShorts === true) (...

How would I go about making the toggle for this feature work in the menu? I have a Prevent Shorts Looping toggle option in the player settings but it doesn't function currently and I can't seem to figure out what else to do for it.

Copy link
Member

@ImprovedTube ImprovedTube Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's good, no need to revert., just to make conditional to a setting of the extension

sorry i didnt read all yet. compare to the the code for our always repeat button for example

if (this.storage.player_always_repeat === true) { ImprovedTube.playerRepeat(); };

these variables are managed automatically through adding it in the menu:

player_always_repeat: {
component: 'switch',
text: 'alwaysActive',
on: {
click: function () {
if (this.dataset.value === 'true') {
document.getElementById('player_repeat_button').flip(true);
}
}
}
},
player_screenshot_button: {
component: 'switch',
text: 'Screenshot',
id: 'player_screenshot_button'
},
embed_subtitle: {
component: 'switch',
text: 'Subtitle_Capture_including_the_current_words',

( and we also add them as attributes to the root element for convenience. ) (while L1080-L1086 are rare/optional/disputable for visually suggesting and imposing to switch on the repeat button then too, for explaining that "always repeat" is a big change)

@@ -96,6 +96,13 @@ ImprovedTube.init = function () {
this.YouTubeExperiments();
this.channelCompactTheme();


let preventShortsLooping = localStorage.getItem("prevent_shorts_looping") === "true";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need local storage? its not available in incognito mode.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to chrome.storage.local so it works in incognito mode now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then 💡 it sounds like you might be the one person in the world now, who is likely to bring forward:
#1408 (comment)

@ImprovedTube
Copy link
Member

hi! and thanks @giulivno

Extension works in Incognito Mode Now
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