YouTube Better Window Title

Add video length in minutes (rounded) and Channel Name to Window Title

< Commentaires sur YouTube Better Window Title

Avis: Bon - le script fonctionne correctement

§
Posté le: 2025-03-02

I'm using Firefox and I noticed this only works if the youtube watch page is focused. If I focus to a different tab, the script won't work. Is this the expected behavior, i.e it will only work if the youtube video tab is focused?

Boris JoffeAuteur
§
Posté le: 2025-03-02

The script generally re-runs every 5 seconds - this is to allow updates to the title when clicking on a different video and to fix the title when YouTube occasionally changes it back to the original. I chose 5 seconds as a reasonable amount of time where the script should work, but not be re-running all the time.

If the tab isn't focused, browsers sometimes delay timers to save battery and speed up your computer (although this script is tiny, runs in milliseconds, and wouldn't affect battery or performance), so the title might update less often when a tab is not focused. However it should still update.

Have you tried waiting a longer time maybe 10-30 seconds to see if it will update when the tab is not in focus? If it doesn't, it's possible that Firefox is very aggressively delaying timers. One solution is switching to the tab, waiting for the title to update, and then moving on to a different tab. However, if that's too annoying or if this issue is affecting your use of the script, I could also make the re-run interval lower or user-configurable to see if that would help. Let me know if you want me to do that.

§
Posté le: 2025-03-10

The script generally re-runs every 5 seconds - this is to allow updates to the title when clicking on a different video and to fix the title when YouTube occasionally changes it back to the original. I chose 5 seconds as a reasonable amount of time where the script should work, but not be re-running all the time.

If the tab isn't focused, browsers sometimes delay timers to save battery and speed up your computer (although this script is tiny, runs in milliseconds, and wouldn't affect battery or performance), so the title might update less often when a tab is not focused. However it should still update.

Have you tried waiting a longer time maybe 10-30 seconds to see if it will update when the tab is not in focus? If it doesn't, it's possible that Firefox is very aggressively delaying timers. One solution is switching to the tab, waiting for the title to update, and then moving on to a different tab. However, if that's too annoying or if this issue is affecting your use of the script, I could also make the re-run interval lower or user-configurable to see if that would help. Let me know if you want me to do that.

I've been testing it in firefox and chrome but I can never make the userscript work if the youtube video tab is not active and focused, regardless how much time I wait.
If I could test a version of your script with user-configurable timer that'd be great to try to troubleshoot things on my side.

Boris JoffeAuteur
§
Posté le: 2025-04-07
Édité le: 2025-04-07

I updated the script to have a user-configurable refresh interval, and I also lowered the default interval to 4 seconds (from 5 seconds) so titles should update a bit faster. There was also an initial 6 second delay (that I forgot to mention before) at the very start of the script which I removed, and now it uses whatever you set the title refresh interval to be.

I also fixed a few unrelated bugs and added the ability for the script to run without a refresh when navigating from a different page (like the Home or Subscriptions page), so this new version took a bit longer to release than I expected.

There is a minimum title refresh interval of 0.05 seconds (50ms) because the code takes a few milliseconds to run and I don't want to overwhelm the browser by running it too often.

Let me know if setting the interval lower works for you - I'd suggest trying 50, 75, 100, 250, 500, 1000, 1500, and 3000ms and using the highest one that works for you. The setting should be in the extension menu options.

§
Posté le: 2025-04-10

Thanks for taking the time to update the user script. These last few days I've been using the latest version and I noticed major improvements. In both Chrome and Firefox I can see the tabs' titles being updated with your userscript even when they are not focused. The few times it didn't work so far, as you suspected previously, was due to the browser suspending the tab to save resources and preventing the youtube video from loading or an extension preventing the video from loading (before even with no extensions or a single tab opened I was seeing issues). Thanks!

Boris JoffeAuteur
§
Posté le: 2025-04-13

I'm glad to hear it's working much better, but I'm also surprised that you experienced such a big difference. While I added some features, lowered the default interval, and changed the code a bit, the fundamental way the script works is still the same.

If I had to guess, it's possible that because the new code checks the timer interval setting each time (i.e. if you update the timer interval, it will apply immediately without needing to reload the tab), the browser doesn't see a "static" interval of 5 seconds anymore, so it doesn't "optimize" it away and delay it for longer.

Also, this browser timer delay is separate from the browser suspending the tab. Tabs can appear active to you but have timers silently delayed

Poster une réponse

Connectez-vous pour poster une réponse.