Javascript that replaces

2

I have a JavaScript code that supposedly should replace the one indicated below:

TheplatformofthischatboxisFORUMEIROSandthecodeIamusingisthefollowing:

$(window).load(function(){varchatbox_script=function(){varoverrided=Chatbox.prototype.refresh;Chatbox.prototype.refresh=function(data){overrided.call(this,data);$('.chatbox-username').each(function(){this.previousSibling&&$.trim(this.previousSibling.nodeValue)=="@"&&$(this.previousSibling).replaceWith('<img src="http://i.imgur.com/zICIAne.png"/>')})};};vars=document.createElement('script');s.text="("+chatbox_script.toString()+")();";$('object[data^="/chatbox/index.forum"],iframe[src^="/chatbox/index.forum"]').each(function(){try{$(this.contentDocument||this.contentWindow.document).find("#chatbox").closest("html").find("head").first().each(function(){this.appendChild(s.cloneNode(true))})}catch(a){}})
    });

Does the code have any errors?

    
asked by anonymous 24.08.2015 / 15:03

1 answer

1

Dude, try this way, I'm kind of amateur but maybe it helps:

$(window).load(function() {
  var chatbox_script = function() {
    var overrided = Chatbox.prototype.refresh;
    Chatbox.prototype.refresh = function(data) {
      overrided.call(this, data);
      $('.chatbox-username').each(function(){
        this.previousSibling&&$.trim(this.previousSibling.nodeValue)=='<img src="http://i.imgur.com/zICIAne.png"/>'&&$(this.previousSibling).replaceWith("@")
      })
    };
  };
  var s=document.createElement('script');s.text="("+chatbox_script.toString()+")();";$('object[data^="/chatbox/index.forum"],iframe[src^="/chatbox/index.forum"]').each(function(){try{$(this.contentDocument||this.contentWindow.document).find("#chatbox").closest("html").find("head").first().each(function(){this.appendChild(s.cloneNode(true))})}catch(a){}})
});
    
26.08.2015 / 20:55