I own this script. What should I add in it so that, when it runs, it appears in a <div>
?
Here's the script:
// Which flash versions are needed for given format
var FLASH_VERSIONS = {
'7/0/0': [5],
'9/0/115': [18, 22, 33, 34, 35, 37, 38, 59, 78, 82, 83, 84, 85, 120, 121],
'10/1/0': [52, 53, 54, 60],
};
// Regex to extract the video format
var RE_ITAG = /&itag=([0-9]*)&/i;
function get_fmt(content) {
var fmt = new Object();
fmt.list = new Array();
fmt.stream_map = new Array();
for (var i=0; i < content.length; i++) {
var url = content[i]['url'];
if (url.search("") == -1)
continue;
var matches = RE_ITAG.exec(url);
var itag = matches[1];
var resolution = '7/0/0';
for (var possible_resolution in FLASH_VERSIONS.length) {
if (FLASH_VERSIONS[possible_resolution].indexOf(itag)) {
resolution = possible_resolution;
}
}
fmt.list.push(itag+'/'+String(content[i].width)+'x'+String(content[i].height)+'/'+resolution);
fmt.stream_map.push(itag+'|'+content[i].url.replace(/,/g, '%2C'));
}
fmt.list.reverse();
fmt.stream_map.reverse();
return fmt;
}
function get_embed(content) {
var fmt = get_fmt(content);
var flashvars = new Array();
flashvars.push('fs=1');
flashvars.push('hl=en');
flashvars.push('autoplay=1');
flashvars.push('ps=');
flashvars.push('playerapiid=uniquePlayerId');
flashvars.push('fmt_list='+encodeURIComponent(fmt.list.join()));
flashvars.push('fmt_stream_map='+encodeURIComponent(fmt.stream_map.join()));
flashvars.push('');
flashvars.push('t=1');
flashvars.push('vq=large');
flashvars.push('auth_timeout=86400000000');
var embed = document.createElement('');
embed.setAttribute("src", "");
embed.setAttribute("type", "application/x-shockwave-flash");
embed.setAttribute("allowfullscreen", "true");
embed.setAttribute("allowscriptaccess", "always");
embed.setAttribute("scale", "noScale");
embed.setAttribute("wmode", "opaque");
embed.setAttribute("flashvars", flashvars.join("&"));
embed.setAttribute("width", "100%");
embed.setAttribute("height", "100%");
return embed;
}
var ts = Math.round((new Date()).getTime() / 1000);
var script = document.createElement('script');
var hash = document.location.hash;
var id = hash.substr(1,hash.length);
var head = document.getElementsByTagName('head').item(0);
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', 'https://');
head.appendChild(script);
myFunction(); // Fails because it hasn't loaded from my.js yet.
window.onload = function() {
// Works most of the time but not all of the time.
// Especially if my.js injects another script that contains myFunction().
myFunction();
};
How do I load it into a html page within the specified div?
Example:
<div id="script" class="#">/div>