Grease Monkey FEN question

Grease Monkey FEN question

Site Ideas

Cookies help us deliver our Services. By using our Services or clicking I agree, you agree to our use of cookies. Learn More.

London

Joined
04 Nov 05
Moves
12606
30 Jan 08

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.

ook

hirsute rooster

Joined
13 Apr 05
Moves
20485
31 Jan 08

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;
}

ook

hirsute rooster

Joined
13 Apr 05
Moves
20485
31 Jan 08

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;
}

Digital Alchemist

Joined
10 Sep 03
Moves
658675
01 Feb 08

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.

ook

hirsute rooster

Joined
13 Apr 05
Moves
20485
01 Feb 08

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.

London

Joined
04 Nov 05
Moves
12606
02 Feb 08

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!

e

Joined
01 Sep 07
Moves
21284
07 Feb 08

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 🙂