Skip to content

Instantly share code, notes, and snippets.

@greghaygood
Created September 28, 2021 18:45
Show Gist options
  • Save greghaygood/11457d0f4908f78385d48f4d2e2ae385 to your computer and use it in GitHub Desktop.
Save greghaygood/11457d0f4908f78385d48f4d2e2ae385 to your computer and use it in GitHub Desktop.
Crossword Puzzle Shortcut Keys UserScript
// ==UserScript==
// @name Crossword Puzzle Shortcut keys
// @namespace https://github.com/greghaygood
// @version 1.0
// @description Add keyboard shortcuts for UI controls on the WaPo crossword puzzle app
// @author Greg Haygood <[email protected]>
// @match https://www.washingtonpost.com/crossword-puzzles/*
// @icon https://www.google.com/s2/favicons?domain=tampermonkey.net
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function simClick(elem) {
elem.dispatchEvent(new MouseEvent('click' , { view: window }))
}
var checkMenu = document.querySelector('#check.dropdown > a')
var checkAllBtn = document.getElementById('check-all-button')
var checkWordBtn = document.getElementById('check-word-button')
var checkLetterBtn = document.getElementById('check-letter-button')
function doCheck(evt) {
if (evt.ctrlKey && evt.key == 'a') {
simClick(checkMenu)
simClick(checkAllBtn)
} else if (evt.ctrlKey && evt.key == 'w') {
simClick(checkMenu)
simClick(checkAllBtn)
} else if (evt.ctrlKey && evt.key == 'l') {
simClick(checkMenu)
simClick(checkAllBtn)
}
}
if (checkMenu) {
document.addEventListener('keyup', doCheck);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment