Help wanted in making a extension

I need guidance and advice. I want to create an extension that can record the time you spend watching a YouTube video compared to the video’s total duration. If the time spent exceeds a specified threshold, I aim to generate a certificate, similar to those received on platforms like Coursera. What are your thoughts on this?

Take a pen and paper and try to design a high level model of how your app should work.
For example, in your background script you should have an event listener for “tabs.onActivated” so that you know that the tab is active (or no longer active).

Then you need to create content script that will be injected into pages and check that users started / paused the video. Although, there may be an easier approach, you could instead register tabs.onUpdated handler (again in your background script) to see if the “audiable” value is TRUE:

Using these two handlers you can already tell that the youtube page is focused and that it produces sound (so the video is playing).

But will probably need content script anyway to extract video name / length / etc…