Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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 <haygoodg@gmail.com>
// @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