The most stupid feature on chess.com, and the cause of a majority of "mouse slips" is that it's not possible to turn of click to move. You can see streamers mouse slip like this all the time when they're accidentally click a square (to clear arrows) and had a piece selected.
Even more stupid is that there is an option to choose between drag to move and click to move, but it doesn't do anything... (who came up with this??)
So, I decided to create a script that turns it off. The code on this site is a bit of a mess, so the script is a mess too, but it does the job.
To use it, paste it in the console or use your favourite script injector (I use Scripty). Without further ado, here it is:
// Keep track of if we're currently waiting to retry clearing
// highlight
var recheck = null;
// Clears a highlighted piece by dispatching a click on the screen
function clearHighlight() {
// If currently dragging a piece, we should wait with trying to
// clear until the piece is dropped
if (document.querySelectorAll('chess-board') [0].querySelectorAll('.dragging').length > 0) {
if (recheck === null) {
recheck = setInterval(function() {
clearHighlight();
}, 50);
}
return;
}
if (recheck !== null) {
clearInterval(recheck);
}
recheck = null;
// Get number of squares highlighted by a move (which have 0.5
// opacity), but ignore squares highlighted by the user
// right-clicking (they have 0.8 opacity)
var highlights = Array.from(document.querySelectorAll('chess-board')[0].querySelectorAll('.highlight')).filter(e => e.style.opacity !== "0.8").length;
if (highlights !== 1 && highlights !== 3) {
// No square highlighted
return;
}
// A square is highlighted (either just the 1, in analysis mode, or
// 3 which includes the opponent move as well)
// So dispatch a click, which clears the highlight
document.dispatchEvent(new PointerEvent('pointerdown'));
}
// Listens to changes in the board element
function initObserver() {
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations, observer) {
clearHighlight();
});
observer.observe(document.getElementById('board-layout-chessboard'), {
subtree: true,
childList: true
});
}
initObserver();
There is already an option in settings to have Drag Only and it's been around for a few months at least.
The most stupid feature on chess.com, and the cause of a majority of "mouse slips" is that it's not possible to turn of click to move. You can see streamers mouse slip like this all the time when they're accidentally click a square (to clear arrows) and had a piece selected.
Even more stupid is that there is an option to choose between drag to move and click to move, but it doesn't do anything... (who came up with this??)
So, I decided to create a script that turns it off. The code on this site is a bit of a mess, so the script is a mess too, but it does the job.
To use it, paste it in the console or use your favourite script injector (I use Scripty). Without further ado, here it is:
// Keep track of if we're currently waiting to retry clearing
// highlight
var recheck = null;
// Clears a highlighted piece by dispatching a click on the screen
function clearHighlight() {
// If currently dragging a piece, we should wait with trying to
// clear until the piece is dropped
if (document.querySelectorAll('chess-board') [0].querySelectorAll('.dragging').length > 0) {
if (recheck === null) {
recheck = setInterval(function() {
clearHighlight();
}, 50);
}
return;
}
if (recheck !== null) {
clearInterval(recheck);
}
recheck = null;
// Get number of squares highlighted by a move (which have 0.5
// opacity), but ignore squares highlighted by the user
// right-clicking (they have 0.8 opacity)
var highlights = Array.from(document.querySelectorAll('chess-board')[0].querySelectorAll('.highlight')).filter(e => e.style.opacity !== "0.8").length;
if (highlights !== 1 && highlights !== 3) {
// No square highlighted
return;
}
// A square is highlighted (either just the 1, in analysis mode, or
// 3 which includes the opponent move as well)
// So dispatch a click, which clears the highlight
document.dispatchEvent(new PointerEvent('pointerdown'));
}
// Listens to changes in the board element
function initObserver() {
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations, observer) {
clearHighlight();
});
observer.observe(document.getElementById('board-layout-chessboard'), {
subtree: true,
childList: true
});
}
initObserver();