Last active
May 14, 2025 14:53
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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