A content script I’ve sets custom properties on an Audio element. The property is later used in a key event handler. However, I notice that the element loses the said property when injected no a BBC website that has video content. Here’s a distilled down version of the content script:
function keyHandler(ev) {
var str = new Array();
if (ev.altKey)
str.push("alt");
str.push(ev.key);
switch (str.join("+").toLowerCase()) {
case "alt+x":
if (audio.name)
console.log("audio has name property");
else
console.log("audio is missing name property that was set earlier");
break;
}
}
var audio = new Audio();
audio.name = "foobar";
// Register keyboard handler
document.addEventListener("keydown", keyHandler);
Press alt+x to trigger the handler. On most web pages, I get the message “audio has name property” on the console. On this BBC page, for example, I get “audio is missing name property that was set earlier”: http://www.bbc.co.uk/news/uk-england-leeds-42225040.
Can someone point me what’s gonig on please? Thanks.