Skip to content

Instantly share code, notes, and snippets.

@nonplus
Last active August 21, 2022 03:09
Show Gist options
  • Save nonplus/69f4bb7953243803ffa0e008869dba36 to your computer and use it in GitHub Desktop.
Save nonplus/69f4bb7953243803ffa0e008869dba36 to your computer and use it in GitHub Desktop.
QuickPass Keyboard Navigation
// ==UserScript==
// @name QuickPass Keyboard Navigation
// @namespace https://gist.github.com/nonplus
// @downloadURL https://gist.githubusercontent.com/nonplus/69f4bb7953243803ffa0e008869dba36/raw
// @updateURL https://gist.githubusercontent.com/nonplus/69f4bb7953243803ffa0e008869dba36/raw
// @version 0.1
// @description Support keyboard input (y,n,s,p,c) when filling out a QuickPass survey
// @author Stepan Riha
// @match https://*.aboquickpass.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
const KEY_MAP = {
'y': 'yes',
'n': 'no',
's': 'skip',
'p': 'btnPrevious',
'c': 'btnContinue',
};
document.addEventListener('keypress', function(evt) {
console.log(evt);
const controlId = KEY_MAP[evt.key];
const elt = controlId && document.getElementById(controlId);
elt?.click();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment