Last active
November 2, 2016 22:22
-
-
Save pke/cd7ded5f9c4d05c5cdaaf3f00b534163 to your computer and use it in GitHub Desktop.
GM Script for CTRL+SEND
This file contains hidden or 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 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