Greasy Fork is available in English.

YouTube Better Window Title

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

< Feedback on YouTube Better Window Title

Review: Good - script works

§
Posted: 29.03.2024

I managed to improve the window.addEventListener call by adapting this suggestion

So this:

setTimeout(function () {
    waitForLoad();
}, 6000);
// window eventListener doesn't work well for some reason
// window.addEventListener('load', waitForLoad, true);
log('YouTube Better Window Title: started script')

becomes this:

// setTimeout(function () {
//  waitForLoad();
// }, 6000);
//
// use focus instead of load for window eventListener
window.addEventListener('focus', waitForLoad, true);
log('YouTube Better Window Title: started script')
Boris JoffeAuthor
§
Posted: 05.04.2024

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 setTimeouts 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.

Post reply

Sign in to post a reply.