Skip to content

Instantly share code, notes, and snippets.

@lunamoth
Last active June 15, 2025 12:55
Show Gist options
  • Save lunamoth/ad31d1534aadc553bb8efa653653d03e to your computer and use it in GitHub Desktop.
Save lunamoth/ad31d1534aadc553bb8efa653653d03e to your computer and use it in GitHub Desktop.
C=chrome,r=C.runtime,T=C.tabs,T?r.onMessage.addListener((e,{tab:t})=>T[["create","remove","goBack","goForward"][e]](e?t.id:{})):(e=addEventListener,e("mousedown",e=>e.button-2||(t=1,n=e.x,o=e.y)),e("mousemove",e=>t-1||99<(e.x-n)**2+(e.y-o)**2&&++t),e("mouseup",e=>t-2||2&e.button&&624<(X=e.x-n)*X+(Y=e.y-o)*Y&&r.sendMessage(Y*Y>X*X?Y<0^1:2|X>0)),e("contextmenu",e=>(t-2||e.preventDefault(),t=0)),e("blur",_=>t=0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment