// Recreate the script tags with the syntax for the new plugin // by appending the ?DestinationID= to the source URL var scriptInstances = document.getElementsByTagName('script'); for (i = 0; i < scriptInstances.length; i++) { if (scriptInstances[i].src.match(/plugin(\.aspx|\.js)/i)) { var sourceUrl = scriptInstances[i].src; // Prevent infinite redirects in case the destinationID or contentID is already appended if (!sourceUrl.match(/(destinationID|contentID|videoID)=.*/i)) { var parentNode = scriptInstances[i].parentNode; var script = document.createElement('script'); script.type = 'text/javascript'; // If this is not a call to embed the content if (!sourceUrl.match(/embed=/i)) { // Set the source of the script and append the destinationID script.src = scriptInstances[i].src + ((scriptInstances[i].src.indexOf('?') > 0) ? '&' : '?') + 'destinationID=' + scriptInstances[i].id; parentNode.id = 'ensembleContentContainer_' + scriptInstances[i].id; parentNode.setAttribute('class', 'ensembleContentContainer'); } else { // Set the source of the script and append the contentID script.src = scriptInstances[i].src + '&contentID=' + scriptInstances[i].id; parentNode.id = 'ensembleEmbeddedContent_' + scriptInstances[i].id; parentNode.setAttribute('class', 'ensembleEmbeddedContent'); } parentNode.innerHTML = ''; parentNode.appendChild(script); } else if (!sourceUrl.match(/q=.*/i)) { var parentNode = scriptInstances[i].parentNode; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = sourceUrl + '&q=' + escape(location.host); parentNode.innerHTML = ''; parentNode.appendChild(script); } } }