Created
March 12, 2019 09:38
-
-
Save scomma/d57a4c2b526cb4c623f1dfa0e66b707f to your computer and use it in GitHub Desktop.
Quick Triage
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 Quick Triage | |
// @namespace https://softbaked.co/ | |
// @version 0.1 | |
// @description Quickly triage Maniphest tasks | |
// @author You | |
// @match https://softbaked.co/* | |
// @require https://cdnjs.cloudflare.com/ajax/libs/mousetrap/1.6.1/mousetrap.js | |
// @require https://raw.githubusercontent.com/ccampbell/mousetrap/master/plugins/global-bind/mousetrap-global-bind.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var option = document.querySelector("option[value='+']"); | |
if (!option) return; // not maniphest task | |
var action = option.parentElement, | |
form = action.parentElement.parentElement.parentElement, | |
change = document.createEvent('HTMLEvents'); | |
change.initEvent('change', false, true); | |
var focusLast = function() { | |
var inputs = form.getElementsByClassName('aphront-form-input'), | |
lastInput = inputs[inputs.length - 3]; | |
setTimeout(function() { | |
var textInput = lastInput.querySelector('input[type=text]'); | |
if (textInput) { textInput.focus(); } | |
else { lastInput.firstChild.focus(); } | |
}, 0); | |
}; | |
var bindQuickAction = function(shortcut, a) { | |
Mousetrap.bindGlobal(shortcut, function(e) { | |
action.value = a; | |
action.dispatchEvent(change); | |
focusLast(); | |
return false; | |
}); | |
}; | |
bindQuickAction('ctrl+o', 'owner'); | |
bindQuickAction('ctrl+s', 'status'); | |
bindQuickAction('ctrl+p', 'priority'); | |
bindQuickAction('ctrl+x', 'points'); | |
bindQuickAction('ctrl+t', 'projectPHIDs'); | |
bindQuickAction('ctrl+m', 'column'); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment