by Ange Tuteur October 26th 2014, 2:10 am
The chatbox is set in a frame, or <object>. You'll need to access that frame to modify its contents. However, it's a bit tricky, since the data is refreshed when a message is submitted. You can set an interval and determine when a new message is posted by comparing a global and local variable. See if this works for you :
Modules > JavaScript codes management > Create a new script
Title : Your choice
Placement : In the homepage
- Code:
$(function() {
 var refresh_rate = 1000, fa_chat = document.getElementById('frame_chatbox'), frame;
 fa_chat.onload = function() {
  if (fa_chat.contentDocument) { frame = fa_chat.contentDocument }
  else if (fa_chat.contentWindow) { frame = fa_chat.contentWindow.document }
  _chatdata_msg_thn = frame.getElementById('chatbox').getElementsByTagName('p').length;
  hideLogs();
 Â
  setInterval(function() {
   var msg_now = frame.getElementById('chatbox').getElementsByTagName('p').length;
   if (msg_now > _chatdata_msg_thn || msg_now < _chatdata_msg_thn) {
    hideLogs();
    _chatdata_msg_thn = msg_now;
   }
  },refresh_rate);
 Â
  function hideLogs() {var s = frame.getElementsByTagName('SPAN');for (i=0; i<s.length; i++) {if (s[i].style.color == 'green' || s[i].style.color == 'red') {var p = s[i].parentNode.parentNode;if (p.style.display != 'none') p.style.display = 'none'}}}
 }
});
This variable determines how often the interval compares the messages from then and now. If there is a difference between the two, it will execute the function to hide the logs. The higher the refresh_rate the longer it will take for the comparison and vise versa.
- Code:
refresh_rate = 1000