Skip to content

Instantly share code, notes, and snippets.

@fortserious
Created April 28, 2020 15:51
Show Gist options
  • Save fortserious/2c43d239c3d7eda33e6e7a7ce0d3fcae to your computer and use it in GitHub Desktop.
Save fortserious/2c43d239c3d7eda33e6e7a7ce0d3fcae to your computer and use it in GitHub Desktop.
nytimes spelling bee allow backspace
// ==UserScript==
// @name nytimes spelling bee fixer
// @namespace www.rossdoran.com
// @version 0.1
// @description wait for key elements
// @match https://www.nytimes.com/puzzles/spelling-bee
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @run-at document-start
// ==/UserScript==
// Prevents the backspace key from navigating back, and remaps to delete key.
// Note: This may disable backspace function for password entry boxes on the page.
$(document).unbind('keydown').bind('keydown', function (event) {
if (event.keyCode === 8) {
var doPrevent = true;
var types = ["text", "password", "file", "search", "email", "number", "date", "color", "datetime", "datetime-local", "month", "range", "search", "tel", "time", "url", "week"];
var d = $(event.srcElement || event.target);
var disabled = d.prop("readonly") || d.prop("disabled");
if (!disabled) {
if (d[0].isContentEditable) {
doPrevent = false;
} else if (d.is("input")) {
var type = d.attr("type");
if (type) {
type = type.toLowerCase();
}
if (types.indexOf(type) > -1) {
doPrevent = false;
}
} else if (d.is("textarea")) {
doPrevent = false;
}
}
if (doPrevent) {
event.preventDefault();
$(e.target).trigger({
type: "keypress",
which: 13
});
return false;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment