> [Script] Hentaiverse Battle Stats, A modern replacement for old statistic tracking tools (v 1.1.3)

 
post Nov 26 2020, 15:39
Post #1
Firew



Casual Poster
****
Group: Gold Star Club
Posts: 256
Joined: 22-February 11
Level 500 (Ponyslayer)



Hentaiverse Battle Stats
Ver. 1.1.3
Attached Image



I've seen some requests for an updated stats tracker. I've been using mine for a while, so I finally polished it up enough to release.

Requirements:
Monsterbation
HVUtils
Firefox or Chrome with Tampermonkey


Download:
Attached File  Battle_Stats.js.txt ( 73.02k ) Number of downloads: 1923


Features:
  1. Saves everything about your battles using monsterbation and hvutils data.
  2. Runs only at the end of every battle, so no performance impact.
  3. Ultra-fast Querying using the browser's built-in IndexedDB database.
  4. Advanced Table view with filters, highlights, tooltips, averages, totals, and min/max statistics.
  5. Highly customizable column system allows you to see what you want to see.
  6. DRILL DOWN and view each battle or DRILL UP and view totals per day.
  7. Accessible in a drop-down integrated with the other menus OR on a separate page (loads even in battle).
  8. Export your data to JSON files to save or share.
Attached ImageAttached Image

Installation Instructions (also included in the script):
  1. Install this script, Monsterbation, and HVUtils
  2. In Monsterbation settings, set trackDrops, trackProficiency, trackSpeed, trackDamage, trackUsage to on
  3. In Monsterbation settings, set deleteDropLog and deleteCombatLog to 2.


Acknowledgements:
Members of the Discord Server for preliminary testing.


Feedback is welcome. Please post in this topic for any bugs or feedback.

--------------------
This looks really weird with a sig, so I'm making a fake one.

This post has been edited by Firew: Feb 10 2021, 10:52
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

 
Reply to this topicStart new topic
Replies(1 - 11)
 
post Nov 26 2020, 15:39
Post #2
Firew



Casual Poster
****
Group: Gold Star Club
Posts: 256
Joined: 22-February 11
Level 500 (Ponyslayer)


reserved
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

 
post Nov 26 2020, 15:39
Post #3
Firew



Casual Poster
****
Group: Gold Star Club
Posts: 256
Joined: 22-February 11
Level 500 (Ponyslayer)


reserved
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

 
post Jan 8 2021, 17:44
Post #4
what_is_name



Regular Poster
*****
Group: Gold Star Club
Posts: 554
Joined: 5-May 19
Level 500 (Ponyslayer)


some advices:
combatlog/timelog and etc. in Hentaiverse Monsterbation are global variables, and both scripts dirctly run in browser as they grant none permission, so you don't need to transfer them via localStorage, just use window.combatlog/window.timelog to reach them. Ignore this now, it not work, I may messed up different test
Beside that, you only need to dispatch an event after battle end. Change the event name to battleEnd and add it to the main function of hvmb should be more reasonable and clear:

CODE

// main function triggered on new turn
function Observe() {
    // check for battle end
    if ( document.querySelector('img[src$="finishbattle.png"]') ) {
        if ( cfg.alertColours ) {
            document.getElementById(cfg.alertBackground ? 'csp' : 'pane_vitals').style.background = cfg.colours.default;
            document.getElementById('pane_effects').style.background = cfg.colours.default;
            document.getElementById('ckey_spirit').style.background = cfg.colours.default; }
        ProcessLog();
        FormatLog();
        TrackDrops();
        Profbar();
        ShowDrops(true);
        ShowUsage();
        ShowDamage();
        window.dispatchEvent(new Event('battleEnd')); // Used for Battle Stats or maybe other scripts



This post has been edited by what_is_name: Jan 26 2021, 14:00
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

 
post Jan 26 2021, 13:07
Post #5
Firew



Casual Poster
****
Group: Gold Star Club
Posts: 256
Joined: 22-February 11
Level 500 (Ponyslayer)


I am having trouble getting it to work the way you describe.

I am not seeing the window.combatlog or window.timelog variables when I load a battle with monsterbation.

CODE
// ==UserScript==
// @name         Testing
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        *://*.hentaiverse.org/*
// @grant        none
// ==/UserScript==

console.log(window.timelog);
console.log(window.combatlog);


Both return
CODE
undefined
undefined


It cannot see the monsterbation variables.
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

 
post Jan 26 2021, 13:41
Post #6
what_is_name



Regular Poster
*****
Group: Gold Star Club
Posts: 554
Joined: 5-May 19
Level 500 (Ponyslayer)


That's strange, I assume the global variables auto assign to window if they run without sandbox and I remember I tested it before I post, but I get same result as your test now, I may messed up different test when I posted it. Anyway the describe above is not work, so as result you need to contact sickentide about HVMB change now. A window global variables is fine, beside another way the CustomEvent can transfer datas also, like
CODE
window.dispatchEvent(new CustomEvent("battleEnd", {"detail":{timelog,combatlog,droplog}}));

Of couse it up to you and sickentide's choose, ignore my post above now

This post has been edited by what_is_name: Feb 1 2021, 14:19
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

 
post Feb 10 2021, 10:45
Post #7
Firew



Casual Poster
****
Group: Gold Star Club
Posts: 256
Joined: 22-February 11
Level 500 (Ponyslayer)


Updated to 1.1.3

Attached File  Battle_Stats.js.txt ( 73.02k ) Number of downloads: 64


This update properly integrates changes in monsterbation and HVUtils. You do not need to modify monsterbation anymore. This works out of the box thanks to some changes by sickentide.

Please use the following checkboxes to select Persistent data, Isekai data, or both (or none?). You can also specify the default within the script.

Attached Image

In the interest of time, I have not updated some parts of the script listed below. These will be fixed at a later point when I have more time to work on this:

1. there is no option to separate prices between isekai/persistent. If you really need this now, please use two copies of the script and modify the @exclude statement to make it work.

2. Modified Arena and Ring of Blood pages will show aggregate data from both isekai and persistent. There is no easy fix for users to make the data show properly.

User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

 
post Feb 15 2021, 22:46
Post #8
OnceForAll



Off Topic Police
*******
Group: Catgirl Camarilla
Posts: 1,247
Joined: 3-January 21
Level 500 (Ponyslayer)


CODE
//Secret code to access automatically updating prices. Only needs to trigger once per page load.
        if (!document.prices_updated) {
            let bs_prices = JSON.parse(localStorage.getItem("bs_prices"));
            if (bs_prices) {
                for (let item in prices) {
                    if (item in bs_prices) {
                        //console.log(item + ': replacing ' + prices[item] + ' with ' + bs_prices[item])
                        prices[item] = bs_prices[item]
                    } else {
                        console.log("Couldn't find " + item + ": " + prices[item])
                    }
                }
                console.log("prices automatically loaded");
                console.log(prices)
            }
            document.prices_updated = true
        }


Find this "secret code" inside your script. I am very interested in how you generate the "bs_prices" value.

Maybe I could ask Nezu to see if he would like to provide an API in his HVMarket and all users would have the exciting feature.

---------------------------

Update: Asked.

QUOTE(OnceForAll @ Feb 15 2021, 22:58) *

Thanks for your reply!

BTW, I find every utility HV script (HV Util, Battle Stat, HVToolBox) requires the user to manually configure material prices. Would you mind adding a RESTful API to HVMarket so that userscripts could update material prices automatically?


This post has been edited by OnceForAll: Feb 15 2021, 23:12


--------------------

Karma, Karma from everywhere! · My HentaiVerse To-Do List (8/18) · My Peerless Log
Monster Database & Script · Monsterbation Configuration Checker · Auction Countdown Timer - Dynamic Edition
QUOTE(blue penguin @ Jan 17 2015, 02:15) *
Get away from that clicky game before it sucks you in.
QUOTE(Nezu @ Sep 16 2020, 18:14) *
QUOTE(Altona Falcon @ Sep 16 2020, 18:01) *
Your goal to play the game is something to use IN the game?
That's the spirit, a true HV player

User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

 
post Feb 18 2021, 19:28
Post #9
aWeirdo



Lurker
Group: Recruits
Posts: 4
Joined: 10-February 21
Level 0 (Newbie)


Interesting!!
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

 
post May 30 2021, 04:39
Post #10
OnceForAll



Off Topic Police
*******
Group: Catgirl Camarilla
Posts: 1,247
Joined: 3-January 21
Level 500 (Ponyslayer)


[Feature Request] Add the "formatter" key to table_column configuration.

E.g.

CODE
let table_columns = {
  'Details': [
    {column_name: 'Level', field: 'level'},
    {column_name: 'Persona', field: 'persona', tooltip: 'equipped'},
    {column_name: 'Prof', presence: 'proficiency', tooltip: 'proficiency'},
    {column_name: 'EXP', drops: 'EXP', formatter: (value) => value.toLocaleString()}
  ]
};


Alternative: Add a new format option, e.g.

CODE
let table_columns = {
  'Details': [
    {column_name: 'Level', field: 'level'},
    {column_name: 'Persona', field: 'persona', tooltip: 'equipped'},
    {column_name: 'Prof', presence: 'proficiency', tooltip: 'proficiency'},
    {column_name: 'EXP', drops: 'EXP', format: 'numberLocalString'}
  ]
};


Implementation:

CODE

} else if ('presence' in columns[j]) {
  cell_content = columns[j].presence in data ? "True" : "False"
} else if ('formatter' in columns[j] && typeof columns[j].formatter === 'function') {
  cell_content = columns[j].formatter(cell_content);
} else {
  console.log('Invalid Format',columns[j]);
}

if ('format' in columns[j]) {
  if (columns[j].format === 'time_string') {
    cell_content = getTimeString(cell_content)
  } else if (columns[j].format === 'local_number_string') {
    const number = Number(cell_content);
    if (!Number.isNaN(number)) {
      cell_content = number.toLocaleString();
    }
  }
}


This post has been edited by OnceForAll: May 30 2021, 04:44


--------------------

Karma, Karma from everywhere! · My HentaiVerse To-Do List (8/18) · My Peerless Log
Monster Database & Script · Monsterbation Configuration Checker · Auction Countdown Timer - Dynamic Edition
QUOTE(blue penguin @ Jan 17 2015, 02:15) *
Get away from that clicky game before it sucks you in.
QUOTE(Nezu @ Sep 16 2020, 18:14) *
QUOTE(Altona Falcon @ Sep 16 2020, 18:01) *
Your goal to play the game is something to use IN the game?
That's the spirit, a true HV player

User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

 
post May 30 2021, 05:15
Post #11
Firew



Casual Poster
****
Group: Gold Star Club
Posts: 256
Joined: 22-February 11
Level 500 (Ponyslayer)


Yes, thank you for the idea. I think I will implement both format and formatter and use it exclusively (getting rid of else if statement)

This is all psuedo-code as an outline, apologies if it doesn't work or if I made mistakes

CODE


const default_column: {
  formatter: x => x //Maybe add in "if x is a number, format to 2 decimals as a default
}

// Enum for ease of use for non-coders
const format_options = {
  PRESENCE: (x) -> x in data
  TWO_DIGITS:  (x) -> Math.round(x * 100) / 100
  etc.
}

//Example colums
let table_columns = {
  'Details': [
    {column_name: 'Level', field: 'level'},
    {column_name: 'Persona', field: 'persona', tooltip: 'equipped'},
    {column_name: 'Prof', field: 'proficiency', format: 'PRESENCE', tooltip: 'proficiency'},
    {column_name: 'EXP', drops: 'EXP', formatter: (value) => value.toLocaleString()}
  ]
};

//Preprocessing, by using default then merge in values
for (let j=0, j<columns.length; j++) {

  column_config = {
    ...default_column,
    ...columns[j]
  }
  
  let value
  
  //get raw value
  if ('field' in column_config) {
     value = data[column_config.field]
  } else if ('drops' in column_config) {
     value = data.drops[column_config.drops] || 0
  } else etc.

  //format value
  let formatter = column_config.formatter
  if ('format' in column_config) {
    //Look up formatter in format_options enumerable and use this instead
   formatter = <format from enum>
  }

  cell_content = <apply formatter>
  
}
//



I can then remove most of the hard-coded format code.

This post has been edited by Firew: May 30 2021, 05:17
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post

 
post Jun 8 2021, 08:36
Post #12
little_wuke



Newcomer
*
Group: Members
Posts: 39
Joined: 20-June 17
Level 374 (Godslayer)


Can't get it to work on mobile
Environment: Android 11, Kiwi Browser(which uses Chrome Tampermonkey), newest HVUtils and Monsterbation
Settings are as suggested and at the end of battle it says "added to battle stats" but when I go to check it it's always "querying". Is there any more information I need to provide to locate the problem?

Edit: I tried exporting data it looks like proper json, it just can't display as it should be.

This post has been edited by little_wuke: Jun 8 2021, 09:06
User is offlineProfile CardPM
Report PostGo to the top of the page
+Quote Post


Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
1 Members: k999k99

 


Lo-Fi Version Time is now: 27th September 2022 - 17:50