Skip to content

Instantly share code, notes, and snippets.

@jared-hughes
Last active May 24, 2021 03:06
Show Gist options
  • Save jared-hughes/a21dbeead4c6d0969334707cc1a735bd to your computer and use it in GitHub Desktop.
Save jared-hughes/a21dbeead4c6d0969334707cc1a735bd to your computer and use it in GitHub Desktop.
Desmos Duplicate Expression Hotkey. Now bundled into the extension https://github.com/DesModder/DesModder
// ==UserScript==
// @name Desmos Duplicate Expression Hotkey
// @namespace http://github.com/jared-hughes
// @version 0.1
// @author fireflame241
// @description Binds Ctrl+Q to duplicate the selected expression
// @grant none
// @match https://*.desmos.com/calculator*
// ==/UserScript==
/*jshint esversion: 6 */
'use strict';
const waitInterval = setInterval(() => {
const el = document.querySelector('.dcg-exppanel-outer')
const Calc = window.Calc
if (Calc && el) {
clearInterval(waitInterval)
el.addEventListener('keydown', e => {
if (e.code === 'KeyQ' && e.ctrlKey) {
Calc.controller.dispatch({
type: 'duplicate-expression',
id: Calc.selectedExpressionId,
})
}
})
}
}, 50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment