I want to make it easier for me to import games from other sites to the magnificent analyse tool that lichess has. Hence, I want to create a userscript that sends a POST request to lichess.org/import with the PGN data. Is this considered ok? Is it even possible, or does lichess use some kind of CSFR protection that stops this?
Absolutely.
Thanks thibault!
power on self test? Jeez guys! Stop confusing things!
For the slow ones at the back - could you give as a simple sample script?
Peter
Peter
Well, say you get the PGN using a function named getPGN(). If you add a link to the website you want to analyze games from like this:
<a href="#" onclick="redirectToLichess()">Analyze at lichess.org</a>
Now you'd only have to create a JS function like this (I'm a pretty crappy at JS, so pardon my ugly code!):
function redirectToLichess() {
var form = document.createElement('form');
form.action = 'lichess.org/import';
form.method = 'post';
form.target = '_blank';
var textArea = document.createElement('textarea');
textArea.name = 'pgn';
textArea.id = 'pgn';
textArea.innerHTML = getPGN();
form.appendChild(textArea);
document.body.appendChild(form);
form.submit();
}
How you retrieve the PGN depends on the site you want to extract it from, someone makes it easy for you I'd guess, while in other cases you'd have to manually extract the meta-data and moves to create your own PGN - but that shouldn't be hard at all.
<a href="#" onclick="redirectToLichess()">Analyze at lichess.org</a>
Now you'd only have to create a JS function like this (I'm a pretty crappy at JS, so pardon my ugly code!):
function redirectToLichess() {
var form = document.createElement('form');
form.action = 'lichess.org/import';
form.method = 'post';
form.target = '_blank';
var textArea = document.createElement('textarea');
textArea.name = 'pgn';
textArea.id = 'pgn';
textArea.innerHTML = getPGN();
form.appendChild(textArea);
document.body.appendChild(form);
form.submit();
}
How you retrieve the PGN depends on the site you want to extract it from, someone makes it easy for you I'd guess, while in other cases you'd have to manually extract the meta-data and moves to create your own PGN - but that shouldn't be hard at all.
Looks like this is no longer allowed.
This topic has been archived and can no longer be replied to.