This JavaScript/HTML Source Code
I have a problem where I actually don't know how to retrieve the commands in the stockfish.js output because I have tried to manipulate the nmurgg code to the code I get, so the problem is:
myFunctions.loadChessEngine = function() {
if(!stockfishObjectURL) {
stockfishObjectURL = URL.createObjectURL(new Blob([GM_getResourceText('stockfish.js')], {type: 'application/javascript'}));
}
console.log(stockfishObjectURL);
if(stockfishObjectURL) {
engine.engine = new Worker(stockfishObjectURL);
engine.engine.onmessage = e => {
parser(e);
};
engine.engine.onerror = e => {
console.log("Worker Error: "+e);
};
engine.engine.postMessage('ucinewgame');
}
console.log('loaded chess engine');
}
And This is the code that makes my head spin
function parser(e){
if(e.data.includes('bestmove')){
console.log(e.data.split(' ')[3]);
myFunctions.color(e.data.split(' ')[1]);
isThinking = false;
}
}
If I delete 'bestmove'
Then it will output all the information along with score, pv, steps, but if I don't delete 'bestmove', it outputs two words "BESTMOVE and PONDER"
I actually want to add a new command, which is to get "score cp" or things that need to be taken from the information, but I have done it like the nrumgg github that he made, it doesn't work in the existing script.
Is there anyone who can help me make the addition.
Like
Score Cp = Score
for me to see the results of the stockfish movement every step taken.
Thank you if you can help m e.