manuelc / YouTube Downloader Converter MP3

// ==UserScript==
// @name           YouTube Downloader Converter MP3
// @description    A download button will be added to YouTube videos that allow you to download the video in MP3-format. No java required!
// @include        http://*youtube.*/*watch*
// @include        https://*youtube.*/*watch*
// @version        1.4.1
// @license        MIT
// @icon        https://s.ytimg.com/yts/img/favicon-vfl8qSV2F.ico
// @require        https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// ==/UserScript==

// ==ChangeLog==
// @history        1.4.0  Server upgrade
// @history        1.3.1  Quick tweak
// @history        1.3.0  Compatible with the latest update
// @history        1.2.2  Server update
// @history        1.2.1  Server update
// @history        1.11 Server edit
// @history        1.00 Initial release.
// ==/ChangeLog==



function addbutton(){
console.log("addButton");

if (window.location.href.match(/youtube.com/i)) {
var DIV = document.createElement('div');
	//DIV.innerHTML = '';
	DIV.style.cssFloat = "";

var divp = document.getElementById("meta");
if (divp)
	$(divp).prepend(DIV);

var url = encodeURIComponent(window.location);


var INAU = document.createElement('input');
	INAU.setAttribute('type','button');
	INAU.setAttribute('name','INAU');
	INAU.setAttribute('value','DOWNLOAD MP3');
	INAU.setAttribute('class','style-scope ytd-video-secondary-info-renderer');
	INAU.style.borderLeft = "";
	INAU.style.marginRight = "";
	INAU.style.marginLeft = "";
	INAU.style.borderRadius = "0 3px 3px 0";
    $(INAU).css('background-color','#FF0000');
    $(INAU).css('border-radius','2px');
        $(INAU).css('color','#FFF');
   $(INAU).css('padding','10px 16px');
    $(INAU).css('font-size','1.4rem');
        $(INAU).css('font-weight','500');
     $(INAU).css('font-family',"'Roboto', 'Noto', sans-serif");
  $(INAU).css('border',"none");
     $(INAU).css('float',"right");
  $(INAU).css('margin-top',"22px");
	DIV.appendChild(INAU);
	INAU.addEventListener('click', function(){window.open("http://www.mp3convert.me/index.php?url=" + url + ""); self.focus();}, false);

}

}


if (window.location.href.match(/youtube.com/i)) {


 $( document ).ready(function() {


     setTimeout(addbutton(), 5000);

	var prevHash = window.location.href;
	//console.log(window.location.href);
	//console.log(prevHash);
        window.setInterval(function () {
		//console.log("setlocati:" + window.location.href);
		//console.log("sethash:" + prevHash);
           if (window.location.href != prevHash) {
              prevHash = window.location.href;
			  //console.log("hrefdiff");
				 setTimeout(addbutton(), 5000);
           }
        }, 2000);


   });

}