Go back
Grease Monkey FEN question

Grease Monkey FEN question

Site Ideas

Vote Up
Vote Down

I use the greasemonkey add-on in my firefox browser so I get an FEN below the analyze board. However the FEN doesn't progress in accordance with the pieces as I move them on the analyze board. I was wondering if this is something that might be possible...or if there were another way of obtaining a FEN from a position you've arrived at on the analyze board...other than transcribing it manually.

Vote Up
Vote Down

Originally posted by Mahout
I use the greasemonkey add-on in my firefox browser so I get an FEN below the analyze board. However the FEN doesn't progress in accordance with the pieces as I move them on the analyze board. I was wondering if this is something that might be possible...or if there were another way of obtaining a FEN from a position you've arrived at on the analyze board...other than transcribing it manually.
Try this -


// ==UserScript==
// @name RHP Analysis Board
// @namespace orangutan
// @description Adds updating FEN to the analysis board
// @include http://www.redhotpawn.com/gameanalysis/boardanalysis.php*
// @include http://www.chessatwork.com/gameanalysis/boardanalysis.php*
// @include http://www.timeforchess.com/gameanalysis/boardanalysis.php*
// @include http://www.redhotchess.com/gameanalysis/boardanalysis.php*
// @include http://www.playtheimmortalgame.com/gameanalysis/boardanalysis.php*
// ==/UserScript==

addFenBox();

document.addEventListener(
'click',
function (e) {
var fenHandle = document.getElementById('fenStr'😉;
if (fenHandle) {
fenHandle.innerHTML = unsafeWindow.JSExp_GetFenFromBoardState(unsafeWindow.g_boardState);
}
}, false);

function addFenBox() {

var captureDiv = document.getElementById('capturedwhiteid'😉.parentNode.parentNode;

if (captureDiv) {

var fen = unsafeWindow.JSExp_GetFenFromBoardState(unsafeWindow.g_boardState);

var fenString = document.createElement('div'😉;
fenString.setAttribute('id', 'fenStr'😉;
fenString.setAttribute('style', 'border: none; width: 100%;'😉;
fenString.innerHTML = fen;

var fenBox = document.createElement('div'😉;
fenBox.setAttribute('class', 'consolecontent'😉;
fenBox.setAttribute('id', 'fenBox'😉;
fenBox.appendChild(fenString);

captureDiv.parentNode.insertBefore(fenBox, captureDiv.nextSibling);

}

return true;
}

Vote Up
Vote Down

I've just noticed that the FEN does not update the move number, whose go it is and castling rights etc. - as these come from the last position reached on the game itself.

The analysis window turns off the logic to validate moves - you can move pieces around as you see fit - so the end portion of the FEN does not get updated.

With that in mind here's another version that has an incomplete FEN showing just the positional field.

---

// ==UserScript==
// @name RHP Analysis Board
// @namespace orangutan
// @description Adds updating FEN to the analysis board
// @include http://www.redhotpawn.com/gameanalysis/boardanalysis.php*
// @include http://www.chessatwork.com/gameanalysis/boardanalysis.php*
// @include http://www.timeforchess.com/gameanalysis/boardanalysis.php*
// @include http://www.redhotchess.com/gameanalysis/boardanalysis.php*
// @include http://www.playtheimmortalgame.com/gameanalysis/boardanalysis.php*
// ==/UserScript==

addFenBox();

document.addEventListener(
'click',
function (e) {
var fenHandle = document.getElementById('fenStr'😉;
if (fenHandle) {
var pieces = unsafeWindow.JSExp_GetFenFromBoardState(unsafeWindow.g_boardState).split(' '😉;
fenHandle.innerHTML = pieces[0];
}
}, false);

function addFenBox() {

var captureDiv = document.getElementById('capturedwhiteid'😉.parentNode.parentNode;

if (captureDiv) {

var fen = unsafeWindow.JSExp_GetFenFromBoardState(unsafeWindow.g_boardState).split(' '😉;

var fenString = document.createElement('div'😉;
fenString.setAttribute('id', 'fenStr'😉;
fenString.setAttribute('style', 'border: none; width: 100%;'😉;
fenString.innerHTML = fen[0];

var fenBox = document.createElement('div'😉;
fenBox.setAttribute('class', 'consolecontent'😉;
fenBox.setAttribute('id', 'fenBox'😉;
fenBox.appendChild(fenString);

captureDiv.parentNode.insertBefore(fenBox, captureDiv.nextSibling);

}

return true;
}

Vote Up
Vote Down

Thanks orangutan. I've posted your script at the bottom of:

http://members.shaw.ca/ouroboros/RHP/

And I've incorporated your code into my version of the analysis board script.

Vote Up
Vote Down

Originally posted by ouroboros
Thanks orangutan. I've posted your script at the bottom of:

http://members.shaw.ca/ouroboros/RHP/

And I've incorporated your code into my version of the analysis board script.
Nice one.

Vote Up
Vote Down

Originally posted by orangutan
I've just noticed that the FEN does not update the move number, whose go it is and castling rights etc. - as these come from the last position reached on the game itself.

The analysis window turns off the logic to validate moves - you can move pieces around as you see fit - so the end portion of the FEN does not get updated.

With that in mind here's ...[text shortened]... e(fenBox, captureDiv.nextSibling);

}

return true;
}
Wow...thanks!

Vote Up
Vote Down

Why would you want this?

I had this on for a while, but noticed it slowed the screen load and since I never use the FEN for anything.. I turned it off again 🙂