var dycObject = function(){
var video_id = null;
var getParameterByName = function(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
var getVideoId = function(){
return getParameterByName('v', location.href);
}
var showLinks = function(){
var vid = getVideoId();
if(vid !== video_id && vid !== null){
video_id = vid;
var ext = document.getElementById('download-youtube-chrome-extension');
if(ext !== null) {
ext.parentElement.removeChild(ext);
}
var titleH1 = document.querySelector('h1.title');
var div = document.createElement('div');
div.id = 'download-youtube-chrome-extension';
div.setAttribute('style', 'font-size: 1.4em;');
div.innerHTML = 'Download this video (powered by Download Youtube Chrome) ';
if(titleH1 != null){
title = titleH1.children[0].innerText;
titleH1.parentElement.insertBefore(div, titleH1.nextSibling);
}
_gaq.push(['_trackPageview']);
}
}
this.init = function(){
setInterval(showLinks, 300);
}
}
dyc = new dycObject();
dyc.init();
// ga tracking
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-28955501-2']);
_gaq.push(['_setDomainName', 'youtube.com']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
_gaq.push(['_trackPageview']);