Skip to content

Instantly share code, notes, and snippets.

@pke
Last active November 2, 2016 22:22
Show Gist options
  • Save pke/cd7ded5f9c4d05c5cdaaf3f00b534163 to your computer and use it in GitHub Desktop.
Save pke/cd7ded5f9c4d05c5cdaaf3f00b534163 to your computer and use it in GitHub Desktop.
GM Script for CTRL+SEND
// ==UserScript==
// @name CTRL+SEND
// @namespace http://tampermonkey.net/
// @version 1.0
// @description try to take over the world!
// @author pke
// @match http*://*/*
// @exclude https://twitter.com/*
// @exclude https://mail.google.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
if (document.forms.length === 0) {
return;
}
document.addEventListener("keypress", function(event) {
if (event.keyCode === 10 && event.ctrlKey) {
// Search back the form
var form = event.target;
while (form && form.tagName !== "FORM") {
form = form.parentElement;
}
//console.debug("Found form", form);
if (form) {
var submit = form.querySelector("input[type=submit]");
//console.debug("Found submit", submit);
if (submit) {
submit.click();
}
}
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment