Created
September 28, 2021 18:45
-
-
Save greghaygood/11457d0f4908f78385d48f4d2e2ae385 to your computer and use it in GitHub Desktop.
Crossword Puzzle Shortcut Keys UserScript
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 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