I'm writing an extension to remember your spot in a youtube video and automatically resume it later. These two lines work perfectly well if I paste them in a youtube video page:
var player = document.getElementById("movie_player");
player.getDuration();
But not when they are in a Chrome extension. To account for the possibility of the video loading async, I have set a timeout of 5 seconds during which the whole page has loaded. The extension keeps on throwing an error on 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 shown as 'undefined' so for some reason the function is not present on the player when accessed through the extension.