Skip to content

Instantly share code, notes, and snippets.

@tacone
Last active May 14, 2025 14:53
Show Gist options
  • Save tacone/c44e75e26ea57abea460e0e90aa63cd5 to your computer and use it in GitHub Desktop.
Save tacone/c44e75e26ea57abea460e0e90aa63cd5 to your computer and use it in GitHub Desktop.
GreaseMonkey: Fix Figma on Linux (mouse third button should not paste when dragging)
// ==UserScript==
// @name Fix Figma
// @version 1
// @grant none
// @match https://www.figma.com/*
// ==/UserScript==
const middle_button = 1
let nopaste = false
const delta = 6;
let startX;
let startY;
document.addEventListener('mousedown', function (event) {
startX = event.pageX;
startY = event.pageY;
});
document.addEventListener('mouseup', function(e) {
const diffX = Math.abs(e.pageX - startX);
const diffY = Math.abs(e.pageY - startY);
//if (diffX < delta && diffY < delta) {
// It's a click, not a drag
//return false
//}
if (e.button == middle_button) {
nopaste = true
}
return false;
}, true);
document.addEventListener('paste', function(e) {
if (nopaste) {
e.cancelBubble = true;
e.stopImmediatePropagation();
nopaste = false
}
return false;
}, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment