Jump to content
jaylow

mute user from chat

Recommended Posts

Hi, i am playing a game and there is a user in chat that bothers me and other players a lot but he does not break any game rule...

 

i was wondering if there is a way i could block or mute his text with a JavaScript

if so, does anyone have a tutorial on how to code something like this?

 

the chat have no ID but every chat message is put out like this.

<table border="0" padding="0" cellspacing="0" width="100%">    <tbody>           <tr>               <td width="90" class="chat">                   <div id="202525"></div>                     2015-08-24 06:06:00               </td>               <td style="">               <a href="javascript:newmsg('The Martyr','')" style="">The Martyr:</a>                " so I starting to give up"               </td>           </tr>    </tbody></table>

and it looks like this in chat:

2015-08-24 06:06:00 The Martyr: so I starting to give up

 

i was thinking i could use the user name 'The Martyr' in some way to block that user

 

i would love to code something that would just remove the lines from the chat box. and any other line the user typed and will type.

i just have no idea where to start.

any kind of help would be appreciated

thanks

Share this post


Link to post
Share on other sites

You can use document.getElementsByTagName to get all <a> elements, and loop through them to check the innerHTML to see if it's the matching username followed by a colon. If so, then the <a> element's parentNode property will point to the <td>, and that element's parentNode property will point to the <tr>, and you can delete or hide the <tr>.I'm not all that sure how to integrate all of that on a page though. I guess you could make a browser extension or Greasemonkey script specifically for that site which would hopefully be able to hook into the same code that updates the chat text. I guess a lot of that would depend on the how the site actually works.

Share this post


Link to post
Share on other sites

Thank you, I am now able to hide all the tables in the chat box, i just need to figure out how to select only the ones from the user(s) i would like to hide.

Share this post


Link to post
Share on other sites

Is each message a separate table, or is each message a table row inside a single table? If each message is a table, here's the reference for a table:https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableElementSo you can use something like table.tBodies[0].rows[0].cells[1].childNodes[0], that will refer to the <a> element. You can check the innerHTML of that to see the username with the colon after it. If each message is a separate row in the same table then you would get the table, the body, and then loop through the rows to check the first child of the second cell in each row. If you find a match then you can remove either the table or just the one row.

Share this post


Link to post
Share on other sites

in a separate table,

like this.:

<div><table></table><table></table><table></table><table></table><table></table><div>

every table is set up like the one in my first post code

the div has the id="chat_txt"

Share this post


Link to post
Share on other sites

So there's no reason to loop through the rows then, and you can just access the text of that cell directly. Just make sure to account for the colon after the username.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...