-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent-script.js
More file actions
26 lines (23 loc) · 937 Bytes
/
content-script.js
File metadata and controls
26 lines (23 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Add Lichess button below FEN control
const lichessButton = createLichessButton();
const fenContainer = document.getElementById("fencontrol");
fenContainer.appendChild(lichessButton);
// Open Lichess analysis URL in new tab on click
lichessButton.addEventListener("click", () => {
const lichessUrl = getLichessAnalysisUrl();
window.open(lichessUrl, "_blank").focus();
});
function getLichessAnalysisUrl() {
const fenInput = document.getElementById("inputFEN");
const escapedFen = fenInput.value.replace(/\s/g, "_");
return `https://lichess.org/analysis/standard/${escapedFen}`;
}
function createLichessButton() {
const button = document.createElement("input");
button.setAttribute("id", "analyze-on-lichess");
button.setAttribute("type", "button");
button.setAttribute("value", "Analyze on Lichess");
button.style.marginTop = "15px";
button.classList.add("myButton", "myButton--dark-blue");
return button;
}