Author Topic: [Tutorial] How to fix chatlog and add features  (Read 1377 times)

Offline pastmistake

  • Full Member
  • *
  • Topic Author
  • Posts: 87
  • Country: 00
  • Karma: +12/-6
  • Awards LA Ladder #4-10 [LEGENDARY]
    • View Profile
    • D1Map
    • Awards
It can be easy fixed with CSS/JS injections.
Works only on CHROME.

RESULT: https://prnt.sc/ru5vyu

Features:
- removed duplicate kill-events
- easy button to toggle game/kill-events ON/OFF so you see only the chat
- removed the "player name suffix" from before kill/game-events.

TUTORIAL
Step 1: Install this CHROME JS injection extension: https://chrome.google.com/webstore/detail/user-javascript-and-css/nbhcbdghjpllgmfilhnhkllmkecfmpld

Step 2:
Click on the extension icon >  ADD NEW

Step 3:
Complete the top Address with http://dota.eurobattle.net/la/forum , like in the picture: https://prnt.sc/ru5z7u

Step 4: Add this JS (left panel):
Code: [Select]
$(document).ready(function(){
//add buttons
$('.chatLog').append(`<div class="btn btn-success btn-toggle-chat-events">Game Events</div>`);
$('.chatLog').eq(0).css('max-height', '200px');
$('.chatLog').eq(1).css('max-height', '600px');

var events = [];
$('.chatLog tr').each(function(){
var isLog;

if ($(this).find('td').eq(1).find('span').length){
isLog = $(this).find('td').eq(1).find('span').html() ? false : true;
}else{
isLog = $(this).find('td').eq(1).html() ? false : true;
}

var t = $(this).find('td').eq(0).html().split(':');
var time = (+t[0]) * 60 + (+t[1]);

$(this).attr({
'data-line': $(this).index() + 1,
'data-log': isLog,
'data-time': time
});

if (isLog){
var text = $(this).find('td').eq(3).text();

if (text[0] == "["){
    var _o = 0;
    var _c = 0;
    var _n = "";
   
    for(i = 0; i < text.length; i++){
        _o += text[i] == "[" ? 1 : 0;
        _c += text[i] == "]" ? 1 : 0;
        _n += text[i];

        if (_o == _c){
            break;
        }
    }
   
    text = text.replace(_n, "");

var found = $.grep(events, (e) => {
return (text == e.text && time < e.time + 2) ? true : false;
})

if(found.length){
$(this).remove();
}else{
$(this).find('td').eq(3).text(text);
events.push({
text: text,
time: time
});
}
}
}
})


$('.btn-toggle-chat-events').on('click', function(){
$(this).toggleClass('off');

$(this).closest('.chatLog').find('tr[data-log="true"]').toggle();
});
})

Step 5: Add this CSS (right panel):
Code: [Select]
.chatLog{
position: relative;
}

.btn-toggle-chat-events{
position: sticky;
    bottom: 10px;
    left: calc(100% - 100px);
    font-size: 10px;
    word-break: break-word;
    width: 75px;
    background: #471;
    color: #000;
    padding: 6px 6px;
    border-radius: 3px;
    box-shadow: inset 0px 0px 0px 1px #FFF2;
    text-align: center;
    text-transform: uppercase;
    cursor: pointer;
}

.btn-toggle-chat-events:after{
content: "ON";
color: #FFF;
font-size: 14px;
font-weight: bold;
display: inline-block;
width: 100%;
}

.btn-toggle-chat-events.off{
background: #900;
}

.btn-toggle-chat-events.off:after{
content: "OFF"
}


.btn-toggle-chat-events:active{
transform: scale(0.96);
}

Step 6: Click options, and make sure only "Enabled" Checkbox is selected.

Step 7: Save (or CTRL-S)

Step 8: Go to any game-log page on lagabuse
« Last Edit: May 29, 2020, 15:50 by pastmistake »

Offline AntlermanXXL

  • Deer
  • Contributor
  • Hero Member
  • *
  • Posts: 792
  • Country: ru
  • Karma: +200/-274
  • Server Account: deer-door
    PSR: Loading
    Games: Loading
    Wins/Loses: Loading/Loading
    Hero K/D/A: Loading
    Creep K/D/N: Loading
    Show/hide more stats
  • Awards Advisor Deer Member Contributor [COMMON]
    • View Profile
    • Awards
Re: [Tutorial] How to fix chatlog and add features
« Reply #1 on: April 06, 2020, 18:39 »
It can be working for every browser tho

Spoiler for Hiden:
what a trash semi-ecma4 code with anormous selectors amount and cache abuse!

Still, thank you, cool idea to actually do it by ourselves, since no one else does !

I might post another snippet for mister Cen for YouTube (and similar) embeds lazy-loading, because it kills even modern browsers here
« Last Edit: April 06, 2020, 18:46 by AntlermanXXL »
https://www.twitch.tv/EvergreenDeer
http://www.youtube.com/user/AloneMonaX

Spoiler for Hiden:
10, 3rd places are mine, wew!

40:14 don_Kondo [Allies] olen olen
40:15 don_Kondo [Allies] olenishka
40:18 Hiatus [Allies] AHAH
40:21 don_Kondo [Allies] ya net olen
40:22 Hiatus [Allies] OLENISHKA
40:23 Hiatus [Allies] AHAHAH
40:25 don_Kondo [Allies] ya mala myshka
40:28 Hiatus [Allies] AHAHAHAH

Offline luke

  • ~evil~
  • Contributor
  • MonsterKill Member
  • *
  • Posts: 3837
  • Country: de
  • Karma: +482/-243
  • Server Account: FatAndViolent
    PSR: Loading
    Games: Loading
    Wins/Loses: Loading/Loading
    Hero K/D/A: Loading
    Creep K/D/N: Loading
    Show/hide more stats
  • Awards Warlock Tour Winner [RARE] Pudge Wars Tournament Winner [RARE] Hacks staff member [RARE] Shadow Raze Tour Award [RARE] Best B&U mod of the month 3 times in a row [EPIC] 3rd Place Admins Cup [EPIC] Uther Party Tournament Winner [COMMON]
    • View Profile
    • My channel
    • Awards
Re: [Tutorial] How to fix chatlog and add features
« Reply #2 on: April 06, 2020, 19:31 »
So you propose to remove duplicate stuff post factum?

There is a problem that it may be hard to find out who killed who because i dont think that these events are shown in a deterministic order

Technically the log recorder should be fixed. I gave suggestion how it can be done but it seems not as simple.

Let me explain in short how it works without spoiling private info:
Wc3 works in the p2p way here, all players send packets about what happens to each other. Since all sit in different countries the delay between packets arrival is different, so bot has no idea which packet with kill event arrived first and cant filter out the duplicate events. If you have an idea how to deal with this better talk with @cen directly since all this is tied with security and shouldnt be discussed in public.

Edit: though i just noticed that you mean to remove them completely. Well this is a 1 line change in the bot code, i think could be a temporary solution
« Last Edit: April 06, 2020, 19:44 by luke »

Offline pastmistake

  • Full Member
  • *
  • Topic Author
  • Posts: 87
  • Country: 00
  • Karma: +12/-6
  • Awards LA Ladder #4-10 [LEGENDARY]
    • View Profile
    • D1Map
    • Awards
Re: [Tutorial] How to fix chatlog and add features
« Reply #3 on: April 06, 2020, 20:04 »
NO. I didn't said to remove them, I simply added a TOGGLE. Some times you want to see only the chat (for mod-usage mostly).

Yes. If it's hard to remove duplicates PRE, u can remove them POST [as proven by the JS injection]. Also removing POST means you don;t have to hustle with core-changes and/or you can do them on client-side.

But since I can remove them POST, clearly means they could as easily be removed PRE. But for the end-user, doesn't really matter how it's done. If you check my code, I simply do a 2s delay check to see if message should be considerated a "duplicate" and kept only once (the rest of the occurances are removed)

The provided solution covers only the surface and needed fixes. But I can tell you I can easily parse the already given logs and add a lot more comprehensiveness and features to it.

From the top of my head:
1) detect rampage, ultrakills, triplekills, doublekills ..
2) color nicknames accordingly in "x killed y" game-events messages
3) add another column before the player's name, that contains the hero-icon,
OR
4) add hero icons before nicknames, in "x killed y" game-events messages
5) Chat Toggle to select what users to see chat for. Ex: when you want to fast see the conversation of only 2 players. You simply hide all the other messages.
« Last Edit: April 06, 2020, 20:09 by pastmistake »

Offline luke

  • ~evil~
  • Contributor
  • MonsterKill Member
  • *
  • Posts: 3837
  • Country: de
  • Karma: +482/-243
  • Server Account: FatAndViolent
    PSR: Loading
    Games: Loading
    Wins/Loses: Loading/Loading
    Hero K/D/A: Loading
    Creep K/D/N: Loading
    Show/hide more stats
  • Awards Warlock Tour Winner [RARE] Pudge Wars Tournament Winner [RARE] Hacks staff member [RARE] Shadow Raze Tour Award [RARE] Best B&U mod of the month 3 times in a row [EPIC] 3rd Place Admins Cup [EPIC] Uther Party Tournament Winner [COMMON]
    • View Profile
    • My channel
    • Awards
Re: [Tutorial] How to fix chatlog and add features
« Reply #4 on: April 06, 2020, 20:09 »
Quote
Chat Toggle to select what users to see chat for. Ex: when you want to fast see the conversation of only 2 players. You simply hide all the other messages.

This one is really cool


I think you can give it a try but i would rather modify the php plugin directly instead. You need to contact server owner cen so he gives you necessary files or discuss details if you want to do like you said.

Broken log is indeed very annoying problem

Offline pastmistake

  • Full Member
  • *
  • Topic Author
  • Posts: 87
  • Country: 00
  • Karma: +12/-6
  • Awards LA Ladder #4-10 [LEGENDARY]
    • View Profile
    • D1Map
    • Awards
Re: [Tutorial] How to fix chatlog and add features
« Reply #5 on: April 06, 2020, 20:10 »
He can simply add the jQuery and CSS , provided in my tutorial, directly in the GAMELOG page .php file. No need for access or anything. He simply injects/includes the scripts, so we don;t have to.

Also, this way, there's literally 0 server changes or extra-load. It all happens clientside. WIN/WIN.
« Last Edit: April 06, 2020, 20:12 by pastmistake »

Offline cen

  • Eurobattle.net Admin
  • WickedSick Member
  • *
  • Posts: 2166
  • Country: si
  • Karma: +280/-57
  • Lok'tar Ogar
  • Awards Lagabuse Legend LA High Staff [EPIC] MadBalls Tournament Winner [RARE] MVP Member [LEGENDARY]
    • View Profile
    • EuroBattle.net
    • Awards
Re: [Tutorial] How to fix chatlog and add features
« Reply #6 on: April 06, 2020, 20:23 »
We will fix the logs server side soon enough, it has been on my TODO list. As it was mentioned above it is a bit complex to do but I have a basic idea in mind.

 Until then, people can use this helpful script if they need it fixed right now.

Offline pastmistake

  • Full Member
  • *
  • Topic Author
  • Posts: 87
  • Country: 00
  • Karma: +12/-6
  • Awards LA Ladder #4-10 [LEGENDARY]
    • View Profile
    • D1Map
    • Awards
Re: [Tutorial] How to fix chatlog and add features
« Reply #7 on: May 29, 2020, 15:51 »
I revised the JS code. Nickname detection was conflicting with players having "[" or "]" in name.