Help with header code

sure

<script>
    (function(scope) {
        
        scope.$watch('msg', function(data) {
            var elem = document.getElementById(data.topic)
            if(elem !== null) {
                if (data.hasOwnProperty('fontFamily')) {elem.style.fontFamily = data.fontFamily}
                if (data.hasOwnProperty('fontStyle')) {elem.style.fontStyle = data.fontStyle}
                if (data.hasOwnProperty('color')) {elem.style.color = data.color}
                if (data.hasOwnProperty('fontSize')) {elem.style.fontSize = data.fontSize}
                if (data.hasOwnProperty('fontWeight')) {elem.style.fontWeight = data.fontWeight}
                if (data.hasOwnProperty('payload')) {elem.innerHTML = data.payload};
                if (data.hasOwnProperty('image')) {elem.src = data.image};
                
            }
        });

        var theScope = scope;
        var myButton = document.getElementById("my-refresh-button");
        if(!myButton) {
          var button = document.createElement('BUTTON');
          button.addEventListener('click', sendPayload);
          button.innerHTML ='Refresh'
          button.id = 'my-refresh-button'
          var titleBar = document.getElementById("nr-dashboard-toolbar");
          titleBar.append(button);
        }
        function sendPayload(){
            theScope.send("1");
        }

    })(scope);

</script>