Add video length in minutes (rounded) and Channel Name to Window Title
< Feedback on YouTube Better Window Title
I tried this out and it looks like the focus
listener can get triggered multiple times causing the setTimeout
in updateWindowTitle
to update the title too often. If you remove that setTimeout
, it doesn't get triggered often enough.
I'll likely clean up the code a bit later and replace all these setTimeout
s with a ~5 second setInterval
.
I also eventually want this script to run on all youtube URLs with the update title logic running only on actual video pages. This will fix the issue with the script not running when opening a video in the same tab from the home/subscription page. In that case a setInterval
would work better than a focus
listener. I appreciate your suggestion though.
I recently improved the code similarly to your suggestion - it still uses a setTimeout
but the interval is user-configurable so you can make it update as often as you want via the extension menu options. I shortened the default refresh interval to 4 seconds (from 5 seconds) and you can go as low as 0.05 seconds (although at least 0.5 seconds is recommended to avoid making your browser do a bunch of unnecessary work).
And I updated the code to not require a refresh when navigating from non-video pages like Home/Subscriptions.
I managed to improve the
window.addEventListener
call by adapting this suggestionSo this:
becomes this: