Roukys / HHauto

GNU General Public License v3.0
45 stars 44 forks source link

Bug [5.6.15] - Script does not run #389

Closed Memerino closed 2 years ago

Memerino commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

The script does not start, config button on the game does not show up.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

The script was working fine until the last update.

Screenshots If applicable, add screenshots to help explain your problem. image

System:

Console output

VM209616:69 Syntax error @ "HaremHeroes Automatic++"! ########################## JSHINT output: ##########################

SyntaxError: Unexpected token . at eval () at F_a.s (:4:80) at Object.t [as F_c] (:3:191) at Object.E_u (:4:244) at eval (eval at exec_fn (:2:115), :67:477) at Object.create (eval at exec_fn (:2:115), :69:193) at c (eval at exec_fn (:2:115), :7:231) at F_a.s (:4:80) at i (eval at exec_fn (:2:115), :5:165) at r.send (eval at exec_fn (:2:115), :5:292) Re.syntaxCheck.r @ VM209616:69 VM209616:69 Uncaught SyntaxError: Unexpected token . at eval () at F_a.s (:4:80) at Object.t [as F_c] (:3:191) at Object.E_u (:4:244) at eval (eval at exec_fn ((index):2), :67:477) at Object.create (eval at exec_fn ((index):2), :69:193) at c (eval at exec_fn ((index):2), :7:231) at F_a.s (:4:80) at i (eval at exec_fn ((index):2), :5:165) at r.send (eval at exec_fn ((index):2), :5:292)

Memerino commented 2 years ago

More info on the error:

image

Roukys commented 2 years ago

@Memerino very strange ... could you try to clear the storage juste to check ? in console you can enter sessionStorage.clear();localStorage.clear(); or got to application tab of developer tool

Memerino commented 2 years ago

@Roukys nope, cleared it both from console and the application developer tab and the same error still shows up. ☹

Roukys commented 2 years ago

@Memerino ;( ok so let's try another way could you go to tampermonkey and edit script in editor, you've got developer option, choose check syntax, it should point to the faulty line :)

do copy me the line I'll check, but that is strange you're the only one concerned ...

on which instance are you playing ? (it seems on nutaku, but is it comix, Gay or classic HH ?)

Memerino commented 2 years ago

function FindOpponent(opponentsPowerList,opponentsIDList) { var maxScore = -1; var IdOppo = -1; var OppoScore; logHHAuto('finding best chance opponent in '+opponentsIDList.length); for (var oppo of opponentsIDList) { //logHHAuto({Opponent:oppo,OppoGet:Number(opponentsPowerList.get(oppo)),maxScore:maxScore}); OppoScore = Number(opponentsPowerList.get(Number(oppo))?.win); if (( maxScore == -1 || OppoScore > maxScore ) && !isNaN(OppoScore)) {

            maxScore = OppoScore;
            IdOppo = oppo;
        }
    }
    logHHAuto("highest score opponent : "+IdOppo+'('+nRounding(100*maxScore, 2, -1)+'%)');
    return IdOppo;

Points to line 3175 image

I'm playing on Nutaku, it doesent work both in Comix and Harem

Memerino commented 2 years ago

@Roukys Just copy pasted the function in an online Syntax validator service (i have little experience with javascript) and the same error shows up. image

dagget-beaver commented 2 years ago

@Memerino The issue is with an unsupported feature of Javascript optional chaining used in the code as it's compatible only from Chrome v80 - see below: https://caniuse.com/mdn-javascript_operators_optional_chaining https://v8.dev/features/optional-chaining

I don't know if it's possible to get or update Chromium on Raspbian (seems like latest official build is 78) but try to upgrade to at least Chromium v80.

It'll be up to @Roukys to decide whether to rewrite the code or leave it "as is".

Roukys commented 2 years ago

@dagget-beaver thanks , you spared me search time. @Memerino I'll check if it would be much work to change Could you try and replace ?. By . Everywhere to see if it is the only issue ?

Roukys commented 2 years ago

@Memerino it should work with 5.6.16

Memerino commented 2 years ago

@Roukys yep, this update fixed the issue and the script runs again. Console is not showing the error anymore.

Sorry for not answering earlier, i had no acces to my server these days.

Thank you SO MUCH for this fix, and for the work you put in this script 🤠👍

Roukys commented 2 years ago

;) pleasure.

I'll try not to use this anymore, but if it happen again do not hesitate