Last active
June 21, 2022 23:12
-
-
Save awatertrevi/4149c10f4511ef99eb351e8b2197beb7 to your computer and use it in GitHub Desktop.
Cmd + Enter = Save on Google Calendar #tampermonkey
This file contains 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 Google Calendar (Cmd + Enter = Save) | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Saves a calendar event when Cmd + Enter is pressed. | |
// @author Trevi Awater | |
// @match https://calendar.google.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let isHoldingCmd = false; | |
document.addEventListener('keydown', keyDown); | |
document.addEventListener('keyup', keyUp); | |
function keyDown (e) { | |
if (e.code === 'MetaLeft') { | |
isHoldingCmd = true; | |
} | |
else if (e.code === 'Enter' && isHoldingCmd) { | |
document.getElementById('xSaveBu').click(); | |
} | |
} | |
function keyUp (e) { | |
if (e.code === 'MetaLeft') { | |
isHoldingCmd = false; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment