FreeStyler / Shazam go to track

// ==UserScript==
// @name         Shazam go to track
// @description  Show links to tracks on YouTube
// @namespace    https://www.shazam.com/myshazam
// @version      0.0.2
// @license      GPL-3.0-only
// @author       FreeStyler
// @match        https://www.shazam.com/*
// @grant        none
// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @require      file:///home/alex/0Mega/MyProjects/UserScripts/shazam_go_to_track.user.js
// ==/UserScript==

(function() {
    //'use strict';

    var cl = console.log,
        //checked_urls = localStorage.getItem('checked_urls'),
        //count = 0,
        details_loaded = 0,
    endvar;

    //localStorage.removeItem('ads');    return;    //cl($('.tagcount'));

    var arrow_image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABjUlEQVRYR+3WMUscURTF8d+KpFGIjREiQgIBYyMEu0Bim0JLExJIinyB1JZp7C20SNr4FWITG1stFCv1C6RTIZUEIneZWWZ3Z2Z3yI7bzGsGZt7c839nzrtvWsY8WmPW1wA0DtThwA6+4O8wAa8D4B9+4S2uBkHUBRC6F1hProUcdQKEaDgQToQjuaNugBCNLEQmdvMI7gMg1Q2AvnBWBXiIV1jBEp5gDjOYwiSl3bUvnMMAPMB7fMLrRGRQuMued4WzDGACn/EVj/9HMefdTjiLAOaxh9URC2fLtcOZB7CMnwiIOkcuwHMcYrZO5aQ/bOAg60Ak/BjPahaPEK7hMnSyAPHNP/SInyRd7Ajn+I0/yZxpPMLTZEu+wEsslCwgtmGs/DqdkwK8wX5y8wbf8D2lrOhIHEZ5o7ARxXY7xSK2sTXMKVYC1QswsBW/wyY+4qziavOmZwFiv7fDVlQ3PkE0mx+4HYF4lEgBusJWBjAi3U6Z9IekK2z3CTD2X7JKjg5zGlYqWHVyA9A4cAesTEn1iUoW6wAAAABJRU5ErkJggg==';

    function after_details_loaded(){        //cl('details_loaded');
        //var $details = $('.details');

        var $details = $('.details');

        $details.each(function(){
            var $this = $(this);
            var exist = $this.children().eq(1).find('.mysearch').length;
            if(exist) return;

            var song_name = $this.children().eq(0).children().eq(0);
            //cl(event.target.nodeName);
            //cl(event.target.type);
            if(song_name.length){
                if(song_name[0].nodeName === 'META'){
                  song_name = $(song_name[0]).attr('content');
                }
            }

            var artist_name = $this.children().eq(1).children().eq(1).eq(0).html();
            if(artist_name){
                //var to_search = encodeURIComponent(artist_name + ' '+ song_name);
                var to_search = (artist_name +' '+ song_name).replace(/#/g, '%23');
                //to_search = to_search.replace(/&/g, '%26');
                to_search = to_search.replace(/&/g, '%26');
                to_search = to_search.replace(/\+/g, '%2B');
                to_search = to_search.replace(/\s/g, '+');
                //cl(to_search);
                //cl($this.children().eq(1).find('.mysearch'));
                //cl($this.children().eq(1).last());
                $this.children().eq(1).append('<a class=mysearch style=color:black;margin-left:55px target=_blank href="https://www.youtube.com/results?search_query='+ to_search +'">' + artist_name +' - '+ song_name +' on YouTube <img src='+ arrow_image +' style=width:24px></a>');
                //cl($this.children().eq(1).last());
                //cl($this.children().eq(1).find('.mysearch'));
            }

        });

    }

    function load_details(){

        if(details_loaded > 1) return;

        details_loaded = $('.details').length;
        if(details_loaded > 1){
            after_details_loaded();
        } else {
            setTimeout(load_details, 500);
        }
    }

    if(!details_loaded) load_details();

    var send = window.XMLHttpRequest.prototype.send;

    function sendReplacement(data) {
        if(this.onreadystatechange) {
          this._onreadystatechange = this.onreadystatechange;
        }
        /**
         * PLACE HERE YOUR CODE WHEN REQUEST IS SENT
         */
         //cl(1123);
        this.onreadystatechange = onReadyStateChangeReplacement;
        return send.apply(this, arguments);
    }

    function onReadyStateChangeReplacement() {
        /**
         * PLACE HERE YOUR CODE FOR READYSTATECHANGE
         */
          //cl(1223);
        //cl(this);
        //cl(this.readyState);
        //if(this._onreadystatechange){ cl(1233);
        if(this.readyState === 4){ //cl(1233);
            setTimeout(function(){ /*cl(123);*/ after_details_loaded(); }, 2000);
            //return this._onreadystatechange.apply(this, arguments);
        }
    }

    window.XMLHttpRequest.prototype.send = sendReplacement;

})();