I am writing an extension to remember your place in a YouTube video and automatically resume it later. These two lines work fine if I embed them on a YouTube video page:
var player = document.getElementById("movie_player");
player.getDuration();
But not when they are in the Chrome extension. To take into account the possibility of asynchronous video loading, I set a timeout for 5 seconds, during which the entire page loaded. The extension continues to throw an error in the second line, even when it works on the console at the same time.
TypeError: document.getElementById (...). getDuration is not a function (...)
The type is displayed as "undefined", so for some reason the function is not available on the player when accessed through the extension.
source
share