Jump to content

mute user from chat


jaylow

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

Link to comment
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.

Link to comment
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.

Link to comment
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"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...